babylon.module.d.ts 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993
  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. }
  1058. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1059. import { Nullable } from "babylonjs/types";
  1060. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1061. /**
  1062. * This represents the required contract to create a new type of texture loader.
  1063. */
  1064. export interface IInternalTextureLoader {
  1065. /**
  1066. * Defines wether the loader supports cascade loading the different faces.
  1067. */
  1068. supportCascades: boolean;
  1069. /**
  1070. * This returns if the loader support the current file information.
  1071. * @param extension defines the file extension of the file being loaded
  1072. * @param mimeType defines the optional mime type of the file being loaded
  1073. * @returns true if the loader can load the specified file
  1074. */
  1075. canLoad(extension: string, mimeType?: string): boolean;
  1076. /**
  1077. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param createPolynomials will be true if polynomials have been requested
  1081. * @param onLoad defines the callback to trigger once the texture is ready
  1082. * @param onError defines the callback to trigger in case of error
  1083. */
  1084. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1085. /**
  1086. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param callback defines the method to call once ready to upload
  1090. */
  1091. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1092. }
  1093. }
  1094. declare module "babylonjs/Engines/IPipelineContext" {
  1095. /**
  1096. * Class used to store and describe the pipeline context associated with an effect
  1097. */
  1098. export interface IPipelineContext {
  1099. /**
  1100. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1101. */
  1102. isAsync: boolean;
  1103. /**
  1104. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1105. */
  1106. isReady: boolean;
  1107. /** @hidden */
  1108. _getVertexShaderCode(): string | null;
  1109. /** @hidden */
  1110. _getFragmentShaderCode(): string | null;
  1111. /** @hidden */
  1112. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1113. }
  1114. }
  1115. declare module "babylonjs/Meshes/dataBuffer" {
  1116. /**
  1117. * Class used to store gfx data (like WebGLBuffer)
  1118. */
  1119. export class DataBuffer {
  1120. /**
  1121. * Gets or sets the number of objects referencing this buffer
  1122. */
  1123. references: number;
  1124. /** Gets or sets the size of the underlying buffer */
  1125. capacity: number;
  1126. /**
  1127. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1128. */
  1129. is32Bits: boolean;
  1130. /**
  1131. * Gets the underlying buffer
  1132. */
  1133. get underlyingResource(): any;
  1134. }
  1135. }
  1136. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1137. /** @hidden */
  1138. export interface IShaderProcessor {
  1139. attributeProcessor?: (attribute: string) => string;
  1140. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1141. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1142. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1143. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1144. lineProcessor?: (line: string, isFragment: boolean) => string;
  1145. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1146. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1147. }
  1148. }
  1149. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1150. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1151. /** @hidden */
  1152. export interface ProcessingOptions {
  1153. defines: string[];
  1154. indexParameters: any;
  1155. isFragment: boolean;
  1156. shouldUseHighPrecisionShader: boolean;
  1157. supportsUniformBuffers: boolean;
  1158. shadersRepository: string;
  1159. includesShadersStore: {
  1160. [key: string]: string;
  1161. };
  1162. processor?: IShaderProcessor;
  1163. version: string;
  1164. platformName: string;
  1165. lookForClosingBracketForUniformBuffer?: boolean;
  1166. }
  1167. }
  1168. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1169. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1170. /** @hidden */
  1171. export class ShaderCodeNode {
  1172. line: string;
  1173. children: ShaderCodeNode[];
  1174. additionalDefineKey?: string;
  1175. additionalDefineValue?: string;
  1176. isValid(preprocessors: {
  1177. [key: string]: string;
  1178. }): boolean;
  1179. process(preprocessors: {
  1180. [key: string]: string;
  1181. }, options: ProcessingOptions): string;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1185. /** @hidden */
  1186. export class ShaderCodeCursor {
  1187. private _lines;
  1188. lineIndex: number;
  1189. get currentLine(): string;
  1190. get canRead(): boolean;
  1191. set lines(value: string[]);
  1192. }
  1193. }
  1194. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1195. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1196. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1197. /** @hidden */
  1198. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1199. process(preprocessors: {
  1200. [key: string]: string;
  1201. }, options: ProcessingOptions): string;
  1202. }
  1203. }
  1204. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1205. /** @hidden */
  1206. export class ShaderDefineExpression {
  1207. isTrue(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. private static _OperatorPriority;
  1211. private static _Stack;
  1212. static postfixToInfix(postfix: string[]): string;
  1213. static infixToPostfix(infix: string): string[];
  1214. }
  1215. }
  1216. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1217. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1218. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1219. /** @hidden */
  1220. export class ShaderCodeTestNode extends ShaderCodeNode {
  1221. testExpression: ShaderDefineExpression;
  1222. isValid(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1228. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1229. /** @hidden */
  1230. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1231. define: string;
  1232. not: boolean;
  1233. constructor(define: string, not?: boolean);
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1240. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1241. /** @hidden */
  1242. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1243. leftOperand: ShaderDefineExpression;
  1244. rightOperand: ShaderDefineExpression;
  1245. isTrue(preprocessors: {
  1246. [key: string]: string;
  1247. }): boolean;
  1248. }
  1249. }
  1250. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1251. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1252. /** @hidden */
  1253. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1254. leftOperand: ShaderDefineExpression;
  1255. rightOperand: ShaderDefineExpression;
  1256. isTrue(preprocessors: {
  1257. [key: string]: string;
  1258. }): boolean;
  1259. }
  1260. }
  1261. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1262. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module "babylonjs/Offline/IOfflineProvider" {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module "babylonjs/Misc/filesInputStore" {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module "babylonjs/Misc/retryStrategy" {
  1326. import { WebRequest } from "babylonjs/Misc/webRequest";
  1327. /**
  1328. * Class used to define a retry strategy when error happens while loading assets
  1329. */
  1330. export class RetryStrategy {
  1331. /**
  1332. * Function used to defines an exponential back off strategy
  1333. * @param maxRetries defines the maximum number of retries (3 by default)
  1334. * @param baseInterval defines the interval between retries
  1335. * @returns the strategy function to use
  1336. */
  1337. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1338. }
  1339. }
  1340. declare module "babylonjs/Misc/baseError" {
  1341. /**
  1342. * @ignore
  1343. * Application error to support additional information when loading a file
  1344. */
  1345. export abstract class BaseError extends Error {
  1346. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1347. }
  1348. }
  1349. declare module "babylonjs/Misc/fileTools" {
  1350. import { WebRequest } from "babylonjs/Misc/webRequest";
  1351. import { Nullable } from "babylonjs/types";
  1352. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1353. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1354. import { BaseError } from "babylonjs/Misc/baseError";
  1355. /** @ignore */
  1356. export class LoadFileError extends BaseError {
  1357. request?: WebRequest;
  1358. file?: File;
  1359. /**
  1360. * Creates a new LoadFileError
  1361. * @param message defines the message of the error
  1362. * @param request defines the optional web request
  1363. * @param file defines the optional file
  1364. */
  1365. constructor(message: string, object?: WebRequest | File);
  1366. }
  1367. /** @ignore */
  1368. export class RequestFileError extends BaseError {
  1369. request: WebRequest;
  1370. /**
  1371. * Creates a new LoadFileError
  1372. * @param message defines the message of the error
  1373. * @param request defines the optional web request
  1374. */
  1375. constructor(message: string, request: WebRequest);
  1376. }
  1377. /** @ignore */
  1378. export class ReadFileError extends BaseError {
  1379. file: File;
  1380. /**
  1381. * Creates a new ReadFileError
  1382. * @param message defines the message of the error
  1383. * @param file defines the optional file
  1384. */
  1385. constructor(message: string, file: File);
  1386. }
  1387. /**
  1388. * @hidden
  1389. */
  1390. export class FileTools {
  1391. /**
  1392. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1393. */
  1394. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1395. /**
  1396. * Gets or sets the base URL to use to load assets
  1397. */
  1398. static BaseUrl: string;
  1399. /**
  1400. * Default behaviour for cors in the application.
  1401. * It can be a string if the expected behavior is identical in the entire app.
  1402. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1403. */
  1404. static CorsBehavior: string | ((url: string | string[]) => string);
  1405. /**
  1406. * Gets or sets a function used to pre-process url before using them to load assets
  1407. */
  1408. static PreprocessUrl: (url: string) => string;
  1409. /**
  1410. * Removes unwanted characters from an url
  1411. * @param url defines the url to clean
  1412. * @returns the cleaned url
  1413. */
  1414. private static _CleanUrl;
  1415. /**
  1416. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1417. * @param url define the url we are trying
  1418. * @param element define the dom element where to configure the cors policy
  1419. */
  1420. static SetCorsBehavior(url: string | string[], element: {
  1421. crossOrigin: string | null;
  1422. }): void;
  1423. /**
  1424. * Loads an image as an HTMLImageElement.
  1425. * @param input url string, ArrayBuffer, or Blob to load
  1426. * @param onLoad callback called when the image successfully loads
  1427. * @param onError callback called when the image fails to load
  1428. * @param offlineProvider offline provider for caching
  1429. * @param mimeType optional mime type
  1430. * @returns the HTMLImageElement of the loaded image
  1431. */
  1432. 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>;
  1433. /**
  1434. * Reads a file from a File object
  1435. * @param file defines the file to load
  1436. * @param onSuccess defines the callback to call when data is loaded
  1437. * @param onProgress defines the callback to call during loading process
  1438. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1439. * @param onError defines the callback to call when an error occurs
  1440. * @returns a file request object
  1441. */
  1442. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1443. /**
  1444. * Loads a file from a url
  1445. * @param url url to load
  1446. * @param onSuccess callback called when the file successfully loads
  1447. * @param onProgress callback called while file is loading (if the server supports this mode)
  1448. * @param offlineProvider defines the offline provider for caching
  1449. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1450. * @param onError callback called when the file fails to load
  1451. * @returns a file request object
  1452. */
  1453. 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;
  1454. /**
  1455. * Loads a file
  1456. * @param url url to load
  1457. * @param onSuccess callback called when the file successfully loads
  1458. * @param onProgress callback called while file is loading (if the server supports this mode)
  1459. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1460. * @param onError callback called when the file fails to load
  1461. * @param onOpened callback called when the web request is opened
  1462. * @returns a file request object
  1463. */
  1464. 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;
  1465. /**
  1466. * Checks if the loaded document was accessed via `file:`-Protocol.
  1467. * @returns boolean
  1468. */
  1469. static IsFileURL(): boolean;
  1470. }
  1471. }
  1472. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1473. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1474. import { WebRequest } from "babylonjs/Misc/webRequest";
  1475. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1476. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1477. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1478. /** @hidden */
  1479. export class ShaderProcessor {
  1480. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1481. private static _ProcessPrecision;
  1482. private static _ExtractOperation;
  1483. private static _BuildSubExpression;
  1484. private static _BuildExpression;
  1485. private static _MoveCursorWithinIf;
  1486. private static _MoveCursor;
  1487. private static _EvaluatePreProcessors;
  1488. private static _PreparePreProcessors;
  1489. private static _ProcessShaderConversion;
  1490. private static _ProcessIncludes;
  1491. /**
  1492. * Loads a file from a url
  1493. * @param url url to load
  1494. * @param onSuccess callback called when the file successfully loads
  1495. * @param onProgress callback called while file is loading (if the server supports this mode)
  1496. * @param offlineProvider defines the offline provider for caching
  1497. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1498. * @param onError callback called when the file fails to load
  1499. * @returns a file request object
  1500. * @hidden
  1501. */
  1502. 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;
  1503. }
  1504. }
  1505. declare module "babylonjs/Maths/math.like" {
  1506. import { float, int, DeepImmutable } from "babylonjs/types";
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IColor4Like {
  1511. r: float;
  1512. g: float;
  1513. b: float;
  1514. a: float;
  1515. }
  1516. /**
  1517. * @hidden
  1518. */
  1519. export interface IColor3Like {
  1520. r: float;
  1521. g: float;
  1522. b: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IVector4Like {
  1528. x: float;
  1529. y: float;
  1530. z: float;
  1531. w: float;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IVector3Like {
  1537. x: float;
  1538. y: float;
  1539. z: float;
  1540. }
  1541. /**
  1542. * @hidden
  1543. */
  1544. export interface IVector2Like {
  1545. x: float;
  1546. y: float;
  1547. }
  1548. /**
  1549. * @hidden
  1550. */
  1551. export interface IMatrixLike {
  1552. toArray(): DeepImmutable<Float32Array>;
  1553. updateFlag: int;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IViewportLike {
  1559. x: float;
  1560. y: float;
  1561. width: float;
  1562. height: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IPlaneLike {
  1568. normal: IVector3Like;
  1569. d: float;
  1570. normalize(): void;
  1571. }
  1572. }
  1573. declare module "babylonjs/Materials/iEffectFallbacks" {
  1574. import { Effect } from "babylonjs/Materials/effect";
  1575. /**
  1576. * Interface used to define common properties for effect fallbacks
  1577. */
  1578. export interface IEffectFallbacks {
  1579. /**
  1580. * Removes the defines that should be removed when falling back.
  1581. * @param currentDefines defines the current define statements for the shader.
  1582. * @param effect defines the current effect we try to compile
  1583. * @returns The resulting defines with defines of the current rank removed.
  1584. */
  1585. reduce(currentDefines: string, effect: Effect): string;
  1586. /**
  1587. * Removes the fallback from the bound mesh.
  1588. */
  1589. unBindMesh(): void;
  1590. /**
  1591. * Checks to see if more fallbacks are still availible.
  1592. */
  1593. hasMoreFallbacks: boolean;
  1594. }
  1595. }
  1596. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1597. /**
  1598. * Class used to evalaute queries containing `and` and `or` operators
  1599. */
  1600. export class AndOrNotEvaluator {
  1601. /**
  1602. * Evaluate a query
  1603. * @param query defines the query to evaluate
  1604. * @param evaluateCallback defines the callback used to filter result
  1605. * @returns true if the query matches
  1606. */
  1607. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1608. private static _HandleParenthesisContent;
  1609. private static _SimplifyNegation;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/tags" {
  1613. /**
  1614. * Class used to store custom tags
  1615. */
  1616. export class Tags {
  1617. /**
  1618. * Adds support for tags on the given object
  1619. * @param obj defines the object to use
  1620. */
  1621. static EnableFor(obj: any): void;
  1622. /**
  1623. * Removes tags support
  1624. * @param obj defines the object to use
  1625. */
  1626. static DisableFor(obj: any): void;
  1627. /**
  1628. * Gets a boolean indicating if the given object has tags
  1629. * @param obj defines the object to use
  1630. * @returns a boolean
  1631. */
  1632. static HasTags(obj: any): boolean;
  1633. /**
  1634. * Gets the tags available on a given object
  1635. * @param obj defines the object to use
  1636. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1637. * @returns the tags
  1638. */
  1639. static GetTags(obj: any, asString?: boolean): any;
  1640. /**
  1641. * Adds tags to an object
  1642. * @param obj defines the object to use
  1643. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1644. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1645. */
  1646. static AddTagsTo(obj: any, tagsString: string): void;
  1647. /**
  1648. * @hidden
  1649. */
  1650. static _AddTagTo(obj: any, tag: string): void;
  1651. /**
  1652. * Removes specific tags from a specific object
  1653. * @param obj defines the object to use
  1654. * @param tagsString defines the tags to remove
  1655. */
  1656. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1657. /**
  1658. * @hidden
  1659. */
  1660. static _RemoveTagFrom(obj: any, tag: string): void;
  1661. /**
  1662. * Defines if tags hosted on an object match a given query
  1663. * @param obj defines the object to use
  1664. * @param tagsQuery defines the tag query
  1665. * @returns a boolean
  1666. */
  1667. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1668. }
  1669. }
  1670. declare module "babylonjs/Maths/math.scalar" {
  1671. /**
  1672. * Scalar computation library
  1673. */
  1674. export class Scalar {
  1675. /**
  1676. * Two pi constants convenient for computation.
  1677. */
  1678. static TwoPi: number;
  1679. /**
  1680. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1681. * @param a number
  1682. * @param b number
  1683. * @param epsilon (default = 1.401298E-45)
  1684. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1685. */
  1686. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1687. /**
  1688. * Returns a string : the upper case translation of the number i to hexadecimal.
  1689. * @param i number
  1690. * @returns the upper case translation of the number i to hexadecimal.
  1691. */
  1692. static ToHex(i: number): string;
  1693. /**
  1694. * Returns -1 if value is negative and +1 is value is positive.
  1695. * @param value the value
  1696. * @returns the value itself if it's equal to zero.
  1697. */
  1698. static Sign(value: number): number;
  1699. /**
  1700. * Returns the value itself if it's between min and max.
  1701. * Returns min if the value is lower than min.
  1702. * Returns max if the value is greater than max.
  1703. * @param value the value to clmap
  1704. * @param min the min value to clamp to (default: 0)
  1705. * @param max the max value to clamp to (default: 1)
  1706. * @returns the clamped value
  1707. */
  1708. static Clamp(value: number, min?: number, max?: number): number;
  1709. /**
  1710. * the log2 of value.
  1711. * @param value the value to compute log2 of
  1712. * @returns the log2 of value.
  1713. */
  1714. static Log2(value: number): number;
  1715. /**
  1716. * Loops the value, so that it is never larger than length and never smaller than 0.
  1717. *
  1718. * This is similar to the modulo operator but it works with floating point numbers.
  1719. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1720. * With t = 5 and length = 2.5, the result would be 0.0.
  1721. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1722. * @param value the value
  1723. * @param length the length
  1724. * @returns the looped value
  1725. */
  1726. static Repeat(value: number, length: number): number;
  1727. /**
  1728. * Normalize the value between 0.0 and 1.0 using min and max values
  1729. * @param value value to normalize
  1730. * @param min max to normalize between
  1731. * @param max min to normalize between
  1732. * @returns the normalized value
  1733. */
  1734. static Normalize(value: number, min: number, max: number): number;
  1735. /**
  1736. * Denormalize the value from 0.0 and 1.0 using min and max values
  1737. * @param normalized value to denormalize
  1738. * @param min max to denormalize between
  1739. * @param max min to denormalize between
  1740. * @returns the denormalized value
  1741. */
  1742. static Denormalize(normalized: number, min: number, max: number): number;
  1743. /**
  1744. * Calculates the shortest difference between two given angles given in degrees.
  1745. * @param current current angle in degrees
  1746. * @param target target angle in degrees
  1747. * @returns the delta
  1748. */
  1749. static DeltaAngle(current: number, target: number): number;
  1750. /**
  1751. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1752. * @param tx value
  1753. * @param length length
  1754. * @returns The returned value will move back and forth between 0 and length
  1755. */
  1756. static PingPong(tx: number, length: number): number;
  1757. /**
  1758. * Interpolates between min and max with smoothing at the limits.
  1759. *
  1760. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1761. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1762. * @param from from
  1763. * @param to to
  1764. * @param tx value
  1765. * @returns the smooth stepped value
  1766. */
  1767. static SmoothStep(from: number, to: number, tx: number): number;
  1768. /**
  1769. * Moves a value current towards target.
  1770. *
  1771. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1772. * Negative values of maxDelta pushes the value away from target.
  1773. * @param current current value
  1774. * @param target target value
  1775. * @param maxDelta max distance to move
  1776. * @returns resulting value
  1777. */
  1778. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1779. /**
  1780. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1781. *
  1782. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1783. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1784. * @param current current value
  1785. * @param target target value
  1786. * @param maxDelta max distance to move
  1787. * @returns resulting angle
  1788. */
  1789. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1790. /**
  1791. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1792. * @param start start value
  1793. * @param end target value
  1794. * @param amount amount to lerp between
  1795. * @returns the lerped value
  1796. */
  1797. static Lerp(start: number, end: number, amount: number): number;
  1798. /**
  1799. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1800. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1801. * @param start start value
  1802. * @param end target value
  1803. * @param amount amount to lerp between
  1804. * @returns the lerped value
  1805. */
  1806. static LerpAngle(start: number, end: number, amount: number): number;
  1807. /**
  1808. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1809. * @param a start value
  1810. * @param b target value
  1811. * @param value value between a and b
  1812. * @returns the inverseLerp value
  1813. */
  1814. static InverseLerp(a: number, b: number, value: number): number;
  1815. /**
  1816. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1817. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1818. * @param value1 spline value
  1819. * @param tangent1 spline value
  1820. * @param value2 spline value
  1821. * @param tangent2 spline value
  1822. * @param amount input value
  1823. * @returns hermite result
  1824. */
  1825. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1826. /**
  1827. * Returns a random float number between and min and max values
  1828. * @param min min value of random
  1829. * @param max max value of random
  1830. * @returns random value
  1831. */
  1832. static RandomRange(min: number, max: number): number;
  1833. /**
  1834. * This function returns percentage of a number in a given range.
  1835. *
  1836. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1837. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1838. * @param number to convert to percentage
  1839. * @param min min range
  1840. * @param max max range
  1841. * @returns the percentage
  1842. */
  1843. static RangeToPercent(number: number, min: number, max: number): number;
  1844. /**
  1845. * This function returns number that corresponds to the percentage in a given range.
  1846. *
  1847. * PercentToRange(0.34,0,100) will return 34.
  1848. * @param percent to convert to number
  1849. * @param min min range
  1850. * @param max max range
  1851. * @returns the number
  1852. */
  1853. static PercentToRange(percent: number, min: number, max: number): number;
  1854. /**
  1855. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1856. * @param angle The angle to normalize in radian.
  1857. * @return The converted angle.
  1858. */
  1859. static NormalizeRadians(angle: number): number;
  1860. }
  1861. }
  1862. declare module "babylonjs/Maths/math.constants" {
  1863. /**
  1864. * Constant used to convert a value to gamma space
  1865. * @ignorenaming
  1866. */
  1867. export const ToGammaSpace: number;
  1868. /**
  1869. * Constant used to convert a value to linear space
  1870. * @ignorenaming
  1871. */
  1872. export const ToLinearSpace = 2.2;
  1873. /**
  1874. * Constant used to define the minimal number value in Babylon.js
  1875. * @ignorenaming
  1876. */
  1877. let Epsilon: number;
  1878. export { Epsilon };
  1879. }
  1880. declare module "babylonjs/Maths/math.viewport" {
  1881. /**
  1882. * Class used to represent a viewport on screen
  1883. */
  1884. export class Viewport {
  1885. /** viewport left coordinate */
  1886. x: number;
  1887. /** viewport top coordinate */
  1888. y: number;
  1889. /**viewport width */
  1890. width: number;
  1891. /** viewport height */
  1892. height: number;
  1893. /**
  1894. * Creates a Viewport object located at (x, y) and sized (width, height)
  1895. * @param x defines viewport left coordinate
  1896. * @param y defines viewport top coordinate
  1897. * @param width defines the viewport width
  1898. * @param height defines the viewport height
  1899. */
  1900. constructor(
  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 new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1911. * @param renderWidth defines the rendering width
  1912. * @param renderHeight defines the rendering height
  1913. * @returns a new Viewport
  1914. */
  1915. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1916. /**
  1917. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1918. * @param renderWidth defines the rendering width
  1919. * @param renderHeight defines the rendering height
  1920. * @param ref defines the target viewport
  1921. * @returns the current viewport
  1922. */
  1923. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1924. /**
  1925. * Returns a new Viewport copied from the current one
  1926. * @returns a new Viewport
  1927. */
  1928. clone(): Viewport;
  1929. }
  1930. }
  1931. declare module "babylonjs/Misc/arrayTools" {
  1932. /**
  1933. * Class containing a set of static utilities functions for arrays.
  1934. */
  1935. export class ArrayTools {
  1936. /**
  1937. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1938. * @param size the number of element to construct and put in the array
  1939. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1940. * @returns a new array filled with new objects
  1941. */
  1942. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1943. }
  1944. }
  1945. declare module "babylonjs/Maths/math.plane" {
  1946. import { DeepImmutable } from "babylonjs/types";
  1947. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1948. /**
  1949. * Represents a plane by the equation ax + by + cz + d = 0
  1950. */
  1951. export class Plane {
  1952. private static _TmpMatrix;
  1953. /**
  1954. * Normal of the plane (a,b,c)
  1955. */
  1956. normal: Vector3;
  1957. /**
  1958. * d component of the plane
  1959. */
  1960. d: number;
  1961. /**
  1962. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1963. * @param a a component of the plane
  1964. * @param b b component of the plane
  1965. * @param c c component of the plane
  1966. * @param d d component of the plane
  1967. */
  1968. constructor(a: number, b: number, c: number, d: number);
  1969. /**
  1970. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1971. */
  1972. asArray(): number[];
  1973. /**
  1974. * @returns a new plane copied from the current Plane.
  1975. */
  1976. clone(): Plane;
  1977. /**
  1978. * @returns the string "Plane".
  1979. */
  1980. getClassName(): string;
  1981. /**
  1982. * @returns the Plane hash code.
  1983. */
  1984. getHashCode(): number;
  1985. /**
  1986. * Normalize the current Plane in place.
  1987. * @returns the updated Plane.
  1988. */
  1989. normalize(): Plane;
  1990. /**
  1991. * Applies a transformation the plane and returns the result
  1992. * @param transformation the transformation matrix to be applied to the plane
  1993. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1994. */
  1995. transform(transformation: DeepImmutable<Matrix>): Plane;
  1996. /**
  1997. * Compute the dot product between the point and the plane normal
  1998. * @param point point to calculate the dot product with
  1999. * @returns the dot product (float) of the point coordinates and the plane normal.
  2000. */
  2001. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2002. /**
  2003. * Updates the current Plane from the plane defined by the three given points.
  2004. * @param point1 one of the points used to contruct the plane
  2005. * @param point2 one of the points used to contruct the plane
  2006. * @param point3 one of the points used to contruct the plane
  2007. * @returns the updated Plane.
  2008. */
  2009. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2010. /**
  2011. * Checks if the plane is facing a given direction
  2012. * @param direction the direction to check if the plane is facing
  2013. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2014. * @returns True is the vector "direction" is the same side than the plane normal.
  2015. */
  2016. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2017. /**
  2018. * Calculates the distance to a point
  2019. * @param point point to calculate distance to
  2020. * @returns the signed distance (float) from the given point to the Plane.
  2021. */
  2022. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2023. /**
  2024. * Creates a plane from an array
  2025. * @param array the array to create a plane from
  2026. * @returns a new Plane from the given array.
  2027. */
  2028. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2029. /**
  2030. * Creates a plane from three points
  2031. * @param point1 point used to create the plane
  2032. * @param point2 point used to create the plane
  2033. * @param point3 point used to create the plane
  2034. * @returns a new Plane defined by the three given points.
  2035. */
  2036. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2037. /**
  2038. * Creates a plane from an origin point and a normal
  2039. * @param origin origin of the plane to be constructed
  2040. * @param normal normal of the plane to be constructed
  2041. * @returns a new Plane the normal vector to this plane at the given origin point.
  2042. * Note : the vector "normal" is updated because normalized.
  2043. */
  2044. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2045. /**
  2046. * Calculates the distance from a plane and a point
  2047. * @param origin origin of the plane to be constructed
  2048. * @param normal normal of the plane to be constructed
  2049. * @param point point to calculate distance to
  2050. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2051. */
  2052. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2053. }
  2054. }
  2055. declare module "babylonjs/Maths/math.vector" {
  2056. import { Viewport } from "babylonjs/Maths/math.viewport";
  2057. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2058. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2059. import { Plane } from "babylonjs/Maths/math.plane";
  2060. /**
  2061. * Class representing a vector containing 2 coordinates
  2062. */
  2063. export class Vector2 {
  2064. /** defines the first coordinate */
  2065. x: number;
  2066. /** defines the second coordinate */
  2067. y: number;
  2068. /**
  2069. * Creates a new Vector2 from the given x and y coordinates
  2070. * @param x defines the first coordinate
  2071. * @param y defines the second coordinate
  2072. */
  2073. constructor(
  2074. /** defines the first coordinate */
  2075. x?: number,
  2076. /** defines the second coordinate */
  2077. y?: number);
  2078. /**
  2079. * Gets a string with the Vector2 coordinates
  2080. * @returns a string with the Vector2 coordinates
  2081. */
  2082. toString(): string;
  2083. /**
  2084. * Gets class name
  2085. * @returns the string "Vector2"
  2086. */
  2087. getClassName(): string;
  2088. /**
  2089. * Gets current vector hash code
  2090. * @returns the Vector2 hash code as a number
  2091. */
  2092. getHashCode(): number;
  2093. /**
  2094. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2095. * @param array defines the source array
  2096. * @param index defines the offset in source array
  2097. * @returns the current Vector2
  2098. */
  2099. toArray(array: FloatArray, index?: number): Vector2;
  2100. /**
  2101. * Copy the current vector to an array
  2102. * @returns a new array with 2 elements: the Vector2 coordinates.
  2103. */
  2104. asArray(): number[];
  2105. /**
  2106. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2107. * @param source defines the source Vector2
  2108. * @returns the current updated Vector2
  2109. */
  2110. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2111. /**
  2112. * Sets the Vector2 coordinates with the given floats
  2113. * @param x defines the first coordinate
  2114. * @param y defines the second coordinate
  2115. * @returns the current updated Vector2
  2116. */
  2117. copyFromFloats(x: number, y: number): Vector2;
  2118. /**
  2119. * Sets the Vector2 coordinates with the given floats
  2120. * @param x defines the first coordinate
  2121. * @param y defines the second coordinate
  2122. * @returns the current updated Vector2
  2123. */
  2124. set(x: number, y: number): Vector2;
  2125. /**
  2126. * Add another vector with the current one
  2127. * @param otherVector defines the other vector
  2128. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2129. */
  2130. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2131. /**
  2132. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2133. * @param otherVector defines the other vector
  2134. * @param result defines the target vector
  2135. * @returns the unmodified current Vector2
  2136. */
  2137. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2138. /**
  2139. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2140. * @param otherVector defines the other vector
  2141. * @returns the current updated Vector2
  2142. */
  2143. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2146. * @param otherVector defines the other vector
  2147. * @returns a new Vector2
  2148. */
  2149. addVector3(otherVector: Vector3): Vector2;
  2150. /**
  2151. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2152. * @param otherVector defines the other vector
  2153. * @returns a new Vector2
  2154. */
  2155. subtract(otherVector: Vector2): Vector2;
  2156. /**
  2157. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2158. * @param otherVector defines the other vector
  2159. * @param result defines the target vector
  2160. * @returns the unmodified current Vector2
  2161. */
  2162. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2163. /**
  2164. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2165. * @param otherVector defines the other vector
  2166. * @returns the current updated Vector2
  2167. */
  2168. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Multiplies in place the current Vector2 coordinates by the given ones
  2171. * @param otherVector defines the other vector
  2172. * @returns the current updated Vector2
  2173. */
  2174. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2175. /**
  2176. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2177. * @param otherVector defines the other vector
  2178. * @returns a new Vector2
  2179. */
  2180. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2183. * @param otherVector defines the other vector
  2184. * @param result defines the target vector
  2185. * @returns the unmodified current Vector2
  2186. */
  2187. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2190. * @param x defines the first coordinate
  2191. * @param y defines the second coordinate
  2192. * @returns a new Vector2
  2193. */
  2194. multiplyByFloats(x: number, y: number): Vector2;
  2195. /**
  2196. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2197. * @param otherVector defines the other vector
  2198. * @returns a new Vector2
  2199. */
  2200. divide(otherVector: Vector2): Vector2;
  2201. /**
  2202. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @param result defines the target vector
  2205. * @returns the unmodified current Vector2
  2206. */
  2207. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2208. /**
  2209. * Divides the current Vector2 coordinates by the given ones
  2210. * @param otherVector defines the other vector
  2211. * @returns the current updated Vector2
  2212. */
  2213. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Gets a new Vector2 with current Vector2 negated coordinates
  2216. * @returns a new Vector2
  2217. */
  2218. negate(): Vector2;
  2219. /**
  2220. * Negate this vector in place
  2221. * @returns this
  2222. */
  2223. negateInPlace(): Vector2;
  2224. /**
  2225. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2226. * @param result defines the Vector3 object where to store the result
  2227. * @returns the current Vector2
  2228. */
  2229. negateToRef(result: Vector2): Vector2;
  2230. /**
  2231. * Multiply the Vector2 coordinates by scale
  2232. * @param scale defines the scaling factor
  2233. * @returns the current updated Vector2
  2234. */
  2235. scaleInPlace(scale: number): Vector2;
  2236. /**
  2237. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2238. * @param scale defines the scaling factor
  2239. * @returns a new Vector2
  2240. */
  2241. scale(scale: number): Vector2;
  2242. /**
  2243. * Scale the current Vector2 values by a factor to a given Vector2
  2244. * @param scale defines the scale factor
  2245. * @param result defines the Vector2 object where to store the result
  2246. * @returns the unmodified current Vector2
  2247. */
  2248. scaleToRef(scale: number, result: Vector2): Vector2;
  2249. /**
  2250. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2251. * @param scale defines the scale factor
  2252. * @param result defines the Vector2 object where to store the result
  2253. * @returns the unmodified current Vector2
  2254. */
  2255. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2256. /**
  2257. * Gets a boolean if two vectors are equals
  2258. * @param otherVector defines the other vector
  2259. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2260. */
  2261. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2262. /**
  2263. * Gets a boolean if two vectors are equals (using an epsilon value)
  2264. * @param otherVector defines the other vector
  2265. * @param epsilon defines the minimal distance to consider equality
  2266. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2267. */
  2268. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2269. /**
  2270. * Gets a new Vector2 from current Vector2 floored values
  2271. * @returns a new Vector2
  2272. */
  2273. floor(): Vector2;
  2274. /**
  2275. * Gets a new Vector2 from current Vector2 floored values
  2276. * @returns a new Vector2
  2277. */
  2278. fract(): Vector2;
  2279. /**
  2280. * Gets the length of the vector
  2281. * @returns the vector length (float)
  2282. */
  2283. length(): number;
  2284. /**
  2285. * Gets the vector squared length
  2286. * @returns the vector squared length (float)
  2287. */
  2288. lengthSquared(): number;
  2289. /**
  2290. * Normalize the vector
  2291. * @returns the current updated Vector2
  2292. */
  2293. normalize(): Vector2;
  2294. /**
  2295. * Gets a new Vector2 copied from the Vector2
  2296. * @returns a new Vector2
  2297. */
  2298. clone(): Vector2;
  2299. /**
  2300. * Gets a new Vector2(0, 0)
  2301. * @returns a new Vector2
  2302. */
  2303. static Zero(): Vector2;
  2304. /**
  2305. * Gets a new Vector2(1, 1)
  2306. * @returns a new Vector2
  2307. */
  2308. static One(): Vector2;
  2309. /**
  2310. * Gets a new Vector2 set from the given index element of the given array
  2311. * @param array defines the data source
  2312. * @param offset defines the offset in the data source
  2313. * @returns a new Vector2
  2314. */
  2315. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2316. /**
  2317. * Sets "result" from the given index element of the given array
  2318. * @param array defines the data source
  2319. * @param offset defines the offset in the data source
  2320. * @param result defines the target vector
  2321. */
  2322. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2323. /**
  2324. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2325. * @param value1 defines 1st point of control
  2326. * @param value2 defines 2nd point of control
  2327. * @param value3 defines 3rd point of control
  2328. * @param value4 defines 4th point of control
  2329. * @param amount defines the interpolation factor
  2330. * @returns a new Vector2
  2331. */
  2332. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2333. /**
  2334. * 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".
  2335. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2336. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2337. * @param value defines the value to clamp
  2338. * @param min defines the lower limit
  2339. * @param max defines the upper limit
  2340. * @returns a new Vector2
  2341. */
  2342. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2343. /**
  2344. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2345. * @param value1 defines the 1st control point
  2346. * @param tangent1 defines the outgoing tangent
  2347. * @param value2 defines the 2nd control point
  2348. * @param tangent2 defines the incoming tangent
  2349. * @param amount defines the interpolation factor
  2350. * @returns a new Vector2
  2351. */
  2352. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2353. /**
  2354. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2355. * @param start defines the start vector
  2356. * @param end defines the end vector
  2357. * @param amount defines the interpolation factor
  2358. * @returns a new Vector2
  2359. */
  2360. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2361. /**
  2362. * Gets the dot product of the vector "left" and the vector "right"
  2363. * @param left defines first vector
  2364. * @param right defines second vector
  2365. * @returns the dot product (float)
  2366. */
  2367. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2368. /**
  2369. * Returns a new Vector2 equal to the normalized given vector
  2370. * @param vector defines the vector to normalize
  2371. * @returns a new Vector2
  2372. */
  2373. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2374. /**
  2375. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2376. * @param left defines 1st vector
  2377. * @param right defines 2nd vector
  2378. * @returns a new Vector2
  2379. */
  2380. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2383. * @param left defines 1st vector
  2384. * @param right defines 2nd vector
  2385. * @returns a new Vector2
  2386. */
  2387. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2388. /**
  2389. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2390. * @param vector defines the vector to transform
  2391. * @param transformation defines the matrix to apply
  2392. * @returns a new Vector2
  2393. */
  2394. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2395. /**
  2396. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2397. * @param vector defines the vector to transform
  2398. * @param transformation defines the matrix to apply
  2399. * @param result defines the target vector
  2400. */
  2401. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2402. /**
  2403. * Determines if a given vector is included in a triangle
  2404. * @param p defines the vector to test
  2405. * @param p0 defines 1st triangle point
  2406. * @param p1 defines 2nd triangle point
  2407. * @param p2 defines 3rd triangle point
  2408. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2409. */
  2410. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2411. /**
  2412. * Gets the distance between the vectors "value1" and "value2"
  2413. * @param value1 defines first vector
  2414. * @param value2 defines second vector
  2415. * @returns the distance between vectors
  2416. */
  2417. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2418. /**
  2419. * Returns the squared distance between the vectors "value1" and "value2"
  2420. * @param value1 defines first vector
  2421. * @param value2 defines second vector
  2422. * @returns the squared distance between vectors
  2423. */
  2424. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2425. /**
  2426. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2427. * @param value1 defines first vector
  2428. * @param value2 defines second vector
  2429. * @returns a new Vector2
  2430. */
  2431. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2432. /**
  2433. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2434. * @param p defines the middle point
  2435. * @param segA defines one point of the segment
  2436. * @param segB defines the other point of the segment
  2437. * @returns the shortest distance
  2438. */
  2439. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2440. }
  2441. /**
  2442. * Class used to store (x,y,z) vector representation
  2443. * A Vector3 is the main object used in 3D geometry
  2444. * It can represent etiher the coordinates of a point the space, either a direction
  2445. * Reminder: js uses a left handed forward facing system
  2446. */
  2447. export class Vector3 {
  2448. private static _UpReadOnly;
  2449. private static _ZeroReadOnly;
  2450. /** @hidden */
  2451. _x: number;
  2452. /** @hidden */
  2453. _y: number;
  2454. /** @hidden */
  2455. _z: number;
  2456. /** @hidden */
  2457. _isDirty: boolean;
  2458. /** Gets or sets the x coordinate */
  2459. get x(): number;
  2460. set x(value: number);
  2461. /** Gets or sets the y coordinate */
  2462. get y(): number;
  2463. set y(value: number);
  2464. /** Gets or sets the z coordinate */
  2465. get z(): number;
  2466. set z(value: number);
  2467. /**
  2468. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2469. * @param x defines the first coordinates (on X axis)
  2470. * @param y defines the second coordinates (on Y axis)
  2471. * @param z defines the third coordinates (on Z axis)
  2472. */
  2473. constructor(x?: number, y?: number, z?: number);
  2474. /**
  2475. * Creates a string representation of the Vector3
  2476. * @returns a string with the Vector3 coordinates.
  2477. */
  2478. toString(): string;
  2479. /**
  2480. * Gets the class name
  2481. * @returns the string "Vector3"
  2482. */
  2483. getClassName(): string;
  2484. /**
  2485. * Creates the Vector3 hash code
  2486. * @returns a number which tends to be unique between Vector3 instances
  2487. */
  2488. getHashCode(): number;
  2489. /**
  2490. * Creates an array containing three elements : the coordinates of the Vector3
  2491. * @returns a new array of numbers
  2492. */
  2493. asArray(): number[];
  2494. /**
  2495. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2496. * @param array defines the destination array
  2497. * @param index defines the offset in the destination array
  2498. * @returns the current Vector3
  2499. */
  2500. toArray(array: FloatArray, index?: number): Vector3;
  2501. /**
  2502. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2503. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2504. */
  2505. toQuaternion(): Quaternion;
  2506. /**
  2507. * Adds the given vector to the current Vector3
  2508. * @param otherVector defines the second operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2512. /**
  2513. * Adds the given coordinates to the current Vector3
  2514. * @param x defines the x coordinate of the operand
  2515. * @param y defines the y coordinate of the operand
  2516. * @param z defines the z coordinate of the operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2520. /**
  2521. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2522. * @param otherVector defines the second operand
  2523. * @returns the resulting Vector3
  2524. */
  2525. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2526. /**
  2527. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2528. * @param otherVector defines the second operand
  2529. * @param result defines the Vector3 object where to store the result
  2530. * @returns the current Vector3
  2531. */
  2532. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2533. /**
  2534. * Subtract the given vector from the current Vector3
  2535. * @param otherVector defines the second operand
  2536. * @returns the current updated Vector3
  2537. */
  2538. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2539. /**
  2540. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2541. * @param otherVector defines the second operand
  2542. * @returns the resulting Vector3
  2543. */
  2544. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2545. /**
  2546. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2547. * @param otherVector defines the second operand
  2548. * @param result defines the Vector3 object where to store the result
  2549. * @returns the current Vector3
  2550. */
  2551. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2552. /**
  2553. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the resulting Vector3
  2558. */
  2559. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2562. * @param x defines the x coordinate of the operand
  2563. * @param y defines the y coordinate of the operand
  2564. * @param z defines the z coordinate of the operand
  2565. * @param result defines the Vector3 object where to store the result
  2566. * @returns the current Vector3
  2567. */
  2568. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2569. /**
  2570. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2571. * @returns a new Vector3
  2572. */
  2573. negate(): Vector3;
  2574. /**
  2575. * Negate this vector in place
  2576. * @returns this
  2577. */
  2578. negateInPlace(): Vector3;
  2579. /**
  2580. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2581. * @param result defines the Vector3 object where to store the result
  2582. * @returns the current Vector3
  2583. */
  2584. negateToRef(result: Vector3): Vector3;
  2585. /**
  2586. * Multiplies the Vector3 coordinates by the float "scale"
  2587. * @param scale defines the multiplier factor
  2588. * @returns the current updated Vector3
  2589. */
  2590. scaleInPlace(scale: number): Vector3;
  2591. /**
  2592. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2593. * @param scale defines the multiplier factor
  2594. * @returns a new Vector3
  2595. */
  2596. scale(scale: number): Vector3;
  2597. /**
  2598. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2599. * @param scale defines the multiplier factor
  2600. * @param result defines the Vector3 object where to store the result
  2601. * @returns the current Vector3
  2602. */
  2603. scaleToRef(scale: number, result: Vector3): Vector3;
  2604. /**
  2605. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2606. * @param scale defines the scale factor
  2607. * @param result defines the Vector3 object where to store the result
  2608. * @returns the unmodified current Vector3
  2609. */
  2610. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2611. /**
  2612. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2613. * @param origin defines the origin of the projection ray
  2614. * @param plane defines the plane to project to
  2615. * @returns the projected vector3
  2616. */
  2617. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2618. /**
  2619. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2620. * @param origin defines the origin of the projection ray
  2621. * @param plane defines the plane to project to
  2622. * @param result defines the Vector3 where to store the result
  2623. */
  2624. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2625. /**
  2626. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2627. * @param otherVector defines the second operand
  2628. * @returns true if both vectors are equals
  2629. */
  2630. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2631. /**
  2632. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2633. * @param otherVector defines the second operand
  2634. * @param epsilon defines the minimal distance to define values as equals
  2635. * @returns true if both vectors are distant less than epsilon
  2636. */
  2637. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2638. /**
  2639. * Returns true if the current Vector3 coordinates equals the given floats
  2640. * @param x defines the x coordinate of the operand
  2641. * @param y defines the y coordinate of the operand
  2642. * @param z defines the z coordinate of the operand
  2643. * @returns true if both vectors are equals
  2644. */
  2645. equalsToFloats(x: number, y: number, z: number): boolean;
  2646. /**
  2647. * Multiplies the current Vector3 coordinates by the given ones
  2648. * @param otherVector defines the second operand
  2649. * @returns the current updated Vector3
  2650. */
  2651. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2654. * @param otherVector defines the second operand
  2655. * @returns the new Vector3
  2656. */
  2657. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2658. /**
  2659. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2660. * @param otherVector defines the second operand
  2661. * @param result defines the Vector3 object where to store the result
  2662. * @returns the current Vector3
  2663. */
  2664. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2665. /**
  2666. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2667. * @param x defines the x coordinate of the operand
  2668. * @param y defines the y coordinate of the operand
  2669. * @param z defines the z coordinate of the operand
  2670. * @returns the new Vector3
  2671. */
  2672. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2673. /**
  2674. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2675. * @param otherVector defines the second operand
  2676. * @returns the new Vector3
  2677. */
  2678. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2679. /**
  2680. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2681. * @param otherVector defines the second operand
  2682. * @param result defines the Vector3 object where to store the result
  2683. * @returns the current Vector3
  2684. */
  2685. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2686. /**
  2687. * Divides the current Vector3 coordinates by the given ones.
  2688. * @param otherVector defines the second operand
  2689. * @returns the current updated Vector3
  2690. */
  2691. divideInPlace(otherVector: Vector3): Vector3;
  2692. /**
  2693. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2694. * @param other defines the second operand
  2695. * @returns the current updated Vector3
  2696. */
  2697. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2698. /**
  2699. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2700. * @param other defines the second operand
  2701. * @returns the current updated Vector3
  2702. */
  2703. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2704. /**
  2705. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2706. * @param x defines the x coordinate of the operand
  2707. * @param y defines the y coordinate of the operand
  2708. * @param z defines the z coordinate of the operand
  2709. * @returns the current updated Vector3
  2710. */
  2711. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2712. /**
  2713. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2714. * @param x defines the x coordinate of the operand
  2715. * @param y defines the y coordinate of the operand
  2716. * @param z defines the z coordinate of the operand
  2717. * @returns the current updated Vector3
  2718. */
  2719. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2720. /**
  2721. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2722. * Check if is non uniform within a certain amount of decimal places to account for this
  2723. * @param epsilon the amount the values can differ
  2724. * @returns if the the vector is non uniform to a certain number of decimal places
  2725. */
  2726. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2727. /**
  2728. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2729. */
  2730. get isNonUniform(): boolean;
  2731. /**
  2732. * Gets a new Vector3 from current Vector3 floored values
  2733. * @returns a new Vector3
  2734. */
  2735. floor(): Vector3;
  2736. /**
  2737. * Gets a new Vector3 from current Vector3 floored values
  2738. * @returns a new Vector3
  2739. */
  2740. fract(): Vector3;
  2741. /**
  2742. * Gets the length of the Vector3
  2743. * @returns the length of the Vector3
  2744. */
  2745. length(): number;
  2746. /**
  2747. * Gets the squared length of the Vector3
  2748. * @returns squared length of the Vector3
  2749. */
  2750. lengthSquared(): number;
  2751. /**
  2752. * Normalize the current Vector3.
  2753. * Please note that this is an in place operation.
  2754. * @returns the current updated Vector3
  2755. */
  2756. normalize(): Vector3;
  2757. /**
  2758. * Reorders the x y z properties of the vector in place
  2759. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2760. * @returns the current updated vector
  2761. */
  2762. reorderInPlace(order: string): this;
  2763. /**
  2764. * Rotates the vector around 0,0,0 by a quaternion
  2765. * @param quaternion the rotation quaternion
  2766. * @param result vector to store the result
  2767. * @returns the resulting vector
  2768. */
  2769. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2770. /**
  2771. * Rotates a vector around a given point
  2772. * @param quaternion the rotation quaternion
  2773. * @param point the point to rotate around
  2774. * @param result vector to store the result
  2775. * @returns the resulting vector
  2776. */
  2777. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2778. /**
  2779. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2780. * The cross product is then orthogonal to both current and "other"
  2781. * @param other defines the right operand
  2782. * @returns the cross product
  2783. */
  2784. cross(other: Vector3): Vector3;
  2785. /**
  2786. * Normalize the current Vector3 with the given input length.
  2787. * Please note that this is an in place operation.
  2788. * @param len the length of the vector
  2789. * @returns the current updated Vector3
  2790. */
  2791. normalizeFromLength(len: number): Vector3;
  2792. /**
  2793. * Normalize the current Vector3 to a new vector
  2794. * @returns the new Vector3
  2795. */
  2796. normalizeToNew(): Vector3;
  2797. /**
  2798. * Normalize the current Vector3 to the reference
  2799. * @param reference define the Vector3 to update
  2800. * @returns the updated Vector3
  2801. */
  2802. normalizeToRef(reference: Vector3): Vector3;
  2803. /**
  2804. * Creates a new Vector3 copied from the current Vector3
  2805. * @returns the new Vector3
  2806. */
  2807. clone(): Vector3;
  2808. /**
  2809. * Copies the given vector coordinates to the current Vector3 ones
  2810. * @param source defines the source Vector3
  2811. * @returns the current updated Vector3
  2812. */
  2813. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2814. /**
  2815. * Copies the given floats to the current Vector3 coordinates
  2816. * @param x defines the x coordinate of the operand
  2817. * @param y defines the y coordinate of the operand
  2818. * @param z defines the z coordinate of the operand
  2819. * @returns the current updated Vector3
  2820. */
  2821. copyFromFloats(x: number, y: number, z: number): Vector3;
  2822. /**
  2823. * Copies the given floats to the current Vector3 coordinates
  2824. * @param x defines the x coordinate of the operand
  2825. * @param y defines the y coordinate of the operand
  2826. * @param z defines the z coordinate of the operand
  2827. * @returns the current updated Vector3
  2828. */
  2829. set(x: number, y: number, z: number): Vector3;
  2830. /**
  2831. * Copies the given float to the current Vector3 coordinates
  2832. * @param v defines the x, y and z coordinates of the operand
  2833. * @returns the current updated Vector3
  2834. */
  2835. setAll(v: number): Vector3;
  2836. /**
  2837. * Get the clip factor between two vectors
  2838. * @param vector0 defines the first operand
  2839. * @param vector1 defines the second operand
  2840. * @param axis defines the axis to use
  2841. * @param size defines the size along the axis
  2842. * @returns the clip factor
  2843. */
  2844. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2845. /**
  2846. * Get angle between two vectors
  2847. * @param vector0 angle between vector0 and vector1
  2848. * @param vector1 angle between vector0 and vector1
  2849. * @param normal direction of the normal
  2850. * @return the angle between vector0 and vector1
  2851. */
  2852. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2853. /**
  2854. * Returns a new Vector3 set from the index "offset" of the given array
  2855. * @param array defines the source array
  2856. * @param offset defines the offset in the source array
  2857. * @returns the new Vector3
  2858. */
  2859. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2860. /**
  2861. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2862. * @param array defines the source array
  2863. * @param offset defines the offset in the source array
  2864. * @returns the new Vector3
  2865. * @deprecated Please use FromArray instead.
  2866. */
  2867. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2868. /**
  2869. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2870. * @param array defines the source array
  2871. * @param offset defines the offset in the source array
  2872. * @param result defines the Vector3 where to store the result
  2873. */
  2874. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2875. /**
  2876. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2877. * @param array defines the source array
  2878. * @param offset defines the offset in the source array
  2879. * @param result defines the Vector3 where to store the result
  2880. * @deprecated Please use FromArrayToRef instead.
  2881. */
  2882. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2883. /**
  2884. * Sets the given vector "result" with the given floats.
  2885. * @param x defines the x coordinate of the source
  2886. * @param y defines the y coordinate of the source
  2887. * @param z defines the z coordinate of the source
  2888. * @param result defines the Vector3 where to store the result
  2889. */
  2890. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2891. /**
  2892. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2893. * @returns a new empty Vector3
  2894. */
  2895. static Zero(): Vector3;
  2896. /**
  2897. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2898. * @returns a new unit Vector3
  2899. */
  2900. static One(): Vector3;
  2901. /**
  2902. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2903. * @returns a new up Vector3
  2904. */
  2905. static Up(): Vector3;
  2906. /**
  2907. * Gets a up Vector3 that must not be updated
  2908. */
  2909. static get UpReadOnly(): DeepImmutable<Vector3>;
  2910. /**
  2911. * Gets a zero Vector3 that must not be updated
  2912. */
  2913. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2914. /**
  2915. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2916. * @returns a new down Vector3
  2917. */
  2918. static Down(): Vector3;
  2919. /**
  2920. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2921. * @param rightHandedSystem is the scene right-handed (negative z)
  2922. * @returns a new forward Vector3
  2923. */
  2924. static Forward(rightHandedSystem?: boolean): Vector3;
  2925. /**
  2926. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2927. * @param rightHandedSystem is the scene right-handed (negative-z)
  2928. * @returns a new forward Vector3
  2929. */
  2930. static Backward(rightHandedSystem?: boolean): Vector3;
  2931. /**
  2932. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2933. * @returns a new right Vector3
  2934. */
  2935. static Right(): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2938. * @returns a new left Vector3
  2939. */
  2940. static Left(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2943. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2944. * @param vector defines the Vector3 to transform
  2945. * @param transformation defines the transformation matrix
  2946. * @returns the transformed Vector3
  2947. */
  2948. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2949. /**
  2950. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2951. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2952. * @param vector defines the Vector3 to transform
  2953. * @param transformation defines the transformation matrix
  2954. * @param result defines the Vector3 where to store the result
  2955. */
  2956. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2957. /**
  2958. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2959. * This method computes tranformed coordinates only, not transformed direction vectors
  2960. * @param x define the x coordinate of the source vector
  2961. * @param y define the y coordinate of the source vector
  2962. * @param z define the z coordinate of the source vector
  2963. * @param transformation defines the transformation matrix
  2964. * @param result defines the Vector3 where to store the result
  2965. */
  2966. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2967. /**
  2968. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2969. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2970. * @param vector defines the Vector3 to transform
  2971. * @param transformation defines the transformation matrix
  2972. * @returns the new Vector3
  2973. */
  2974. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2975. /**
  2976. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2977. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2978. * @param vector defines the Vector3 to transform
  2979. * @param transformation defines the transformation matrix
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2985. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2986. * @param x define the x coordinate of the source vector
  2987. * @param y define the y coordinate of the source vector
  2988. * @param z define the z coordinate of the source vector
  2989. * @param transformation defines the transformation matrix
  2990. * @param result defines the Vector3 where to store the result
  2991. */
  2992. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2993. /**
  2994. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2995. * @param value1 defines the first control point
  2996. * @param value2 defines the second control point
  2997. * @param value3 defines the third control point
  2998. * @param value4 defines the fourth control point
  2999. * @param amount defines the amount on the spline to use
  3000. * @returns the new Vector3
  3001. */
  3002. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3003. /**
  3004. * 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"
  3005. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3006. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3007. * @param value defines the current value
  3008. * @param min defines the lower range value
  3009. * @param max defines the upper range value
  3010. * @returns the new Vector3
  3011. */
  3012. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3013. /**
  3014. * 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"
  3015. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3016. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3017. * @param value defines the current value
  3018. * @param min defines the lower range value
  3019. * @param max defines the upper range value
  3020. * @param result defines the Vector3 where to store the result
  3021. */
  3022. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3023. /**
  3024. * Checks if a given vector is inside a specific range
  3025. * @param v defines the vector to test
  3026. * @param min defines the minimum range
  3027. * @param max defines the maximum range
  3028. */
  3029. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3030. /**
  3031. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3032. * @param value1 defines the first control point
  3033. * @param tangent1 defines the first tangent vector
  3034. * @param value2 defines the second control point
  3035. * @param tangent2 defines the second tangent vector
  3036. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3037. * @returns the new Vector3
  3038. */
  3039. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3040. /**
  3041. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3042. * @param start defines the start value
  3043. * @param end defines the end value
  3044. * @param amount max defines amount between both (between 0 and 1)
  3045. * @returns the new Vector3
  3046. */
  3047. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3050. * @param start defines the start value
  3051. * @param end defines the end value
  3052. * @param amount max defines amount between both (between 0 and 1)
  3053. * @param result defines the Vector3 where to store the result
  3054. */
  3055. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3056. /**
  3057. * Returns the dot product (float) between the vectors "left" and "right"
  3058. * @param left defines the left operand
  3059. * @param right defines the right operand
  3060. * @returns the dot product
  3061. */
  3062. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3063. /**
  3064. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3065. * The cross product is then orthogonal to both "left" and "right"
  3066. * @param left defines the left operand
  3067. * @param right defines the right operand
  3068. * @returns the cross product
  3069. */
  3070. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3071. /**
  3072. * Sets the given vector "result" with the cross product of "left" and "right"
  3073. * The cross product is then orthogonal to both "left" and "right"
  3074. * @param left defines the left operand
  3075. * @param right defines the right operand
  3076. * @param result defines the Vector3 where to store the result
  3077. */
  3078. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3079. /**
  3080. * Returns a new Vector3 as the normalization of the given vector
  3081. * @param vector defines the Vector3 to normalize
  3082. * @returns the new Vector3
  3083. */
  3084. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3085. /**
  3086. * Sets the given vector "result" with the normalization of the given first vector
  3087. * @param vector defines the Vector3 to normalize
  3088. * @param result defines the Vector3 where to store the result
  3089. */
  3090. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3091. /**
  3092. * Project a Vector3 onto screen space
  3093. * @param vector defines the Vector3 to project
  3094. * @param world defines the world matrix to use
  3095. * @param transform defines the transform (view x projection) matrix to use
  3096. * @param viewport defines the screen viewport to use
  3097. * @returns the new Vector3
  3098. */
  3099. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3100. /** @hidden */
  3101. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3102. /**
  3103. * Unproject from screen space to object space
  3104. * @param source defines the screen space Vector3 to use
  3105. * @param viewportWidth defines the current width of the viewport
  3106. * @param viewportHeight defines the current height of the viewport
  3107. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3108. * @param transform defines the transform (view x projection) matrix to use
  3109. * @returns the new Vector3
  3110. */
  3111. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3112. /**
  3113. * Unproject from screen space to object space
  3114. * @param source defines the screen space Vector3 to use
  3115. * @param viewportWidth defines the current width of the viewport
  3116. * @param viewportHeight defines the current height of the viewport
  3117. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3118. * @param view defines the view matrix to use
  3119. * @param projection defines the projection matrix to use
  3120. * @returns the new Vector3
  3121. */
  3122. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3123. /**
  3124. * Unproject from screen space to object space
  3125. * @param source defines the screen space Vector3 to use
  3126. * @param viewportWidth defines the current width of the viewport
  3127. * @param viewportHeight defines the current height of the viewport
  3128. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3129. * @param view defines the view matrix to use
  3130. * @param projection defines the projection matrix to use
  3131. * @param result defines the Vector3 where to store the result
  3132. */
  3133. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3134. /**
  3135. * Unproject from screen space to object space
  3136. * @param sourceX defines the screen space x coordinate to use
  3137. * @param sourceY defines the screen space y coordinate to use
  3138. * @param sourceZ defines the screen space z coordinate to use
  3139. * @param viewportWidth defines the current width of the viewport
  3140. * @param viewportHeight defines the current height of the viewport
  3141. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3142. * @param view defines the view matrix to use
  3143. * @param projection defines the projection matrix to use
  3144. * @param result defines the Vector3 where to store the result
  3145. */
  3146. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Gets the minimal coordinate values between two Vector3
  3149. * @param left defines the first operand
  3150. * @param right defines the second operand
  3151. * @returns the new Vector3
  3152. */
  3153. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3154. /**
  3155. * Gets the maximal coordinate values between two Vector3
  3156. * @param left defines the first operand
  3157. * @param right defines the second operand
  3158. * @returns the new Vector3
  3159. */
  3160. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3161. /**
  3162. * Returns the distance between the vectors "value1" and "value2"
  3163. * @param value1 defines the first operand
  3164. * @param value2 defines the second operand
  3165. * @returns the distance
  3166. */
  3167. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3168. /**
  3169. * Returns the squared distance between the vectors "value1" and "value2"
  3170. * @param value1 defines the first operand
  3171. * @param value2 defines the second operand
  3172. * @returns the squared distance
  3173. */
  3174. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3175. /**
  3176. * Returns a new Vector3 located at the center between "value1" and "value2"
  3177. * @param value1 defines the first operand
  3178. * @param value2 defines the second operand
  3179. * @returns the new Vector3
  3180. */
  3181. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3182. /**
  3183. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3184. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3185. * to something in order to rotate it from its local system to the given target system
  3186. * Note: axis1, axis2 and axis3 are normalized during this operation
  3187. * @param axis1 defines the first axis
  3188. * @param axis2 defines the second axis
  3189. * @param axis3 defines the third axis
  3190. * @returns a new Vector3
  3191. */
  3192. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3193. /**
  3194. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3195. * @param axis1 defines the first axis
  3196. * @param axis2 defines the second axis
  3197. * @param axis3 defines the third axis
  3198. * @param ref defines the Vector3 where to store the result
  3199. */
  3200. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3201. }
  3202. /**
  3203. * Vector4 class created for EulerAngle class conversion to Quaternion
  3204. */
  3205. export class Vector4 {
  3206. /** x value of the vector */
  3207. x: number;
  3208. /** y value of the vector */
  3209. y: number;
  3210. /** z value of the vector */
  3211. z: number;
  3212. /** w value of the vector */
  3213. w: number;
  3214. /**
  3215. * Creates a Vector4 object from the given floats.
  3216. * @param x x value of the vector
  3217. * @param y y value of the vector
  3218. * @param z z value of the vector
  3219. * @param w w value of the vector
  3220. */
  3221. constructor(
  3222. /** x value of the vector */
  3223. x: number,
  3224. /** y value of the vector */
  3225. y: number,
  3226. /** z value of the vector */
  3227. z: number,
  3228. /** w value of the vector */
  3229. w: number);
  3230. /**
  3231. * Returns the string with the Vector4 coordinates.
  3232. * @returns a string containing all the vector values
  3233. */
  3234. toString(): string;
  3235. /**
  3236. * Returns the string "Vector4".
  3237. * @returns "Vector4"
  3238. */
  3239. getClassName(): string;
  3240. /**
  3241. * Returns the Vector4 hash code.
  3242. * @returns a unique hash code
  3243. */
  3244. getHashCode(): number;
  3245. /**
  3246. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3247. * @returns the resulting array
  3248. */
  3249. asArray(): number[];
  3250. /**
  3251. * Populates the given array from the given index with the Vector4 coordinates.
  3252. * @param array array to populate
  3253. * @param index index of the array to start at (default: 0)
  3254. * @returns the Vector4.
  3255. */
  3256. toArray(array: FloatArray, index?: number): Vector4;
  3257. /**
  3258. * Adds the given vector to the current Vector4.
  3259. * @param otherVector the vector to add
  3260. * @returns the updated Vector4.
  3261. */
  3262. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3263. /**
  3264. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3265. * @param otherVector the vector to add
  3266. * @returns the resulting vector
  3267. */
  3268. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3271. * @param otherVector the vector to add
  3272. * @param result the vector to store the result
  3273. * @returns the current Vector4.
  3274. */
  3275. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3276. /**
  3277. * Subtract in place the given vector from the current Vector4.
  3278. * @param otherVector the vector to subtract
  3279. * @returns the updated Vector4.
  3280. */
  3281. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3282. /**
  3283. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3284. * @param otherVector the vector to add
  3285. * @returns the new vector with the result
  3286. */
  3287. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3288. /**
  3289. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3290. * @param otherVector the vector to subtract
  3291. * @param result the vector to store the result
  3292. * @returns the current Vector4.
  3293. */
  3294. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3295. /**
  3296. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3297. */
  3298. /**
  3299. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3300. * @param x value to subtract
  3301. * @param y value to subtract
  3302. * @param z value to subtract
  3303. * @param w value to subtract
  3304. * @returns new vector containing the result
  3305. */
  3306. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3307. /**
  3308. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3309. * @param x value to subtract
  3310. * @param y value to subtract
  3311. * @param z value to subtract
  3312. * @param w value to subtract
  3313. * @param result the vector to store the result in
  3314. * @returns the current Vector4.
  3315. */
  3316. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3317. /**
  3318. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3319. * @returns a new vector with the negated values
  3320. */
  3321. negate(): Vector4;
  3322. /**
  3323. * Negate this vector in place
  3324. * @returns this
  3325. */
  3326. negateInPlace(): Vector4;
  3327. /**
  3328. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3329. * @param result defines the Vector3 object where to store the result
  3330. * @returns the current Vector4
  3331. */
  3332. negateToRef(result: Vector4): Vector4;
  3333. /**
  3334. * Multiplies the current Vector4 coordinates by scale (float).
  3335. * @param scale the number to scale with
  3336. * @returns the updated Vector4.
  3337. */
  3338. scaleInPlace(scale: number): Vector4;
  3339. /**
  3340. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3341. * @param scale the number to scale with
  3342. * @returns a new vector with the result
  3343. */
  3344. scale(scale: number): Vector4;
  3345. /**
  3346. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3347. * @param scale the number to scale with
  3348. * @param result a vector to store the result in
  3349. * @returns the current Vector4.
  3350. */
  3351. scaleToRef(scale: number, result: Vector4): Vector4;
  3352. /**
  3353. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3354. * @param scale defines the scale factor
  3355. * @param result defines the Vector4 object where to store the result
  3356. * @returns the unmodified current Vector4
  3357. */
  3358. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3359. /**
  3360. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3361. * @param otherVector the vector to compare against
  3362. * @returns true if they are equal
  3363. */
  3364. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3365. /**
  3366. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3367. * @param otherVector vector to compare against
  3368. * @param epsilon (Default: very small number)
  3369. * @returns true if they are equal
  3370. */
  3371. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3372. /**
  3373. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3374. * @param x x value to compare against
  3375. * @param y y value to compare against
  3376. * @param z z value to compare against
  3377. * @param w w value to compare against
  3378. * @returns true if equal
  3379. */
  3380. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3381. /**
  3382. * Multiplies in place the current Vector4 by the given one.
  3383. * @param otherVector vector to multiple with
  3384. * @returns the updated Vector4.
  3385. */
  3386. multiplyInPlace(otherVector: Vector4): Vector4;
  3387. /**
  3388. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3389. * @param otherVector vector to multiple with
  3390. * @returns resulting new vector
  3391. */
  3392. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3393. /**
  3394. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3395. * @param otherVector vector to multiple with
  3396. * @param result vector to store the result
  3397. * @returns the current Vector4.
  3398. */
  3399. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3400. /**
  3401. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3402. * @param x x value multiply with
  3403. * @param y y value multiply with
  3404. * @param z z value multiply with
  3405. * @param w w value multiply with
  3406. * @returns resulting new vector
  3407. */
  3408. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3409. /**
  3410. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3411. * @param otherVector vector to devide with
  3412. * @returns resulting new vector
  3413. */
  3414. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3415. /**
  3416. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3417. * @param otherVector vector to devide with
  3418. * @param result vector to store the result
  3419. * @returns the current Vector4.
  3420. */
  3421. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3422. /**
  3423. * Divides the current Vector3 coordinates by the given ones.
  3424. * @param otherVector vector to devide with
  3425. * @returns the updated Vector3.
  3426. */
  3427. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3428. /**
  3429. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3430. * @param other defines the second operand
  3431. * @returns the current updated Vector4
  3432. */
  3433. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3434. /**
  3435. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3436. * @param other defines the second operand
  3437. * @returns the current updated Vector4
  3438. */
  3439. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3440. /**
  3441. * Gets a new Vector4 from current Vector4 floored values
  3442. * @returns a new Vector4
  3443. */
  3444. floor(): Vector4;
  3445. /**
  3446. * Gets a new Vector4 from current Vector3 floored values
  3447. * @returns a new Vector4
  3448. */
  3449. fract(): Vector4;
  3450. /**
  3451. * Returns the Vector4 length (float).
  3452. * @returns the length
  3453. */
  3454. length(): number;
  3455. /**
  3456. * Returns the Vector4 squared length (float).
  3457. * @returns the length squared
  3458. */
  3459. lengthSquared(): number;
  3460. /**
  3461. * Normalizes in place the Vector4.
  3462. * @returns the updated Vector4.
  3463. */
  3464. normalize(): Vector4;
  3465. /**
  3466. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3467. * @returns this converted to a new vector3
  3468. */
  3469. toVector3(): Vector3;
  3470. /**
  3471. * Returns a new Vector4 copied from the current one.
  3472. * @returns the new cloned vector
  3473. */
  3474. clone(): Vector4;
  3475. /**
  3476. * Updates the current Vector4 with the given one coordinates.
  3477. * @param source the source vector to copy from
  3478. * @returns the updated Vector4.
  3479. */
  3480. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3481. /**
  3482. * Updates the current Vector4 coordinates with the given floats.
  3483. * @param x float to copy from
  3484. * @param y float to copy from
  3485. * @param z float to copy from
  3486. * @param w float to copy from
  3487. * @returns the updated Vector4.
  3488. */
  3489. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3490. /**
  3491. * Updates the current Vector4 coordinates with the given floats.
  3492. * @param x float to set from
  3493. * @param y float to set from
  3494. * @param z float to set from
  3495. * @param w float to set from
  3496. * @returns the updated Vector4.
  3497. */
  3498. set(x: number, y: number, z: number, w: number): Vector4;
  3499. /**
  3500. * Copies the given float to the current Vector3 coordinates
  3501. * @param v defines the x, y, z and w coordinates of the operand
  3502. * @returns the current updated Vector3
  3503. */
  3504. setAll(v: number): Vector4;
  3505. /**
  3506. * Returns a new Vector4 set from the starting index of the given array.
  3507. * @param array the array to pull values from
  3508. * @param offset the offset into the array to start at
  3509. * @returns the new vector
  3510. */
  3511. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3512. /**
  3513. * Updates the given vector "result" from the starting index of the given array.
  3514. * @param array the array to pull values from
  3515. * @param offset the offset into the array to start at
  3516. * @param result the vector to store the result in
  3517. */
  3518. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3519. /**
  3520. * Updates the given vector "result" from the starting index of the given Float32Array.
  3521. * @param array the array to pull values from
  3522. * @param offset the offset into the array to start at
  3523. * @param result the vector to store the result in
  3524. */
  3525. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3526. /**
  3527. * Updates the given vector "result" coordinates from the given floats.
  3528. * @param x float to set from
  3529. * @param y float to set from
  3530. * @param z float to set from
  3531. * @param w float to set from
  3532. * @param result the vector to the floats in
  3533. */
  3534. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3535. /**
  3536. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3537. * @returns the new vector
  3538. */
  3539. static Zero(): Vector4;
  3540. /**
  3541. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3542. * @returns the new vector
  3543. */
  3544. static One(): Vector4;
  3545. /**
  3546. * Returns a new normalized Vector4 from the given one.
  3547. * @param vector the vector to normalize
  3548. * @returns the vector
  3549. */
  3550. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3551. /**
  3552. * Updates the given vector "result" from the normalization of the given one.
  3553. * @param vector the vector to normalize
  3554. * @param result the vector to store the result in
  3555. */
  3556. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3557. /**
  3558. * Returns a vector with the minimum values from the left and right vectors
  3559. * @param left left vector to minimize
  3560. * @param right right vector to minimize
  3561. * @returns a new vector with the minimum of the left and right vector values
  3562. */
  3563. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3564. /**
  3565. * Returns a vector with the maximum values from the left and right vectors
  3566. * @param left left vector to maximize
  3567. * @param right right vector to maximize
  3568. * @returns a new vector with the maximum of the left and right vector values
  3569. */
  3570. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3571. /**
  3572. * Returns the distance (float) between the vectors "value1" and "value2".
  3573. * @param value1 value to calulate the distance between
  3574. * @param value2 value to calulate the distance between
  3575. * @return the distance between the two vectors
  3576. */
  3577. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3578. /**
  3579. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3580. * @param value1 value to calulate the distance between
  3581. * @param value2 value to calulate the distance between
  3582. * @return the distance between the two vectors squared
  3583. */
  3584. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3585. /**
  3586. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3587. * @param value1 value to calulate the center between
  3588. * @param value2 value to calulate the center between
  3589. * @return the center between the two vectors
  3590. */
  3591. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3594. * This methods computes transformed normalized direction vectors only.
  3595. * @param vector the vector to transform
  3596. * @param transformation the transformation matrix to apply
  3597. * @returns the new vector
  3598. */
  3599. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3600. /**
  3601. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3602. * This methods computes transformed normalized direction vectors only.
  3603. * @param vector the vector to transform
  3604. * @param transformation the transformation matrix to apply
  3605. * @param result the vector to store the result in
  3606. */
  3607. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3608. /**
  3609. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param x value to transform
  3612. * @param y value to transform
  3613. * @param z value to transform
  3614. * @param w value to transform
  3615. * @param transformation the transformation matrix to apply
  3616. * @param result the vector to store the results in
  3617. */
  3618. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3619. /**
  3620. * Creates a new Vector4 from a Vector3
  3621. * @param source defines the source data
  3622. * @param w defines the 4th component (default is 0)
  3623. * @returns a new Vector4
  3624. */
  3625. static FromVector3(source: Vector3, w?: number): Vector4;
  3626. }
  3627. /**
  3628. * Class used to store quaternion data
  3629. * @see https://en.wikipedia.org/wiki/Quaternion
  3630. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3631. */
  3632. export class Quaternion {
  3633. /** @hidden */
  3634. _x: number;
  3635. /** @hidden */
  3636. _y: number;
  3637. /** @hidden */
  3638. _z: number;
  3639. /** @hidden */
  3640. _w: number;
  3641. /** @hidden */
  3642. _isDirty: boolean;
  3643. /** Gets or sets the x coordinate */
  3644. get x(): number;
  3645. set x(value: number);
  3646. /** Gets or sets the y coordinate */
  3647. get y(): number;
  3648. set y(value: number);
  3649. /** Gets or sets the z coordinate */
  3650. get z(): number;
  3651. set z(value: number);
  3652. /** Gets or sets the w coordinate */
  3653. get w(): number;
  3654. set w(value: number);
  3655. /**
  3656. * Creates a new Quaternion from the given floats
  3657. * @param x defines the first component (0 by default)
  3658. * @param y defines the second component (0 by default)
  3659. * @param z defines the third component (0 by default)
  3660. * @param w defines the fourth component (1.0 by default)
  3661. */
  3662. constructor(x?: number, y?: number, z?: number, w?: number);
  3663. /**
  3664. * Gets a string representation for the current quaternion
  3665. * @returns a string with the Quaternion coordinates
  3666. */
  3667. toString(): string;
  3668. /**
  3669. * Gets the class name of the quaternion
  3670. * @returns the string "Quaternion"
  3671. */
  3672. getClassName(): string;
  3673. /**
  3674. * Gets a hash code for this quaternion
  3675. * @returns the quaternion hash code
  3676. */
  3677. getHashCode(): number;
  3678. /**
  3679. * Copy the quaternion to an array
  3680. * @returns a new array populated with 4 elements from the quaternion coordinates
  3681. */
  3682. asArray(): number[];
  3683. /**
  3684. * Check if two quaternions are equals
  3685. * @param otherQuaternion defines the second operand
  3686. * @return true if the current quaternion and the given one coordinates are strictly equals
  3687. */
  3688. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3689. /**
  3690. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3691. * @param otherQuaternion defines the other quaternion
  3692. * @param epsilon defines the minimal distance to consider equality
  3693. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3694. */
  3695. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3696. /**
  3697. * Clone the current quaternion
  3698. * @returns a new quaternion copied from the current one
  3699. */
  3700. clone(): Quaternion;
  3701. /**
  3702. * Copy a quaternion to the current one
  3703. * @param other defines the other quaternion
  3704. * @returns the updated current quaternion
  3705. */
  3706. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3707. /**
  3708. * Updates the current quaternion with the given float coordinates
  3709. * @param x defines the x coordinate
  3710. * @param y defines the y coordinate
  3711. * @param z defines the z coordinate
  3712. * @param w defines the w coordinate
  3713. * @returns the updated current quaternion
  3714. */
  3715. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3716. /**
  3717. * Updates the current quaternion from the given float coordinates
  3718. * @param x defines the x coordinate
  3719. * @param y defines the y coordinate
  3720. * @param z defines the z coordinate
  3721. * @param w defines the w coordinate
  3722. * @returns the updated current quaternion
  3723. */
  3724. set(x: number, y: number, z: number, w: number): Quaternion;
  3725. /**
  3726. * Adds two quaternions
  3727. * @param other defines the second operand
  3728. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3729. */
  3730. add(other: DeepImmutable<Quaternion>): Quaternion;
  3731. /**
  3732. * Add a quaternion to the current one
  3733. * @param other defines the quaternion to add
  3734. * @returns the current quaternion
  3735. */
  3736. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3737. /**
  3738. * Subtract two quaternions
  3739. * @param other defines the second operand
  3740. * @returns a new quaternion as the subtraction result of the given one from the current one
  3741. */
  3742. subtract(other: Quaternion): Quaternion;
  3743. /**
  3744. * Multiplies the current quaternion by a scale factor
  3745. * @param value defines the scale factor
  3746. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3747. */
  3748. scale(value: number): Quaternion;
  3749. /**
  3750. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3751. * @param scale defines the scale factor
  3752. * @param result defines the Quaternion object where to store the result
  3753. * @returns the unmodified current quaternion
  3754. */
  3755. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3756. /**
  3757. * Multiplies in place the current quaternion by a scale factor
  3758. * @param value defines the scale factor
  3759. * @returns the current modified quaternion
  3760. */
  3761. scaleInPlace(value: number): Quaternion;
  3762. /**
  3763. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3764. * @param scale defines the scale factor
  3765. * @param result defines the Quaternion object where to store the result
  3766. * @returns the unmodified current quaternion
  3767. */
  3768. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3769. /**
  3770. * Multiplies two quaternions
  3771. * @param q1 defines the second operand
  3772. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3773. */
  3774. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3775. /**
  3776. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3777. * @param q1 defines the second operand
  3778. * @param result defines the target quaternion
  3779. * @returns the current quaternion
  3780. */
  3781. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3782. /**
  3783. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3784. * @param q1 defines the second operand
  3785. * @returns the currentupdated quaternion
  3786. */
  3787. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3790. * @param ref defines the target quaternion
  3791. * @returns the current quaternion
  3792. */
  3793. conjugateToRef(ref: Quaternion): Quaternion;
  3794. /**
  3795. * Conjugates in place (1-q) the current quaternion
  3796. * @returns the current updated quaternion
  3797. */
  3798. conjugateInPlace(): Quaternion;
  3799. /**
  3800. * Conjugates in place (1-q) the current quaternion
  3801. * @returns a new quaternion
  3802. */
  3803. conjugate(): Quaternion;
  3804. /**
  3805. * Gets length of current quaternion
  3806. * @returns the quaternion length (float)
  3807. */
  3808. length(): number;
  3809. /**
  3810. * Normalize in place the current quaternion
  3811. * @returns the current updated quaternion
  3812. */
  3813. normalize(): Quaternion;
  3814. /**
  3815. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3816. * @param order is a reserved parameter and is ignore for now
  3817. * @returns a new Vector3 containing the Euler angles
  3818. */
  3819. toEulerAngles(order?: string): Vector3;
  3820. /**
  3821. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3822. * @param result defines the vector which will be filled with the Euler angles
  3823. * @param order is a reserved parameter and is ignore for now
  3824. * @returns the current unchanged quaternion
  3825. */
  3826. toEulerAnglesToRef(result: Vector3): Quaternion;
  3827. /**
  3828. * Updates the given rotation matrix with the current quaternion values
  3829. * @param result defines the target matrix
  3830. * @returns the current unchanged quaternion
  3831. */
  3832. toRotationMatrix(result: Matrix): Quaternion;
  3833. /**
  3834. * Updates the current quaternion from the given rotation matrix values
  3835. * @param matrix defines the source matrix
  3836. * @returns the current updated quaternion
  3837. */
  3838. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3839. /**
  3840. * Creates a new quaternion from a rotation matrix
  3841. * @param matrix defines the source matrix
  3842. * @returns a new quaternion created from the given rotation matrix values
  3843. */
  3844. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3845. /**
  3846. * Updates the given quaternion with the given rotation matrix values
  3847. * @param matrix defines the source matrix
  3848. * @param result defines the target quaternion
  3849. */
  3850. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3851. /**
  3852. * Returns the dot product (float) between the quaternions "left" and "right"
  3853. * @param left defines the left operand
  3854. * @param right defines the right operand
  3855. * @returns the dot product
  3856. */
  3857. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3858. /**
  3859. * Checks if the two quaternions are close to each other
  3860. * @param quat0 defines the first quaternion to check
  3861. * @param quat1 defines the second quaternion to check
  3862. * @returns true if the two quaternions are close to each other
  3863. */
  3864. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3865. /**
  3866. * Creates an empty quaternion
  3867. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3868. */
  3869. static Zero(): Quaternion;
  3870. /**
  3871. * Inverse a given quaternion
  3872. * @param q defines the source quaternion
  3873. * @returns a new quaternion as the inverted current quaternion
  3874. */
  3875. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3876. /**
  3877. * Inverse a given quaternion
  3878. * @param q defines the source quaternion
  3879. * @param result the quaternion the result will be stored in
  3880. * @returns the result quaternion
  3881. */
  3882. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3883. /**
  3884. * Creates an identity quaternion
  3885. * @returns the identity quaternion
  3886. */
  3887. static Identity(): Quaternion;
  3888. /**
  3889. * Gets a boolean indicating if the given quaternion is identity
  3890. * @param quaternion defines the quaternion to check
  3891. * @returns true if the quaternion is identity
  3892. */
  3893. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3894. /**
  3895. * Creates a quaternion from a rotation around an axis
  3896. * @param axis defines the axis to use
  3897. * @param angle defines the angle to use
  3898. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3899. */
  3900. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3901. /**
  3902. * Creates a rotation around an axis and stores it into the given quaternion
  3903. * @param axis defines the axis to use
  3904. * @param angle defines the angle to use
  3905. * @param result defines the target quaternion
  3906. * @returns the target quaternion
  3907. */
  3908. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from data stored into an array
  3911. * @param array defines the data source
  3912. * @param offset defines the offset in the source array where the data starts
  3913. * @returns a new quaternion
  3914. */
  3915. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3916. /**
  3917. * Updates the given quaternion "result" from the starting index of the given array.
  3918. * @param array the array to pull values from
  3919. * @param offset the offset into the array to start at
  3920. * @param result the quaternion to store the result in
  3921. */
  3922. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3923. /**
  3924. * Create a quaternion from Euler rotation angles
  3925. * @param x Pitch
  3926. * @param y Yaw
  3927. * @param z Roll
  3928. * @returns the new Quaternion
  3929. */
  3930. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3931. /**
  3932. * Updates a quaternion from Euler rotation angles
  3933. * @param x Pitch
  3934. * @param y Yaw
  3935. * @param z Roll
  3936. * @param result the quaternion to store the result
  3937. * @returns the updated quaternion
  3938. */
  3939. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3940. /**
  3941. * Create a quaternion from Euler rotation vector
  3942. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3943. * @returns the new Quaternion
  3944. */
  3945. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3946. /**
  3947. * Updates a quaternion from Euler rotation vector
  3948. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3949. * @param result the quaternion to store the result
  3950. * @returns the updated quaternion
  3951. */
  3952. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3955. * @param yaw defines the rotation around Y axis
  3956. * @param pitch defines the rotation around X axis
  3957. * @param roll defines the rotation around Z axis
  3958. * @returns the new quaternion
  3959. */
  3960. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3961. /**
  3962. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3963. * @param yaw defines the rotation around Y axis
  3964. * @param pitch defines the rotation around X axis
  3965. * @param roll defines the rotation around Z axis
  3966. * @param result defines the target quaternion
  3967. */
  3968. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3971. * @param alpha defines the rotation around first axis
  3972. * @param beta defines the rotation around second axis
  3973. * @param gamma defines the rotation around third axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3977. /**
  3978. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3979. * @param alpha defines the rotation around first axis
  3980. * @param beta defines the rotation around second axis
  3981. * @param gamma defines the rotation around third axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3985. /**
  3986. * 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)
  3987. * @param axis1 defines the first axis
  3988. * @param axis2 defines the second axis
  3989. * @param axis3 defines the third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3993. /**
  3994. * 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
  3995. * @param axis1 defines the first axis
  3996. * @param axis2 defines the second axis
  3997. * @param axis3 defines the third axis
  3998. * @param ref defines the target quaternion
  3999. */
  4000. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4001. /**
  4002. * Interpolates between two quaternions
  4003. * @param left defines first quaternion
  4004. * @param right defines second quaternion
  4005. * @param amount defines the gradient to use
  4006. * @returns the new interpolated quaternion
  4007. */
  4008. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4009. /**
  4010. * Interpolates between two quaternions and stores it into a target quaternion
  4011. * @param left defines first quaternion
  4012. * @param right defines second quaternion
  4013. * @param amount defines the gradient to use
  4014. * @param result defines the target quaternion
  4015. */
  4016. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4017. /**
  4018. * Interpolate between two quaternions using Hermite interpolation
  4019. * @param value1 defines first quaternion
  4020. * @param tangent1 defines the incoming tangent
  4021. * @param value2 defines second quaternion
  4022. * @param tangent2 defines the outgoing tangent
  4023. * @param amount defines the target quaternion
  4024. * @returns the new interpolated quaternion
  4025. */
  4026. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4027. }
  4028. /**
  4029. * Class used to store matrix data (4x4)
  4030. */
  4031. export class Matrix {
  4032. private static _updateFlagSeed;
  4033. private static _identityReadOnly;
  4034. private _isIdentity;
  4035. private _isIdentityDirty;
  4036. private _isIdentity3x2;
  4037. private _isIdentity3x2Dirty;
  4038. /**
  4039. * Gets the update flag of the matrix which is an unique number for the matrix.
  4040. * It will be incremented every time the matrix data change.
  4041. * You can use it to speed the comparison between two versions of the same matrix.
  4042. */
  4043. updateFlag: number;
  4044. private readonly _m;
  4045. /**
  4046. * Gets the internal data of the matrix
  4047. */
  4048. get m(): DeepImmutable<Float32Array>;
  4049. /** @hidden */
  4050. _markAsUpdated(): void;
  4051. /** @hidden */
  4052. private _updateIdentityStatus;
  4053. /**
  4054. * Creates an empty matrix (filled with zeros)
  4055. */
  4056. constructor();
  4057. /**
  4058. * Check if the current matrix is identity
  4059. * @returns true is the matrix is the identity matrix
  4060. */
  4061. isIdentity(): boolean;
  4062. /**
  4063. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4064. * @returns true is the matrix is the identity matrix
  4065. */
  4066. isIdentityAs3x2(): boolean;
  4067. /**
  4068. * Gets the determinant of the matrix
  4069. * @returns the matrix determinant
  4070. */
  4071. determinant(): number;
  4072. /**
  4073. * Returns the matrix as a Float32Array
  4074. * @returns the matrix underlying array
  4075. */
  4076. toArray(): DeepImmutable<Float32Array>;
  4077. /**
  4078. * Returns the matrix as a Float32Array
  4079. * @returns the matrix underlying array.
  4080. */
  4081. asArray(): DeepImmutable<Float32Array>;
  4082. /**
  4083. * Inverts the current matrix in place
  4084. * @returns the current inverted matrix
  4085. */
  4086. invert(): Matrix;
  4087. /**
  4088. * Sets all the matrix elements to zero
  4089. * @returns the current matrix
  4090. */
  4091. reset(): Matrix;
  4092. /**
  4093. * Adds the current matrix with a second one
  4094. * @param other defines the matrix to add
  4095. * @returns a new matrix as the addition of the current matrix and the given one
  4096. */
  4097. add(other: DeepImmutable<Matrix>): Matrix;
  4098. /**
  4099. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4100. * @param other defines the matrix to add
  4101. * @param result defines the target matrix
  4102. * @returns the current matrix
  4103. */
  4104. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4105. /**
  4106. * Adds in place the given matrix to the current matrix
  4107. * @param other defines the second operand
  4108. * @returns the current updated matrix
  4109. */
  4110. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4111. /**
  4112. * Sets the given matrix to the current inverted Matrix
  4113. * @param other defines the target matrix
  4114. * @returns the unmodified current matrix
  4115. */
  4116. invertToRef(other: Matrix): Matrix;
  4117. /**
  4118. * add a value at the specified position in the current Matrix
  4119. * @param index the index of the value within the matrix. between 0 and 15.
  4120. * @param value the value to be added
  4121. * @returns the current updated matrix
  4122. */
  4123. addAtIndex(index: number, value: number): Matrix;
  4124. /**
  4125. * mutiply the specified position in the current Matrix by a value
  4126. * @param index the index of the value within the matrix. between 0 and 15.
  4127. * @param value the value to be added
  4128. * @returns the current updated matrix
  4129. */
  4130. multiplyAtIndex(index: number, value: number): Matrix;
  4131. /**
  4132. * Inserts the translation vector (using 3 floats) in the current matrix
  4133. * @param x defines the 1st component of the translation
  4134. * @param y defines the 2nd component of the translation
  4135. * @param z defines the 3rd component of the translation
  4136. * @returns the current updated matrix
  4137. */
  4138. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4139. /**
  4140. * Adds the translation vector (using 3 floats) in the current matrix
  4141. * @param x defines the 1st component of the translation
  4142. * @param y defines the 2nd component of the translation
  4143. * @param z defines the 3rd component of the translation
  4144. * @returns the current updated matrix
  4145. */
  4146. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4147. /**
  4148. * Inserts the translation vector in the current matrix
  4149. * @param vector3 defines the translation to insert
  4150. * @returns the current updated matrix
  4151. */
  4152. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4153. /**
  4154. * Gets the translation value of the current matrix
  4155. * @returns a new Vector3 as the extracted translation from the matrix
  4156. */
  4157. getTranslation(): Vector3;
  4158. /**
  4159. * Fill a Vector3 with the extracted translation from the matrix
  4160. * @param result defines the Vector3 where to store the translation
  4161. * @returns the current matrix
  4162. */
  4163. getTranslationToRef(result: Vector3): Matrix;
  4164. /**
  4165. * Remove rotation and scaling part from the matrix
  4166. * @returns the updated matrix
  4167. */
  4168. removeRotationAndScaling(): Matrix;
  4169. /**
  4170. * Multiply two matrices
  4171. * @param other defines the second operand
  4172. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4173. */
  4174. multiply(other: DeepImmutable<Matrix>): Matrix;
  4175. /**
  4176. * Copy the current matrix from the given one
  4177. * @param other defines the source matrix
  4178. * @returns the current updated matrix
  4179. */
  4180. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4181. /**
  4182. * Populates the given array from the starting index with the current matrix values
  4183. * @param array defines the target array
  4184. * @param offset defines the offset in the target array where to start storing values
  4185. * @returns the current matrix
  4186. */
  4187. copyToArray(array: Float32Array, offset?: number): Matrix;
  4188. /**
  4189. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4190. * @param other defines the second operand
  4191. * @param result defines the matrix where to store the multiplication
  4192. * @returns the current matrix
  4193. */
  4194. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4195. /**
  4196. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4197. * @param other defines the second operand
  4198. * @param result defines the array where to store the multiplication
  4199. * @param offset defines the offset in the target array where to start storing values
  4200. * @returns the current matrix
  4201. */
  4202. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4203. /**
  4204. * Check equality between this matrix and a second one
  4205. * @param value defines the second matrix to compare
  4206. * @returns true is the current matrix and the given one values are strictly equal
  4207. */
  4208. equals(value: DeepImmutable<Matrix>): boolean;
  4209. /**
  4210. * Clone the current matrix
  4211. * @returns a new matrix from the current matrix
  4212. */
  4213. clone(): Matrix;
  4214. /**
  4215. * Returns the name of the current matrix class
  4216. * @returns the string "Matrix"
  4217. */
  4218. getClassName(): string;
  4219. /**
  4220. * Gets the hash code of the current matrix
  4221. * @returns the hash code
  4222. */
  4223. getHashCode(): number;
  4224. /**
  4225. * Decomposes the current Matrix into a translation, rotation and scaling components
  4226. * @param scale defines the scale vector3 given as a reference to update
  4227. * @param rotation defines the rotation quaternion given as a reference to update
  4228. * @param translation defines the translation vector3 given as a reference to update
  4229. * @returns true if operation was successful
  4230. */
  4231. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4232. /**
  4233. * Gets specific row of the matrix
  4234. * @param index defines the number of the row to get
  4235. * @returns the index-th row of the current matrix as a new Vector4
  4236. */
  4237. getRow(index: number): Nullable<Vector4>;
  4238. /**
  4239. * Sets the index-th row of the current matrix to the vector4 values
  4240. * @param index defines the number of the row to set
  4241. * @param row defines the target vector4
  4242. * @returns the updated current matrix
  4243. */
  4244. setRow(index: number, row: Vector4): Matrix;
  4245. /**
  4246. * Compute the transpose of the matrix
  4247. * @returns the new transposed matrix
  4248. */
  4249. transpose(): Matrix;
  4250. /**
  4251. * Compute the transpose of the matrix and store it in a given matrix
  4252. * @param result defines the target matrix
  4253. * @returns the current matrix
  4254. */
  4255. transposeToRef(result: Matrix): Matrix;
  4256. /**
  4257. * Sets the index-th row of the current matrix with the given 4 x float values
  4258. * @param index defines the row index
  4259. * @param x defines the x component to set
  4260. * @param y defines the y component to set
  4261. * @param z defines the z component to set
  4262. * @param w defines the w component to set
  4263. * @returns the updated current matrix
  4264. */
  4265. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4266. /**
  4267. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4268. * @param scale defines the scale factor
  4269. * @returns a new matrix
  4270. */
  4271. scale(scale: number): Matrix;
  4272. /**
  4273. * Scale the current matrix values by a factor to a given result matrix
  4274. * @param scale defines the scale factor
  4275. * @param result defines the matrix to store the result
  4276. * @returns the current matrix
  4277. */
  4278. scaleToRef(scale: number, result: Matrix): Matrix;
  4279. /**
  4280. * Scale the current matrix values by a factor and add the result to a given matrix
  4281. * @param scale defines the scale factor
  4282. * @param result defines the Matrix to store the result
  4283. * @returns the current matrix
  4284. */
  4285. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4286. /**
  4287. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4288. * @param ref matrix to store the result
  4289. */
  4290. toNormalMatrix(ref: Matrix): void;
  4291. /**
  4292. * Gets only rotation part of the current matrix
  4293. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4294. */
  4295. getRotationMatrix(): Matrix;
  4296. /**
  4297. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4298. * @param result defines the target matrix to store data to
  4299. * @returns the current matrix
  4300. */
  4301. getRotationMatrixToRef(result: Matrix): Matrix;
  4302. /**
  4303. * Toggles model matrix from being right handed to left handed in place and vice versa
  4304. */
  4305. toggleModelMatrixHandInPlace(): void;
  4306. /**
  4307. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4308. */
  4309. toggleProjectionMatrixHandInPlace(): void;
  4310. /**
  4311. * Creates a matrix from an array
  4312. * @param array defines the source array
  4313. * @param offset defines an offset in the source array
  4314. * @returns a new Matrix set from the starting index of the given array
  4315. */
  4316. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4317. /**
  4318. * Copy the content of an array into a given matrix
  4319. * @param array defines the source array
  4320. * @param offset defines an offset in the source array
  4321. * @param result defines the target matrix
  4322. */
  4323. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4324. /**
  4325. * Stores an array into a matrix after having multiplied each component by a given factor
  4326. * @param array defines the source array
  4327. * @param offset defines the offset in the source array
  4328. * @param scale defines the scaling factor
  4329. * @param result defines the target matrix
  4330. */
  4331. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4332. /**
  4333. * Gets an identity matrix that must not be updated
  4334. */
  4335. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4336. /**
  4337. * Stores a list of values (16) inside a given matrix
  4338. * @param initialM11 defines 1st value of 1st row
  4339. * @param initialM12 defines 2nd value of 1st row
  4340. * @param initialM13 defines 3rd value of 1st row
  4341. * @param initialM14 defines 4th value of 1st row
  4342. * @param initialM21 defines 1st value of 2nd row
  4343. * @param initialM22 defines 2nd value of 2nd row
  4344. * @param initialM23 defines 3rd value of 2nd row
  4345. * @param initialM24 defines 4th value of 2nd row
  4346. * @param initialM31 defines 1st value of 3rd row
  4347. * @param initialM32 defines 2nd value of 3rd row
  4348. * @param initialM33 defines 3rd value of 3rd row
  4349. * @param initialM34 defines 4th value of 3rd row
  4350. * @param initialM41 defines 1st value of 4th row
  4351. * @param initialM42 defines 2nd value of 4th row
  4352. * @param initialM43 defines 3rd value of 4th row
  4353. * @param initialM44 defines 4th value of 4th row
  4354. * @param result defines the target matrix
  4355. */
  4356. 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;
  4357. /**
  4358. * Creates new matrix from a list of values (16)
  4359. * @param initialM11 defines 1st value of 1st row
  4360. * @param initialM12 defines 2nd value of 1st row
  4361. * @param initialM13 defines 3rd value of 1st row
  4362. * @param initialM14 defines 4th value of 1st row
  4363. * @param initialM21 defines 1st value of 2nd row
  4364. * @param initialM22 defines 2nd value of 2nd row
  4365. * @param initialM23 defines 3rd value of 2nd row
  4366. * @param initialM24 defines 4th value of 2nd row
  4367. * @param initialM31 defines 1st value of 3rd row
  4368. * @param initialM32 defines 2nd value of 3rd row
  4369. * @param initialM33 defines 3rd value of 3rd row
  4370. * @param initialM34 defines 4th value of 3rd row
  4371. * @param initialM41 defines 1st value of 4th row
  4372. * @param initialM42 defines 2nd value of 4th row
  4373. * @param initialM43 defines 3rd value of 4th row
  4374. * @param initialM44 defines 4th value of 4th row
  4375. * @returns the new matrix
  4376. */
  4377. 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;
  4378. /**
  4379. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4380. * @param scale defines the scale vector3
  4381. * @param rotation defines the rotation quaternion
  4382. * @param translation defines the translation vector3
  4383. * @returns a new matrix
  4384. */
  4385. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4386. /**
  4387. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4388. * @param scale defines the scale vector3
  4389. * @param rotation defines the rotation quaternion
  4390. * @param translation defines the translation vector3
  4391. * @param result defines the target matrix
  4392. */
  4393. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4394. /**
  4395. * Creates a new identity matrix
  4396. * @returns a new identity matrix
  4397. */
  4398. static Identity(): Matrix;
  4399. /**
  4400. * Creates a new identity matrix and stores the result in a given matrix
  4401. * @param result defines the target matrix
  4402. */
  4403. static IdentityToRef(result: Matrix): void;
  4404. /**
  4405. * Creates a new zero matrix
  4406. * @returns a new zero matrix
  4407. */
  4408. static Zero(): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the X axis
  4411. * @param angle defines the angle (in radians) to use
  4412. * @return the new matrix
  4413. */
  4414. static RotationX(angle: number): Matrix;
  4415. /**
  4416. * Creates a new matrix as the invert of a given matrix
  4417. * @param source defines the source matrix
  4418. * @returns the new matrix
  4419. */
  4420. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4421. /**
  4422. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4423. * @param angle defines the angle (in radians) to use
  4424. * @param result defines the target matrix
  4425. */
  4426. static RotationXToRef(angle: number, result: Matrix): void;
  4427. /**
  4428. * Creates a new rotation matrix for "angle" radians around the Y axis
  4429. * @param angle defines the angle (in radians) to use
  4430. * @return the new matrix
  4431. */
  4432. static RotationY(angle: number): Matrix;
  4433. /**
  4434. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4435. * @param angle defines the angle (in radians) to use
  4436. * @param result defines the target matrix
  4437. */
  4438. static RotationYToRef(angle: number, result: Matrix): void;
  4439. /**
  4440. * Creates a new rotation matrix for "angle" radians around the Z axis
  4441. * @param angle defines the angle (in radians) to use
  4442. * @return the new matrix
  4443. */
  4444. static RotationZ(angle: number): Matrix;
  4445. /**
  4446. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4447. * @param angle defines the angle (in radians) to use
  4448. * @param result defines the target matrix
  4449. */
  4450. static RotationZToRef(angle: number, result: Matrix): void;
  4451. /**
  4452. * Creates a new rotation matrix for "angle" radians around the given axis
  4453. * @param axis defines the axis to use
  4454. * @param angle defines the angle (in radians) to use
  4455. * @return the new matrix
  4456. */
  4457. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4458. /**
  4459. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4460. * @param axis defines the axis to use
  4461. * @param angle defines the angle (in radians) to use
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4465. /**
  4466. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4467. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4468. * @param from defines the vector to align
  4469. * @param to defines the vector to align to
  4470. * @param result defines the target matrix
  4471. */
  4472. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4473. /**
  4474. * Creates a rotation matrix
  4475. * @param yaw defines the yaw angle in radians (Y axis)
  4476. * @param pitch defines the pitch angle in radians (X axis)
  4477. * @param roll defines the roll angle in radians (X axis)
  4478. * @returns the new rotation matrix
  4479. */
  4480. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4481. /**
  4482. * Creates a rotation matrix and stores it in a given matrix
  4483. * @param yaw defines the yaw angle in radians (Y axis)
  4484. * @param pitch defines the pitch angle in radians (X axis)
  4485. * @param roll defines the roll angle in radians (X axis)
  4486. * @param result defines the target matrix
  4487. */
  4488. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4489. /**
  4490. * Creates a scaling matrix
  4491. * @param x defines the scale factor on X axis
  4492. * @param y defines the scale factor on Y axis
  4493. * @param z defines the scale factor on Z axis
  4494. * @returns the new matrix
  4495. */
  4496. static Scaling(x: number, y: number, z: number): Matrix;
  4497. /**
  4498. * Creates a scaling matrix and stores it in a given matrix
  4499. * @param x defines the scale factor on X axis
  4500. * @param y defines the scale factor on Y axis
  4501. * @param z defines the scale factor on Z axis
  4502. * @param result defines the target matrix
  4503. */
  4504. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4505. /**
  4506. * Creates a translation matrix
  4507. * @param x defines the translation on X axis
  4508. * @param y defines the translation on Y axis
  4509. * @param z defines the translationon Z axis
  4510. * @returns the new matrix
  4511. */
  4512. static Translation(x: number, y: number, z: number): Matrix;
  4513. /**
  4514. * Creates a translation matrix and stores it in a given matrix
  4515. * @param x defines the translation on X axis
  4516. * @param y defines the translation on Y axis
  4517. * @param z defines the translationon Z axis
  4518. * @param result defines the target matrix
  4519. */
  4520. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4521. /**
  4522. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4523. * @param startValue defines the start value
  4524. * @param endValue defines the end value
  4525. * @param gradient defines the gradient factor
  4526. * @returns the new matrix
  4527. */
  4528. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4529. /**
  4530. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4531. * @param startValue defines the start value
  4532. * @param endValue defines the end value
  4533. * @param gradient defines the gradient factor
  4534. * @param result defines the Matrix object where to store data
  4535. */
  4536. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4537. /**
  4538. * Builds a new matrix whose values are computed by:
  4539. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4540. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4541. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4542. * @param startValue defines the first matrix
  4543. * @param endValue defines the second matrix
  4544. * @param gradient defines the gradient between the two matrices
  4545. * @returns the new matrix
  4546. */
  4547. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4548. /**
  4549. * Update a matrix to values which are computed by:
  4550. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4551. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4552. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4553. * @param startValue defines the first matrix
  4554. * @param endValue defines the second matrix
  4555. * @param gradient defines the gradient between the two matrices
  4556. * @param result defines the target matrix
  4557. */
  4558. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4559. /**
  4560. * 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"
  4561. * This function works in left handed mode
  4562. * @param eye defines the final position of the entity
  4563. * @param target defines where the entity should look at
  4564. * @param up defines the up vector for the entity
  4565. * @returns the new matrix
  4566. */
  4567. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4568. /**
  4569. * 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".
  4570. * This function works in left handed mode
  4571. * @param eye defines the final position of the entity
  4572. * @param target defines where the entity should look at
  4573. * @param up defines the up vector for the entity
  4574. * @param result defines the target matrix
  4575. */
  4576. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4577. /**
  4578. * 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"
  4579. * This function works in right handed mode
  4580. * @param eye defines the final position of the entity
  4581. * @param target defines where the entity should look at
  4582. * @param up defines the up vector for the entity
  4583. * @returns the new matrix
  4584. */
  4585. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4586. /**
  4587. * 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".
  4588. * This function works in right handed mode
  4589. * @param eye defines the final position of the entity
  4590. * @param target defines where the entity should look at
  4591. * @param up defines the up vector for the entity
  4592. * @param result defines the target matrix
  4593. */
  4594. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4595. /**
  4596. * Create a left-handed orthographic projection matrix
  4597. * @param width defines the viewport width
  4598. * @param height defines the viewport height
  4599. * @param znear defines the near clip plane
  4600. * @param zfar defines the far clip plane
  4601. * @returns a new matrix as a left-handed orthographic projection matrix
  4602. */
  4603. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4604. /**
  4605. * Store a left-handed orthographic projection to a given matrix
  4606. * @param width defines the viewport width
  4607. * @param height defines the viewport height
  4608. * @param znear defines the near clip plane
  4609. * @param zfar defines the far clip plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4613. /**
  4614. * Create a left-handed orthographic projection matrix
  4615. * @param left defines the viewport left coordinate
  4616. * @param right defines the viewport right coordinate
  4617. * @param bottom defines the viewport bottom coordinate
  4618. * @param top defines the viewport top coordinate
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Stores a left-handed orthographic projection into a given matrix
  4626. * @param left defines the viewport left coordinate
  4627. * @param right defines the viewport right coordinate
  4628. * @param bottom defines the viewport bottom coordinate
  4629. * @param top defines the viewport top coordinate
  4630. * @param znear defines the near clip plane
  4631. * @param zfar defines the far clip plane
  4632. * @param result defines the target matrix
  4633. */
  4634. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4635. /**
  4636. * Creates a right-handed orthographic projection matrix
  4637. * @param left defines the viewport left coordinate
  4638. * @param right defines the viewport right coordinate
  4639. * @param bottom defines the viewport bottom coordinate
  4640. * @param top defines the viewport top coordinate
  4641. * @param znear defines the near clip plane
  4642. * @param zfar defines the far clip plane
  4643. * @returns a new matrix as a right-handed orthographic projection matrix
  4644. */
  4645. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4646. /**
  4647. * Stores a right-handed orthographic projection into a given matrix
  4648. * @param left defines the viewport left coordinate
  4649. * @param right defines the viewport right coordinate
  4650. * @param bottom defines the viewport bottom coordinate
  4651. * @param top defines the viewport top coordinate
  4652. * @param znear defines the near clip plane
  4653. * @param zfar defines the far clip plane
  4654. * @param result defines the target matrix
  4655. */
  4656. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4657. /**
  4658. * Creates a left-handed perspective projection matrix
  4659. * @param width defines the viewport width
  4660. * @param height defines the viewport height
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a left-handed perspective projection matrix
  4664. */
  4665. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Creates a left-handed perspective projection matrix
  4668. * @param fov defines the horizontal field of view
  4669. * @param aspect defines the aspect ratio
  4670. * @param znear defines the near clip plane
  4671. * @param zfar defines the far clip plane
  4672. * @returns a new matrix as a left-handed perspective projection matrix
  4673. */
  4674. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4675. /**
  4676. * Stores a left-handed perspective projection into a given matrix
  4677. * @param fov defines the horizontal field of view
  4678. * @param aspect defines the aspect ratio
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @param result defines the target matrix
  4682. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4683. */
  4684. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4685. /**
  4686. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4687. * @param fov defines the horizontal field of view
  4688. * @param aspect defines the aspect ratio
  4689. * @param znear defines the near clip plane
  4690. * @param zfar not used as infinity is used as far clip
  4691. * @param result defines the target matrix
  4692. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4693. */
  4694. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4695. /**
  4696. * Creates a right-handed perspective projection matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @returns a new matrix as a right-handed perspective projection matrix
  4702. */
  4703. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4704. /**
  4705. * Stores a right-handed perspective projection into a given matrix
  4706. * @param fov defines the horizontal field of view
  4707. * @param aspect defines the aspect ratio
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4712. */
  4713. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4714. /**
  4715. * Stores a right-handed perspective projection into a given matrix
  4716. * @param fov defines the horizontal field of view
  4717. * @param aspect defines the aspect ratio
  4718. * @param znear defines the near clip plane
  4719. * @param zfar not used as infinity is used as far clip
  4720. * @param result defines the target matrix
  4721. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4722. */
  4723. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4724. /**
  4725. * Stores a perspective projection for WebVR info a given matrix
  4726. * @param fov defines the field of view
  4727. * @param znear defines the near clip plane
  4728. * @param zfar defines the far clip plane
  4729. * @param result defines the target matrix
  4730. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4731. */
  4732. static PerspectiveFovWebVRToRef(fov: {
  4733. upDegrees: number;
  4734. downDegrees: number;
  4735. leftDegrees: number;
  4736. rightDegrees: number;
  4737. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4738. /**
  4739. * Computes a complete transformation matrix
  4740. * @param viewport defines the viewport to use
  4741. * @param world defines the world matrix
  4742. * @param view defines the view matrix
  4743. * @param projection defines the projection matrix
  4744. * @param zmin defines the near clip plane
  4745. * @param zmax defines the far clip plane
  4746. * @returns the transformation matrix
  4747. */
  4748. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4749. /**
  4750. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4751. * @param matrix defines the matrix to use
  4752. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4753. */
  4754. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4755. /**
  4756. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4757. * @param matrix defines the matrix to use
  4758. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4759. */
  4760. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4761. /**
  4762. * Compute the transpose of a given matrix
  4763. * @param matrix defines the matrix to transpose
  4764. * @returns the new matrix
  4765. */
  4766. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4767. /**
  4768. * Compute the transpose of a matrix and store it in a target matrix
  4769. * @param matrix defines the matrix to transpose
  4770. * @param result defines the target matrix
  4771. */
  4772. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4773. /**
  4774. * Computes a reflection matrix from a plane
  4775. * @param plane defines the reflection plane
  4776. * @returns a new matrix
  4777. */
  4778. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4779. /**
  4780. * Computes a reflection matrix from a plane
  4781. * @param plane defines the reflection plane
  4782. * @param result defines the target matrix
  4783. */
  4784. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4785. /**
  4786. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4787. * @param xaxis defines the value of the 1st axis
  4788. * @param yaxis defines the value of the 2nd axis
  4789. * @param zaxis defines the value of the 3rd axis
  4790. * @param result defines the target matrix
  4791. */
  4792. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4793. /**
  4794. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4795. * @param quat defines the quaternion to use
  4796. * @param result defines the target matrix
  4797. */
  4798. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4799. }
  4800. /**
  4801. * @hidden
  4802. */
  4803. export class TmpVectors {
  4804. static Vector2: Vector2[];
  4805. static Vector3: Vector3[];
  4806. static Vector4: Vector4[];
  4807. static Quaternion: Quaternion[];
  4808. static Matrix: Matrix[];
  4809. }
  4810. }
  4811. declare module "babylonjs/Maths/math.path" {
  4812. import { DeepImmutable, Nullable } from "babylonjs/types";
  4813. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4814. /**
  4815. * Defines potential orientation for back face culling
  4816. */
  4817. export enum Orientation {
  4818. /**
  4819. * Clockwise
  4820. */
  4821. CW = 0,
  4822. /** Counter clockwise */
  4823. CCW = 1
  4824. }
  4825. /** Class used to represent a Bezier curve */
  4826. export class BezierCurve {
  4827. /**
  4828. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4829. * @param t defines the time
  4830. * @param x1 defines the left coordinate on X axis
  4831. * @param y1 defines the left coordinate on Y axis
  4832. * @param x2 defines the right coordinate on X axis
  4833. * @param y2 defines the right coordinate on Y axis
  4834. * @returns the interpolated value
  4835. */
  4836. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4837. }
  4838. /**
  4839. * Defines angle representation
  4840. */
  4841. export class Angle {
  4842. private _radians;
  4843. /**
  4844. * Creates an Angle object of "radians" radians (float).
  4845. * @param radians the angle in radians
  4846. */
  4847. constructor(radians: number);
  4848. /**
  4849. * Get value in degrees
  4850. * @returns the Angle value in degrees (float)
  4851. */
  4852. degrees(): number;
  4853. /**
  4854. * Get value in radians
  4855. * @returns the Angle value in radians (float)
  4856. */
  4857. radians(): number;
  4858. /**
  4859. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4860. * @param a defines first vector
  4861. * @param b defines second vector
  4862. * @returns a new Angle
  4863. */
  4864. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4865. /**
  4866. * Gets a new Angle object from the given float in radians
  4867. * @param radians defines the angle value in radians
  4868. * @returns a new Angle
  4869. */
  4870. static FromRadians(radians: number): Angle;
  4871. /**
  4872. * Gets a new Angle object from the given float in degrees
  4873. * @param degrees defines the angle value in degrees
  4874. * @returns a new Angle
  4875. */
  4876. static FromDegrees(degrees: number): Angle;
  4877. }
  4878. /**
  4879. * This represents an arc in a 2d space.
  4880. */
  4881. export class Arc2 {
  4882. /** Defines the start point of the arc */
  4883. startPoint: Vector2;
  4884. /** Defines the mid point of the arc */
  4885. midPoint: Vector2;
  4886. /** Defines the end point of the arc */
  4887. endPoint: Vector2;
  4888. /**
  4889. * Defines the center point of the arc.
  4890. */
  4891. centerPoint: Vector2;
  4892. /**
  4893. * Defines the radius of the arc.
  4894. */
  4895. radius: number;
  4896. /**
  4897. * Defines the angle of the arc (from mid point to end point).
  4898. */
  4899. angle: Angle;
  4900. /**
  4901. * Defines the start angle of the arc (from start point to middle point).
  4902. */
  4903. startAngle: Angle;
  4904. /**
  4905. * Defines the orientation of the arc (clock wise/counter clock wise).
  4906. */
  4907. orientation: Orientation;
  4908. /**
  4909. * Creates an Arc object from the three given points : start, middle and end.
  4910. * @param startPoint Defines the start point of the arc
  4911. * @param midPoint Defines the midlle point of the arc
  4912. * @param endPoint Defines the end point of the arc
  4913. */
  4914. constructor(
  4915. /** Defines the start point of the arc */
  4916. startPoint: Vector2,
  4917. /** Defines the mid point of the arc */
  4918. midPoint: Vector2,
  4919. /** Defines the end point of the arc */
  4920. endPoint: Vector2);
  4921. }
  4922. /**
  4923. * Represents a 2D path made up of multiple 2D points
  4924. */
  4925. export class Path2 {
  4926. private _points;
  4927. private _length;
  4928. /**
  4929. * If the path start and end point are the same
  4930. */
  4931. closed: boolean;
  4932. /**
  4933. * Creates a Path2 object from the starting 2D coordinates x and y.
  4934. * @param x the starting points x value
  4935. * @param y the starting points y value
  4936. */
  4937. constructor(x: number, y: number);
  4938. /**
  4939. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4940. * @param x the added points x value
  4941. * @param y the added points y value
  4942. * @returns the updated Path2.
  4943. */
  4944. addLineTo(x: number, y: number): Path2;
  4945. /**
  4946. * 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.
  4947. * @param midX middle point x value
  4948. * @param midY middle point y value
  4949. * @param endX end point x value
  4950. * @param endY end point y value
  4951. * @param numberOfSegments (default: 36)
  4952. * @returns the updated Path2.
  4953. */
  4954. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4955. /**
  4956. * Closes the Path2.
  4957. * @returns the Path2.
  4958. */
  4959. close(): Path2;
  4960. /**
  4961. * Gets the sum of the distance between each sequential point in the path
  4962. * @returns the Path2 total length (float).
  4963. */
  4964. length(): number;
  4965. /**
  4966. * Gets the points which construct the path
  4967. * @returns the Path2 internal array of points.
  4968. */
  4969. getPoints(): Vector2[];
  4970. /**
  4971. * Retreives the point at the distance aways from the starting point
  4972. * @param normalizedLengthPosition the length along the path to retreive the point from
  4973. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4974. */
  4975. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4976. /**
  4977. * Creates a new path starting from an x and y position
  4978. * @param x starting x value
  4979. * @param y starting y value
  4980. * @returns a new Path2 starting at the coordinates (x, y).
  4981. */
  4982. static StartingAt(x: number, y: number): Path2;
  4983. }
  4984. /**
  4985. * Represents a 3D path made up of multiple 3D points
  4986. */
  4987. export class Path3D {
  4988. /**
  4989. * an array of Vector3, the curve axis of the Path3D
  4990. */
  4991. path: Vector3[];
  4992. private _curve;
  4993. private _distances;
  4994. private _tangents;
  4995. private _normals;
  4996. private _binormals;
  4997. private _raw;
  4998. private _alignTangentsWithPath;
  4999. private readonly _pointAtData;
  5000. /**
  5001. * new Path3D(path, normal, raw)
  5002. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5003. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5004. * @param path an array of Vector3, the curve axis of the Path3D
  5005. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5006. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5007. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5008. */
  5009. constructor(
  5010. /**
  5011. * an array of Vector3, the curve axis of the Path3D
  5012. */
  5013. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5014. /**
  5015. * Returns the Path3D array of successive Vector3 designing its curve.
  5016. * @returns the Path3D array of successive Vector3 designing its curve.
  5017. */
  5018. getCurve(): Vector3[];
  5019. /**
  5020. * Returns the Path3D array of successive Vector3 designing its curve.
  5021. * @returns the Path3D array of successive Vector3 designing its curve.
  5022. */
  5023. getPoints(): Vector3[];
  5024. /**
  5025. * @returns the computed length (float) of the path.
  5026. */
  5027. length(): number;
  5028. /**
  5029. * Returns an array populated with tangent vectors on each Path3D curve point.
  5030. * @returns an array populated with tangent vectors on each Path3D curve point.
  5031. */
  5032. getTangents(): Vector3[];
  5033. /**
  5034. * Returns an array populated with normal vectors on each Path3D curve point.
  5035. * @returns an array populated with normal vectors on each Path3D curve point.
  5036. */
  5037. getNormals(): Vector3[];
  5038. /**
  5039. * Returns an array populated with binormal vectors on each Path3D curve point.
  5040. * @returns an array populated with binormal vectors on each Path3D curve point.
  5041. */
  5042. getBinormals(): Vector3[];
  5043. /**
  5044. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5045. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5046. */
  5047. getDistances(): number[];
  5048. /**
  5049. * Returns an interpolated point along this path
  5050. * @param position the position of the point along this path, from 0.0 to 1.0
  5051. * @returns a new Vector3 as the point
  5052. */
  5053. getPointAt(position: number): Vector3;
  5054. /**
  5055. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5056. * @param position the position of the point along this path, from 0.0 to 1.0
  5057. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5058. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5059. */
  5060. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5061. /**
  5062. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5063. * @param position the position of the point along this path, from 0.0 to 1.0
  5064. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5065. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5066. */
  5067. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5068. /**
  5069. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5070. * @param position the position of the point along this path, from 0.0 to 1.0
  5071. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5072. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5073. */
  5074. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5075. /**
  5076. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5077. * @param position the position of the point along this path, from 0.0 to 1.0
  5078. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5079. */
  5080. getDistanceAt(position: number): number;
  5081. /**
  5082. * Returns the array index of the previous point of an interpolated point along this path
  5083. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5084. * @returns the array index
  5085. */
  5086. getPreviousPointIndexAt(position: number): number;
  5087. /**
  5088. * 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)
  5089. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5090. * @returns the sub position
  5091. */
  5092. getSubPositionAt(position: number): number;
  5093. /**
  5094. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5095. * @param target the vector of which to get the closest position to
  5096. * @returns the position of the closest virtual point on this path to the target vector
  5097. */
  5098. getClosestPositionTo(target: Vector3): number;
  5099. /**
  5100. * Returns a sub path (slice) of this path
  5101. * @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
  5102. * @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
  5103. * @returns a sub path (slice) of this path
  5104. */
  5105. slice(start?: number, end?: number): Path3D;
  5106. /**
  5107. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5108. * @param path path which all values are copied into the curves points
  5109. * @param firstNormal which should be projected onto the curve
  5110. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5111. * @returns the same object updated.
  5112. */
  5113. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5114. private _compute;
  5115. private _getFirstNonNullVector;
  5116. private _getLastNonNullVector;
  5117. private _normalVector;
  5118. /**
  5119. * Updates the point at data for an interpolated point along this curve
  5120. * @param position the position of the point along this curve, from 0.0 to 1.0
  5121. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5122. * @returns the (updated) point at data
  5123. */
  5124. private _updatePointAtData;
  5125. /**
  5126. * Updates the point at data from the specified parameters
  5127. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5128. * @param point the interpolated point
  5129. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5130. */
  5131. private _setPointAtData;
  5132. /**
  5133. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5134. */
  5135. private _updateInterpolationMatrix;
  5136. }
  5137. /**
  5138. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5139. * A Curve3 is designed from a series of successive Vector3.
  5140. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5141. */
  5142. export class Curve3 {
  5143. private _points;
  5144. private _length;
  5145. /**
  5146. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5147. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5148. * @param v1 (Vector3) the control point
  5149. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5150. * @param nbPoints (integer) the wanted number of points in the curve
  5151. * @returns the created Curve3
  5152. */
  5153. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5154. /**
  5155. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5156. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5157. * @param v1 (Vector3) the first control point
  5158. * @param v2 (Vector3) the second control point
  5159. * @param v3 (Vector3) the end point of the Cubic Bezier
  5160. * @param nbPoints (integer) the wanted number of points in the curve
  5161. * @returns the created Curve3
  5162. */
  5163. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5164. /**
  5165. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5166. * @param p1 (Vector3) the origin point of the Hermite Spline
  5167. * @param t1 (Vector3) the tangent vector at the origin point
  5168. * @param p2 (Vector3) the end point of the Hermite Spline
  5169. * @param t2 (Vector3) the tangent vector at the end point
  5170. * @param nbPoints (integer) the wanted number of points in the curve
  5171. * @returns the created Curve3
  5172. */
  5173. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5174. /**
  5175. * Returns a Curve3 object along a CatmullRom Spline curve :
  5176. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5177. * @param nbPoints (integer) the wanted number of points between each curve control points
  5178. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5182. /**
  5183. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5184. * A Curve3 is designed from a series of successive Vector3.
  5185. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5186. * @param points points which make up the curve
  5187. */
  5188. constructor(points: Vector3[]);
  5189. /**
  5190. * @returns the Curve3 stored array of successive Vector3
  5191. */
  5192. getPoints(): Vector3[];
  5193. /**
  5194. * @returns the computed length (float) of the curve.
  5195. */
  5196. length(): number;
  5197. /**
  5198. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5199. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5200. * curveA and curveB keep unchanged.
  5201. * @param curve the curve to continue from this curve
  5202. * @returns the newly constructed curve
  5203. */
  5204. continue(curve: DeepImmutable<Curve3>): Curve3;
  5205. private _computeLength;
  5206. }
  5207. }
  5208. declare module "babylonjs/Animations/easing" {
  5209. /**
  5210. * This represents the main contract an easing function should follow.
  5211. * Easing functions are used throughout the animation system.
  5212. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export interface IEasingFunction {
  5215. /**
  5216. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5217. * of the easing function.
  5218. * The link below provides some of the most common examples of easing functions.
  5219. * @see https://easings.net/
  5220. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5221. * @returns the corresponding value on the curve defined by the easing function
  5222. */
  5223. ease(gradient: number): number;
  5224. }
  5225. /**
  5226. * Base class used for every default easing function.
  5227. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5228. */
  5229. export class EasingFunction implements IEasingFunction {
  5230. /**
  5231. * Interpolation follows the mathematical formula associated with the easing function.
  5232. */
  5233. static readonly EASINGMODE_EASEIN: number;
  5234. /**
  5235. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5236. */
  5237. static readonly EASINGMODE_EASEOUT: number;
  5238. /**
  5239. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5240. */
  5241. static readonly EASINGMODE_EASEINOUT: number;
  5242. private _easingMode;
  5243. /**
  5244. * Sets the easing mode of the current function.
  5245. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5246. */
  5247. setEasingMode(easingMode: number): void;
  5248. /**
  5249. * Gets the current easing mode.
  5250. * @returns the easing mode
  5251. */
  5252. getEasingMode(): number;
  5253. /**
  5254. * @hidden
  5255. */
  5256. easeInCore(gradient: number): number;
  5257. /**
  5258. * Given an input gradient between 0 and 1, this returns the corresponding value
  5259. * of the easing function.
  5260. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5261. * @returns the corresponding value on the curve defined by the easing function
  5262. */
  5263. ease(gradient: number): number;
  5264. }
  5265. /**
  5266. * Easing function with a circle shape (see link below).
  5267. * @see https://easings.net/#easeInCirc
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export class CircleEase extends EasingFunction implements IEasingFunction {
  5271. /** @hidden */
  5272. easeInCore(gradient: number): number;
  5273. }
  5274. /**
  5275. * Easing function with a ease back shape (see link below).
  5276. * @see https://easings.net/#easeInBack
  5277. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5278. */
  5279. export class BackEase extends EasingFunction implements IEasingFunction {
  5280. /** Defines the amplitude of the function */
  5281. amplitude: number;
  5282. /**
  5283. * Instantiates a back ease easing
  5284. * @see https://easings.net/#easeInBack
  5285. * @param amplitude Defines the amplitude of the function
  5286. */
  5287. constructor(
  5288. /** Defines the amplitude of the function */
  5289. amplitude?: number);
  5290. /** @hidden */
  5291. easeInCore(gradient: number): number;
  5292. }
  5293. /**
  5294. * Easing function with a bouncing shape (see link below).
  5295. * @see https://easings.net/#easeInBounce
  5296. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5297. */
  5298. export class BounceEase extends EasingFunction implements IEasingFunction {
  5299. /** Defines the number of bounces */
  5300. bounces: number;
  5301. /** Defines the amplitude of the bounce */
  5302. bounciness: number;
  5303. /**
  5304. * Instantiates a bounce easing
  5305. * @see https://easings.net/#easeInBounce
  5306. * @param bounces Defines the number of bounces
  5307. * @param bounciness Defines the amplitude of the bounce
  5308. */
  5309. constructor(
  5310. /** Defines the number of bounces */
  5311. bounces?: number,
  5312. /** Defines the amplitude of the bounce */
  5313. bounciness?: number);
  5314. /** @hidden */
  5315. easeInCore(gradient: number): number;
  5316. }
  5317. /**
  5318. * Easing function with a power of 3 shape (see link below).
  5319. * @see https://easings.net/#easeInCubic
  5320. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5321. */
  5322. export class CubicEase extends EasingFunction implements IEasingFunction {
  5323. /** @hidden */
  5324. easeInCore(gradient: number): number;
  5325. }
  5326. /**
  5327. * Easing function with an elastic shape (see link below).
  5328. * @see https://easings.net/#easeInElastic
  5329. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5330. */
  5331. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5332. /** Defines the number of oscillations*/
  5333. oscillations: number;
  5334. /** Defines the amplitude of the oscillations*/
  5335. springiness: number;
  5336. /**
  5337. * Instantiates an elastic easing function
  5338. * @see https://easings.net/#easeInElastic
  5339. * @param oscillations Defines the number of oscillations
  5340. * @param springiness Defines the amplitude of the oscillations
  5341. */
  5342. constructor(
  5343. /** Defines the number of oscillations*/
  5344. oscillations?: number,
  5345. /** Defines the amplitude of the oscillations*/
  5346. springiness?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with an exponential shape (see link below).
  5352. * @see https://easings.net/#easeInExpo
  5353. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5356. /** Defines the exponent of the function */
  5357. exponent: number;
  5358. /**
  5359. * Instantiates an exponential easing function
  5360. * @see https://easings.net/#easeInExpo
  5361. * @param exponent Defines the exponent of the function
  5362. */
  5363. constructor(
  5364. /** Defines the exponent of the function */
  5365. exponent?: number);
  5366. /** @hidden */
  5367. easeInCore(gradient: number): number;
  5368. }
  5369. /**
  5370. * Easing function with a power shape (see link below).
  5371. * @see https://easings.net/#easeInQuad
  5372. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5373. */
  5374. export class PowerEase extends EasingFunction implements IEasingFunction {
  5375. /** Defines the power of the function */
  5376. power: number;
  5377. /**
  5378. * Instantiates an power base easing function
  5379. * @see https://easings.net/#easeInQuad
  5380. * @param power Defines the power of the function
  5381. */
  5382. constructor(
  5383. /** Defines the power of the function */
  5384. power?: number);
  5385. /** @hidden */
  5386. easeInCore(gradient: number): number;
  5387. }
  5388. /**
  5389. * Easing function with a power of 2 shape (see link below).
  5390. * @see https://easings.net/#easeInQuad
  5391. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5392. */
  5393. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5394. /** @hidden */
  5395. easeInCore(gradient: number): number;
  5396. }
  5397. /**
  5398. * Easing function with a power of 4 shape (see link below).
  5399. * @see https://easings.net/#easeInQuart
  5400. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5401. */
  5402. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 5 shape (see link below).
  5408. * @see https://easings.net/#easeInQuint
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a sin shape (see link below).
  5417. * @see https://easings.net/#easeInSine
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class SineEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a bezier shape (see link below).
  5426. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the x component of the start tangent in the bezier curve */
  5431. x1: number;
  5432. /** Defines the y component of the start tangent in the bezier curve */
  5433. y1: number;
  5434. /** Defines the x component of the end tangent in the bezier curve */
  5435. x2: number;
  5436. /** Defines the y component of the end tangent in the bezier curve */
  5437. y2: number;
  5438. /**
  5439. * Instantiates a bezier function
  5440. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5441. * @param x1 Defines the x component of the start tangent in the bezier curve
  5442. * @param y1 Defines the y component of the start tangent in the bezier curve
  5443. * @param x2 Defines the x component of the end tangent in the bezier curve
  5444. * @param y2 Defines the y component of the end tangent in the bezier curve
  5445. */
  5446. constructor(
  5447. /** Defines the x component of the start tangent in the bezier curve */
  5448. x1?: number,
  5449. /** Defines the y component of the start tangent in the bezier curve */
  5450. y1?: number,
  5451. /** Defines the x component of the end tangent in the bezier curve */
  5452. x2?: number,
  5453. /** Defines the y component of the end tangent in the bezier curve */
  5454. y2?: number);
  5455. /** @hidden */
  5456. easeInCore(gradient: number): number;
  5457. }
  5458. }
  5459. declare module "babylonjs/Maths/math.color" {
  5460. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5461. /**
  5462. * Class used to hold a RBG color
  5463. */
  5464. export class Color3 {
  5465. /**
  5466. * Defines the red component (between 0 and 1, default is 0)
  5467. */
  5468. r: number;
  5469. /**
  5470. * Defines the green component (between 0 and 1, default is 0)
  5471. */
  5472. g: number;
  5473. /**
  5474. * Defines the blue component (between 0 and 1, default is 0)
  5475. */
  5476. b: number;
  5477. /**
  5478. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5479. * @param r defines the red component (between 0 and 1, default is 0)
  5480. * @param g defines the green component (between 0 and 1, default is 0)
  5481. * @param b defines the blue component (between 0 and 1, default is 0)
  5482. */
  5483. constructor(
  5484. /**
  5485. * Defines the red component (between 0 and 1, default is 0)
  5486. */
  5487. r?: number,
  5488. /**
  5489. * Defines the green component (between 0 and 1, default is 0)
  5490. */
  5491. g?: number,
  5492. /**
  5493. * Defines the blue component (between 0 and 1, default is 0)
  5494. */
  5495. b?: number);
  5496. /**
  5497. * Creates a string with the Color3 current values
  5498. * @returns the string representation of the Color3 object
  5499. */
  5500. toString(): string;
  5501. /**
  5502. * Returns the string "Color3"
  5503. * @returns "Color3"
  5504. */
  5505. getClassName(): string;
  5506. /**
  5507. * Compute the Color3 hash code
  5508. * @returns an unique number that can be used to hash Color3 objects
  5509. */
  5510. getHashCode(): number;
  5511. /**
  5512. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5513. * @param array defines the array where to store the r,g,b components
  5514. * @param index defines an optional index in the target array to define where to start storing values
  5515. * @returns the current Color3 object
  5516. */
  5517. toArray(array: FloatArray, index?: number): Color3;
  5518. /**
  5519. * Returns a new Color4 object from the current Color3 and the given alpha
  5520. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5521. * @returns a new Color4 object
  5522. */
  5523. toColor4(alpha?: number): Color4;
  5524. /**
  5525. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5526. * @returns the new array
  5527. */
  5528. asArray(): number[];
  5529. /**
  5530. * Returns the luminance value
  5531. * @returns a float value
  5532. */
  5533. toLuminance(): number;
  5534. /**
  5535. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5536. * @param otherColor defines the second operand
  5537. * @returns the new Color3 object
  5538. */
  5539. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5540. /**
  5541. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5542. * @param otherColor defines the second operand
  5543. * @param result defines the Color3 object where to store the result
  5544. * @returns the current Color3
  5545. */
  5546. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5547. /**
  5548. * Determines equality between Color3 objects
  5549. * @param otherColor defines the second operand
  5550. * @returns true if the rgb values are equal to the given ones
  5551. */
  5552. equals(otherColor: DeepImmutable<Color3>): boolean;
  5553. /**
  5554. * Determines equality between the current Color3 object and a set of r,b,g values
  5555. * @param r defines the red component to check
  5556. * @param g defines the green component to check
  5557. * @param b defines the blue component to check
  5558. * @returns true if the rgb values are equal to the given ones
  5559. */
  5560. equalsFloats(r: number, g: number, b: number): boolean;
  5561. /**
  5562. * Multiplies in place each rgb value by scale
  5563. * @param scale defines the scaling factor
  5564. * @returns the updated Color3
  5565. */
  5566. scale(scale: number): Color3;
  5567. /**
  5568. * Multiplies the rgb values by scale and stores the result into "result"
  5569. * @param scale defines the scaling factor
  5570. * @param result defines the Color3 object where to store the result
  5571. * @returns the unmodified current Color3
  5572. */
  5573. scaleToRef(scale: number, result: Color3): Color3;
  5574. /**
  5575. * Scale the current Color3 values by a factor and add the result to a given Color3
  5576. * @param scale defines the scale factor
  5577. * @param result defines color to store the result into
  5578. * @returns the unmodified current Color3
  5579. */
  5580. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5581. /**
  5582. * Clamps the rgb values by the min and max values and stores the result into "result"
  5583. * @param min defines minimum clamping value (default is 0)
  5584. * @param max defines maximum clamping value (default is 1)
  5585. * @param result defines color to store the result into
  5586. * @returns the original Color3
  5587. */
  5588. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5589. /**
  5590. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5591. * @param otherColor defines the second operand
  5592. * @returns the new Color3
  5593. */
  5594. add(otherColor: DeepImmutable<Color3>): Color3;
  5595. /**
  5596. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5597. * @param otherColor defines the second operand
  5598. * @param result defines Color3 object to store the result into
  5599. * @returns the unmodified current Color3
  5600. */
  5601. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5602. /**
  5603. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5604. * @param otherColor defines the second operand
  5605. * @returns the new Color3
  5606. */
  5607. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5608. /**
  5609. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5610. * @param otherColor defines the second operand
  5611. * @param result defines Color3 object to store the result into
  5612. * @returns the unmodified current Color3
  5613. */
  5614. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5615. /**
  5616. * Copy the current object
  5617. * @returns a new Color3 copied the current one
  5618. */
  5619. clone(): Color3;
  5620. /**
  5621. * Copies the rgb values from the source in the current Color3
  5622. * @param source defines the source Color3 object
  5623. * @returns the updated Color3 object
  5624. */
  5625. copyFrom(source: DeepImmutable<Color3>): Color3;
  5626. /**
  5627. * Updates the Color3 rgb values from the given floats
  5628. * @param r defines the red component to read from
  5629. * @param g defines the green component to read from
  5630. * @param b defines the blue component to read from
  5631. * @returns the current Color3 object
  5632. */
  5633. copyFromFloats(r: number, g: number, b: number): Color3;
  5634. /**
  5635. * Updates the Color3 rgb values from the given floats
  5636. * @param r defines the red component to read from
  5637. * @param g defines the green component to read from
  5638. * @param b defines the blue component to read from
  5639. * @returns the current Color3 object
  5640. */
  5641. set(r: number, g: number, b: number): Color3;
  5642. /**
  5643. * Compute the Color3 hexadecimal code as a string
  5644. * @returns a string containing the hexadecimal representation of the Color3 object
  5645. */
  5646. toHexString(): string;
  5647. /**
  5648. * Computes a new Color3 converted from the current one to linear space
  5649. * @returns a new Color3 object
  5650. */
  5651. toLinearSpace(): Color3;
  5652. /**
  5653. * Converts current color in rgb space to HSV values
  5654. * @returns a new color3 representing the HSV values
  5655. */
  5656. toHSV(): Color3;
  5657. /**
  5658. * Converts current color in rgb space to HSV values
  5659. * @param result defines the Color3 where to store the HSV values
  5660. */
  5661. toHSVToRef(result: Color3): void;
  5662. /**
  5663. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5664. * @param convertedColor defines the Color3 object where to store the linear space version
  5665. * @returns the unmodified Color3
  5666. */
  5667. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5668. /**
  5669. * Computes a new Color3 converted from the current one to gamma space
  5670. * @returns a new Color3 object
  5671. */
  5672. toGammaSpace(): Color3;
  5673. /**
  5674. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5675. * @param convertedColor defines the Color3 object where to store the gamma space version
  5676. * @returns the unmodified Color3
  5677. */
  5678. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5679. private static _BlackReadOnly;
  5680. /**
  5681. * Convert Hue, saturation and value to a Color3 (RGB)
  5682. * @param hue defines the hue
  5683. * @param saturation defines the saturation
  5684. * @param value defines the value
  5685. * @param result defines the Color3 where to store the RGB values
  5686. */
  5687. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5688. /**
  5689. * Creates a new Color3 from the string containing valid hexadecimal values
  5690. * @param hex defines a string containing valid hexadecimal values
  5691. * @returns a new Color3 object
  5692. */
  5693. static FromHexString(hex: string): Color3;
  5694. /**
  5695. * Creates a new Color3 from the starting index of the given array
  5696. * @param array defines the source array
  5697. * @param offset defines an offset in the source array
  5698. * @returns a new Color3 object
  5699. */
  5700. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5701. /**
  5702. * Creates a new Color3 from integer values (< 256)
  5703. * @param r defines the red component to read from (value between 0 and 255)
  5704. * @param g defines the green component to read from (value between 0 and 255)
  5705. * @param b defines the blue component to read from (value between 0 and 255)
  5706. * @returns a new Color3 object
  5707. */
  5708. static FromInts(r: number, g: number, b: number): Color3;
  5709. /**
  5710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5711. * @param start defines the start Color3 value
  5712. * @param end defines the end Color3 value
  5713. * @param amount defines the gradient value between start and end
  5714. * @returns a new Color3 object
  5715. */
  5716. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5717. /**
  5718. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5719. * @param left defines the start value
  5720. * @param right defines the end value
  5721. * @param amount defines the gradient factor
  5722. * @param result defines the Color3 object where to store the result
  5723. */
  5724. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5725. /**
  5726. * Returns a Color3 value containing a red color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Red(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a green color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Green(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a blue color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Blue(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a black color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Black(): Color3;
  5745. /**
  5746. * Gets a Color3 value containing a black color that must not be updated
  5747. */
  5748. static get BlackReadOnly(): DeepImmutable<Color3>;
  5749. /**
  5750. * Returns a Color3 value containing a white color
  5751. * @returns a new Color3 object
  5752. */
  5753. static White(): Color3;
  5754. /**
  5755. * Returns a Color3 value containing a purple color
  5756. * @returns a new Color3 object
  5757. */
  5758. static Purple(): Color3;
  5759. /**
  5760. * Returns a Color3 value containing a magenta color
  5761. * @returns a new Color3 object
  5762. */
  5763. static Magenta(): Color3;
  5764. /**
  5765. * Returns a Color3 value containing a yellow color
  5766. * @returns a new Color3 object
  5767. */
  5768. static Yellow(): Color3;
  5769. /**
  5770. * Returns a Color3 value containing a gray color
  5771. * @returns a new Color3 object
  5772. */
  5773. static Gray(): Color3;
  5774. /**
  5775. * Returns a Color3 value containing a teal color
  5776. * @returns a new Color3 object
  5777. */
  5778. static Teal(): Color3;
  5779. /**
  5780. * Returns a Color3 value containing a random color
  5781. * @returns a new Color3 object
  5782. */
  5783. static Random(): Color3;
  5784. }
  5785. /**
  5786. * Class used to hold a RBGA color
  5787. */
  5788. export class Color4 {
  5789. /**
  5790. * Defines the red component (between 0 and 1, default is 0)
  5791. */
  5792. r: number;
  5793. /**
  5794. * Defines the green component (between 0 and 1, default is 0)
  5795. */
  5796. g: number;
  5797. /**
  5798. * Defines the blue component (between 0 and 1, default is 0)
  5799. */
  5800. b: number;
  5801. /**
  5802. * Defines the alpha component (between 0 and 1, default is 1)
  5803. */
  5804. a: number;
  5805. /**
  5806. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5807. * @param r defines the red component (between 0 and 1, default is 0)
  5808. * @param g defines the green component (between 0 and 1, default is 0)
  5809. * @param b defines the blue component (between 0 and 1, default is 0)
  5810. * @param a defines the alpha component (between 0 and 1, default is 1)
  5811. */
  5812. constructor(
  5813. /**
  5814. * Defines the red component (between 0 and 1, default is 0)
  5815. */
  5816. r?: number,
  5817. /**
  5818. * Defines the green component (between 0 and 1, default is 0)
  5819. */
  5820. g?: number,
  5821. /**
  5822. * Defines the blue component (between 0 and 1, default is 0)
  5823. */
  5824. b?: number,
  5825. /**
  5826. * Defines the alpha component (between 0 and 1, default is 1)
  5827. */
  5828. a?: number);
  5829. /**
  5830. * Adds in place the given Color4 values to the current Color4 object
  5831. * @param right defines the second operand
  5832. * @returns the current updated Color4 object
  5833. */
  5834. addInPlace(right: DeepImmutable<Color4>): Color4;
  5835. /**
  5836. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5837. * @returns the new array
  5838. */
  5839. asArray(): number[];
  5840. /**
  5841. * Stores from the starting index in the given array the Color4 successive values
  5842. * @param array defines the array where to store the r,g,b components
  5843. * @param index defines an optional index in the target array to define where to start storing values
  5844. * @returns the current Color4 object
  5845. */
  5846. toArray(array: number[], index?: number): Color4;
  5847. /**
  5848. * Determines equality between Color4 objects
  5849. * @param otherColor defines the second operand
  5850. * @returns true if the rgba values are equal to the given ones
  5851. */
  5852. equals(otherColor: DeepImmutable<Color4>): boolean;
  5853. /**
  5854. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5855. * @param right defines the second operand
  5856. * @returns a new Color4 object
  5857. */
  5858. add(right: DeepImmutable<Color4>): Color4;
  5859. /**
  5860. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5861. * @param right defines the second operand
  5862. * @returns a new Color4 object
  5863. */
  5864. subtract(right: DeepImmutable<Color4>): Color4;
  5865. /**
  5866. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5867. * @param right defines the second operand
  5868. * @param result defines the Color4 object where to store the result
  5869. * @returns the current Color4 object
  5870. */
  5871. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5872. /**
  5873. * Creates a new Color4 with the current Color4 values multiplied by scale
  5874. * @param scale defines the scaling factor to apply
  5875. * @returns a new Color4 object
  5876. */
  5877. scale(scale: number): Color4;
  5878. /**
  5879. * Multiplies the current Color4 values by scale and stores the result in "result"
  5880. * @param scale defines the scaling factor to apply
  5881. * @param result defines the Color4 object where to store the result
  5882. * @returns the current unmodified Color4
  5883. */
  5884. scaleToRef(scale: number, result: Color4): Color4;
  5885. /**
  5886. * Scale the current Color4 values by a factor and add the result to a given Color4
  5887. * @param scale defines the scale factor
  5888. * @param result defines the Color4 object where to store the result
  5889. * @returns the unmodified current Color4
  5890. */
  5891. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5892. /**
  5893. * Clamps the rgb values by the min and max values and stores the result into "result"
  5894. * @param min defines minimum clamping value (default is 0)
  5895. * @param max defines maximum clamping value (default is 1)
  5896. * @param result defines color to store the result into.
  5897. * @returns the cuurent Color4
  5898. */
  5899. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5900. /**
  5901. * Multipy an Color4 value by another and return a new Color4 object
  5902. * @param color defines the Color4 value to multiply by
  5903. * @returns a new Color4 object
  5904. */
  5905. multiply(color: Color4): Color4;
  5906. /**
  5907. * Multipy a Color4 value by another and push the result in a reference value
  5908. * @param color defines the Color4 value to multiply by
  5909. * @param result defines the Color4 to fill the result in
  5910. * @returns the result Color4
  5911. */
  5912. multiplyToRef(color: Color4, result: Color4): Color4;
  5913. /**
  5914. * Creates a string with the Color4 current values
  5915. * @returns the string representation of the Color4 object
  5916. */
  5917. toString(): string;
  5918. /**
  5919. * Returns the string "Color4"
  5920. * @returns "Color4"
  5921. */
  5922. getClassName(): string;
  5923. /**
  5924. * Compute the Color4 hash code
  5925. * @returns an unique number that can be used to hash Color4 objects
  5926. */
  5927. getHashCode(): number;
  5928. /**
  5929. * Creates a new Color4 copied from the current one
  5930. * @returns a new Color4 object
  5931. */
  5932. clone(): Color4;
  5933. /**
  5934. * Copies the given Color4 values into the current one
  5935. * @param source defines the source Color4 object
  5936. * @returns the current updated Color4 object
  5937. */
  5938. copyFrom(source: Color4): Color4;
  5939. /**
  5940. * Copies the given float values into the current one
  5941. * @param r defines the red component to read from
  5942. * @param g defines the green component to read from
  5943. * @param b defines the blue component to read from
  5944. * @param a defines the alpha component to read from
  5945. * @returns the current updated Color4 object
  5946. */
  5947. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5948. /**
  5949. * Copies the given float values into the current one
  5950. * @param r defines the red component to read from
  5951. * @param g defines the green component to read from
  5952. * @param b defines the blue component to read from
  5953. * @param a defines the alpha component to read from
  5954. * @returns the current updated Color4 object
  5955. */
  5956. set(r: number, g: number, b: number, a: number): Color4;
  5957. /**
  5958. * Compute the Color4 hexadecimal code as a string
  5959. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5960. * @returns a string containing the hexadecimal representation of the Color4 object
  5961. */
  5962. toHexString(returnAsColor3?: boolean): string;
  5963. /**
  5964. * Computes a new Color4 converted from the current one to linear space
  5965. * @returns a new Color4 object
  5966. */
  5967. toLinearSpace(): Color4;
  5968. /**
  5969. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5970. * @param convertedColor defines the Color4 object where to store the linear space version
  5971. * @returns the unmodified Color4
  5972. */
  5973. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5974. /**
  5975. * Computes a new Color4 converted from the current one to gamma space
  5976. * @returns a new Color4 object
  5977. */
  5978. toGammaSpace(): Color4;
  5979. /**
  5980. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5981. * @param convertedColor defines the Color4 object where to store the gamma space version
  5982. * @returns the unmodified Color4
  5983. */
  5984. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5985. /**
  5986. * Creates a new Color4 from the string containing valid hexadecimal values
  5987. * @param hex defines a string containing valid hexadecimal values
  5988. * @returns a new Color4 object
  5989. */
  5990. static FromHexString(hex: string): Color4;
  5991. /**
  5992. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5993. * @param left defines the start value
  5994. * @param right defines the end value
  5995. * @param amount defines the gradient factor
  5996. * @returns a new Color4 object
  5997. */
  5998. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5999. /**
  6000. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6001. * @param left defines the start value
  6002. * @param right defines the end value
  6003. * @param amount defines the gradient factor
  6004. * @param result defines the Color4 object where to store data
  6005. */
  6006. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6007. /**
  6008. * Creates a new Color4 from a Color3 and an alpha value
  6009. * @param color3 defines the source Color3 to read from
  6010. * @param alpha defines the alpha component (1.0 by default)
  6011. * @returns a new Color4 object
  6012. */
  6013. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6014. /**
  6015. * Creates a new Color4 from the starting index element of the given array
  6016. * @param array defines the source array to read from
  6017. * @param offset defines the offset in the source array
  6018. * @returns a new Color4 object
  6019. */
  6020. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6021. /**
  6022. * Creates a new Color3 from integer values (< 256)
  6023. * @param r defines the red component to read from (value between 0 and 255)
  6024. * @param g defines the green component to read from (value between 0 and 255)
  6025. * @param b defines the blue component to read from (value between 0 and 255)
  6026. * @param a defines the alpha component to read from (value between 0 and 255)
  6027. * @returns a new Color3 object
  6028. */
  6029. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6030. /**
  6031. * Check the content of a given array and convert it to an array containing RGBA data
  6032. * If the original array was already containing count * 4 values then it is returned directly
  6033. * @param colors defines the array to check
  6034. * @param count defines the number of RGBA data to expect
  6035. * @returns an array containing count * 4 values (RGBA)
  6036. */
  6037. static CheckColors4(colors: number[], count: number): number[];
  6038. }
  6039. /**
  6040. * @hidden
  6041. */
  6042. export class TmpColors {
  6043. static Color3: Color3[];
  6044. static Color4: Color4[];
  6045. }
  6046. }
  6047. declare module "babylonjs/Animations/animationKey" {
  6048. /**
  6049. * Defines an interface which represents an animation key frame
  6050. */
  6051. export interface IAnimationKey {
  6052. /**
  6053. * Frame of the key frame
  6054. */
  6055. frame: number;
  6056. /**
  6057. * Value at the specifies key frame
  6058. */
  6059. value: any;
  6060. /**
  6061. * The input tangent for the cubic hermite spline
  6062. */
  6063. inTangent?: any;
  6064. /**
  6065. * The output tangent for the cubic hermite spline
  6066. */
  6067. outTangent?: any;
  6068. /**
  6069. * The animation interpolation type
  6070. */
  6071. interpolation?: AnimationKeyInterpolation;
  6072. }
  6073. /**
  6074. * Enum for the animation key frame interpolation type
  6075. */
  6076. export enum AnimationKeyInterpolation {
  6077. /**
  6078. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6079. */
  6080. STEP = 1
  6081. }
  6082. }
  6083. declare module "babylonjs/Animations/animationRange" {
  6084. /**
  6085. * Represents the range of an animation
  6086. */
  6087. export class AnimationRange {
  6088. /**The name of the animation range**/
  6089. name: string;
  6090. /**The starting frame of the animation */
  6091. from: number;
  6092. /**The ending frame of the animation*/
  6093. to: number;
  6094. /**
  6095. * Initializes the range of an animation
  6096. * @param name The name of the animation range
  6097. * @param from The starting frame of the animation
  6098. * @param to The ending frame of the animation
  6099. */
  6100. constructor(
  6101. /**The name of the animation range**/
  6102. name: string,
  6103. /**The starting frame of the animation */
  6104. from: number,
  6105. /**The ending frame of the animation*/
  6106. to: number);
  6107. /**
  6108. * Makes a copy of the animation range
  6109. * @returns A copy of the animation range
  6110. */
  6111. clone(): AnimationRange;
  6112. }
  6113. }
  6114. declare module "babylonjs/Animations/animationEvent" {
  6115. /**
  6116. * Composed of a frame, and an action function
  6117. */
  6118. export class AnimationEvent {
  6119. /** The frame for which the event is triggered **/
  6120. frame: number;
  6121. /** The event to perform when triggered **/
  6122. action: (currentFrame: number) => void;
  6123. /** Specifies if the event should be triggered only once**/
  6124. onlyOnce?: boolean | undefined;
  6125. /**
  6126. * Specifies if the animation event is done
  6127. */
  6128. isDone: boolean;
  6129. /**
  6130. * Initializes the animation event
  6131. * @param frame The frame for which the event is triggered
  6132. * @param action The event to perform when triggered
  6133. * @param onlyOnce Specifies if the event should be triggered only once
  6134. */
  6135. constructor(
  6136. /** The frame for which the event is triggered **/
  6137. frame: number,
  6138. /** The event to perform when triggered **/
  6139. action: (currentFrame: number) => void,
  6140. /** Specifies if the event should be triggered only once**/
  6141. onlyOnce?: boolean | undefined);
  6142. /** @hidden */
  6143. _clone(): AnimationEvent;
  6144. }
  6145. }
  6146. declare module "babylonjs/Behaviors/behavior" {
  6147. import { Nullable } from "babylonjs/types";
  6148. /**
  6149. * Interface used to define a behavior
  6150. */
  6151. export interface Behavior<T> {
  6152. /** gets or sets behavior's name */
  6153. name: string;
  6154. /**
  6155. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6156. */
  6157. init(): void;
  6158. /**
  6159. * Called when the behavior is attached to a target
  6160. * @param target defines the target where the behavior is attached to
  6161. */
  6162. attach(target: T): void;
  6163. /**
  6164. * Called when the behavior is detached from its target
  6165. */
  6166. detach(): void;
  6167. }
  6168. /**
  6169. * Interface implemented by classes supporting behaviors
  6170. */
  6171. export interface IBehaviorAware<T> {
  6172. /**
  6173. * Attach a behavior
  6174. * @param behavior defines the behavior to attach
  6175. * @returns the current host
  6176. */
  6177. addBehavior(behavior: Behavior<T>): T;
  6178. /**
  6179. * Remove a behavior from the current object
  6180. * @param behavior defines the behavior to detach
  6181. * @returns the current host
  6182. */
  6183. removeBehavior(behavior: Behavior<T>): T;
  6184. /**
  6185. * Gets a behavior using its name to search
  6186. * @param name defines the name to search
  6187. * @returns the behavior or null if not found
  6188. */
  6189. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6190. }
  6191. }
  6192. declare module "babylonjs/Misc/smartArray" {
  6193. /**
  6194. * Defines an array and its length.
  6195. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6196. */
  6197. export interface ISmartArrayLike<T> {
  6198. /**
  6199. * The data of the array.
  6200. */
  6201. data: Array<T>;
  6202. /**
  6203. * The active length of the array.
  6204. */
  6205. length: number;
  6206. }
  6207. /**
  6208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6209. */
  6210. export class SmartArray<T> implements ISmartArrayLike<T> {
  6211. /**
  6212. * The full set of data from the array.
  6213. */
  6214. data: Array<T>;
  6215. /**
  6216. * The active length of the array.
  6217. */
  6218. length: number;
  6219. protected _id: number;
  6220. /**
  6221. * Instantiates a Smart Array.
  6222. * @param capacity defines the default capacity of the array.
  6223. */
  6224. constructor(capacity: number);
  6225. /**
  6226. * Pushes a value at the end of the active data.
  6227. * @param value defines the object to push in the array.
  6228. */
  6229. push(value: T): void;
  6230. /**
  6231. * Iterates over the active data and apply the lambda to them.
  6232. * @param func defines the action to apply on each value.
  6233. */
  6234. forEach(func: (content: T) => void): void;
  6235. /**
  6236. * Sorts the full sets of data.
  6237. * @param compareFn defines the comparison function to apply.
  6238. */
  6239. sort(compareFn: (a: T, b: T) => number): void;
  6240. /**
  6241. * Resets the active data to an empty array.
  6242. */
  6243. reset(): void;
  6244. /**
  6245. * Releases all the data from the array as well as the array.
  6246. */
  6247. dispose(): void;
  6248. /**
  6249. * Concats the active data with a given array.
  6250. * @param array defines the data to concatenate with.
  6251. */
  6252. concat(array: any): void;
  6253. /**
  6254. * Returns the position of a value in the active data.
  6255. * @param value defines the value to find the index for
  6256. * @returns the index if found in the active data otherwise -1
  6257. */
  6258. indexOf(value: T): number;
  6259. /**
  6260. * Returns whether an element is part of the active data.
  6261. * @param value defines the value to look for
  6262. * @returns true if found in the active data otherwise false
  6263. */
  6264. contains(value: T): boolean;
  6265. private static _GlobalId;
  6266. }
  6267. /**
  6268. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6269. * The data in this array can only be present once
  6270. */
  6271. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6272. private _duplicateId;
  6273. /**
  6274. * Pushes a value at the end of the active data.
  6275. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6276. * @param value defines the object to push in the array.
  6277. */
  6278. push(value: T): void;
  6279. /**
  6280. * Pushes a value at the end of the active data.
  6281. * If the data is already present, it won t be added again
  6282. * @param value defines the object to push in the array.
  6283. * @returns true if added false if it was already present
  6284. */
  6285. pushNoDuplicate(value: T): boolean;
  6286. /**
  6287. * Resets the active data to an empty array.
  6288. */
  6289. reset(): void;
  6290. /**
  6291. * Concats the active data with a given array.
  6292. * This ensures no dupplicate will be present in the result.
  6293. * @param array defines the data to concatenate with.
  6294. */
  6295. concatWithNoDuplicate(array: any): void;
  6296. }
  6297. }
  6298. declare module "babylonjs/Cameras/cameraInputsManager" {
  6299. import { Nullable } from "babylonjs/types";
  6300. import { Camera } from "babylonjs/Cameras/camera";
  6301. /**
  6302. * @ignore
  6303. * This is a list of all the different input types that are available in the application.
  6304. * Fo instance: ArcRotateCameraGamepadInput...
  6305. */
  6306. export var CameraInputTypes: {};
  6307. /**
  6308. * This is the contract to implement in order to create a new input class.
  6309. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6310. */
  6311. export interface ICameraInput<TCamera extends Camera> {
  6312. /**
  6313. * Defines the camera the input is attached to.
  6314. */
  6315. camera: Nullable<TCamera>;
  6316. /**
  6317. * Gets the class name of the current intput.
  6318. * @returns the class name
  6319. */
  6320. getClassName(): string;
  6321. /**
  6322. * Get the friendly name associated with the input class.
  6323. * @returns the input friendly name
  6324. */
  6325. getSimpleName(): string;
  6326. /**
  6327. * Attach the input controls to a specific dom element to get the input from.
  6328. * @param element Defines the element the controls should be listened from
  6329. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6330. */
  6331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6332. /**
  6333. * Detach the current controls from the specified dom element.
  6334. * @param element Defines the element to stop listening the inputs from
  6335. */
  6336. detachControl(element: Nullable<HTMLElement>): void;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs?: () => void;
  6342. }
  6343. /**
  6344. * Represents a map of input types to input instance or input index to input instance.
  6345. */
  6346. export interface CameraInputsMap<TCamera extends Camera> {
  6347. /**
  6348. * Accessor to the input by input type.
  6349. */
  6350. [name: string]: ICameraInput<TCamera>;
  6351. /**
  6352. * Accessor to the input by input index.
  6353. */
  6354. [idx: number]: ICameraInput<TCamera>;
  6355. }
  6356. /**
  6357. * This represents the input manager used within a camera.
  6358. * It helps dealing with all the different kind of input attached to a camera.
  6359. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6360. */
  6361. export class CameraInputsManager<TCamera extends Camera> {
  6362. /**
  6363. * Defines the list of inputs attahed to the camera.
  6364. */
  6365. attached: CameraInputsMap<TCamera>;
  6366. /**
  6367. * Defines the dom element the camera is collecting inputs from.
  6368. * This is null if the controls have not been attached.
  6369. */
  6370. attachedElement: Nullable<HTMLElement>;
  6371. /**
  6372. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6373. */
  6374. noPreventDefault: boolean;
  6375. /**
  6376. * Defined the camera the input manager belongs to.
  6377. */
  6378. camera: TCamera;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs: () => void;
  6384. /**
  6385. * Instantiate a new Camera Input Manager.
  6386. * @param camera Defines the camera the input manager blongs to
  6387. */
  6388. constructor(camera: TCamera);
  6389. /**
  6390. * Add an input method to a camera
  6391. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6392. * @param input camera input method
  6393. */
  6394. add(input: ICameraInput<TCamera>): void;
  6395. /**
  6396. * Remove a specific input method from a camera
  6397. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6398. * @param inputToRemove camera input method
  6399. */
  6400. remove(inputToRemove: ICameraInput<TCamera>): void;
  6401. /**
  6402. * Remove a specific input type from a camera
  6403. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6404. * @param inputType the type of the input to remove
  6405. */
  6406. removeByType(inputType: string): void;
  6407. private _addCheckInputs;
  6408. /**
  6409. * Attach the input controls to the currently attached dom element to listen the events from.
  6410. * @param input Defines the input to attach
  6411. */
  6412. attachInput(input: ICameraInput<TCamera>): void;
  6413. /**
  6414. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6415. * @param element Defines the dom element to collect the events from
  6416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6417. */
  6418. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6419. /**
  6420. * Detach the current manager inputs controls from a specific dom element.
  6421. * @param element Defines the dom element to collect the events from
  6422. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6423. */
  6424. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6425. /**
  6426. * Rebuild the dynamic inputCheck function from the current list of
  6427. * defined inputs in the manager.
  6428. */
  6429. rebuildInputCheck(): void;
  6430. /**
  6431. * Remove all attached input methods from a camera
  6432. */
  6433. clear(): void;
  6434. /**
  6435. * Serialize the current input manager attached to a camera.
  6436. * This ensures than once parsed,
  6437. * the input associated to the camera will be identical to the current ones
  6438. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6439. */
  6440. serialize(serializedCamera: any): void;
  6441. /**
  6442. * Parses an input manager serialized JSON to restore the previous list of inputs
  6443. * and states associated to a camera.
  6444. * @param parsedCamera Defines the JSON to parse
  6445. */
  6446. parse(parsedCamera: any): void;
  6447. }
  6448. }
  6449. declare module "babylonjs/Meshes/buffer" {
  6450. import { Nullable, DataArray } from "babylonjs/types";
  6451. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6452. /**
  6453. * Class used to store data that will be store in GPU memory
  6454. */
  6455. export class Buffer {
  6456. private _engine;
  6457. private _buffer;
  6458. /** @hidden */
  6459. _data: Nullable<DataArray>;
  6460. private _updatable;
  6461. private _instanced;
  6462. private _divisor;
  6463. /**
  6464. * Gets the byte stride.
  6465. */
  6466. readonly byteStride: number;
  6467. /**
  6468. * Constructor
  6469. * @param engine the engine
  6470. * @param data the data to use for this buffer
  6471. * @param updatable whether the data is updatable
  6472. * @param stride the stride (optional)
  6473. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6474. * @param instanced whether the buffer is instanced (optional)
  6475. * @param useBytes set to true if the stride in in bytes (optional)
  6476. * @param divisor sets an optional divisor for instances (1 by default)
  6477. */
  6478. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6479. /**
  6480. * Create a new VertexBuffer based on the current buffer
  6481. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6482. * @param offset defines offset in the buffer (0 by default)
  6483. * @param size defines the size in floats of attributes (position is 3 for instance)
  6484. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6485. * @param instanced defines if the vertex buffer contains indexed data
  6486. * @param useBytes defines if the offset and stride are in bytes *
  6487. * @param divisor sets an optional divisor for instances (1 by default)
  6488. * @returns the new vertex buffer
  6489. */
  6490. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6491. /**
  6492. * Gets a boolean indicating if the Buffer is updatable?
  6493. * @returns true if the buffer is updatable
  6494. */
  6495. isUpdatable(): boolean;
  6496. /**
  6497. * Gets current buffer's data
  6498. * @returns a DataArray or null
  6499. */
  6500. getData(): Nullable<DataArray>;
  6501. /**
  6502. * Gets underlying native buffer
  6503. * @returns underlying native buffer
  6504. */
  6505. getBuffer(): Nullable<DataBuffer>;
  6506. /**
  6507. * Gets the stride in float32 units (i.e. byte stride / 4).
  6508. * May not be an integer if the byte stride is not divisible by 4.
  6509. * @returns the stride in float32 units
  6510. * @deprecated Please use byteStride instead.
  6511. */
  6512. getStrideSize(): number;
  6513. /**
  6514. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6515. * @param data defines the data to store
  6516. */
  6517. create(data?: Nullable<DataArray>): void;
  6518. /** @hidden */
  6519. _rebuild(): void;
  6520. /**
  6521. * Update current buffer data
  6522. * @param data defines the data to store
  6523. */
  6524. update(data: DataArray): void;
  6525. /**
  6526. * Updates the data directly.
  6527. * @param data the new data
  6528. * @param offset the new offset
  6529. * @param vertexCount the vertex count (optional)
  6530. * @param useBytes set to true if the offset is in bytes
  6531. */
  6532. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6533. /**
  6534. * Release all resources
  6535. */
  6536. dispose(): void;
  6537. }
  6538. /**
  6539. * Specialized buffer used to store vertex data
  6540. */
  6541. export class VertexBuffer {
  6542. /** @hidden */
  6543. _buffer: Buffer;
  6544. private _kind;
  6545. private _size;
  6546. private _ownsBuffer;
  6547. private _instanced;
  6548. private _instanceDivisor;
  6549. /**
  6550. * The byte type.
  6551. */
  6552. static readonly BYTE: number;
  6553. /**
  6554. * The unsigned byte type.
  6555. */
  6556. static readonly UNSIGNED_BYTE: number;
  6557. /**
  6558. * The short type.
  6559. */
  6560. static readonly SHORT: number;
  6561. /**
  6562. * The unsigned short type.
  6563. */
  6564. static readonly UNSIGNED_SHORT: number;
  6565. /**
  6566. * The integer type.
  6567. */
  6568. static readonly INT: number;
  6569. /**
  6570. * The unsigned integer type.
  6571. */
  6572. static readonly UNSIGNED_INT: number;
  6573. /**
  6574. * The float type.
  6575. */
  6576. static readonly FLOAT: number;
  6577. /**
  6578. * Gets or sets the instance divisor when in instanced mode
  6579. */
  6580. get instanceDivisor(): number;
  6581. set instanceDivisor(value: number);
  6582. /**
  6583. * Gets the byte stride.
  6584. */
  6585. readonly byteStride: number;
  6586. /**
  6587. * Gets the byte offset.
  6588. */
  6589. readonly byteOffset: number;
  6590. /**
  6591. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6592. */
  6593. readonly normalized: boolean;
  6594. /**
  6595. * Gets the data type of each component in the array.
  6596. */
  6597. readonly type: number;
  6598. /**
  6599. * Constructor
  6600. * @param engine the engine
  6601. * @param data the data to use for this vertex buffer
  6602. * @param kind the vertex buffer kind
  6603. * @param updatable whether the data is updatable
  6604. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6605. * @param stride the stride (optional)
  6606. * @param instanced whether the buffer is instanced (optional)
  6607. * @param offset the offset of the data (optional)
  6608. * @param size the number of components (optional)
  6609. * @param type the type of the component (optional)
  6610. * @param normalized whether the data contains normalized data (optional)
  6611. * @param useBytes set to true if stride and offset are in bytes (optional)
  6612. * @param divisor defines the instance divisor to use (1 by default)
  6613. */
  6614. 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);
  6615. /** @hidden */
  6616. _rebuild(): void;
  6617. /**
  6618. * Returns the kind of the VertexBuffer (string)
  6619. * @returns a string
  6620. */
  6621. getKind(): string;
  6622. /**
  6623. * Gets a boolean indicating if the VertexBuffer is updatable?
  6624. * @returns true if the buffer is updatable
  6625. */
  6626. isUpdatable(): boolean;
  6627. /**
  6628. * Gets current buffer's data
  6629. * @returns a DataArray or null
  6630. */
  6631. getData(): Nullable<DataArray>;
  6632. /**
  6633. * Gets underlying native buffer
  6634. * @returns underlying native buffer
  6635. */
  6636. getBuffer(): Nullable<DataBuffer>;
  6637. /**
  6638. * Gets the stride in float32 units (i.e. byte stride / 4).
  6639. * May not be an integer if the byte stride is not divisible by 4.
  6640. * @returns the stride in float32 units
  6641. * @deprecated Please use byteStride instead.
  6642. */
  6643. getStrideSize(): number;
  6644. /**
  6645. * Returns the offset as a multiple of the type byte length.
  6646. * @returns the offset in bytes
  6647. * @deprecated Please use byteOffset instead.
  6648. */
  6649. getOffset(): number;
  6650. /**
  6651. * Returns the number of components per vertex attribute (integer)
  6652. * @returns the size in float
  6653. */
  6654. getSize(): number;
  6655. /**
  6656. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6657. * @returns true if this buffer is instanced
  6658. */
  6659. getIsInstanced(): boolean;
  6660. /**
  6661. * Returns the instancing divisor, zero for non-instanced (integer).
  6662. * @returns a number
  6663. */
  6664. getInstanceDivisor(): number;
  6665. /**
  6666. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6667. * @param data defines the data to store
  6668. */
  6669. create(data?: DataArray): void;
  6670. /**
  6671. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6672. * This function will create a new buffer if the current one is not updatable
  6673. * @param data defines the data to store
  6674. */
  6675. update(data: DataArray): void;
  6676. /**
  6677. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6678. * Returns the directly updated WebGLBuffer.
  6679. * @param data the new data
  6680. * @param offset the new offset
  6681. * @param useBytes set to true if the offset is in bytes
  6682. */
  6683. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6684. /**
  6685. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6686. */
  6687. dispose(): void;
  6688. /**
  6689. * Enumerates each value of this vertex buffer as numbers.
  6690. * @param count the number of values to enumerate
  6691. * @param callback the callback function called for each value
  6692. */
  6693. forEach(count: number, callback: (value: number, index: number) => void): void;
  6694. /**
  6695. * Positions
  6696. */
  6697. static readonly PositionKind: string;
  6698. /**
  6699. * Normals
  6700. */
  6701. static readonly NormalKind: string;
  6702. /**
  6703. * Tangents
  6704. */
  6705. static readonly TangentKind: string;
  6706. /**
  6707. * Texture coordinates
  6708. */
  6709. static readonly UVKind: string;
  6710. /**
  6711. * Texture coordinates 2
  6712. */
  6713. static readonly UV2Kind: string;
  6714. /**
  6715. * Texture coordinates 3
  6716. */
  6717. static readonly UV3Kind: string;
  6718. /**
  6719. * Texture coordinates 4
  6720. */
  6721. static readonly UV4Kind: string;
  6722. /**
  6723. * Texture coordinates 5
  6724. */
  6725. static readonly UV5Kind: string;
  6726. /**
  6727. * Texture coordinates 6
  6728. */
  6729. static readonly UV6Kind: string;
  6730. /**
  6731. * Colors
  6732. */
  6733. static readonly ColorKind: string;
  6734. /**
  6735. * Matrix indices (for bones)
  6736. */
  6737. static readonly MatricesIndicesKind: string;
  6738. /**
  6739. * Matrix weights (for bones)
  6740. */
  6741. static readonly MatricesWeightsKind: string;
  6742. /**
  6743. * Additional matrix indices (for bones)
  6744. */
  6745. static readonly MatricesIndicesExtraKind: string;
  6746. /**
  6747. * Additional matrix weights (for bones)
  6748. */
  6749. static readonly MatricesWeightsExtraKind: string;
  6750. /**
  6751. * Deduces the stride given a kind.
  6752. * @param kind The kind string to deduce
  6753. * @returns The deduced stride
  6754. */
  6755. static DeduceStride(kind: string): number;
  6756. /**
  6757. * Gets the byte length of the given type.
  6758. * @param type the type
  6759. * @returns the number of bytes
  6760. */
  6761. static GetTypeByteLength(type: number): number;
  6762. /**
  6763. * Enumerates each value of the given parameters as numbers.
  6764. * @param data the data to enumerate
  6765. * @param byteOffset the byte offset of the data
  6766. * @param byteStride the byte stride of the data
  6767. * @param componentCount the number of components per element
  6768. * @param componentType the type of the component
  6769. * @param count the number of values to enumerate
  6770. * @param normalized whether the data is normalized
  6771. * @param callback the callback function called for each value
  6772. */
  6773. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6774. private static _GetFloatValue;
  6775. }
  6776. }
  6777. declare module "babylonjs/Collisions/intersectionInfo" {
  6778. import { Nullable } from "babylonjs/types";
  6779. /**
  6780. * @hidden
  6781. */
  6782. export class IntersectionInfo {
  6783. bu: Nullable<number>;
  6784. bv: Nullable<number>;
  6785. distance: number;
  6786. faceId: number;
  6787. subMeshId: number;
  6788. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6789. }
  6790. }
  6791. declare module "babylonjs/Culling/boundingSphere" {
  6792. import { DeepImmutable } from "babylonjs/types";
  6793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6794. import { Plane } from "babylonjs/Maths/math.plane";
  6795. /**
  6796. * Class used to store bounding sphere information
  6797. */
  6798. export class BoundingSphere {
  6799. /**
  6800. * Gets the center of the bounding sphere in local space
  6801. */
  6802. readonly center: Vector3;
  6803. /**
  6804. * Radius of the bounding sphere in local space
  6805. */
  6806. radius: number;
  6807. /**
  6808. * Gets the center of the bounding sphere in world space
  6809. */
  6810. readonly centerWorld: Vector3;
  6811. /**
  6812. * Radius of the bounding sphere in world space
  6813. */
  6814. radiusWorld: number;
  6815. /**
  6816. * Gets the minimum vector in local space
  6817. */
  6818. readonly minimum: Vector3;
  6819. /**
  6820. * Gets the maximum vector in local space
  6821. */
  6822. readonly maximum: Vector3;
  6823. private _worldMatrix;
  6824. private static readonly TmpVector3;
  6825. /**
  6826. * Creates a new bounding sphere
  6827. * @param min defines the minimum vector (in local space)
  6828. * @param max defines the maximum vector (in local space)
  6829. * @param worldMatrix defines the new world matrix
  6830. */
  6831. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6832. /**
  6833. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6834. * @param min defines the new minimum vector (in local space)
  6835. * @param max defines the new maximum vector (in local space)
  6836. * @param worldMatrix defines the new world matrix
  6837. */
  6838. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6839. /**
  6840. * Scale the current bounding sphere by applying a scale factor
  6841. * @param factor defines the scale factor to apply
  6842. * @returns the current bounding box
  6843. */
  6844. scale(factor: number): BoundingSphere;
  6845. /**
  6846. * Gets the world matrix of the bounding box
  6847. * @returns a matrix
  6848. */
  6849. getWorldMatrix(): DeepImmutable<Matrix>;
  6850. /** @hidden */
  6851. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6852. /**
  6853. * Tests if the bounding sphere is intersecting the frustum planes
  6854. * @param frustumPlanes defines the frustum planes to test
  6855. * @returns true if there is an intersection
  6856. */
  6857. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6858. /**
  6859. * Tests if the bounding sphere center is in between the frustum planes.
  6860. * Used for optimistic fast inclusion.
  6861. * @param frustumPlanes defines the frustum planes to test
  6862. * @returns true if the sphere center is in between the frustum planes
  6863. */
  6864. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6865. /**
  6866. * Tests if a point is inside the bounding sphere
  6867. * @param point defines the point to test
  6868. * @returns true if the point is inside the bounding sphere
  6869. */
  6870. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6871. /**
  6872. * Checks if two sphere intersct
  6873. * @param sphere0 sphere 0
  6874. * @param sphere1 sphere 1
  6875. * @returns true if the speres intersect
  6876. */
  6877. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6878. }
  6879. }
  6880. declare module "babylonjs/Culling/boundingBox" {
  6881. import { DeepImmutable } from "babylonjs/types";
  6882. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6883. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6884. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6885. import { Plane } from "babylonjs/Maths/math.plane";
  6886. /**
  6887. * Class used to store bounding box information
  6888. */
  6889. export class BoundingBox implements ICullable {
  6890. /**
  6891. * Gets the 8 vectors representing the bounding box in local space
  6892. */
  6893. readonly vectors: Vector3[];
  6894. /**
  6895. * Gets the center of the bounding box in local space
  6896. */
  6897. readonly center: Vector3;
  6898. /**
  6899. * Gets the center of the bounding box in world space
  6900. */
  6901. readonly centerWorld: Vector3;
  6902. /**
  6903. * Gets the extend size in local space
  6904. */
  6905. readonly extendSize: Vector3;
  6906. /**
  6907. * Gets the extend size in world space
  6908. */
  6909. readonly extendSizeWorld: Vector3;
  6910. /**
  6911. * Gets the OBB (object bounding box) directions
  6912. */
  6913. readonly directions: Vector3[];
  6914. /**
  6915. * Gets the 8 vectors representing the bounding box in world space
  6916. */
  6917. readonly vectorsWorld: Vector3[];
  6918. /**
  6919. * Gets the minimum vector in world space
  6920. */
  6921. readonly minimumWorld: Vector3;
  6922. /**
  6923. * Gets the maximum vector in world space
  6924. */
  6925. readonly maximumWorld: Vector3;
  6926. /**
  6927. * Gets the minimum vector in local space
  6928. */
  6929. readonly minimum: Vector3;
  6930. /**
  6931. * Gets the maximum vector in local space
  6932. */
  6933. readonly maximum: Vector3;
  6934. private _worldMatrix;
  6935. private static readonly TmpVector3;
  6936. /**
  6937. * @hidden
  6938. */
  6939. _tag: number;
  6940. /**
  6941. * Creates a new bounding box
  6942. * @param min defines the minimum vector (in local space)
  6943. * @param max defines the maximum vector (in local space)
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * Scale the current bounding box by applying a scale factor
  6956. * @param factor defines the scale factor to apply
  6957. * @returns the current bounding box
  6958. */
  6959. scale(factor: number): BoundingBox;
  6960. /**
  6961. * Gets the world matrix of the bounding box
  6962. * @returns a matrix
  6963. */
  6964. getWorldMatrix(): DeepImmutable<Matrix>;
  6965. /** @hidden */
  6966. _update(world: DeepImmutable<Matrix>): void;
  6967. /**
  6968. * Tests if the bounding box is intersecting the frustum planes
  6969. * @param frustumPlanes defines the frustum planes to test
  6970. * @returns true if there is an intersection
  6971. */
  6972. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6973. /**
  6974. * Tests if the bounding box is entirely inside the frustum planes
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if there is an inclusion
  6977. */
  6978. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding box
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding box
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Tests if the bounding box intersects with a bounding sphere
  6987. * @param sphere defines the sphere to test
  6988. * @returns true if there is an intersection
  6989. */
  6990. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6991. /**
  6992. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6993. * @param min defines the min vector to use
  6994. * @param max defines the max vector to use
  6995. * @returns true if there is an intersection
  6996. */
  6997. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6998. /**
  6999. * Tests if two bounding boxes are intersections
  7000. * @param box0 defines the first box to test
  7001. * @param box1 defines the second box to test
  7002. * @returns true if there is an intersection
  7003. */
  7004. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7005. /**
  7006. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7007. * @param minPoint defines the minimum vector of the bounding box
  7008. * @param maxPoint defines the maximum vector of the bounding box
  7009. * @param sphereCenter defines the sphere center
  7010. * @param sphereRadius defines the sphere radius
  7011. * @returns true if there is an intersection
  7012. */
  7013. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7014. /**
  7015. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7016. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7017. * @param frustumPlanes defines the frustum planes to test
  7018. * @return true if there is an inclusion
  7019. */
  7020. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7021. /**
  7022. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7023. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7024. * @param frustumPlanes defines the frustum planes to test
  7025. * @return true if there is an intersection
  7026. */
  7027. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7028. }
  7029. }
  7030. declare module "babylonjs/Collisions/collider" {
  7031. import { Nullable, IndicesArray } from "babylonjs/types";
  7032. import { Vector3 } from "babylonjs/Maths/math.vector";
  7033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7034. import { Plane } from "babylonjs/Maths/math.plane";
  7035. /** @hidden */
  7036. export class Collider {
  7037. /** Define if a collision was found */
  7038. collisionFound: boolean;
  7039. /**
  7040. * Define last intersection point in local space
  7041. */
  7042. intersectionPoint: Vector3;
  7043. /**
  7044. * Define last collided mesh
  7045. */
  7046. collidedMesh: Nullable<AbstractMesh>;
  7047. private _collisionPoint;
  7048. private _planeIntersectionPoint;
  7049. private _tempVector;
  7050. private _tempVector2;
  7051. private _tempVector3;
  7052. private _tempVector4;
  7053. private _edge;
  7054. private _baseToVertex;
  7055. private _destinationPoint;
  7056. private _slidePlaneNormal;
  7057. private _displacementVector;
  7058. /** @hidden */
  7059. _radius: Vector3;
  7060. /** @hidden */
  7061. _retry: number;
  7062. private _velocity;
  7063. private _basePoint;
  7064. private _epsilon;
  7065. /** @hidden */
  7066. _velocityWorldLength: number;
  7067. /** @hidden */
  7068. _basePointWorld: Vector3;
  7069. private _velocityWorld;
  7070. private _normalizedVelocity;
  7071. /** @hidden */
  7072. _initialVelocity: Vector3;
  7073. /** @hidden */
  7074. _initialPosition: Vector3;
  7075. private _nearestDistance;
  7076. private _collisionMask;
  7077. get collisionMask(): number;
  7078. set collisionMask(mask: number);
  7079. /**
  7080. * Gets the plane normal used to compute the sliding response (in local space)
  7081. */
  7082. get slidePlaneNormal(): Vector3;
  7083. /** @hidden */
  7084. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7085. /** @hidden */
  7086. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7087. /** @hidden */
  7088. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7089. /** @hidden */
  7090. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7091. /** @hidden */
  7092. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7093. /** @hidden */
  7094. _getResponse(pos: Vector3, vel: Vector3): void;
  7095. }
  7096. }
  7097. declare module "babylonjs/Culling/boundingInfo" {
  7098. import { DeepImmutable } from "babylonjs/types";
  7099. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7100. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7101. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7102. import { Plane } from "babylonjs/Maths/math.plane";
  7103. import { Collider } from "babylonjs/Collisions/collider";
  7104. /**
  7105. * Interface for cullable objects
  7106. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7107. */
  7108. export interface ICullable {
  7109. /**
  7110. * Checks if the object or part of the object is in the frustum
  7111. * @param frustumPlanes Camera near/planes
  7112. * @returns true if the object is in frustum otherwise false
  7113. */
  7114. isInFrustum(frustumPlanes: Plane[]): boolean;
  7115. /**
  7116. * Checks if a cullable object (mesh...) is in the camera frustum
  7117. * Unlike isInFrustum this cheks the full bounding box
  7118. * @param frustumPlanes Camera near/planes
  7119. * @returns true if the object is in frustum otherwise false
  7120. */
  7121. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7122. }
  7123. /**
  7124. * Info for a bounding data of a mesh
  7125. */
  7126. export class BoundingInfo implements ICullable {
  7127. /**
  7128. * Bounding box for the mesh
  7129. */
  7130. readonly boundingBox: BoundingBox;
  7131. /**
  7132. * Bounding sphere for the mesh
  7133. */
  7134. readonly boundingSphere: BoundingSphere;
  7135. private _isLocked;
  7136. private static readonly TmpVector3;
  7137. /**
  7138. * Constructs bounding info
  7139. * @param minimum min vector of the bounding box/sphere
  7140. * @param maximum max vector of the bounding box/sphere
  7141. * @param worldMatrix defines the new world matrix
  7142. */
  7143. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7144. /**
  7145. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7146. * @param min defines the new minimum vector (in local space)
  7147. * @param max defines the new maximum vector (in local space)
  7148. * @param worldMatrix defines the new world matrix
  7149. */
  7150. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7151. /**
  7152. * min vector of the bounding box/sphere
  7153. */
  7154. get minimum(): Vector3;
  7155. /**
  7156. * max vector of the bounding box/sphere
  7157. */
  7158. get maximum(): Vector3;
  7159. /**
  7160. * If the info is locked and won't be updated to avoid perf overhead
  7161. */
  7162. get isLocked(): boolean;
  7163. set isLocked(value: boolean);
  7164. /**
  7165. * Updates the bounding sphere and box
  7166. * @param world world matrix to be used to update
  7167. */
  7168. update(world: DeepImmutable<Matrix>): void;
  7169. /**
  7170. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7171. * @param center New center of the bounding info
  7172. * @param extend New extend of the bounding info
  7173. * @returns the current bounding info
  7174. */
  7175. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7176. /**
  7177. * Scale the current bounding info by applying a scale factor
  7178. * @param factor defines the scale factor to apply
  7179. * @returns the current bounding info
  7180. */
  7181. scale(factor: number): BoundingInfo;
  7182. /**
  7183. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7184. * @param frustumPlanes defines the frustum to test
  7185. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7186. * @returns true if the bounding info is in the frustum planes
  7187. */
  7188. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7189. /**
  7190. * Gets the world distance between the min and max points of the bounding box
  7191. */
  7192. get diagonalLength(): number;
  7193. /**
  7194. * Checks if a cullable object (mesh...) is in the camera frustum
  7195. * Unlike isInFrustum this cheks the full bounding box
  7196. * @param frustumPlanes Camera near/planes
  7197. * @returns true if the object is in frustum otherwise false
  7198. */
  7199. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7200. /** @hidden */
  7201. _checkCollision(collider: Collider): boolean;
  7202. /**
  7203. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param point the point to check intersection with
  7206. * @returns if the point intersects
  7207. */
  7208. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7209. /**
  7210. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7211. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7212. * @param boundingInfo the bounding info to check intersection with
  7213. * @param precise if the intersection should be done using OBB
  7214. * @returns if the bounding info intersects
  7215. */
  7216. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7217. }
  7218. }
  7219. declare module "babylonjs/Maths/math.functions" {
  7220. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7221. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7222. /**
  7223. * Extracts minimum and maximum values from a list of indexed positions
  7224. * @param positions defines the positions to use
  7225. * @param indices defines the indices to the positions
  7226. * @param indexStart defines the start index
  7227. * @param indexCount defines the end index
  7228. * @param bias defines bias value to add to the result
  7229. * @return minimum and maximum values
  7230. */
  7231. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7232. minimum: Vector3;
  7233. maximum: Vector3;
  7234. };
  7235. /**
  7236. * Extracts minimum and maximum values from a list of positions
  7237. * @param positions defines the positions to use
  7238. * @param start defines the start index in the positions array
  7239. * @param count defines the number of positions to handle
  7240. * @param bias defines bias value to add to the result
  7241. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7242. * @return minimum and maximum values
  7243. */
  7244. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7245. minimum: Vector3;
  7246. maximum: Vector3;
  7247. };
  7248. }
  7249. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7251. /** @hidden */
  7252. export class WebGLDataBuffer extends DataBuffer {
  7253. private _buffer;
  7254. constructor(resource: WebGLBuffer);
  7255. get underlyingResource(): any;
  7256. }
  7257. }
  7258. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7259. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7260. import { Nullable } from "babylonjs/types";
  7261. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7262. /** @hidden */
  7263. export class WebGLPipelineContext implements IPipelineContext {
  7264. engine: ThinEngine;
  7265. program: Nullable<WebGLProgram>;
  7266. context?: WebGLRenderingContext;
  7267. vertexShader?: WebGLShader;
  7268. fragmentShader?: WebGLShader;
  7269. isParallelCompiled: boolean;
  7270. onCompiled?: () => void;
  7271. transformFeedback?: WebGLTransformFeedback | null;
  7272. vertexCompilationError: Nullable<string>;
  7273. fragmentCompilationError: Nullable<string>;
  7274. programLinkError: Nullable<string>;
  7275. programValidationError: Nullable<string>;
  7276. get isAsync(): boolean;
  7277. get isReady(): boolean;
  7278. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7279. _getVertexShaderCode(): string | null;
  7280. _getFragmentShaderCode(): string | null;
  7281. }
  7282. }
  7283. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7284. import { FloatArray, Nullable } from "babylonjs/types";
  7285. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7286. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7287. module "babylonjs/Engines/thinEngine" {
  7288. interface ThinEngine {
  7289. /**
  7290. * Create an uniform buffer
  7291. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7292. * @param elements defines the content of the uniform buffer
  7293. * @returns the webGL uniform buffer
  7294. */
  7295. createUniformBuffer(elements: FloatArray): DataBuffer;
  7296. /**
  7297. * Create a dynamic uniform buffer
  7298. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7299. * @param elements defines the content of the uniform buffer
  7300. * @returns the webGL uniform buffer
  7301. */
  7302. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7303. /**
  7304. * Update an existing uniform buffer
  7305. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7306. * @param uniformBuffer defines the target uniform buffer
  7307. * @param elements defines the content to update
  7308. * @param offset defines the offset in the uniform buffer where update should start
  7309. * @param count defines the size of the data to update
  7310. */
  7311. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7312. /**
  7313. * Bind an uniform buffer to the current webGL context
  7314. * @param buffer defines the buffer to bind
  7315. */
  7316. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7317. /**
  7318. * Bind a buffer to the current webGL context at a given location
  7319. * @param buffer defines the buffer to bind
  7320. * @param location defines the index where to bind the buffer
  7321. */
  7322. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7323. /**
  7324. * Bind a specific block at a given index in a specific shader program
  7325. * @param pipelineContext defines the pipeline context to use
  7326. * @param blockName defines the block name
  7327. * @param index defines the index where to bind the block
  7328. */
  7329. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7330. }
  7331. }
  7332. }
  7333. declare module "babylonjs/Materials/uniformBuffer" {
  7334. import { Nullable, FloatArray } from "babylonjs/types";
  7335. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7336. import { Engine } from "babylonjs/Engines/engine";
  7337. import { Effect } from "babylonjs/Materials/effect";
  7338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7340. import { Color3 } from "babylonjs/Maths/math.color";
  7341. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7342. /**
  7343. * Uniform buffer objects.
  7344. *
  7345. * Handles blocks of uniform on the GPU.
  7346. *
  7347. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7348. *
  7349. * For more information, please refer to :
  7350. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7351. */
  7352. export class UniformBuffer {
  7353. private _engine;
  7354. private _buffer;
  7355. private _data;
  7356. private _bufferData;
  7357. private _dynamic?;
  7358. private _uniformLocations;
  7359. private _uniformSizes;
  7360. private _uniformLocationPointer;
  7361. private _needSync;
  7362. private _noUBO;
  7363. private _currentEffect;
  7364. /** @hidden */
  7365. _alreadyBound: boolean;
  7366. private static _MAX_UNIFORM_SIZE;
  7367. private static _tempBuffer;
  7368. /**
  7369. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7370. * This is dynamic to allow compat with webgl 1 and 2.
  7371. * You will need to pass the name of the uniform as well as the value.
  7372. */
  7373. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7374. /**
  7375. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7376. * This is dynamic to allow compat with webgl 1 and 2.
  7377. * You will need to pass the name of the uniform as well as the value.
  7378. */
  7379. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7380. /**
  7381. * Lambda to Update a single float in a uniform buffer.
  7382. * This is dynamic to allow compat with webgl 1 and 2.
  7383. * You will need to pass the name of the uniform as well as the value.
  7384. */
  7385. updateFloat: (name: string, x: number) => void;
  7386. /**
  7387. * Lambda to Update a vec2 of float in a uniform buffer.
  7388. * This is dynamic to allow compat with webgl 1 and 2.
  7389. * You will need to pass the name of the uniform as well as the value.
  7390. */
  7391. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7392. /**
  7393. * Lambda to Update a vec3 of float in a uniform buffer.
  7394. * This is dynamic to allow compat with webgl 1 and 2.
  7395. * You will need to pass the name of the uniform as well as the value.
  7396. */
  7397. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7398. /**
  7399. * Lambda to Update a vec4 of float in a uniform buffer.
  7400. * This is dynamic to allow compat with webgl 1 and 2.
  7401. * You will need to pass the name of the uniform as well as the value.
  7402. */
  7403. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7404. /**
  7405. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7406. * This is dynamic to allow compat with webgl 1 and 2.
  7407. * You will need to pass the name of the uniform as well as the value.
  7408. */
  7409. updateMatrix: (name: string, mat: Matrix) => void;
  7410. /**
  7411. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7412. * This is dynamic to allow compat with webgl 1 and 2.
  7413. * You will need to pass the name of the uniform as well as the value.
  7414. */
  7415. updateVector3: (name: string, vector: Vector3) => void;
  7416. /**
  7417. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7418. * This is dynamic to allow compat with webgl 1 and 2.
  7419. * You will need to pass the name of the uniform as well as the value.
  7420. */
  7421. updateVector4: (name: string, vector: Vector4) => void;
  7422. /**
  7423. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7424. * This is dynamic to allow compat with webgl 1 and 2.
  7425. * You will need to pass the name of the uniform as well as the value.
  7426. */
  7427. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7428. /**
  7429. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7430. * This is dynamic to allow compat with webgl 1 and 2.
  7431. * You will need to pass the name of the uniform as well as the value.
  7432. */
  7433. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7434. /**
  7435. * Instantiates a new Uniform buffer objects.
  7436. *
  7437. * Handles blocks of uniform on the GPU.
  7438. *
  7439. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7440. *
  7441. * For more information, please refer to :
  7442. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7443. * @param engine Define the engine the buffer is associated with
  7444. * @param data Define the data contained in the buffer
  7445. * @param dynamic Define if the buffer is updatable
  7446. */
  7447. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7448. /**
  7449. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7450. * or just falling back on setUniformXXX calls.
  7451. */
  7452. get useUbo(): boolean;
  7453. /**
  7454. * Indicates if the WebGL underlying uniform buffer is in sync
  7455. * with the javascript cache data.
  7456. */
  7457. get isSync(): boolean;
  7458. /**
  7459. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7460. * Also, a dynamic UniformBuffer will disable cache verification and always
  7461. * update the underlying WebGL uniform buffer to the GPU.
  7462. * @returns if Dynamic, otherwise false
  7463. */
  7464. isDynamic(): boolean;
  7465. /**
  7466. * The data cache on JS side.
  7467. * @returns the underlying data as a float array
  7468. */
  7469. getData(): Float32Array;
  7470. /**
  7471. * The underlying WebGL Uniform buffer.
  7472. * @returns the webgl buffer
  7473. */
  7474. getBuffer(): Nullable<DataBuffer>;
  7475. /**
  7476. * std140 layout specifies how to align data within an UBO structure.
  7477. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7478. * for specs.
  7479. */
  7480. private _fillAlignment;
  7481. /**
  7482. * Adds an uniform in the buffer.
  7483. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7484. * for the layout to be correct !
  7485. * @param name Name of the uniform, as used in the uniform block in the shader.
  7486. * @param size Data size, or data directly.
  7487. */
  7488. addUniform(name: string, size: number | number[]): void;
  7489. /**
  7490. * Adds a Matrix 4x4 to the uniform buffer.
  7491. * @param name Name of the uniform, as used in the uniform block in the shader.
  7492. * @param mat A 4x4 matrix.
  7493. */
  7494. addMatrix(name: string, mat: Matrix): void;
  7495. /**
  7496. * Adds a vec2 to the uniform buffer.
  7497. * @param name Name of the uniform, as used in the uniform block in the shader.
  7498. * @param x Define the x component value of the vec2
  7499. * @param y Define the y component value of the vec2
  7500. */
  7501. addFloat2(name: string, x: number, y: number): void;
  7502. /**
  7503. * Adds a vec3 to the uniform buffer.
  7504. * @param name Name of the uniform, as used in the uniform block in the shader.
  7505. * @param x Define the x component value of the vec3
  7506. * @param y Define the y component value of the vec3
  7507. * @param z Define the z component value of the vec3
  7508. */
  7509. addFloat3(name: string, x: number, y: number, z: number): void;
  7510. /**
  7511. * Adds a vec3 to the uniform buffer.
  7512. * @param name Name of the uniform, as used in the uniform block in the shader.
  7513. * @param color Define the vec3 from a Color
  7514. */
  7515. addColor3(name: string, color: Color3): void;
  7516. /**
  7517. * Adds a vec4 to the uniform buffer.
  7518. * @param name Name of the uniform, as used in the uniform block in the shader.
  7519. * @param color Define the rgb components from a Color
  7520. * @param alpha Define the a component of the vec4
  7521. */
  7522. addColor4(name: string, color: Color3, alpha: number): void;
  7523. /**
  7524. * Adds a vec3 to the uniform buffer.
  7525. * @param name Name of the uniform, as used in the uniform block in the shader.
  7526. * @param vector Define the vec3 components from a Vector
  7527. */
  7528. addVector3(name: string, vector: Vector3): void;
  7529. /**
  7530. * Adds a Matrix 3x3 to the uniform buffer.
  7531. * @param name Name of the uniform, as used in the uniform block in the shader.
  7532. */
  7533. addMatrix3x3(name: string): void;
  7534. /**
  7535. * Adds a Matrix 2x2 to the uniform buffer.
  7536. * @param name Name of the uniform, as used in the uniform block in the shader.
  7537. */
  7538. addMatrix2x2(name: string): void;
  7539. /**
  7540. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7541. */
  7542. create(): void;
  7543. /** @hidden */
  7544. _rebuild(): void;
  7545. /**
  7546. * Updates the WebGL Uniform Buffer on the GPU.
  7547. * If the `dynamic` flag is set to true, no cache comparison is done.
  7548. * Otherwise, the buffer will be updated only if the cache differs.
  7549. */
  7550. update(): void;
  7551. /**
  7552. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7553. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7554. * @param data Define the flattened data
  7555. * @param size Define the size of the data.
  7556. */
  7557. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7558. private _valueCache;
  7559. private _cacheMatrix;
  7560. private _updateMatrix3x3ForUniform;
  7561. private _updateMatrix3x3ForEffect;
  7562. private _updateMatrix2x2ForEffect;
  7563. private _updateMatrix2x2ForUniform;
  7564. private _updateFloatForEffect;
  7565. private _updateFloatForUniform;
  7566. private _updateFloat2ForEffect;
  7567. private _updateFloat2ForUniform;
  7568. private _updateFloat3ForEffect;
  7569. private _updateFloat3ForUniform;
  7570. private _updateFloat4ForEffect;
  7571. private _updateFloat4ForUniform;
  7572. private _updateMatrixForEffect;
  7573. private _updateMatrixForUniform;
  7574. private _updateVector3ForEffect;
  7575. private _updateVector3ForUniform;
  7576. private _updateVector4ForEffect;
  7577. private _updateVector4ForUniform;
  7578. private _updateColor3ForEffect;
  7579. private _updateColor3ForUniform;
  7580. private _updateColor4ForEffect;
  7581. private _updateColor4ForUniform;
  7582. /**
  7583. * Sets a sampler uniform on the effect.
  7584. * @param name Define the name of the sampler.
  7585. * @param texture Define the texture to set in the sampler
  7586. */
  7587. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7588. /**
  7589. * Directly updates the value of the uniform in the cache AND on the GPU.
  7590. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7591. * @param data Define the flattened data
  7592. */
  7593. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7594. /**
  7595. * Binds this uniform buffer to an effect.
  7596. * @param effect Define the effect to bind the buffer to
  7597. * @param name Name of the uniform block in the shader.
  7598. */
  7599. bindToEffect(effect: Effect, name: string): void;
  7600. /**
  7601. * Disposes the uniform buffer.
  7602. */
  7603. dispose(): void;
  7604. }
  7605. }
  7606. declare module "babylonjs/Misc/iInspectable" {
  7607. /**
  7608. * Enum that determines the text-wrapping mode to use.
  7609. */
  7610. export enum InspectableType {
  7611. /**
  7612. * Checkbox for booleans
  7613. */
  7614. Checkbox = 0,
  7615. /**
  7616. * Sliders for numbers
  7617. */
  7618. Slider = 1,
  7619. /**
  7620. * Vector3
  7621. */
  7622. Vector3 = 2,
  7623. /**
  7624. * Quaternions
  7625. */
  7626. Quaternion = 3,
  7627. /**
  7628. * Color3
  7629. */
  7630. Color3 = 4,
  7631. /**
  7632. * String
  7633. */
  7634. String = 5
  7635. }
  7636. /**
  7637. * Interface used to define custom inspectable properties.
  7638. * This interface is used by the inspector to display custom property grids
  7639. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7640. */
  7641. export interface IInspectable {
  7642. /**
  7643. * Gets the label to display
  7644. */
  7645. label: string;
  7646. /**
  7647. * Gets the name of the property to edit
  7648. */
  7649. propertyName: string;
  7650. /**
  7651. * Gets the type of the editor to use
  7652. */
  7653. type: InspectableType;
  7654. /**
  7655. * Gets the minimum value of the property when using in "slider" mode
  7656. */
  7657. min?: number;
  7658. /**
  7659. * Gets the maximum value of the property when using in "slider" mode
  7660. */
  7661. max?: number;
  7662. /**
  7663. * Gets the setp to use when using in "slider" mode
  7664. */
  7665. step?: number;
  7666. }
  7667. }
  7668. declare module "babylonjs/Misc/timingTools" {
  7669. /**
  7670. * Class used to provide helper for timing
  7671. */
  7672. export class TimingTools {
  7673. /**
  7674. * Polyfill for setImmediate
  7675. * @param action defines the action to execute after the current execution block
  7676. */
  7677. static SetImmediate(action: () => void): void;
  7678. }
  7679. }
  7680. declare module "babylonjs/Misc/instantiationTools" {
  7681. /**
  7682. * Class used to enable instatition of objects by class name
  7683. */
  7684. export class InstantiationTools {
  7685. /**
  7686. * Use this object to register external classes like custom textures or material
  7687. * to allow the laoders to instantiate them
  7688. */
  7689. static RegisteredExternalClasses: {
  7690. [key: string]: Object;
  7691. };
  7692. /**
  7693. * Tries to instantiate a new object from a given class name
  7694. * @param className defines the class name to instantiate
  7695. * @returns the new object or null if the system was not able to do the instantiation
  7696. */
  7697. static Instantiate(className: string): any;
  7698. }
  7699. }
  7700. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7701. /**
  7702. * Define options used to create a depth texture
  7703. */
  7704. export class DepthTextureCreationOptions {
  7705. /** Specifies whether or not a stencil should be allocated in the texture */
  7706. generateStencil?: boolean;
  7707. /** Specifies whether or not bilinear filtering is enable on the texture */
  7708. bilinearFiltering?: boolean;
  7709. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7710. comparisonFunction?: number;
  7711. /** Specifies if the created texture is a cube texture */
  7712. isCube?: boolean;
  7713. }
  7714. }
  7715. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7717. import { Nullable } from "babylonjs/types";
  7718. import { Scene } from "babylonjs/scene";
  7719. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7720. module "babylonjs/Engines/thinEngine" {
  7721. interface ThinEngine {
  7722. /**
  7723. * Creates a depth stencil cube texture.
  7724. * This is only available in WebGL 2.
  7725. * @param size The size of face edge in the cube texture.
  7726. * @param options The options defining the cube texture.
  7727. * @returns The cube texture
  7728. */
  7729. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7730. /**
  7731. * Creates a cube texture
  7732. * @param rootUrl defines the url where the files to load is located
  7733. * @param scene defines the current scene
  7734. * @param files defines the list of files to load (1 per face)
  7735. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7736. * @param onLoad defines an optional callback raised when the texture is loaded
  7737. * @param onError defines an optional callback raised if there is an issue to load the texture
  7738. * @param format defines the format of the data
  7739. * @param forcedExtension defines the extension to use to pick the right loader
  7740. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7741. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7742. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7743. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7744. * @returns the cube texture as an InternalTexture
  7745. */
  7746. 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;
  7747. /**
  7748. * Creates a cube texture
  7749. * @param rootUrl defines the url where the files to load is located
  7750. * @param scene defines the current scene
  7751. * @param files defines the list of files to load (1 per face)
  7752. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7753. * @param onLoad defines an optional callback raised when the texture is loaded
  7754. * @param onError defines an optional callback raised if there is an issue to load the texture
  7755. * @param format defines the format of the data
  7756. * @param forcedExtension defines the extension to use to pick the right loader
  7757. * @returns the cube texture as an InternalTexture
  7758. */
  7759. 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;
  7760. /**
  7761. * Creates a cube texture
  7762. * @param rootUrl defines the url where the files to load is located
  7763. * @param scene defines the current scene
  7764. * @param files defines the list of files to load (1 per face)
  7765. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7766. * @param onLoad defines an optional callback raised when the texture is loaded
  7767. * @param onError defines an optional callback raised if there is an issue to load the texture
  7768. * @param format defines the format of the data
  7769. * @param forcedExtension defines the extension to use to pick the right loader
  7770. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7771. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7772. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7773. * @returns the cube texture as an InternalTexture
  7774. */
  7775. 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;
  7776. /** @hidden */
  7777. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7778. /** @hidden */
  7779. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7780. /** @hidden */
  7781. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7782. /** @hidden */
  7783. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7784. /**
  7785. * @hidden
  7786. */
  7787. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7788. }
  7789. }
  7790. }
  7791. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7792. import { Nullable } from "babylonjs/types";
  7793. import { Scene } from "babylonjs/scene";
  7794. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7796. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7797. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7798. import { Observable } from "babylonjs/Misc/observable";
  7799. /**
  7800. * Class for creating a cube texture
  7801. */
  7802. export class CubeTexture extends BaseTexture {
  7803. private _delayedOnLoad;
  7804. /**
  7805. * Observable triggered once the texture has been loaded.
  7806. */
  7807. onLoadObservable: Observable<CubeTexture>;
  7808. /**
  7809. * The url of the texture
  7810. */
  7811. url: string;
  7812. /**
  7813. * Gets or sets the center of the bounding box associated with the cube texture.
  7814. * It must define where the camera used to render the texture was set
  7815. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7816. */
  7817. boundingBoxPosition: Vector3;
  7818. private _boundingBoxSize;
  7819. /**
  7820. * Gets or sets the size of the bounding box associated with the cube texture
  7821. * When defined, the cubemap will switch to local mode
  7822. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7823. * @example https://www.babylonjs-playground.com/#RNASML
  7824. */
  7825. set boundingBoxSize(value: Vector3);
  7826. /**
  7827. * Returns the bounding box size
  7828. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7829. */
  7830. get boundingBoxSize(): Vector3;
  7831. protected _rotationY: number;
  7832. /**
  7833. * Sets texture matrix rotation angle around Y axis in radians.
  7834. */
  7835. set rotationY(value: number);
  7836. /**
  7837. * Gets texture matrix rotation angle around Y axis radians.
  7838. */
  7839. get rotationY(): number;
  7840. /**
  7841. * Are mip maps generated for this texture or not.
  7842. */
  7843. get noMipmap(): boolean;
  7844. private _noMipmap;
  7845. private _files;
  7846. protected _forcedExtension: Nullable<string>;
  7847. private _extensions;
  7848. private _textureMatrix;
  7849. private _format;
  7850. private _createPolynomials;
  7851. /**
  7852. * Creates a cube texture from an array of image urls
  7853. * @param files defines an array of image urls
  7854. * @param scene defines the hosting scene
  7855. * @param noMipmap specifies if mip maps are not used
  7856. * @returns a cube texture
  7857. */
  7858. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7859. /**
  7860. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7861. * @param url defines the url of the prefiltered texture
  7862. * @param scene defines the scene the texture is attached to
  7863. * @param forcedExtension defines the extension of the file if different from the url
  7864. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7865. * @return the prefiltered texture
  7866. */
  7867. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7868. /**
  7869. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7870. * as prefiltered data.
  7871. * @param rootUrl defines the url of the texture or the root name of the six images
  7872. * @param null defines the scene or engine the texture is attached to
  7873. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7874. * @param noMipmap defines if mipmaps should be created or not
  7875. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7876. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7877. * @param onError defines a callback triggered in case of error during load
  7878. * @param format defines the internal format to use for the texture once loaded
  7879. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7880. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7881. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7882. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7883. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7884. * @return the cube texture
  7885. */
  7886. 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);
  7887. /**
  7888. * Get the current class name of the texture useful for serialization or dynamic coding.
  7889. * @returns "CubeTexture"
  7890. */
  7891. getClassName(): string;
  7892. /**
  7893. * Update the url (and optional buffer) of this texture if url was null during construction.
  7894. * @param url the url of the texture
  7895. * @param forcedExtension defines the extension to use
  7896. * @param onLoad callback called when the texture is loaded (defaults to null)
  7897. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7898. */
  7899. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7900. /**
  7901. * Delays loading of the cube texture
  7902. * @param forcedExtension defines the extension to use
  7903. */
  7904. delayLoad(forcedExtension?: string): void;
  7905. /**
  7906. * Returns the reflection texture matrix
  7907. * @returns the reflection texture matrix
  7908. */
  7909. getReflectionTextureMatrix(): Matrix;
  7910. /**
  7911. * Sets the reflection texture matrix
  7912. * @param value Reflection texture matrix
  7913. */
  7914. setReflectionTextureMatrix(value: Matrix): void;
  7915. /**
  7916. * Parses text to create a cube texture
  7917. * @param parsedTexture define the serialized text to read from
  7918. * @param scene defines the hosting scene
  7919. * @param rootUrl defines the root url of the cube texture
  7920. * @returns a cube texture
  7921. */
  7922. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7923. /**
  7924. * Makes a clone, or deep copy, of the cube texture
  7925. * @returns a new cube texture
  7926. */
  7927. clone(): CubeTexture;
  7928. }
  7929. }
  7930. declare module "babylonjs/Materials/materialDefines" {
  7931. /**
  7932. * Manages the defines for the Material
  7933. */
  7934. export class MaterialDefines {
  7935. /** @hidden */
  7936. protected _keys: string[];
  7937. private _isDirty;
  7938. /** @hidden */
  7939. _renderId: number;
  7940. /** @hidden */
  7941. _areLightsDirty: boolean;
  7942. /** @hidden */
  7943. _areLightsDisposed: boolean;
  7944. /** @hidden */
  7945. _areAttributesDirty: boolean;
  7946. /** @hidden */
  7947. _areTexturesDirty: boolean;
  7948. /** @hidden */
  7949. _areFresnelDirty: boolean;
  7950. /** @hidden */
  7951. _areMiscDirty: boolean;
  7952. /** @hidden */
  7953. _areImageProcessingDirty: boolean;
  7954. /** @hidden */
  7955. _normals: boolean;
  7956. /** @hidden */
  7957. _uvs: boolean;
  7958. /** @hidden */
  7959. _needNormals: boolean;
  7960. /** @hidden */
  7961. _needUVs: boolean;
  7962. [id: string]: any;
  7963. /**
  7964. * Specifies if the material needs to be re-calculated
  7965. */
  7966. get isDirty(): boolean;
  7967. /**
  7968. * Marks the material to indicate that it has been re-calculated
  7969. */
  7970. markAsProcessed(): void;
  7971. /**
  7972. * Marks the material to indicate that it needs to be re-calculated
  7973. */
  7974. markAsUnprocessed(): void;
  7975. /**
  7976. * Marks the material to indicate all of its defines need to be re-calculated
  7977. */
  7978. markAllAsDirty(): void;
  7979. /**
  7980. * Marks the material to indicate that image processing needs to be re-calculated
  7981. */
  7982. markAsImageProcessingDirty(): void;
  7983. /**
  7984. * Marks the material to indicate the lights need to be re-calculated
  7985. * @param disposed Defines whether the light is dirty due to dispose or not
  7986. */
  7987. markAsLightDirty(disposed?: boolean): void;
  7988. /**
  7989. * Marks the attribute state as changed
  7990. */
  7991. markAsAttributesDirty(): void;
  7992. /**
  7993. * Marks the texture state as changed
  7994. */
  7995. markAsTexturesDirty(): void;
  7996. /**
  7997. * Marks the fresnel state as changed
  7998. */
  7999. markAsFresnelDirty(): void;
  8000. /**
  8001. * Marks the misc state as changed
  8002. */
  8003. markAsMiscDirty(): void;
  8004. /**
  8005. * Rebuilds the material defines
  8006. */
  8007. rebuild(): void;
  8008. /**
  8009. * Specifies if two material defines are equal
  8010. * @param other - A material define instance to compare to
  8011. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8012. */
  8013. isEqual(other: MaterialDefines): boolean;
  8014. /**
  8015. * Clones this instance's defines to another instance
  8016. * @param other - material defines to clone values to
  8017. */
  8018. cloneTo(other: MaterialDefines): void;
  8019. /**
  8020. * Resets the material define values
  8021. */
  8022. reset(): void;
  8023. /**
  8024. * Converts the material define values to a string
  8025. * @returns - String of material define information
  8026. */
  8027. toString(): string;
  8028. }
  8029. }
  8030. declare module "babylonjs/Materials/colorCurves" {
  8031. import { Effect } from "babylonjs/Materials/effect";
  8032. /**
  8033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8035. * 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;
  8036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8037. */
  8038. export class ColorCurves {
  8039. private _dirty;
  8040. private _tempColor;
  8041. private _globalCurve;
  8042. private _highlightsCurve;
  8043. private _midtonesCurve;
  8044. private _shadowsCurve;
  8045. private _positiveCurve;
  8046. private _negativeCurve;
  8047. private _globalHue;
  8048. private _globalDensity;
  8049. private _globalSaturation;
  8050. private _globalExposure;
  8051. /**
  8052. * Gets the global Hue value.
  8053. * 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).
  8054. */
  8055. get globalHue(): number;
  8056. /**
  8057. * Sets the global Hue value.
  8058. * 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).
  8059. */
  8060. set globalHue(value: number);
  8061. /**
  8062. * Gets the global Density value.
  8063. * 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.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. get globalDensity(): number;
  8067. /**
  8068. * Sets the global Density value.
  8069. * 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.
  8070. * Values less than zero provide a filter of opposite hue.
  8071. */
  8072. set globalDensity(value: number);
  8073. /**
  8074. * Gets the global Saturation value.
  8075. * 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.
  8076. */
  8077. get globalSaturation(): number;
  8078. /**
  8079. * Sets the global Saturation value.
  8080. * 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.
  8081. */
  8082. set globalSaturation(value: number);
  8083. /**
  8084. * Gets the global Exposure value.
  8085. * 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.
  8086. */
  8087. get globalExposure(): number;
  8088. /**
  8089. * Sets the global Exposure value.
  8090. * 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.
  8091. */
  8092. set globalExposure(value: number);
  8093. private _highlightsHue;
  8094. private _highlightsDensity;
  8095. private _highlightsSaturation;
  8096. private _highlightsExposure;
  8097. /**
  8098. * Gets the highlights Hue value.
  8099. * 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).
  8100. */
  8101. get highlightsHue(): number;
  8102. /**
  8103. * Sets the highlights Hue value.
  8104. * 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).
  8105. */
  8106. set highlightsHue(value: number);
  8107. /**
  8108. * Gets the highlights Density value.
  8109. * 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.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. get highlightsDensity(): number;
  8113. /**
  8114. * Sets the highlights Density value.
  8115. * 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.
  8116. * Values less than zero provide a filter of opposite hue.
  8117. */
  8118. set highlightsDensity(value: number);
  8119. /**
  8120. * Gets the highlights Saturation value.
  8121. * 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.
  8122. */
  8123. get highlightsSaturation(): number;
  8124. /**
  8125. * Sets the highlights Saturation value.
  8126. * 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.
  8127. */
  8128. set highlightsSaturation(value: number);
  8129. /**
  8130. * Gets the highlights Exposure value.
  8131. * 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.
  8132. */
  8133. get highlightsExposure(): number;
  8134. /**
  8135. * Sets the highlights Exposure value.
  8136. * 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.
  8137. */
  8138. set highlightsExposure(value: number);
  8139. private _midtonesHue;
  8140. private _midtonesDensity;
  8141. private _midtonesSaturation;
  8142. private _midtonesExposure;
  8143. /**
  8144. * Gets the midtones Hue value.
  8145. * 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).
  8146. */
  8147. get midtonesHue(): number;
  8148. /**
  8149. * Sets the midtones Hue value.
  8150. * 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).
  8151. */
  8152. set midtonesHue(value: number);
  8153. /**
  8154. * Gets the midtones Density value.
  8155. * 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.
  8156. * Values less than zero provide a filter of opposite hue.
  8157. */
  8158. get midtonesDensity(): number;
  8159. /**
  8160. * Sets the midtones Density value.
  8161. * 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.
  8162. * Values less than zero provide a filter of opposite hue.
  8163. */
  8164. set midtonesDensity(value: number);
  8165. /**
  8166. * Gets the midtones Saturation value.
  8167. * 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.
  8168. */
  8169. get midtonesSaturation(): number;
  8170. /**
  8171. * Sets the midtones Saturation value.
  8172. * 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.
  8173. */
  8174. set midtonesSaturation(value: number);
  8175. /**
  8176. * Gets the midtones Exposure value.
  8177. * 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.
  8178. */
  8179. get midtonesExposure(): number;
  8180. /**
  8181. * Sets the midtones Exposure value.
  8182. * 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.
  8183. */
  8184. set midtonesExposure(value: number);
  8185. private _shadowsHue;
  8186. private _shadowsDensity;
  8187. private _shadowsSaturation;
  8188. private _shadowsExposure;
  8189. /**
  8190. * Gets the shadows Hue value.
  8191. * 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).
  8192. */
  8193. get shadowsHue(): number;
  8194. /**
  8195. * Sets the shadows Hue value.
  8196. * 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).
  8197. */
  8198. set shadowsHue(value: number);
  8199. /**
  8200. * Gets the shadows Density value.
  8201. * 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.
  8202. * Values less than zero provide a filter of opposite hue.
  8203. */
  8204. get shadowsDensity(): number;
  8205. /**
  8206. * Sets the shadows Density value.
  8207. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. set shadowsDensity(value: number);
  8211. /**
  8212. * Gets the shadows Saturation value.
  8213. * 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.
  8214. */
  8215. get shadowsSaturation(): number;
  8216. /**
  8217. * Sets the shadows Saturation value.
  8218. * 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.
  8219. */
  8220. set shadowsSaturation(value: number);
  8221. /**
  8222. * Gets the shadows Exposure value.
  8223. * 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.
  8224. */
  8225. get shadowsExposure(): number;
  8226. /**
  8227. * Sets the shadows Exposure value.
  8228. * 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.
  8229. */
  8230. set shadowsExposure(value: number);
  8231. /**
  8232. * Returns the class name
  8233. * @returns The class name
  8234. */
  8235. getClassName(): string;
  8236. /**
  8237. * Binds the color curves to the shader.
  8238. * @param colorCurves The color curve to bind
  8239. * @param effect The effect to bind to
  8240. * @param positiveUniform The positive uniform shader parameter
  8241. * @param neutralUniform The neutral uniform shader parameter
  8242. * @param negativeUniform The negative uniform shader parameter
  8243. */
  8244. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8245. /**
  8246. * Prepare the list of uniforms associated with the ColorCurves effects.
  8247. * @param uniformsList The list of uniforms used in the effect
  8248. */
  8249. static PrepareUniforms(uniformsList: string[]): void;
  8250. /**
  8251. * Returns color grading data based on a hue, density, saturation and exposure value.
  8252. * @param filterHue The hue of the color filter.
  8253. * @param filterDensity The density of the color filter.
  8254. * @param saturation The saturation.
  8255. * @param exposure The exposure.
  8256. * @param result The result data container.
  8257. */
  8258. private getColorGradingDataToRef;
  8259. /**
  8260. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8261. * @param value The input slider value in range [-100,100].
  8262. * @returns Adjusted value.
  8263. */
  8264. private static applyColorGradingSliderNonlinear;
  8265. /**
  8266. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8267. * @param hue The hue (H) input.
  8268. * @param saturation The saturation (S) input.
  8269. * @param brightness The brightness (B) input.
  8270. * @result An RGBA color represented as Vector4.
  8271. */
  8272. private static fromHSBToRef;
  8273. /**
  8274. * Returns a value clamped between min and max
  8275. * @param value The value to clamp
  8276. * @param min The minimum of value
  8277. * @param max The maximum of value
  8278. * @returns The clamped value.
  8279. */
  8280. private static clamp;
  8281. /**
  8282. * Clones the current color curve instance.
  8283. * @return The cloned curves
  8284. */
  8285. clone(): ColorCurves;
  8286. /**
  8287. * Serializes the current color curve instance to a json representation.
  8288. * @return a JSON representation
  8289. */
  8290. serialize(): any;
  8291. /**
  8292. * Parses the color curve from a json representation.
  8293. * @param source the JSON source to parse
  8294. * @return The parsed curves
  8295. */
  8296. static Parse(source: any): ColorCurves;
  8297. }
  8298. }
  8299. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8300. import { Observable } from "babylonjs/Misc/observable";
  8301. import { Nullable } from "babylonjs/types";
  8302. import { Color4 } from "babylonjs/Maths/math.color";
  8303. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8304. import { Effect } from "babylonjs/Materials/effect";
  8305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8306. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8307. /**
  8308. * Interface to follow in your material defines to integrate easily the
  8309. * Image proccessing functions.
  8310. * @hidden
  8311. */
  8312. export interface IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. EXPOSURE: boolean;
  8321. COLORCURVES: boolean;
  8322. COLORGRADING: boolean;
  8323. COLORGRADING3D: boolean;
  8324. SAMPLER3DGREENDEPTH: boolean;
  8325. SAMPLER3DBGRMAP: boolean;
  8326. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8327. }
  8328. /**
  8329. * @hidden
  8330. */
  8331. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8332. IMAGEPROCESSING: boolean;
  8333. VIGNETTE: boolean;
  8334. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8335. VIGNETTEBLENDMODEOPAQUE: boolean;
  8336. TONEMAPPING: boolean;
  8337. TONEMAPPING_ACES: boolean;
  8338. CONTRAST: boolean;
  8339. COLORCURVES: boolean;
  8340. COLORGRADING: boolean;
  8341. COLORGRADING3D: boolean;
  8342. SAMPLER3DGREENDEPTH: boolean;
  8343. SAMPLER3DBGRMAP: boolean;
  8344. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8345. EXPOSURE: boolean;
  8346. constructor();
  8347. }
  8348. /**
  8349. * This groups together the common properties used for image processing either in direct forward pass
  8350. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8351. * or not.
  8352. */
  8353. export class ImageProcessingConfiguration {
  8354. /**
  8355. * Default tone mapping applied in BabylonJS.
  8356. */
  8357. static readonly TONEMAPPING_STANDARD: number;
  8358. /**
  8359. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8360. * to other engines rendering to increase portability.
  8361. */
  8362. static readonly TONEMAPPING_ACES: number;
  8363. /**
  8364. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8365. */
  8366. colorCurves: Nullable<ColorCurves>;
  8367. private _colorCurvesEnabled;
  8368. /**
  8369. * Gets wether the color curves effect is enabled.
  8370. */
  8371. get colorCurvesEnabled(): boolean;
  8372. /**
  8373. * Sets wether the color curves effect is enabled.
  8374. */
  8375. set colorCurvesEnabled(value: boolean);
  8376. private _colorGradingTexture;
  8377. /**
  8378. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8379. */
  8380. get colorGradingTexture(): Nullable<BaseTexture>;
  8381. /**
  8382. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8383. */
  8384. set colorGradingTexture(value: Nullable<BaseTexture>);
  8385. private _colorGradingEnabled;
  8386. /**
  8387. * Gets wether the color grading effect is enabled.
  8388. */
  8389. get colorGradingEnabled(): boolean;
  8390. /**
  8391. * Sets wether the color grading effect is enabled.
  8392. */
  8393. set colorGradingEnabled(value: boolean);
  8394. private _colorGradingWithGreenDepth;
  8395. /**
  8396. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8397. */
  8398. get colorGradingWithGreenDepth(): boolean;
  8399. /**
  8400. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8401. */
  8402. set colorGradingWithGreenDepth(value: boolean);
  8403. private _colorGradingBGR;
  8404. /**
  8405. * Gets wether the color grading texture contains BGR values.
  8406. */
  8407. get colorGradingBGR(): boolean;
  8408. /**
  8409. * Sets wether the color grading texture contains BGR values.
  8410. */
  8411. set colorGradingBGR(value: boolean);
  8412. /** @hidden */
  8413. _exposure: number;
  8414. /**
  8415. * Gets the Exposure used in the effect.
  8416. */
  8417. get exposure(): number;
  8418. /**
  8419. * Sets the Exposure used in the effect.
  8420. */
  8421. set exposure(value: number);
  8422. private _toneMappingEnabled;
  8423. /**
  8424. * Gets wether the tone mapping effect is enabled.
  8425. */
  8426. get toneMappingEnabled(): boolean;
  8427. /**
  8428. * Sets wether the tone mapping effect is enabled.
  8429. */
  8430. set toneMappingEnabled(value: boolean);
  8431. private _toneMappingType;
  8432. /**
  8433. * Gets the type of tone mapping effect.
  8434. */
  8435. get toneMappingType(): number;
  8436. /**
  8437. * Sets the type of tone mapping effect used in BabylonJS.
  8438. */
  8439. set toneMappingType(value: number);
  8440. protected _contrast: number;
  8441. /**
  8442. * Gets the contrast used in the effect.
  8443. */
  8444. get contrast(): number;
  8445. /**
  8446. * Sets the contrast used in the effect.
  8447. */
  8448. set contrast(value: number);
  8449. /**
  8450. * Vignette stretch size.
  8451. */
  8452. vignetteStretch: number;
  8453. /**
  8454. * Vignette centre X Offset.
  8455. */
  8456. vignetteCentreX: number;
  8457. /**
  8458. * Vignette centre Y Offset.
  8459. */
  8460. vignetteCentreY: number;
  8461. /**
  8462. * Vignette weight or intensity of the vignette effect.
  8463. */
  8464. vignetteWeight: number;
  8465. /**
  8466. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8467. * if vignetteEnabled is set to true.
  8468. */
  8469. vignetteColor: Color4;
  8470. /**
  8471. * Camera field of view used by the Vignette effect.
  8472. */
  8473. vignetteCameraFov: number;
  8474. private _vignetteBlendMode;
  8475. /**
  8476. * Gets the vignette blend mode allowing different kind of effect.
  8477. */
  8478. get vignetteBlendMode(): number;
  8479. /**
  8480. * Sets the vignette blend mode allowing different kind of effect.
  8481. */
  8482. set vignetteBlendMode(value: number);
  8483. private _vignetteEnabled;
  8484. /**
  8485. * Gets wether the vignette effect is enabled.
  8486. */
  8487. get vignetteEnabled(): boolean;
  8488. /**
  8489. * Sets wether the vignette effect is enabled.
  8490. */
  8491. set vignetteEnabled(value: boolean);
  8492. private _applyByPostProcess;
  8493. /**
  8494. * Gets wether the image processing is applied through a post process or not.
  8495. */
  8496. get applyByPostProcess(): boolean;
  8497. /**
  8498. * Sets wether the image processing is applied through a post process or not.
  8499. */
  8500. set applyByPostProcess(value: boolean);
  8501. private _isEnabled;
  8502. /**
  8503. * Gets wether the image processing is enabled or not.
  8504. */
  8505. get isEnabled(): boolean;
  8506. /**
  8507. * Sets wether the image processing is enabled or not.
  8508. */
  8509. set isEnabled(value: boolean);
  8510. /**
  8511. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8512. */
  8513. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8514. /**
  8515. * Method called each time the image processing information changes requires to recompile the effect.
  8516. */
  8517. protected _updateParameters(): void;
  8518. /**
  8519. * Gets the current class name.
  8520. * @return "ImageProcessingConfiguration"
  8521. */
  8522. getClassName(): string;
  8523. /**
  8524. * Prepare the list of uniforms associated with the Image Processing effects.
  8525. * @param uniforms The list of uniforms used in the effect
  8526. * @param defines the list of defines currently in use
  8527. */
  8528. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8529. /**
  8530. * Prepare the list of samplers associated with the Image Processing effects.
  8531. * @param samplersList The list of uniforms used in the effect
  8532. * @param defines the list of defines currently in use
  8533. */
  8534. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8535. /**
  8536. * Prepare the list of defines associated to the shader.
  8537. * @param defines the list of defines to complete
  8538. * @param forPostProcess Define if we are currently in post process mode or not
  8539. */
  8540. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8541. /**
  8542. * Returns true if all the image processing information are ready.
  8543. * @returns True if ready, otherwise, false
  8544. */
  8545. isReady(): boolean;
  8546. /**
  8547. * Binds the image processing to the shader.
  8548. * @param effect The effect to bind to
  8549. * @param overrideAspectRatio Override the aspect ratio of the effect
  8550. */
  8551. bind(effect: Effect, overrideAspectRatio?: number): void;
  8552. /**
  8553. * Clones the current image processing instance.
  8554. * @return The cloned image processing
  8555. */
  8556. clone(): ImageProcessingConfiguration;
  8557. /**
  8558. * Serializes the current image processing instance to a json representation.
  8559. * @return a JSON representation
  8560. */
  8561. serialize(): any;
  8562. /**
  8563. * Parses the image processing from a json representation.
  8564. * @param source the JSON source to parse
  8565. * @return The parsed image processing
  8566. */
  8567. static Parse(source: any): ImageProcessingConfiguration;
  8568. private static _VIGNETTEMODE_MULTIPLY;
  8569. private static _VIGNETTEMODE_OPAQUE;
  8570. /**
  8571. * Used to apply the vignette as a mix with the pixel color.
  8572. */
  8573. static get VIGNETTEMODE_MULTIPLY(): number;
  8574. /**
  8575. * Used to apply the vignette as a replacement of the pixel color.
  8576. */
  8577. static get VIGNETTEMODE_OPAQUE(): number;
  8578. }
  8579. }
  8580. declare module "babylonjs/Shaders/postprocess.vertex" {
  8581. /** @hidden */
  8582. export var postprocessVertexShader: {
  8583. name: string;
  8584. shader: string;
  8585. };
  8586. }
  8587. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8589. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8590. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8591. module "babylonjs/Engines/thinEngine" {
  8592. interface ThinEngine {
  8593. /**
  8594. * Creates a new render target texture
  8595. * @param size defines the size of the texture
  8596. * @param options defines the options used to create the texture
  8597. * @returns a new render target texture stored in an InternalTexture
  8598. */
  8599. createRenderTargetTexture(size: number | {
  8600. width: number;
  8601. height: number;
  8602. layers?: number;
  8603. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8604. /**
  8605. * Creates a depth stencil texture.
  8606. * This is only available in WebGL 2 or with the depth texture extension available.
  8607. * @param size The size of face edge in the texture.
  8608. * @param options The options defining the texture.
  8609. * @returns The texture
  8610. */
  8611. createDepthStencilTexture(size: number | {
  8612. width: number;
  8613. height: number;
  8614. layers?: number;
  8615. }, options: DepthTextureCreationOptions): InternalTexture;
  8616. /** @hidden */
  8617. _createDepthStencilTexture(size: number | {
  8618. width: number;
  8619. height: number;
  8620. layers?: number;
  8621. }, options: DepthTextureCreationOptions): InternalTexture;
  8622. }
  8623. }
  8624. }
  8625. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8626. /**
  8627. * Defines the kind of connection point for node based material
  8628. */
  8629. export enum NodeMaterialBlockConnectionPointTypes {
  8630. /** Float */
  8631. Float = 1,
  8632. /** Int */
  8633. Int = 2,
  8634. /** Vector2 */
  8635. Vector2 = 4,
  8636. /** Vector3 */
  8637. Vector3 = 8,
  8638. /** Vector4 */
  8639. Vector4 = 16,
  8640. /** Color3 */
  8641. Color3 = 32,
  8642. /** Color4 */
  8643. Color4 = 64,
  8644. /** Matrix */
  8645. Matrix = 128,
  8646. /** Custom object */
  8647. Object = 256,
  8648. /** Detect type based on connection */
  8649. AutoDetect = 1024,
  8650. /** Output type that will be defined by input type */
  8651. BasedOnInput = 2048
  8652. }
  8653. }
  8654. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8655. /**
  8656. * Enum used to define the target of a block
  8657. */
  8658. export enum NodeMaterialBlockTargets {
  8659. /** Vertex shader */
  8660. Vertex = 1,
  8661. /** Fragment shader */
  8662. Fragment = 2,
  8663. /** Neutral */
  8664. Neutral = 4,
  8665. /** Vertex and Fragment */
  8666. VertexAndFragment = 3
  8667. }
  8668. }
  8669. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8670. /**
  8671. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8672. */
  8673. export enum NodeMaterialBlockConnectionPointMode {
  8674. /** Value is an uniform */
  8675. Uniform = 0,
  8676. /** Value is a mesh attribute */
  8677. Attribute = 1,
  8678. /** Value is a varying between vertex and fragment shaders */
  8679. Varying = 2,
  8680. /** Mode is undefined */
  8681. Undefined = 3
  8682. }
  8683. }
  8684. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8685. /**
  8686. * Enum used to define system values e.g. values automatically provided by the system
  8687. */
  8688. export enum NodeMaterialSystemValues {
  8689. /** World */
  8690. World = 1,
  8691. /** View */
  8692. View = 2,
  8693. /** Projection */
  8694. Projection = 3,
  8695. /** ViewProjection */
  8696. ViewProjection = 4,
  8697. /** WorldView */
  8698. WorldView = 5,
  8699. /** WorldViewProjection */
  8700. WorldViewProjection = 6,
  8701. /** CameraPosition */
  8702. CameraPosition = 7,
  8703. /** Fog Color */
  8704. FogColor = 8,
  8705. /** Delta time */
  8706. DeltaTime = 9
  8707. }
  8708. }
  8709. declare module "babylonjs/Maths/math.axis" {
  8710. import { Vector3 } from "babylonjs/Maths/math.vector";
  8711. /** Defines supported spaces */
  8712. export enum Space {
  8713. /** Local (object) space */
  8714. LOCAL = 0,
  8715. /** World space */
  8716. WORLD = 1,
  8717. /** Bone space */
  8718. BONE = 2
  8719. }
  8720. /** Defines the 3 main axes */
  8721. export class Axis {
  8722. /** X axis */
  8723. static X: Vector3;
  8724. /** Y axis */
  8725. static Y: Vector3;
  8726. /** Z axis */
  8727. static Z: Vector3;
  8728. }
  8729. }
  8730. declare module "babylonjs/Maths/math.frustum" {
  8731. import { Matrix } from "babylonjs/Maths/math.vector";
  8732. import { DeepImmutable } from "babylonjs/types";
  8733. import { Plane } from "babylonjs/Maths/math.plane";
  8734. /**
  8735. * Represents a camera frustum
  8736. */
  8737. export class Frustum {
  8738. /**
  8739. * Gets the planes representing the frustum
  8740. * @param transform matrix to be applied to the returned planes
  8741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8742. */
  8743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8744. /**
  8745. * Gets the near frustum plane transformed by the transform matrix
  8746. * @param transform transformation matrix to be applied to the resulting frustum plane
  8747. * @param frustumPlane the resuling frustum plane
  8748. */
  8749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8750. /**
  8751. * Gets the far frustum plane transformed by the transform matrix
  8752. * @param transform transformation matrix to be applied to the resulting frustum plane
  8753. * @param frustumPlane the resuling frustum plane
  8754. */
  8755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8756. /**
  8757. * Gets the left frustum plane transformed by the transform matrix
  8758. * @param transform transformation matrix to be applied to the resulting frustum plane
  8759. * @param frustumPlane the resuling frustum plane
  8760. */
  8761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8762. /**
  8763. * Gets the right frustum plane transformed by the transform matrix
  8764. * @param transform transformation matrix to be applied to the resulting frustum plane
  8765. * @param frustumPlane the resuling frustum plane
  8766. */
  8767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8768. /**
  8769. * Gets the top frustum plane transformed by the transform matrix
  8770. * @param transform transformation matrix to be applied to the resulting frustum plane
  8771. * @param frustumPlane the resuling frustum plane
  8772. */
  8773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8774. /**
  8775. * Gets the bottom frustum plane transformed by the transform matrix
  8776. * @param transform transformation matrix to be applied to the resulting frustum plane
  8777. * @param frustumPlane the resuling frustum plane
  8778. */
  8779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8780. /**
  8781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8782. * @param transform transformation matrix to be applied to the resulting frustum planes
  8783. * @param frustumPlanes the resuling frustum planes
  8784. */
  8785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8786. }
  8787. }
  8788. declare module "babylonjs/Maths/math.size" {
  8789. /**
  8790. * Interface for the size containing width and height
  8791. */
  8792. export interface ISize {
  8793. /**
  8794. * Width
  8795. */
  8796. width: number;
  8797. /**
  8798. * Heighht
  8799. */
  8800. height: number;
  8801. }
  8802. /**
  8803. * Size containing widht and height
  8804. */
  8805. export class Size implements ISize {
  8806. /**
  8807. * Width
  8808. */
  8809. width: number;
  8810. /**
  8811. * Height
  8812. */
  8813. height: number;
  8814. /**
  8815. * Creates a Size object from the given width and height (floats).
  8816. * @param width width of the new size
  8817. * @param height height of the new size
  8818. */
  8819. constructor(width: number, height: number);
  8820. /**
  8821. * Returns a string with the Size width and height
  8822. * @returns a string with the Size width and height
  8823. */
  8824. toString(): string;
  8825. /**
  8826. * "Size"
  8827. * @returns the string "Size"
  8828. */
  8829. getClassName(): string;
  8830. /**
  8831. * Returns the Size hash code.
  8832. * @returns a hash code for a unique width and height
  8833. */
  8834. getHashCode(): number;
  8835. /**
  8836. * Updates the current size from the given one.
  8837. * @param src the given size
  8838. */
  8839. copyFrom(src: Size): void;
  8840. /**
  8841. * Updates in place the current Size from the given floats.
  8842. * @param width width of the new size
  8843. * @param height height of the new size
  8844. * @returns the updated Size.
  8845. */
  8846. copyFromFloats(width: number, height: number): Size;
  8847. /**
  8848. * Updates in place the current Size from the given floats.
  8849. * @param width width to set
  8850. * @param height height to set
  8851. * @returns the updated Size.
  8852. */
  8853. set(width: number, height: number): Size;
  8854. /**
  8855. * Multiplies the width and height by numbers
  8856. * @param w factor to multiple the width by
  8857. * @param h factor to multiple the height by
  8858. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8859. */
  8860. multiplyByFloats(w: number, h: number): Size;
  8861. /**
  8862. * Clones the size
  8863. * @returns a new Size copied from the given one.
  8864. */
  8865. clone(): Size;
  8866. /**
  8867. * True if the current Size and the given one width and height are strictly equal.
  8868. * @param other the other size to compare against
  8869. * @returns True if the current Size and the given one width and height are strictly equal.
  8870. */
  8871. equals(other: Size): boolean;
  8872. /**
  8873. * The surface of the Size : width * height (float).
  8874. */
  8875. get surface(): number;
  8876. /**
  8877. * Create a new size of zero
  8878. * @returns a new Size set to (0.0, 0.0)
  8879. */
  8880. static Zero(): Size;
  8881. /**
  8882. * Sums the width and height of two sizes
  8883. * @param otherSize size to add to this size
  8884. * @returns a new Size set as the addition result of the current Size and the given one.
  8885. */
  8886. add(otherSize: Size): Size;
  8887. /**
  8888. * Subtracts the width and height of two
  8889. * @param otherSize size to subtract to this size
  8890. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8891. */
  8892. subtract(otherSize: Size): Size;
  8893. /**
  8894. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8895. * @param start starting size to lerp between
  8896. * @param end end size to lerp between
  8897. * @param amount amount to lerp between the start and end values
  8898. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8899. */
  8900. static Lerp(start: Size, end: Size, amount: number): Size;
  8901. }
  8902. }
  8903. declare module "babylonjs/Maths/math.vertexFormat" {
  8904. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8905. /**
  8906. * Contains position and normal vectors for a vertex
  8907. */
  8908. export class PositionNormalVertex {
  8909. /** the position of the vertex (defaut: 0,0,0) */
  8910. position: Vector3;
  8911. /** the normal of the vertex (defaut: 0,1,0) */
  8912. normal: Vector3;
  8913. /**
  8914. * Creates a PositionNormalVertex
  8915. * @param position the position of the vertex (defaut: 0,0,0)
  8916. * @param normal the normal of the vertex (defaut: 0,1,0)
  8917. */
  8918. constructor(
  8919. /** the position of the vertex (defaut: 0,0,0) */
  8920. position?: Vector3,
  8921. /** the normal of the vertex (defaut: 0,1,0) */
  8922. normal?: Vector3);
  8923. /**
  8924. * Clones the PositionNormalVertex
  8925. * @returns the cloned PositionNormalVertex
  8926. */
  8927. clone(): PositionNormalVertex;
  8928. }
  8929. /**
  8930. * Contains position, normal and uv vectors for a vertex
  8931. */
  8932. export class PositionNormalTextureVertex {
  8933. /** the position of the vertex (defaut: 0,0,0) */
  8934. position: Vector3;
  8935. /** the normal of the vertex (defaut: 0,1,0) */
  8936. normal: Vector3;
  8937. /** the uv of the vertex (default: 0,0) */
  8938. uv: Vector2;
  8939. /**
  8940. * Creates a PositionNormalTextureVertex
  8941. * @param position the position of the vertex (defaut: 0,0,0)
  8942. * @param normal the normal of the vertex (defaut: 0,1,0)
  8943. * @param uv the uv of the vertex (default: 0,0)
  8944. */
  8945. constructor(
  8946. /** the position of the vertex (defaut: 0,0,0) */
  8947. position?: Vector3,
  8948. /** the normal of the vertex (defaut: 0,1,0) */
  8949. normal?: Vector3,
  8950. /** the uv of the vertex (default: 0,0) */
  8951. uv?: Vector2);
  8952. /**
  8953. * Clones the PositionNormalTextureVertex
  8954. * @returns the cloned PositionNormalTextureVertex
  8955. */
  8956. clone(): PositionNormalTextureVertex;
  8957. }
  8958. }
  8959. declare module "babylonjs/Maths/math" {
  8960. export * from "babylonjs/Maths/math.axis";
  8961. export * from "babylonjs/Maths/math.color";
  8962. export * from "babylonjs/Maths/math.constants";
  8963. export * from "babylonjs/Maths/math.frustum";
  8964. export * from "babylonjs/Maths/math.path";
  8965. export * from "babylonjs/Maths/math.plane";
  8966. export * from "babylonjs/Maths/math.size";
  8967. export * from "babylonjs/Maths/math.vector";
  8968. export * from "babylonjs/Maths/math.vertexFormat";
  8969. export * from "babylonjs/Maths/math.viewport";
  8970. }
  8971. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  8972. /**
  8973. * Enum defining the type of animations supported by InputBlock
  8974. */
  8975. export enum AnimatedInputBlockTypes {
  8976. /** No animation */
  8977. None = 0,
  8978. /** Time based animation. Will only work for floats */
  8979. Time = 1
  8980. }
  8981. }
  8982. declare module "babylonjs/Lights/shadowLight" {
  8983. import { Camera } from "babylonjs/Cameras/camera";
  8984. import { Scene } from "babylonjs/scene";
  8985. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8987. import { Light } from "babylonjs/Lights/light";
  8988. /**
  8989. * Interface describing all the common properties and methods a shadow light needs to implement.
  8990. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8991. * as well as binding the different shadow properties to the effects.
  8992. */
  8993. export interface IShadowLight extends Light {
  8994. /**
  8995. * The light id in the scene (used in scene.findLighById for instance)
  8996. */
  8997. id: string;
  8998. /**
  8999. * The position the shdow will be casted from.
  9000. */
  9001. position: Vector3;
  9002. /**
  9003. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9004. */
  9005. direction: Vector3;
  9006. /**
  9007. * The transformed position. Position of the light in world space taking parenting in account.
  9008. */
  9009. transformedPosition: Vector3;
  9010. /**
  9011. * The transformed direction. Direction of the light in world space taking parenting in account.
  9012. */
  9013. transformedDirection: Vector3;
  9014. /**
  9015. * The friendly name of the light in the scene.
  9016. */
  9017. name: string;
  9018. /**
  9019. * Defines the shadow projection clipping minimum z value.
  9020. */
  9021. shadowMinZ: number;
  9022. /**
  9023. * Defines the shadow projection clipping maximum z value.
  9024. */
  9025. shadowMaxZ: number;
  9026. /**
  9027. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9028. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9029. */
  9030. computeTransformedInformation(): boolean;
  9031. /**
  9032. * Gets the scene the light belongs to.
  9033. * @returns The scene
  9034. */
  9035. getScene(): Scene;
  9036. /**
  9037. * Callback defining a custom Projection Matrix Builder.
  9038. * This can be used to override the default projection matrix computation.
  9039. */
  9040. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. /**
  9050. * Gets the current depth scale used in ESM.
  9051. * @returns The scale
  9052. */
  9053. getDepthScale(): number;
  9054. /**
  9055. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9056. * @returns true if a cube texture needs to be use
  9057. */
  9058. needCube(): boolean;
  9059. /**
  9060. * Detects if the projection matrix requires to be recomputed this frame.
  9061. * @returns true if it requires to be recomputed otherwise, false.
  9062. */
  9063. needProjectionMatrixCompute(): boolean;
  9064. /**
  9065. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9066. */
  9067. forceProjectionMatrixCompute(): void;
  9068. /**
  9069. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9070. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9071. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9072. */
  9073. getShadowDirection(faceIndex?: number): Vector3;
  9074. /**
  9075. * Gets the minZ used for shadow according to both the scene and the light.
  9076. * @param activeCamera The camera we are returning the min for
  9077. * @returns the depth min z
  9078. */
  9079. getDepthMinZ(activeCamera: Camera): number;
  9080. /**
  9081. * Gets the maxZ used for shadow according to both the scene and the light.
  9082. * @param activeCamera The camera we are returning the max for
  9083. * @returns the depth max z
  9084. */
  9085. getDepthMaxZ(activeCamera: Camera): number;
  9086. }
  9087. /**
  9088. * Base implementation IShadowLight
  9089. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9090. */
  9091. export abstract class ShadowLight extends Light implements IShadowLight {
  9092. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9093. protected _position: Vector3;
  9094. protected _setPosition(value: Vector3): void;
  9095. /**
  9096. * Sets the position the shadow will be casted from. Also use as the light position for both
  9097. * point and spot lights.
  9098. */
  9099. get position(): Vector3;
  9100. /**
  9101. * Sets the position the shadow will be casted from. Also use as the light position for both
  9102. * point and spot lights.
  9103. */
  9104. set position(value: Vector3);
  9105. protected _direction: Vector3;
  9106. protected _setDirection(value: Vector3): void;
  9107. /**
  9108. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9109. * Also use as the light direction on spot and directional lights.
  9110. */
  9111. get direction(): Vector3;
  9112. /**
  9113. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9114. * Also use as the light direction on spot and directional lights.
  9115. */
  9116. set direction(value: Vector3);
  9117. protected _shadowMinZ: number;
  9118. /**
  9119. * Gets the shadow projection clipping minimum z value.
  9120. */
  9121. get shadowMinZ(): number;
  9122. /**
  9123. * Sets the shadow projection clipping minimum z value.
  9124. */
  9125. set shadowMinZ(value: number);
  9126. protected _shadowMaxZ: number;
  9127. /**
  9128. * Sets the shadow projection clipping maximum z value.
  9129. */
  9130. get shadowMaxZ(): number;
  9131. /**
  9132. * Gets the shadow projection clipping maximum z value.
  9133. */
  9134. set shadowMaxZ(value: number);
  9135. /**
  9136. * Callback defining a custom Projection Matrix Builder.
  9137. * This can be used to override the default projection matrix computation.
  9138. */
  9139. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9140. /**
  9141. * The transformed position. Position of the light in world space taking parenting in account.
  9142. */
  9143. transformedPosition: Vector3;
  9144. /**
  9145. * The transformed direction. Direction of the light in world space taking parenting in account.
  9146. */
  9147. transformedDirection: Vector3;
  9148. private _needProjectionMatrixCompute;
  9149. /**
  9150. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9151. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9152. */
  9153. computeTransformedInformation(): boolean;
  9154. /**
  9155. * Return the depth scale used for the shadow map.
  9156. * @returns the depth scale.
  9157. */
  9158. getDepthScale(): number;
  9159. /**
  9160. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9161. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9162. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9163. */
  9164. getShadowDirection(faceIndex?: number): Vector3;
  9165. /**
  9166. * Returns the ShadowLight absolute position in the World.
  9167. * @returns the position vector in world space
  9168. */
  9169. getAbsolutePosition(): Vector3;
  9170. /**
  9171. * Sets the ShadowLight direction toward the passed target.
  9172. * @param target The point to target in local space
  9173. * @returns the updated ShadowLight direction
  9174. */
  9175. setDirectionToTarget(target: Vector3): Vector3;
  9176. /**
  9177. * Returns the light rotation in euler definition.
  9178. * @returns the x y z rotation in local space.
  9179. */
  9180. getRotation(): Vector3;
  9181. /**
  9182. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9183. * @returns true if a cube texture needs to be use
  9184. */
  9185. needCube(): boolean;
  9186. /**
  9187. * Detects if the projection matrix requires to be recomputed this frame.
  9188. * @returns true if it requires to be recomputed otherwise, false.
  9189. */
  9190. needProjectionMatrixCompute(): boolean;
  9191. /**
  9192. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9193. */
  9194. forceProjectionMatrixCompute(): void;
  9195. /** @hidden */
  9196. _initCache(): void;
  9197. /** @hidden */
  9198. _isSynchronized(): boolean;
  9199. /**
  9200. * Computes the world matrix of the node
  9201. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9202. * @returns the world matrix
  9203. */
  9204. computeWorldMatrix(force?: boolean): Matrix;
  9205. /**
  9206. * Gets the minZ used for shadow according to both the scene and the light.
  9207. * @param activeCamera The camera we are returning the min for
  9208. * @returns the depth min z
  9209. */
  9210. getDepthMinZ(activeCamera: Camera): number;
  9211. /**
  9212. * Gets the maxZ used for shadow according to both the scene and the light.
  9213. * @param activeCamera The camera we are returning the max for
  9214. * @returns the depth max z
  9215. */
  9216. getDepthMaxZ(activeCamera: Camera): number;
  9217. /**
  9218. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9219. * @param matrix The materix to updated with the projection information
  9220. * @param viewMatrix The transform matrix of the light
  9221. * @param renderList The list of mesh to render in the map
  9222. * @returns The current light
  9223. */
  9224. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9225. }
  9226. }
  9227. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9228. /** @hidden */
  9229. export var packingFunctions: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9235. /** @hidden */
  9236. export var bayerDitherFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9244. /** @hidden */
  9245. export var shadowMapFragmentDeclaration: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9251. /** @hidden */
  9252. export var clipPlaneFragmentDeclaration: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9258. /** @hidden */
  9259. export var clipPlaneFragment: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9265. /** @hidden */
  9266. export var shadowMapFragment: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9272. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9273. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9274. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9275. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9276. /** @hidden */
  9277. export var shadowMapPixelShader: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9283. /** @hidden */
  9284. export var bonesDeclaration: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9290. /** @hidden */
  9291. export var morphTargetsVertexGlobalDeclaration: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9297. /** @hidden */
  9298. export var morphTargetsVertexDeclaration: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9304. /** @hidden */
  9305. export var instancesDeclaration: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9311. /** @hidden */
  9312. export var helperFunctions: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9318. /** @hidden */
  9319. export var shadowMapVertexDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9325. /** @hidden */
  9326. export var clipPlaneVertexDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9332. /** @hidden */
  9333. export var morphTargetsVertex: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9339. /** @hidden */
  9340. export var instancesVertex: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9346. /** @hidden */
  9347. export var bonesVertex: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9353. /** @hidden */
  9354. export var shadowMapVertexNormalBias: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9360. /** @hidden */
  9361. export var shadowMapVertexMetric: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9367. /** @hidden */
  9368. export var clipPlaneVertex: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9374. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9376. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9377. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9378. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9379. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9380. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9381. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9382. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9383. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9384. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9385. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9387. /** @hidden */
  9388. export var shadowMapVertexShader: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9394. /** @hidden */
  9395. export var depthBoxBlurPixelShader: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9401. /** @hidden */
  9402. export var shadowMapFragmentSoftTransparentShadow: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Materials/effectFallbacks" {
  9408. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9409. import { Effect } from "babylonjs/Materials/effect";
  9410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9411. /**
  9412. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9413. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9414. */
  9415. export class EffectFallbacks implements IEffectFallbacks {
  9416. private _defines;
  9417. private _currentRank;
  9418. private _maxRank;
  9419. private _mesh;
  9420. /**
  9421. * Removes the fallback from the bound mesh.
  9422. */
  9423. unBindMesh(): void;
  9424. /**
  9425. * Adds a fallback on the specified property.
  9426. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9427. * @param define The name of the define in the shader
  9428. */
  9429. addFallback(rank: number, define: string): void;
  9430. /**
  9431. * Sets the mesh to use CPU skinning when needing to fallback.
  9432. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9433. * @param mesh The mesh to use the fallbacks.
  9434. */
  9435. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9436. /**
  9437. * Checks to see if more fallbacks are still availible.
  9438. */
  9439. get hasMoreFallbacks(): boolean;
  9440. /**
  9441. * Removes the defines that should be removed when falling back.
  9442. * @param currentDefines defines the current define statements for the shader.
  9443. * @param effect defines the current effect we try to compile
  9444. * @returns The resulting defines with defines of the current rank removed.
  9445. */
  9446. reduce(currentDefines: string, effect: Effect): string;
  9447. }
  9448. }
  9449. declare module "babylonjs/Actions/action" {
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. import { Condition } from "babylonjs/Actions/condition";
  9452. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9453. import { Scene } from "babylonjs/scene";
  9454. import { ActionManager } from "babylonjs/Actions/actionManager";
  9455. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9456. import { Node } from "babylonjs/node";
  9457. /**
  9458. * Interface used to define Action
  9459. */
  9460. export interface IAction {
  9461. /**
  9462. * Trigger for the action
  9463. */
  9464. trigger: number;
  9465. /** Options of the trigger */
  9466. triggerOptions: any;
  9467. /**
  9468. * Gets the trigger parameters
  9469. * @returns the trigger parameters
  9470. */
  9471. getTriggerParameter(): any;
  9472. /**
  9473. * Internal only - executes current action event
  9474. * @hidden
  9475. */
  9476. _executeCurrent(evt?: ActionEvent): void;
  9477. /**
  9478. * Serialize placeholder for child classes
  9479. * @param parent of child
  9480. * @returns the serialized object
  9481. */
  9482. serialize(parent: any): any;
  9483. /**
  9484. * Internal only
  9485. * @hidden
  9486. */
  9487. _prepare(): void;
  9488. /**
  9489. * Internal only - manager for action
  9490. * @hidden
  9491. */
  9492. _actionManager: AbstractActionManager;
  9493. /**
  9494. * Adds action to chain of actions, may be a DoNothingAction
  9495. * @param action defines the next action to execute
  9496. * @returns The action passed in
  9497. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9498. */
  9499. then(action: IAction): IAction;
  9500. }
  9501. /**
  9502. * The action to be carried out following a trigger
  9503. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9504. */
  9505. export class Action implements IAction {
  9506. /** the trigger, with or without parameters, for the action */
  9507. triggerOptions: any;
  9508. /**
  9509. * Trigger for the action
  9510. */
  9511. trigger: number;
  9512. /**
  9513. * Internal only - manager for action
  9514. * @hidden
  9515. */
  9516. _actionManager: ActionManager;
  9517. private _nextActiveAction;
  9518. private _child;
  9519. private _condition?;
  9520. private _triggerParameter;
  9521. /**
  9522. * An event triggered prior to action being executed.
  9523. */
  9524. onBeforeExecuteObservable: Observable<Action>;
  9525. /**
  9526. * Creates a new Action
  9527. * @param triggerOptions the trigger, with or without parameters, for the action
  9528. * @param condition an optional determinant of action
  9529. */
  9530. constructor(
  9531. /** the trigger, with or without parameters, for the action */
  9532. triggerOptions: any, condition?: Condition);
  9533. /**
  9534. * Internal only
  9535. * @hidden
  9536. */
  9537. _prepare(): void;
  9538. /**
  9539. * Gets the trigger parameters
  9540. * @returns the trigger parameters
  9541. */
  9542. getTriggerParameter(): any;
  9543. /**
  9544. * Internal only - executes current action event
  9545. * @hidden
  9546. */
  9547. _executeCurrent(evt?: ActionEvent): void;
  9548. /**
  9549. * Execute placeholder for child classes
  9550. * @param evt optional action event
  9551. */
  9552. execute(evt?: ActionEvent): void;
  9553. /**
  9554. * Skips to next active action
  9555. */
  9556. skipToNextActiveAction(): void;
  9557. /**
  9558. * Adds action to chain of actions, may be a DoNothingAction
  9559. * @param action defines the next action to execute
  9560. * @returns The action passed in
  9561. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9562. */
  9563. then(action: Action): Action;
  9564. /**
  9565. * Internal only
  9566. * @hidden
  9567. */
  9568. _getProperty(propertyPath: string): string;
  9569. /**
  9570. * Internal only
  9571. * @hidden
  9572. */
  9573. _getEffectiveTarget(target: any, propertyPath: string): any;
  9574. /**
  9575. * Serialize placeholder for child classes
  9576. * @param parent of child
  9577. * @returns the serialized object
  9578. */
  9579. serialize(parent: any): any;
  9580. /**
  9581. * Internal only called by serialize
  9582. * @hidden
  9583. */
  9584. protected _serialize(serializedAction: any, parent?: any): any;
  9585. /**
  9586. * Internal only
  9587. * @hidden
  9588. */
  9589. static _SerializeValueAsString: (value: any) => string;
  9590. /**
  9591. * Internal only
  9592. * @hidden
  9593. */
  9594. static _GetTargetProperty: (target: Scene | Node) => {
  9595. name: string;
  9596. targetType: string;
  9597. value: string;
  9598. };
  9599. }
  9600. }
  9601. declare module "babylonjs/Actions/condition" {
  9602. import { ActionManager } from "babylonjs/Actions/actionManager";
  9603. /**
  9604. * A Condition applied to an Action
  9605. */
  9606. export class Condition {
  9607. /**
  9608. * Internal only - manager for action
  9609. * @hidden
  9610. */
  9611. _actionManager: ActionManager;
  9612. /**
  9613. * Internal only
  9614. * @hidden
  9615. */
  9616. _evaluationId: number;
  9617. /**
  9618. * Internal only
  9619. * @hidden
  9620. */
  9621. _currentResult: boolean;
  9622. /**
  9623. * Creates a new Condition
  9624. * @param actionManager the manager of the action the condition is applied to
  9625. */
  9626. constructor(actionManager: ActionManager);
  9627. /**
  9628. * Check if the current condition is valid
  9629. * @returns a boolean
  9630. */
  9631. isValid(): boolean;
  9632. /**
  9633. * Internal only
  9634. * @hidden
  9635. */
  9636. _getProperty(propertyPath: string): string;
  9637. /**
  9638. * Internal only
  9639. * @hidden
  9640. */
  9641. _getEffectiveTarget(target: any, propertyPath: string): any;
  9642. /**
  9643. * Serialize placeholder for child classes
  9644. * @returns the serialized object
  9645. */
  9646. serialize(): any;
  9647. /**
  9648. * Internal only
  9649. * @hidden
  9650. */
  9651. protected _serialize(serializedCondition: any): any;
  9652. }
  9653. /**
  9654. * Defines specific conditional operators as extensions of Condition
  9655. */
  9656. export class ValueCondition extends Condition {
  9657. /** path to specify the property of the target the conditional operator uses */
  9658. propertyPath: string;
  9659. /** the value compared by the conditional operator against the current value of the property */
  9660. value: any;
  9661. /** the conditional operator, default ValueCondition.IsEqual */
  9662. operator: number;
  9663. /**
  9664. * Internal only
  9665. * @hidden
  9666. */
  9667. private static _IsEqual;
  9668. /**
  9669. * Internal only
  9670. * @hidden
  9671. */
  9672. private static _IsDifferent;
  9673. /**
  9674. * Internal only
  9675. * @hidden
  9676. */
  9677. private static _IsGreater;
  9678. /**
  9679. * Internal only
  9680. * @hidden
  9681. */
  9682. private static _IsLesser;
  9683. /**
  9684. * returns the number for IsEqual
  9685. */
  9686. static get IsEqual(): number;
  9687. /**
  9688. * Returns the number for IsDifferent
  9689. */
  9690. static get IsDifferent(): number;
  9691. /**
  9692. * Returns the number for IsGreater
  9693. */
  9694. static get IsGreater(): number;
  9695. /**
  9696. * Returns the number for IsLesser
  9697. */
  9698. static get IsLesser(): number;
  9699. /**
  9700. * Internal only The action manager for the condition
  9701. * @hidden
  9702. */
  9703. _actionManager: ActionManager;
  9704. /**
  9705. * Internal only
  9706. * @hidden
  9707. */
  9708. private _target;
  9709. /**
  9710. * Internal only
  9711. * @hidden
  9712. */
  9713. private _effectiveTarget;
  9714. /**
  9715. * Internal only
  9716. * @hidden
  9717. */
  9718. private _property;
  9719. /**
  9720. * Creates a new ValueCondition
  9721. * @param actionManager manager for the action the condition applies to
  9722. * @param target for the action
  9723. * @param propertyPath path to specify the property of the target the conditional operator uses
  9724. * @param value the value compared by the conditional operator against the current value of the property
  9725. * @param operator the conditional operator, default ValueCondition.IsEqual
  9726. */
  9727. constructor(actionManager: ActionManager, target: any,
  9728. /** path to specify the property of the target the conditional operator uses */
  9729. propertyPath: string,
  9730. /** the value compared by the conditional operator against the current value of the property */
  9731. value: any,
  9732. /** the conditional operator, default ValueCondition.IsEqual */
  9733. operator?: number);
  9734. /**
  9735. * Compares the given value with the property value for the specified conditional operator
  9736. * @returns the result of the comparison
  9737. */
  9738. isValid(): boolean;
  9739. /**
  9740. * Serialize the ValueCondition into a JSON compatible object
  9741. * @returns serialization object
  9742. */
  9743. serialize(): any;
  9744. /**
  9745. * Gets the name of the conditional operator for the ValueCondition
  9746. * @param operator the conditional operator
  9747. * @returns the name
  9748. */
  9749. static GetOperatorName(operator: number): string;
  9750. }
  9751. /**
  9752. * Defines a predicate condition as an extension of Condition
  9753. */
  9754. export class PredicateCondition extends Condition {
  9755. /** defines the predicate function used to validate the condition */
  9756. predicate: () => boolean;
  9757. /**
  9758. * Internal only - manager for action
  9759. * @hidden
  9760. */
  9761. _actionManager: ActionManager;
  9762. /**
  9763. * Creates a new PredicateCondition
  9764. * @param actionManager manager for the action the condition applies to
  9765. * @param predicate defines the predicate function used to validate the condition
  9766. */
  9767. constructor(actionManager: ActionManager,
  9768. /** defines the predicate function used to validate the condition */
  9769. predicate: () => boolean);
  9770. /**
  9771. * @returns the validity of the predicate condition
  9772. */
  9773. isValid(): boolean;
  9774. }
  9775. /**
  9776. * Defines a state condition as an extension of Condition
  9777. */
  9778. export class StateCondition extends Condition {
  9779. /** Value to compare with target state */
  9780. value: string;
  9781. /**
  9782. * Internal only - manager for action
  9783. * @hidden
  9784. */
  9785. _actionManager: ActionManager;
  9786. /**
  9787. * Internal only
  9788. * @hidden
  9789. */
  9790. private _target;
  9791. /**
  9792. * Creates a new StateCondition
  9793. * @param actionManager manager for the action the condition applies to
  9794. * @param target of the condition
  9795. * @param value to compare with target state
  9796. */
  9797. constructor(actionManager: ActionManager, target: any,
  9798. /** Value to compare with target state */
  9799. value: string);
  9800. /**
  9801. * Gets a boolean indicating if the current condition is met
  9802. * @returns the validity of the state
  9803. */
  9804. isValid(): boolean;
  9805. /**
  9806. * Serialize the StateCondition into a JSON compatible object
  9807. * @returns serialization object
  9808. */
  9809. serialize(): any;
  9810. }
  9811. }
  9812. declare module "babylonjs/Actions/directActions" {
  9813. import { Action } from "babylonjs/Actions/action";
  9814. import { Condition } from "babylonjs/Actions/condition";
  9815. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9816. /**
  9817. * This defines an action responsible to toggle a boolean once triggered.
  9818. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9819. */
  9820. export class SwitchBooleanAction extends Action {
  9821. /**
  9822. * The path to the boolean property in the target object
  9823. */
  9824. propertyPath: string;
  9825. private _target;
  9826. private _effectiveTarget;
  9827. private _property;
  9828. /**
  9829. * Instantiate the action
  9830. * @param triggerOptions defines the trigger options
  9831. * @param target defines the object containing the boolean
  9832. * @param propertyPath defines the path to the boolean property in the target object
  9833. * @param condition defines the trigger related conditions
  9834. */
  9835. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9836. /** @hidden */
  9837. _prepare(): void;
  9838. /**
  9839. * Execute the action toggle the boolean value.
  9840. */
  9841. execute(): void;
  9842. /**
  9843. * Serializes the actions and its related information.
  9844. * @param parent defines the object to serialize in
  9845. * @returns the serialized object
  9846. */
  9847. serialize(parent: any): any;
  9848. }
  9849. /**
  9850. * This defines an action responsible to set a the state field of the target
  9851. * to a desired value once triggered.
  9852. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9853. */
  9854. export class SetStateAction extends Action {
  9855. /**
  9856. * The value to store in the state field.
  9857. */
  9858. value: string;
  9859. private _target;
  9860. /**
  9861. * Instantiate the action
  9862. * @param triggerOptions defines the trigger options
  9863. * @param target defines the object containing the state property
  9864. * @param value defines the value to store in the state field
  9865. * @param condition defines the trigger related conditions
  9866. */
  9867. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9868. /**
  9869. * Execute the action and store the value on the target state property.
  9870. */
  9871. execute(): void;
  9872. /**
  9873. * Serializes the actions and its related information.
  9874. * @param parent defines the object to serialize in
  9875. * @returns the serialized object
  9876. */
  9877. serialize(parent: any): any;
  9878. }
  9879. /**
  9880. * This defines an action responsible to set a property of the target
  9881. * to a desired value once triggered.
  9882. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9883. */
  9884. export class SetValueAction extends Action {
  9885. /**
  9886. * The path of the property to set in the target.
  9887. */
  9888. propertyPath: string;
  9889. /**
  9890. * The value to set in the property
  9891. */
  9892. value: any;
  9893. private _target;
  9894. private _effectiveTarget;
  9895. private _property;
  9896. /**
  9897. * Instantiate the action
  9898. * @param triggerOptions defines the trigger options
  9899. * @param target defines the object containing the property
  9900. * @param propertyPath defines the path of the property to set in the target
  9901. * @param value defines the value to set in the property
  9902. * @param condition defines the trigger related conditions
  9903. */
  9904. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9905. /** @hidden */
  9906. _prepare(): void;
  9907. /**
  9908. * Execute the action and set the targetted property to the desired value.
  9909. */
  9910. execute(): void;
  9911. /**
  9912. * Serializes the actions and its related information.
  9913. * @param parent defines the object to serialize in
  9914. * @returns the serialized object
  9915. */
  9916. serialize(parent: any): any;
  9917. }
  9918. /**
  9919. * This defines an action responsible to increment the target value
  9920. * to a desired value once triggered.
  9921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9922. */
  9923. export class IncrementValueAction extends Action {
  9924. /**
  9925. * The path of the property to increment in the target.
  9926. */
  9927. propertyPath: string;
  9928. /**
  9929. * The value we should increment the property by.
  9930. */
  9931. value: any;
  9932. private _target;
  9933. private _effectiveTarget;
  9934. private _property;
  9935. /**
  9936. * Instantiate the action
  9937. * @param triggerOptions defines the trigger options
  9938. * @param target defines the object containing the property
  9939. * @param propertyPath defines the path of the property to increment in the target
  9940. * @param value defines the value value we should increment the property by
  9941. * @param condition defines the trigger related conditions
  9942. */
  9943. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9944. /** @hidden */
  9945. _prepare(): void;
  9946. /**
  9947. * Execute the action and increment the target of the value amount.
  9948. */
  9949. execute(): void;
  9950. /**
  9951. * Serializes the actions and its related information.
  9952. * @param parent defines the object to serialize in
  9953. * @returns the serialized object
  9954. */
  9955. serialize(parent: any): any;
  9956. }
  9957. /**
  9958. * This defines an action responsible to start an animation once triggered.
  9959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9960. */
  9961. export class PlayAnimationAction extends Action {
  9962. /**
  9963. * Where the animation should start (animation frame)
  9964. */
  9965. from: number;
  9966. /**
  9967. * Where the animation should stop (animation frame)
  9968. */
  9969. to: number;
  9970. /**
  9971. * Define if the animation should loop or stop after the first play.
  9972. */
  9973. loop?: boolean;
  9974. private _target;
  9975. /**
  9976. * Instantiate the action
  9977. * @param triggerOptions defines the trigger options
  9978. * @param target defines the target animation or animation name
  9979. * @param from defines from where the animation should start (animation frame)
  9980. * @param end defines where the animation should stop (animation frame)
  9981. * @param loop defines if the animation should loop or stop after the first play
  9982. * @param condition defines the trigger related conditions
  9983. */
  9984. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9985. /** @hidden */
  9986. _prepare(): void;
  9987. /**
  9988. * Execute the action and play the animation.
  9989. */
  9990. execute(): void;
  9991. /**
  9992. * Serializes the actions and its related information.
  9993. * @param parent defines the object to serialize in
  9994. * @returns the serialized object
  9995. */
  9996. serialize(parent: any): any;
  9997. }
  9998. /**
  9999. * This defines an action responsible to stop an animation once triggered.
  10000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10001. */
  10002. export class StopAnimationAction extends Action {
  10003. private _target;
  10004. /**
  10005. * Instantiate the action
  10006. * @param triggerOptions defines the trigger options
  10007. * @param target defines the target animation or animation name
  10008. * @param condition defines the trigger related conditions
  10009. */
  10010. constructor(triggerOptions: any, target: any, condition?: Condition);
  10011. /** @hidden */
  10012. _prepare(): void;
  10013. /**
  10014. * Execute the action and stop the animation.
  10015. */
  10016. execute(): void;
  10017. /**
  10018. * Serializes the actions and its related information.
  10019. * @param parent defines the object to serialize in
  10020. * @returns the serialized object
  10021. */
  10022. serialize(parent: any): any;
  10023. }
  10024. /**
  10025. * This defines an action responsible that does nothing once triggered.
  10026. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10027. */
  10028. export class DoNothingAction extends Action {
  10029. /**
  10030. * Instantiate the action
  10031. * @param triggerOptions defines the trigger options
  10032. * @param condition defines the trigger related conditions
  10033. */
  10034. constructor(triggerOptions?: any, condition?: Condition);
  10035. /**
  10036. * Execute the action and do nothing.
  10037. */
  10038. execute(): void;
  10039. /**
  10040. * Serializes the actions and its related information.
  10041. * @param parent defines the object to serialize in
  10042. * @returns the serialized object
  10043. */
  10044. serialize(parent: any): any;
  10045. }
  10046. /**
  10047. * This defines an action responsible to trigger several actions once triggered.
  10048. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10049. */
  10050. export class CombineAction extends Action {
  10051. /**
  10052. * The list of aggregated animations to run.
  10053. */
  10054. children: Action[];
  10055. /**
  10056. * Instantiate the action
  10057. * @param triggerOptions defines the trigger options
  10058. * @param children defines the list of aggregated animations to run
  10059. * @param condition defines the trigger related conditions
  10060. */
  10061. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10062. /** @hidden */
  10063. _prepare(): void;
  10064. /**
  10065. * Execute the action and executes all the aggregated actions.
  10066. */
  10067. execute(evt: ActionEvent): void;
  10068. /**
  10069. * Serializes the actions and its related information.
  10070. * @param parent defines the object to serialize in
  10071. * @returns the serialized object
  10072. */
  10073. serialize(parent: any): any;
  10074. }
  10075. /**
  10076. * This defines an action responsible to run code (external event) once triggered.
  10077. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10078. */
  10079. export class ExecuteCodeAction extends Action {
  10080. /**
  10081. * The callback function to run.
  10082. */
  10083. func: (evt: ActionEvent) => void;
  10084. /**
  10085. * Instantiate the action
  10086. * @param triggerOptions defines the trigger options
  10087. * @param func defines the callback function to run
  10088. * @param condition defines the trigger related conditions
  10089. */
  10090. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10091. /**
  10092. * Execute the action and run the attached code.
  10093. */
  10094. execute(evt: ActionEvent): void;
  10095. }
  10096. /**
  10097. * This defines an action responsible to set the parent property of the target once triggered.
  10098. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10099. */
  10100. export class SetParentAction extends Action {
  10101. private _parent;
  10102. private _target;
  10103. /**
  10104. * Instantiate the action
  10105. * @param triggerOptions defines the trigger options
  10106. * @param target defines the target containing the parent property
  10107. * @param parent defines from where the animation should start (animation frame)
  10108. * @param condition defines the trigger related conditions
  10109. */
  10110. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10111. /** @hidden */
  10112. _prepare(): void;
  10113. /**
  10114. * Execute the action and set the parent property.
  10115. */
  10116. execute(): void;
  10117. /**
  10118. * Serializes the actions and its related information.
  10119. * @param parent defines the object to serialize in
  10120. * @returns the serialized object
  10121. */
  10122. serialize(parent: any): any;
  10123. }
  10124. }
  10125. declare module "babylonjs/Actions/actionManager" {
  10126. import { Nullable } from "babylonjs/types";
  10127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10128. import { Scene } from "babylonjs/scene";
  10129. import { IAction } from "babylonjs/Actions/action";
  10130. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10131. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10132. /**
  10133. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10134. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10136. */
  10137. export class ActionManager extends AbstractActionManager {
  10138. /**
  10139. * Nothing
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly NothingTrigger: number;
  10143. /**
  10144. * On pick
  10145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10146. */
  10147. static readonly OnPickTrigger: number;
  10148. /**
  10149. * On left pick
  10150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10151. */
  10152. static readonly OnLeftPickTrigger: number;
  10153. /**
  10154. * On right pick
  10155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10156. */
  10157. static readonly OnRightPickTrigger: number;
  10158. /**
  10159. * On center pick
  10160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10161. */
  10162. static readonly OnCenterPickTrigger: number;
  10163. /**
  10164. * On pick down
  10165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10166. */
  10167. static readonly OnPickDownTrigger: number;
  10168. /**
  10169. * On double pick
  10170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10171. */
  10172. static readonly OnDoublePickTrigger: number;
  10173. /**
  10174. * On pick up
  10175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10176. */
  10177. static readonly OnPickUpTrigger: number;
  10178. /**
  10179. * On pick out.
  10180. * This trigger will only be raised if you also declared a OnPickDown
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnPickOutTrigger: number;
  10184. /**
  10185. * On long press
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnLongPressTrigger: number;
  10189. /**
  10190. * On pointer over
  10191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10192. */
  10193. static readonly OnPointerOverTrigger: number;
  10194. /**
  10195. * On pointer out
  10196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10197. */
  10198. static readonly OnPointerOutTrigger: number;
  10199. /**
  10200. * On every frame
  10201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10202. */
  10203. static readonly OnEveryFrameTrigger: number;
  10204. /**
  10205. * On intersection enter
  10206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10207. */
  10208. static readonly OnIntersectionEnterTrigger: number;
  10209. /**
  10210. * On intersection exit
  10211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10212. */
  10213. static readonly OnIntersectionExitTrigger: number;
  10214. /**
  10215. * On key down
  10216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10217. */
  10218. static readonly OnKeyDownTrigger: number;
  10219. /**
  10220. * On key up
  10221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10222. */
  10223. static readonly OnKeyUpTrigger: number;
  10224. private _scene;
  10225. /**
  10226. * Creates a new action manager
  10227. * @param scene defines the hosting scene
  10228. */
  10229. constructor(scene: Scene);
  10230. /**
  10231. * Releases all associated resources
  10232. */
  10233. dispose(): void;
  10234. /**
  10235. * Gets hosting scene
  10236. * @returns the hosting scene
  10237. */
  10238. getScene(): Scene;
  10239. /**
  10240. * Does this action manager handles actions of any of the given triggers
  10241. * @param triggers defines the triggers to be tested
  10242. * @return a boolean indicating whether one (or more) of the triggers is handled
  10243. */
  10244. hasSpecificTriggers(triggers: number[]): boolean;
  10245. /**
  10246. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10247. * speed.
  10248. * @param triggerA defines the trigger to be tested
  10249. * @param triggerB defines the trigger to be tested
  10250. * @return a boolean indicating whether one (or more) of the triggers is handled
  10251. */
  10252. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10253. /**
  10254. * Does this action manager handles actions of a given trigger
  10255. * @param trigger defines the trigger to be tested
  10256. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10257. * @return whether the trigger is handled
  10258. */
  10259. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10260. /**
  10261. * Does this action manager has pointer triggers
  10262. */
  10263. get hasPointerTriggers(): boolean;
  10264. /**
  10265. * Does this action manager has pick triggers
  10266. */
  10267. get hasPickTriggers(): boolean;
  10268. /**
  10269. * Registers an action to this action manager
  10270. * @param action defines the action to be registered
  10271. * @return the action amended (prepared) after registration
  10272. */
  10273. registerAction(action: IAction): Nullable<IAction>;
  10274. /**
  10275. * Unregisters an action to this action manager
  10276. * @param action defines the action to be unregistered
  10277. * @return a boolean indicating whether the action has been unregistered
  10278. */
  10279. unregisterAction(action: IAction): Boolean;
  10280. /**
  10281. * Process a specific trigger
  10282. * @param trigger defines the trigger to process
  10283. * @param evt defines the event details to be processed
  10284. */
  10285. processTrigger(trigger: number, evt?: IActionEvent): void;
  10286. /** @hidden */
  10287. _getEffectiveTarget(target: any, propertyPath: string): any;
  10288. /** @hidden */
  10289. _getProperty(propertyPath: string): string;
  10290. /**
  10291. * Serialize this manager to a JSON object
  10292. * @param name defines the property name to store this manager
  10293. * @returns a JSON representation of this manager
  10294. */
  10295. serialize(name: string): any;
  10296. /**
  10297. * Creates a new ActionManager from a JSON data
  10298. * @param parsedActions defines the JSON data to read from
  10299. * @param object defines the hosting mesh
  10300. * @param scene defines the hosting scene
  10301. */
  10302. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10303. /**
  10304. * Get a trigger name by index
  10305. * @param trigger defines the trigger index
  10306. * @returns a trigger name
  10307. */
  10308. static GetTriggerName(trigger: number): string;
  10309. }
  10310. }
  10311. declare module "babylonjs/Sprites/sprite" {
  10312. import { Vector3 } from "babylonjs/Maths/math.vector";
  10313. import { Nullable } from "babylonjs/types";
  10314. import { ActionManager } from "babylonjs/Actions/actionManager";
  10315. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10316. import { Color4 } from "babylonjs/Maths/math.color";
  10317. import { Observable } from "babylonjs/Misc/observable";
  10318. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10319. import { Animation } from "babylonjs/Animations/animation";
  10320. /**
  10321. * Class used to represent a sprite
  10322. * @see https://doc.babylonjs.com/babylon101/sprites
  10323. */
  10324. export class Sprite implements IAnimatable {
  10325. /** defines the name */
  10326. name: string;
  10327. /** Gets or sets the current world position */
  10328. position: Vector3;
  10329. /** Gets or sets the main color */
  10330. color: Color4;
  10331. /** Gets or sets the width */
  10332. width: number;
  10333. /** Gets or sets the height */
  10334. height: number;
  10335. /** Gets or sets rotation angle */
  10336. angle: number;
  10337. /** Gets or sets the cell index in the sprite sheet */
  10338. cellIndex: number;
  10339. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10340. cellRef: string;
  10341. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10342. invertU: boolean;
  10343. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10344. invertV: boolean;
  10345. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10346. disposeWhenFinishedAnimating: boolean;
  10347. /** Gets the list of attached animations */
  10348. animations: Nullable<Array<Animation>>;
  10349. /** Gets or sets a boolean indicating if the sprite can be picked */
  10350. isPickable: boolean;
  10351. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10352. useAlphaForPicking: boolean;
  10353. /** @hidden */
  10354. _xOffset: number;
  10355. /** @hidden */
  10356. _yOffset: number;
  10357. /** @hidden */
  10358. _xSize: number;
  10359. /** @hidden */
  10360. _ySize: number;
  10361. /**
  10362. * Gets or sets the associated action manager
  10363. */
  10364. actionManager: Nullable<ActionManager>;
  10365. /**
  10366. * An event triggered when the control has been disposed
  10367. */
  10368. onDisposeObservable: Observable<Sprite>;
  10369. private _animationStarted;
  10370. private _loopAnimation;
  10371. private _fromIndex;
  10372. private _toIndex;
  10373. private _delay;
  10374. private _direction;
  10375. private _manager;
  10376. private _time;
  10377. private _onAnimationEnd;
  10378. /**
  10379. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10380. */
  10381. isVisible: boolean;
  10382. /**
  10383. * Gets or sets the sprite size
  10384. */
  10385. get size(): number;
  10386. set size(value: number);
  10387. /**
  10388. * Returns a boolean indicating if the animation is started
  10389. */
  10390. get animationStarted(): boolean;
  10391. /**
  10392. * Gets or sets the unique id of the sprite
  10393. */
  10394. uniqueId: number;
  10395. /**
  10396. * Gets the manager of this sprite
  10397. */
  10398. get manager(): ISpriteManager;
  10399. /**
  10400. * Creates a new Sprite
  10401. * @param name defines the name
  10402. * @param manager defines the manager
  10403. */
  10404. constructor(
  10405. /** defines the name */
  10406. name: string, manager: ISpriteManager);
  10407. /**
  10408. * Returns the string "Sprite"
  10409. * @returns "Sprite"
  10410. */
  10411. getClassName(): string;
  10412. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10413. get fromIndex(): number;
  10414. set fromIndex(value: number);
  10415. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10416. get toIndex(): number;
  10417. set toIndex(value: number);
  10418. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10419. get loopAnimation(): boolean;
  10420. set loopAnimation(value: boolean);
  10421. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10422. get delay(): number;
  10423. set delay(value: number);
  10424. /**
  10425. * Starts an animation
  10426. * @param from defines the initial key
  10427. * @param to defines the end key
  10428. * @param loop defines if the animation must loop
  10429. * @param delay defines the start delay (in ms)
  10430. * @param onAnimationEnd defines a callback to call when animation ends
  10431. */
  10432. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10433. /** Stops current animation (if any) */
  10434. stopAnimation(): void;
  10435. /** @hidden */
  10436. _animate(deltaTime: number): void;
  10437. /** Release associated resources */
  10438. dispose(): void;
  10439. /**
  10440. * Serializes the sprite to a JSON object
  10441. * @returns the JSON object
  10442. */
  10443. serialize(): any;
  10444. /**
  10445. * Parses a JSON object to create a new sprite
  10446. * @param parsedSprite The JSON object to parse
  10447. * @param manager defines the hosting manager
  10448. * @returns the new sprite
  10449. */
  10450. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10451. }
  10452. }
  10453. declare module "babylonjs/Collisions/pickingInfo" {
  10454. import { Nullable } from "babylonjs/types";
  10455. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10457. import { Sprite } from "babylonjs/Sprites/sprite";
  10458. import { Ray } from "babylonjs/Culling/ray";
  10459. /**
  10460. * Information about the result of picking within a scene
  10461. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10462. */
  10463. export class PickingInfo {
  10464. /** @hidden */
  10465. _pickingUnavailable: boolean;
  10466. /**
  10467. * If the pick collided with an object
  10468. */
  10469. hit: boolean;
  10470. /**
  10471. * Distance away where the pick collided
  10472. */
  10473. distance: number;
  10474. /**
  10475. * The location of pick collision
  10476. */
  10477. pickedPoint: Nullable<Vector3>;
  10478. /**
  10479. * The mesh corresponding the the pick collision
  10480. */
  10481. pickedMesh: Nullable<AbstractMesh>;
  10482. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10483. bu: number;
  10484. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10485. bv: number;
  10486. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10487. faceId: number;
  10488. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10489. subMeshFaceId: number;
  10490. /** Id of the the submesh that was picked */
  10491. subMeshId: number;
  10492. /** If a sprite was picked, this will be the sprite the pick collided with */
  10493. pickedSprite: Nullable<Sprite>;
  10494. /**
  10495. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10496. */
  10497. originMesh: Nullable<AbstractMesh>;
  10498. /**
  10499. * The ray that was used to perform the picking.
  10500. */
  10501. ray: Nullable<Ray>;
  10502. /**
  10503. * Gets the normal correspodning to the face the pick collided with
  10504. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10505. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10506. * @returns The normal correspodning to the face the pick collided with
  10507. */
  10508. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10509. /**
  10510. * Gets the texture coordinates of where the pick occured
  10511. * @returns the vector containing the coordnates of the texture
  10512. */
  10513. getTextureCoordinates(): Nullable<Vector2>;
  10514. }
  10515. }
  10516. declare module "babylonjs/Culling/ray" {
  10517. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10518. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10520. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10521. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10522. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10523. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10524. import { Plane } from "babylonjs/Maths/math.plane";
  10525. /**
  10526. * Class representing a ray with position and direction
  10527. */
  10528. export class Ray {
  10529. /** origin point */
  10530. origin: Vector3;
  10531. /** direction */
  10532. direction: Vector3;
  10533. /** length of the ray */
  10534. length: number;
  10535. private static readonly TmpVector3;
  10536. private _tmpRay;
  10537. /**
  10538. * Creates a new ray
  10539. * @param origin origin point
  10540. * @param direction direction
  10541. * @param length length of the ray
  10542. */
  10543. constructor(
  10544. /** origin point */
  10545. origin: Vector3,
  10546. /** direction */
  10547. direction: Vector3,
  10548. /** length of the ray */
  10549. length?: number);
  10550. /**
  10551. * Checks if the ray intersects a box
  10552. * This does not account for the ray lenght by design to improve perfs.
  10553. * @param minimum bound of the box
  10554. * @param maximum bound of the box
  10555. * @param intersectionTreshold extra extend to be added to the box in all direction
  10556. * @returns if the box was hit
  10557. */
  10558. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10559. /**
  10560. * Checks if the ray intersects a box
  10561. * This does not account for the ray lenght by design to improve perfs.
  10562. * @param box the bounding box to check
  10563. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10564. * @returns if the box was hit
  10565. */
  10566. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10567. /**
  10568. * If the ray hits a sphere
  10569. * @param sphere the bounding sphere to check
  10570. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10571. * @returns true if it hits the sphere
  10572. */
  10573. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10574. /**
  10575. * If the ray hits a triange
  10576. * @param vertex0 triangle vertex
  10577. * @param vertex1 triangle vertex
  10578. * @param vertex2 triangle vertex
  10579. * @returns intersection information if hit
  10580. */
  10581. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10582. /**
  10583. * Checks if ray intersects a plane
  10584. * @param plane the plane to check
  10585. * @returns the distance away it was hit
  10586. */
  10587. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10588. /**
  10589. * Calculate the intercept of a ray on a given axis
  10590. * @param axis to check 'x' | 'y' | 'z'
  10591. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10592. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10593. */
  10594. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10595. /**
  10596. * Checks if ray intersects a mesh
  10597. * @param mesh the mesh to check
  10598. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10599. * @returns picking info of the intersecton
  10600. */
  10601. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10602. /**
  10603. * Checks if ray intersects a mesh
  10604. * @param meshes the meshes to check
  10605. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10606. * @param results array to store result in
  10607. * @returns Array of picking infos
  10608. */
  10609. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10610. private _comparePickingInfo;
  10611. private static smallnum;
  10612. private static rayl;
  10613. /**
  10614. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10615. * @param sega the first point of the segment to test the intersection against
  10616. * @param segb the second point of the segment to test the intersection against
  10617. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10618. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10619. */
  10620. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10621. /**
  10622. * Update the ray from viewport position
  10623. * @param x position
  10624. * @param y y position
  10625. * @param viewportWidth viewport width
  10626. * @param viewportHeight viewport height
  10627. * @param world world matrix
  10628. * @param view view matrix
  10629. * @param projection projection matrix
  10630. * @returns this ray updated
  10631. */
  10632. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10633. /**
  10634. * Creates a ray with origin and direction of 0,0,0
  10635. * @returns the new ray
  10636. */
  10637. static Zero(): Ray;
  10638. /**
  10639. * Creates a new ray from screen space and viewport
  10640. * @param x position
  10641. * @param y y position
  10642. * @param viewportWidth viewport width
  10643. * @param viewportHeight viewport height
  10644. * @param world world matrix
  10645. * @param view view matrix
  10646. * @param projection projection matrix
  10647. * @returns new ray
  10648. */
  10649. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10650. /**
  10651. * 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
  10652. * transformed to the given world matrix.
  10653. * @param origin The origin point
  10654. * @param end The end point
  10655. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10656. * @returns the new ray
  10657. */
  10658. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10659. /**
  10660. * Transforms a ray by a matrix
  10661. * @param ray ray to transform
  10662. * @param matrix matrix to apply
  10663. * @returns the resulting new ray
  10664. */
  10665. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10666. /**
  10667. * Transforms a ray by a matrix
  10668. * @param ray ray to transform
  10669. * @param matrix matrix to apply
  10670. * @param result ray to store result in
  10671. */
  10672. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10673. /**
  10674. * Unproject a ray from screen space to object space
  10675. * @param sourceX defines the screen space x coordinate to use
  10676. * @param sourceY defines the screen space y coordinate to use
  10677. * @param viewportWidth defines the current width of the viewport
  10678. * @param viewportHeight defines the current height of the viewport
  10679. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10680. * @param view defines the view matrix to use
  10681. * @param projection defines the projection matrix to use
  10682. */
  10683. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10684. }
  10685. /**
  10686. * Type used to define predicate used to select faces when a mesh intersection is detected
  10687. */
  10688. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10689. module "babylonjs/scene" {
  10690. interface Scene {
  10691. /** @hidden */
  10692. _tempPickingRay: Nullable<Ray>;
  10693. /** @hidden */
  10694. _cachedRayForTransform: Ray;
  10695. /** @hidden */
  10696. _pickWithRayInverseMatrix: Matrix;
  10697. /** @hidden */
  10698. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10699. /** @hidden */
  10700. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10701. }
  10702. }
  10703. }
  10704. declare module "babylonjs/sceneComponent" {
  10705. import { Scene } from "babylonjs/scene";
  10706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10707. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10708. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10709. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10710. import { Nullable } from "babylonjs/types";
  10711. import { Camera } from "babylonjs/Cameras/camera";
  10712. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10713. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10714. import { AbstractScene } from "babylonjs/abstractScene";
  10715. import { Mesh } from "babylonjs/Meshes/mesh";
  10716. /**
  10717. * Groups all the scene component constants in one place to ease maintenance.
  10718. * @hidden
  10719. */
  10720. export class SceneComponentConstants {
  10721. static readonly NAME_EFFECTLAYER: string;
  10722. static readonly NAME_LAYER: string;
  10723. static readonly NAME_LENSFLARESYSTEM: string;
  10724. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10725. static readonly NAME_PARTICLESYSTEM: string;
  10726. static readonly NAME_GAMEPAD: string;
  10727. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10728. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10729. static readonly NAME_PREPASSRENDERER: string;
  10730. static readonly NAME_DEPTHRENDERER: string;
  10731. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10732. static readonly NAME_SPRITE: string;
  10733. static readonly NAME_OUTLINERENDERER: string;
  10734. static readonly NAME_PROCEDURALTEXTURE: string;
  10735. static readonly NAME_SHADOWGENERATOR: string;
  10736. static readonly NAME_OCTREE: string;
  10737. static readonly NAME_PHYSICSENGINE: string;
  10738. static readonly NAME_AUDIO: string;
  10739. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10740. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10741. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10742. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10743. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10744. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10745. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10746. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10747. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10748. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10749. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10750. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10751. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10752. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10753. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10754. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10755. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10756. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10757. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10758. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10759. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10760. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10761. static readonly STEP_AFTERRENDER_AUDIO: number;
  10762. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10763. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10764. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10765. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10766. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10767. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10768. static readonly STEP_POINTERMOVE_SPRITE: number;
  10769. static readonly STEP_POINTERDOWN_SPRITE: number;
  10770. static readonly STEP_POINTERUP_SPRITE: number;
  10771. }
  10772. /**
  10773. * This represents a scene component.
  10774. *
  10775. * This is used to decouple the dependency the scene is having on the different workloads like
  10776. * layers, post processes...
  10777. */
  10778. export interface ISceneComponent {
  10779. /**
  10780. * The name of the component. Each component must have a unique name.
  10781. */
  10782. name: string;
  10783. /**
  10784. * The scene the component belongs to.
  10785. */
  10786. scene: Scene;
  10787. /**
  10788. * Register the component to one instance of a scene.
  10789. */
  10790. register(): void;
  10791. /**
  10792. * Rebuilds the elements related to this component in case of
  10793. * context lost for instance.
  10794. */
  10795. rebuild(): void;
  10796. /**
  10797. * Disposes the component and the associated ressources.
  10798. */
  10799. dispose(): void;
  10800. }
  10801. /**
  10802. * This represents a SERIALIZABLE scene component.
  10803. *
  10804. * This extends Scene Component to add Serialization methods on top.
  10805. */
  10806. export interface ISceneSerializableComponent extends ISceneComponent {
  10807. /**
  10808. * Adds all the elements from the container to the scene
  10809. * @param container the container holding the elements
  10810. */
  10811. addFromContainer(container: AbstractScene): void;
  10812. /**
  10813. * Removes all the elements in the container from the scene
  10814. * @param container contains the elements to remove
  10815. * @param dispose if the removed element should be disposed (default: false)
  10816. */
  10817. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10818. /**
  10819. * Serializes the component data to the specified json object
  10820. * @param serializationObject The object to serialize to
  10821. */
  10822. serialize(serializationObject: any): void;
  10823. }
  10824. /**
  10825. * Strong typing of a Mesh related stage step action
  10826. */
  10827. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10828. /**
  10829. * Strong typing of a Evaluate Sub Mesh related stage step action
  10830. */
  10831. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10832. /**
  10833. * Strong typing of a Active Mesh related stage step action
  10834. */
  10835. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10836. /**
  10837. * Strong typing of a Camera related stage step action
  10838. */
  10839. export type CameraStageAction = (camera: Camera) => void;
  10840. /**
  10841. * Strong typing of a Camera Frame buffer related stage step action
  10842. */
  10843. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10844. /**
  10845. * Strong typing of a Render Target related stage step action
  10846. */
  10847. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10848. /**
  10849. * Strong typing of a RenderingGroup related stage step action
  10850. */
  10851. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10852. /**
  10853. * Strong typing of a Mesh Render related stage step action
  10854. */
  10855. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10856. /**
  10857. * Strong typing of a simple stage step action
  10858. */
  10859. export type SimpleStageAction = () => void;
  10860. /**
  10861. * Strong typing of a render target action.
  10862. */
  10863. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10864. /**
  10865. * Strong typing of a pointer move action.
  10866. */
  10867. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10868. /**
  10869. * Strong typing of a pointer up/down action.
  10870. */
  10871. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10872. /**
  10873. * Representation of a stage in the scene (Basically a list of ordered steps)
  10874. * @hidden
  10875. */
  10876. export class Stage<T extends Function> extends Array<{
  10877. index: number;
  10878. component: ISceneComponent;
  10879. action: T;
  10880. }> {
  10881. /**
  10882. * Hide ctor from the rest of the world.
  10883. * @param items The items to add.
  10884. */
  10885. private constructor();
  10886. /**
  10887. * Creates a new Stage.
  10888. * @returns A new instance of a Stage
  10889. */
  10890. static Create<T extends Function>(): Stage<T>;
  10891. /**
  10892. * Registers a step in an ordered way in the targeted stage.
  10893. * @param index Defines the position to register the step in
  10894. * @param component Defines the component attached to the step
  10895. * @param action Defines the action to launch during the step
  10896. */
  10897. registerStep(index: number, component: ISceneComponent, action: T): void;
  10898. /**
  10899. * Clears all the steps from the stage.
  10900. */
  10901. clear(): void;
  10902. }
  10903. }
  10904. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10905. import { Nullable } from "babylonjs/types";
  10906. import { Observable } from "babylonjs/Misc/observable";
  10907. import { Scene } from "babylonjs/scene";
  10908. import { Sprite } from "babylonjs/Sprites/sprite";
  10909. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10910. import { Ray } from "babylonjs/Culling/ray";
  10911. import { Camera } from "babylonjs/Cameras/camera";
  10912. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10913. import { ISceneComponent } from "babylonjs/sceneComponent";
  10914. module "babylonjs/scene" {
  10915. interface Scene {
  10916. /** @hidden */
  10917. _pointerOverSprite: Nullable<Sprite>;
  10918. /** @hidden */
  10919. _pickedDownSprite: Nullable<Sprite>;
  10920. /** @hidden */
  10921. _tempSpritePickingRay: Nullable<Ray>;
  10922. /**
  10923. * All of the sprite managers added to this scene
  10924. * @see https://doc.babylonjs.com/babylon101/sprites
  10925. */
  10926. spriteManagers: Array<ISpriteManager>;
  10927. /**
  10928. * An event triggered when sprites rendering is about to start
  10929. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10930. */
  10931. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10932. /**
  10933. * An event triggered when sprites rendering is done
  10934. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10935. */
  10936. onAfterSpritesRenderingObservable: Observable<Scene>;
  10937. /** @hidden */
  10938. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10939. /** Launch a ray to try to pick a sprite in the scene
  10940. * @param x position on screen
  10941. * @param y position on screen
  10942. * @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
  10943. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10944. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10945. * @returns a PickingInfo
  10946. */
  10947. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10948. /** Use the given ray to pick a sprite in the scene
  10949. * @param ray The ray (in world space) to use to pick meshes
  10950. * @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
  10951. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10952. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10953. * @returns a PickingInfo
  10954. */
  10955. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10956. /** @hidden */
  10957. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10958. /** Launch a ray to try to pick sprites in the scene
  10959. * @param x position on screen
  10960. * @param y position on screen
  10961. * @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
  10962. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10963. * @returns a PickingInfo array
  10964. */
  10965. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10966. /** Use the given ray to pick sprites in the scene
  10967. * @param ray The ray (in world space) to use to pick meshes
  10968. * @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
  10969. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10970. * @returns a PickingInfo array
  10971. */
  10972. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10973. /**
  10974. * Force the sprite under the pointer
  10975. * @param sprite defines the sprite to use
  10976. */
  10977. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10978. /**
  10979. * Gets the sprite under the pointer
  10980. * @returns a Sprite or null if no sprite is under the pointer
  10981. */
  10982. getPointerOverSprite(): Nullable<Sprite>;
  10983. }
  10984. }
  10985. /**
  10986. * Defines the sprite scene component responsible to manage sprites
  10987. * in a given scene.
  10988. */
  10989. export class SpriteSceneComponent implements ISceneComponent {
  10990. /**
  10991. * The component name helpfull to identify the component in the list of scene components.
  10992. */
  10993. readonly name: string;
  10994. /**
  10995. * The scene the component belongs to.
  10996. */
  10997. scene: Scene;
  10998. /** @hidden */
  10999. private _spritePredicate;
  11000. /**
  11001. * Creates a new instance of the component for the given scene
  11002. * @param scene Defines the scene to register the component in
  11003. */
  11004. constructor(scene: Scene);
  11005. /**
  11006. * Registers the component in a given scene
  11007. */
  11008. register(): void;
  11009. /**
  11010. * Rebuilds the elements related to this component in case of
  11011. * context lost for instance.
  11012. */
  11013. rebuild(): void;
  11014. /**
  11015. * Disposes the component and the associated ressources.
  11016. */
  11017. dispose(): void;
  11018. private _pickSpriteButKeepRay;
  11019. private _pointerMove;
  11020. private _pointerDown;
  11021. private _pointerUp;
  11022. }
  11023. }
  11024. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11025. /** @hidden */
  11026. export var fogFragmentDeclaration: {
  11027. name: string;
  11028. shader: string;
  11029. };
  11030. }
  11031. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11032. /** @hidden */
  11033. export var fogFragment: {
  11034. name: string;
  11035. shader: string;
  11036. };
  11037. }
  11038. declare module "babylonjs/Shaders/sprites.fragment" {
  11039. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11040. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11041. /** @hidden */
  11042. export var spritesPixelShader: {
  11043. name: string;
  11044. shader: string;
  11045. };
  11046. }
  11047. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11048. /** @hidden */
  11049. export var fogVertexDeclaration: {
  11050. name: string;
  11051. shader: string;
  11052. };
  11053. }
  11054. declare module "babylonjs/Shaders/sprites.vertex" {
  11055. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11056. /** @hidden */
  11057. export var spritesVertexShader: {
  11058. name: string;
  11059. shader: string;
  11060. };
  11061. }
  11062. declare module "babylonjs/Sprites/spriteManager" {
  11063. import { IDisposable, Scene } from "babylonjs/scene";
  11064. import { Nullable } from "babylonjs/types";
  11065. import { Observable } from "babylonjs/Misc/observable";
  11066. import { Sprite } from "babylonjs/Sprites/sprite";
  11067. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11068. import { Camera } from "babylonjs/Cameras/camera";
  11069. import { Texture } from "babylonjs/Materials/Textures/texture";
  11070. import "babylonjs/Shaders/sprites.fragment";
  11071. import "babylonjs/Shaders/sprites.vertex";
  11072. import { Ray } from "babylonjs/Culling/ray";
  11073. /**
  11074. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11075. */
  11076. export interface ISpriteManager extends IDisposable {
  11077. /**
  11078. * Gets manager's name
  11079. */
  11080. name: string;
  11081. /**
  11082. * Restricts the camera to viewing objects with the same layerMask.
  11083. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11084. */
  11085. layerMask: number;
  11086. /**
  11087. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11088. */
  11089. isPickable: boolean;
  11090. /**
  11091. * Gets the hosting scene
  11092. */
  11093. scene: Scene;
  11094. /**
  11095. * Specifies the rendering group id for this mesh (0 by default)
  11096. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11097. */
  11098. renderingGroupId: number;
  11099. /**
  11100. * Defines the list of sprites managed by the manager.
  11101. */
  11102. sprites: Array<Sprite>;
  11103. /**
  11104. * Gets or sets the spritesheet texture
  11105. */
  11106. texture: Texture;
  11107. /** Defines the default width of a cell in the spritesheet */
  11108. cellWidth: number;
  11109. /** Defines the default height of a cell in the spritesheet */
  11110. cellHeight: number;
  11111. /**
  11112. * Tests the intersection of a sprite with a specific ray.
  11113. * @param ray The ray we are sending to test the collision
  11114. * @param camera The camera space we are sending rays in
  11115. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11116. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11117. * @returns picking info or null.
  11118. */
  11119. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11120. /**
  11121. * Intersects the sprites with a ray
  11122. * @param ray defines the ray to intersect with
  11123. * @param camera defines the current active camera
  11124. * @param predicate defines a predicate used to select candidate sprites
  11125. * @returns null if no hit or a PickingInfo array
  11126. */
  11127. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11128. /**
  11129. * Renders the list of sprites on screen.
  11130. */
  11131. render(): void;
  11132. }
  11133. /**
  11134. * Class used to manage multiple sprites on the same spritesheet
  11135. * @see https://doc.babylonjs.com/babylon101/sprites
  11136. */
  11137. export class SpriteManager implements ISpriteManager {
  11138. /** defines the manager's name */
  11139. name: string;
  11140. /** Define the Url to load snippets */
  11141. static SnippetUrl: string;
  11142. /** Snippet ID if the manager was created from the snippet server */
  11143. snippetId: string;
  11144. /** Gets the list of sprites */
  11145. sprites: Sprite[];
  11146. /** Gets or sets the rendering group id (0 by default) */
  11147. renderingGroupId: number;
  11148. /** Gets or sets camera layer mask */
  11149. layerMask: number;
  11150. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11151. fogEnabled: boolean;
  11152. /** Gets or sets a boolean indicating if the sprites are pickable */
  11153. isPickable: boolean;
  11154. /** Defines the default width of a cell in the spritesheet */
  11155. cellWidth: number;
  11156. /** Defines the default height of a cell in the spritesheet */
  11157. cellHeight: number;
  11158. /** Associative array from JSON sprite data file */
  11159. private _cellData;
  11160. /** Array of sprite names from JSON sprite data file */
  11161. private _spriteMap;
  11162. /** True when packed cell data from JSON file is ready*/
  11163. private _packedAndReady;
  11164. private _textureContent;
  11165. /**
  11166. * An event triggered when the manager is disposed.
  11167. */
  11168. onDisposeObservable: Observable<SpriteManager>;
  11169. private _onDisposeObserver;
  11170. /**
  11171. * Callback called when the manager is disposed
  11172. */
  11173. set onDispose(callback: () => void);
  11174. private _capacity;
  11175. private _fromPacked;
  11176. private _spriteTexture;
  11177. private _epsilon;
  11178. private _scene;
  11179. private _vertexData;
  11180. private _buffer;
  11181. private _vertexBuffers;
  11182. private _indexBuffer;
  11183. private _effectBase;
  11184. private _effectFog;
  11185. /**
  11186. * Gets or sets the unique id of the sprite
  11187. */
  11188. uniqueId: number;
  11189. /**
  11190. * Gets the array of sprites
  11191. */
  11192. get children(): Sprite[];
  11193. /**
  11194. * Gets the hosting scene
  11195. */
  11196. get scene(): Scene;
  11197. /**
  11198. * Gets the capacity of the manager
  11199. */
  11200. get capacity(): number;
  11201. /**
  11202. * Gets or sets the spritesheet texture
  11203. */
  11204. get texture(): Texture;
  11205. set texture(value: Texture);
  11206. private _blendMode;
  11207. /**
  11208. * Blend mode use to render the particle, it can be any of
  11209. * the static Constants.ALPHA_x properties provided in this class.
  11210. * Default value is Constants.ALPHA_COMBINE
  11211. */
  11212. get blendMode(): number;
  11213. set blendMode(blendMode: number);
  11214. /** Disables writing to the depth buffer when rendering the sprites.
  11215. * It can be handy to disable depth writing when using textures without alpha channel
  11216. * and setting some specific blend modes.
  11217. */
  11218. disableDepthWrite: boolean;
  11219. /**
  11220. * Creates a new sprite manager
  11221. * @param name defines the manager's name
  11222. * @param imgUrl defines the sprite sheet url
  11223. * @param capacity defines the maximum allowed number of sprites
  11224. * @param cellSize defines the size of a sprite cell
  11225. * @param scene defines the hosting scene
  11226. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11227. * @param samplingMode defines the smapling mode to use with spritesheet
  11228. * @param fromPacked set to false; do not alter
  11229. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11230. */
  11231. constructor(
  11232. /** defines the manager's name */
  11233. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11234. /**
  11235. * Returns the string "SpriteManager"
  11236. * @returns "SpriteManager"
  11237. */
  11238. getClassName(): string;
  11239. private _makePacked;
  11240. private _appendSpriteVertex;
  11241. private _checkTextureAlpha;
  11242. /**
  11243. * Intersects the sprites with a ray
  11244. * @param ray defines the ray to intersect with
  11245. * @param camera defines the current active camera
  11246. * @param predicate defines a predicate used to select candidate sprites
  11247. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11248. * @returns null if no hit or a PickingInfo
  11249. */
  11250. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11251. /**
  11252. * Intersects the sprites with a ray
  11253. * @param ray defines the ray to intersect with
  11254. * @param camera defines the current active camera
  11255. * @param predicate defines a predicate used to select candidate sprites
  11256. * @returns null if no hit or a PickingInfo array
  11257. */
  11258. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11259. /**
  11260. * Render all child sprites
  11261. */
  11262. render(): void;
  11263. /**
  11264. * Release associated resources
  11265. */
  11266. dispose(): void;
  11267. /**
  11268. * Serializes the sprite manager to a JSON object
  11269. * @param serializeTexture defines if the texture must be serialized as well
  11270. * @returns the JSON object
  11271. */
  11272. serialize(serializeTexture?: boolean): any;
  11273. /**
  11274. * Parses a JSON object to create a new sprite manager.
  11275. * @param parsedManager The JSON object to parse
  11276. * @param scene The scene to create the sprite managerin
  11277. * @param rootUrl The root url to use to load external dependencies like texture
  11278. * @returns the new sprite manager
  11279. */
  11280. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11281. /**
  11282. * Creates a sprite manager from a snippet saved in a remote file
  11283. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11284. * @param url defines the url to load from
  11285. * @param scene defines the hosting scene
  11286. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11287. * @returns a promise that will resolve to the new sprite manager
  11288. */
  11289. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11290. /**
  11291. * Creates a sprite manager from a snippet saved by the sprite editor
  11292. * @param snippetId defines the snippet to load
  11293. * @param scene defines the hosting scene
  11294. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11295. * @returns a promise that will resolve to the new sprite manager
  11296. */
  11297. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11298. }
  11299. }
  11300. declare module "babylonjs/Misc/gradients" {
  11301. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11302. /** Interface used by value gradients (color, factor, ...) */
  11303. export interface IValueGradient {
  11304. /**
  11305. * Gets or sets the gradient value (between 0 and 1)
  11306. */
  11307. gradient: number;
  11308. }
  11309. /** Class used to store color4 gradient */
  11310. export class ColorGradient implements IValueGradient {
  11311. /**
  11312. * Gets or sets the gradient value (between 0 and 1)
  11313. */
  11314. gradient: number;
  11315. /**
  11316. * Gets or sets first associated color
  11317. */
  11318. color1: Color4;
  11319. /**
  11320. * Gets or sets second associated color
  11321. */
  11322. color2?: Color4 | undefined;
  11323. /**
  11324. * Creates a new color4 gradient
  11325. * @param gradient gets or sets the gradient value (between 0 and 1)
  11326. * @param color1 gets or sets first associated color
  11327. * @param color2 gets or sets first second color
  11328. */
  11329. constructor(
  11330. /**
  11331. * Gets or sets the gradient value (between 0 and 1)
  11332. */
  11333. gradient: number,
  11334. /**
  11335. * Gets or sets first associated color
  11336. */
  11337. color1: Color4,
  11338. /**
  11339. * Gets or sets second associated color
  11340. */
  11341. color2?: Color4 | undefined);
  11342. /**
  11343. * Will get a color picked randomly between color1 and color2.
  11344. * If color2 is undefined then color1 will be used
  11345. * @param result defines the target Color4 to store the result in
  11346. */
  11347. getColorToRef(result: Color4): void;
  11348. }
  11349. /** Class used to store color 3 gradient */
  11350. export class Color3Gradient implements IValueGradient {
  11351. /**
  11352. * Gets or sets the gradient value (between 0 and 1)
  11353. */
  11354. gradient: number;
  11355. /**
  11356. * Gets or sets the associated color
  11357. */
  11358. color: Color3;
  11359. /**
  11360. * Creates a new color3 gradient
  11361. * @param gradient gets or sets the gradient value (between 0 and 1)
  11362. * @param color gets or sets associated color
  11363. */
  11364. constructor(
  11365. /**
  11366. * Gets or sets the gradient value (between 0 and 1)
  11367. */
  11368. gradient: number,
  11369. /**
  11370. * Gets or sets the associated color
  11371. */
  11372. color: Color3);
  11373. }
  11374. /** Class used to store factor gradient */
  11375. export class FactorGradient implements IValueGradient {
  11376. /**
  11377. * Gets or sets the gradient value (between 0 and 1)
  11378. */
  11379. gradient: number;
  11380. /**
  11381. * Gets or sets first associated factor
  11382. */
  11383. factor1: number;
  11384. /**
  11385. * Gets or sets second associated factor
  11386. */
  11387. factor2?: number | undefined;
  11388. /**
  11389. * Creates a new factor gradient
  11390. * @param gradient gets or sets the gradient value (between 0 and 1)
  11391. * @param factor1 gets or sets first associated factor
  11392. * @param factor2 gets or sets second associated factor
  11393. */
  11394. constructor(
  11395. /**
  11396. * Gets or sets the gradient value (between 0 and 1)
  11397. */
  11398. gradient: number,
  11399. /**
  11400. * Gets or sets first associated factor
  11401. */
  11402. factor1: number,
  11403. /**
  11404. * Gets or sets second associated factor
  11405. */
  11406. factor2?: number | undefined);
  11407. /**
  11408. * Will get a number picked randomly between factor1 and factor2.
  11409. * If factor2 is undefined then factor1 will be used
  11410. * @returns the picked number
  11411. */
  11412. getFactor(): number;
  11413. }
  11414. /**
  11415. * Helper used to simplify some generic gradient tasks
  11416. */
  11417. export class GradientHelper {
  11418. /**
  11419. * Gets the current gradient from an array of IValueGradient
  11420. * @param ratio defines the current ratio to get
  11421. * @param gradients defines the array of IValueGradient
  11422. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11423. */
  11424. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11425. }
  11426. }
  11427. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11428. import { Nullable } from "babylonjs/types";
  11429. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11430. import { Scene } from "babylonjs/scene";
  11431. module "babylonjs/Engines/thinEngine" {
  11432. interface ThinEngine {
  11433. /**
  11434. * Creates a raw texture
  11435. * @param data defines the data to store in the texture
  11436. * @param width defines the width of the texture
  11437. * @param height defines the height of the texture
  11438. * @param format defines the format of the data
  11439. * @param generateMipMaps defines if the engine should generate the mip levels
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11442. * @param compression defines the compression used (null by default)
  11443. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11444. * @returns the raw texture inside an InternalTexture
  11445. */
  11446. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11447. /**
  11448. * Update a raw texture
  11449. * @param texture defines the texture to update
  11450. * @param data defines the data to store in the texture
  11451. * @param format defines the format of the data
  11452. * @param invertY defines if data must be stored with Y axis inverted
  11453. */
  11454. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11455. /**
  11456. * Update a raw texture
  11457. * @param texture defines the texture to update
  11458. * @param data defines the data to store in the texture
  11459. * @param format defines the format of the data
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. * @param compression defines the compression used (null by default)
  11462. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11463. */
  11464. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11465. /**
  11466. * Creates a new raw cube texture
  11467. * @param data defines the array of data to use to create each face
  11468. * @param size defines the size of the textures
  11469. * @param format defines the format of the data
  11470. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11471. * @param generateMipMaps defines if the engine should generate the mip levels
  11472. * @param invertY defines if data must be stored with Y axis inverted
  11473. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11474. * @param compression defines the compression used (null by default)
  11475. * @returns the cube texture as an InternalTexture
  11476. */
  11477. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11478. /**
  11479. * Update a raw cube texture
  11480. * @param texture defines the texture to udpdate
  11481. * @param data defines the data to store
  11482. * @param format defines the data format
  11483. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11484. * @param invertY defines if data must be stored with Y axis inverted
  11485. */
  11486. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11487. /**
  11488. * Update a raw cube texture
  11489. * @param texture defines the texture to udpdate
  11490. * @param data defines the data to store
  11491. * @param format defines the data format
  11492. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11493. * @param invertY defines if data must be stored with Y axis inverted
  11494. * @param compression defines the compression used (null by default)
  11495. */
  11496. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11497. /**
  11498. * Update a raw cube texture
  11499. * @param texture defines the texture to udpdate
  11500. * @param data defines the data to store
  11501. * @param format defines the data format
  11502. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11503. * @param invertY defines if data must be stored with Y axis inverted
  11504. * @param compression defines the compression used (null by default)
  11505. * @param level defines which level of the texture to update
  11506. */
  11507. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11508. /**
  11509. * Creates a new raw cube texture from a specified url
  11510. * @param url defines the url where the data is located
  11511. * @param scene defines the current scene
  11512. * @param size defines the size of the textures
  11513. * @param format defines the format of the data
  11514. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11515. * @param noMipmap defines if the engine should avoid generating the mip levels
  11516. * @param callback defines a callback used to extract texture data from loaded data
  11517. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11518. * @param onLoad defines a callback called when texture is loaded
  11519. * @param onError defines a callback called if there is an error
  11520. * @returns the cube texture as an InternalTexture
  11521. */
  11522. 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;
  11523. /**
  11524. * Creates a new raw cube texture from a specified url
  11525. * @param url defines the url where the data is located
  11526. * @param scene defines the current scene
  11527. * @param size defines the size of the textures
  11528. * @param format defines the format of the data
  11529. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11530. * @param noMipmap defines if the engine should avoid generating the mip levels
  11531. * @param callback defines a callback used to extract texture data from loaded data
  11532. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11533. * @param onLoad defines a callback called when texture is loaded
  11534. * @param onError defines a callback called if there is an error
  11535. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11536. * @param invertY defines if data must be stored with Y axis inverted
  11537. * @returns the cube texture as an InternalTexture
  11538. */
  11539. 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;
  11540. /**
  11541. * Creates a new raw 3D texture
  11542. * @param data defines the data used to create the texture
  11543. * @param width defines the width of the texture
  11544. * @param height defines the height of the texture
  11545. * @param depth defines the depth of the texture
  11546. * @param format defines the format of the texture
  11547. * @param generateMipMaps defines if the engine must generate mip levels
  11548. * @param invertY defines if data must be stored with Y axis inverted
  11549. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11550. * @param compression defines the compressed used (can be null)
  11551. * @param textureType defines the compressed used (can be null)
  11552. * @returns a new raw 3D texture (stored in an InternalTexture)
  11553. */
  11554. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11555. /**
  11556. * Update a raw 3D texture
  11557. * @param texture defines the texture to update
  11558. * @param data defines the data to store
  11559. * @param format defines the data format
  11560. * @param invertY defines if data must be stored with Y axis inverted
  11561. */
  11562. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11563. /**
  11564. * Update a raw 3D texture
  11565. * @param texture defines the texture to update
  11566. * @param data defines the data to store
  11567. * @param format defines the data format
  11568. * @param invertY defines if data must be stored with Y axis inverted
  11569. * @param compression defines the used compression (can be null)
  11570. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11571. */
  11572. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11573. /**
  11574. * Creates a new raw 2D array texture
  11575. * @param data defines the data used to create the texture
  11576. * @param width defines the width of the texture
  11577. * @param height defines the height of the texture
  11578. * @param depth defines the number of layers of the texture
  11579. * @param format defines the format of the texture
  11580. * @param generateMipMaps defines if the engine must generate mip levels
  11581. * @param invertY defines if data must be stored with Y axis inverted
  11582. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11583. * @param compression defines the compressed used (can be null)
  11584. * @param textureType defines the compressed used (can be null)
  11585. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11586. */
  11587. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11588. /**
  11589. * Update a raw 2D array texture
  11590. * @param texture defines the texture to update
  11591. * @param data defines the data to store
  11592. * @param format defines the data format
  11593. * @param invertY defines if data must be stored with Y axis inverted
  11594. */
  11595. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11596. /**
  11597. * Update a raw 2D array texture
  11598. * @param texture defines the texture to update
  11599. * @param data defines the data to store
  11600. * @param format defines the data format
  11601. * @param invertY defines if data must be stored with Y axis inverted
  11602. * @param compression defines the used compression (can be null)
  11603. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11604. */
  11605. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11606. }
  11607. }
  11608. }
  11609. declare module "babylonjs/Materials/Textures/rawTexture" {
  11610. import { Scene } from "babylonjs/scene";
  11611. import { Texture } from "babylonjs/Materials/Textures/texture";
  11612. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11613. /**
  11614. * Raw texture can help creating a texture directly from an array of data.
  11615. * This can be super useful if you either get the data from an uncompressed source or
  11616. * if you wish to create your texture pixel by pixel.
  11617. */
  11618. export class RawTexture extends Texture {
  11619. /**
  11620. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11621. */
  11622. format: number;
  11623. /**
  11624. * Instantiates a new RawTexture.
  11625. * Raw texture can help creating a texture directly from an array of data.
  11626. * This can be super useful if you either get the data from an uncompressed source or
  11627. * if you wish to create your texture pixel by pixel.
  11628. * @param data define the array of data to use to create the texture
  11629. * @param width define the width of the texture
  11630. * @param height define the height of the texture
  11631. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11632. * @param scene define the scene the texture belongs to
  11633. * @param generateMipMaps define whether mip maps should be generated or not
  11634. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11635. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11636. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11637. */
  11638. constructor(data: ArrayBufferView, width: number, height: number,
  11639. /**
  11640. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11641. */
  11642. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11643. /**
  11644. * Updates the texture underlying data.
  11645. * @param data Define the new data of the texture
  11646. */
  11647. update(data: ArrayBufferView): void;
  11648. /**
  11649. * Creates a luminance texture from some data.
  11650. * @param data Define the texture data
  11651. * @param width Define the width of the texture
  11652. * @param height Define the height of the texture
  11653. * @param scene Define the scene the texture belongs to
  11654. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11655. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11656. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11657. * @returns the luminance texture
  11658. */
  11659. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11660. /**
  11661. * Creates a luminance alpha texture from some data.
  11662. * @param data Define the texture data
  11663. * @param width Define the width of the texture
  11664. * @param height Define the height of the texture
  11665. * @param scene Define the scene the texture belongs to
  11666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11669. * @returns the luminance alpha texture
  11670. */
  11671. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11672. /**
  11673. * Creates an alpha texture from some data.
  11674. * @param data Define the texture data
  11675. * @param width Define the width of the texture
  11676. * @param height Define the height of the texture
  11677. * @param scene Define the scene the texture belongs to
  11678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11681. * @returns the alpha texture
  11682. */
  11683. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11684. /**
  11685. * Creates a RGB texture from some data.
  11686. * @param data Define the texture data
  11687. * @param width Define the width of the texture
  11688. * @param height Define the height of the texture
  11689. * @param scene Define the scene the texture belongs to
  11690. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11691. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11692. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11693. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11694. * @returns the RGB alpha texture
  11695. */
  11696. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11697. /**
  11698. * Creates a RGBA texture from some data.
  11699. * @param data Define the texture data
  11700. * @param width Define the width of the texture
  11701. * @param height Define the height of the texture
  11702. * @param scene Define the scene the texture belongs to
  11703. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11704. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11705. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11706. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11707. * @returns the RGBA texture
  11708. */
  11709. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11710. /**
  11711. * Creates a R texture from some data.
  11712. * @param data Define the texture data
  11713. * @param width Define the width of the texture
  11714. * @param height Define the height of the texture
  11715. * @param scene Define the scene the texture belongs to
  11716. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11717. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11718. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11719. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11720. * @returns the R texture
  11721. */
  11722. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11723. }
  11724. }
  11725. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11726. import { Scene } from "babylonjs/scene";
  11727. import { ISceneComponent } from "babylonjs/sceneComponent";
  11728. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11729. module "babylonjs/abstractScene" {
  11730. interface AbstractScene {
  11731. /**
  11732. * The list of procedural textures added to the scene
  11733. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11734. */
  11735. proceduralTextures: Array<ProceduralTexture>;
  11736. }
  11737. }
  11738. /**
  11739. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11740. * in a given scene.
  11741. */
  11742. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11743. /**
  11744. * The component name helpfull to identify the component in the list of scene components.
  11745. */
  11746. readonly name: string;
  11747. /**
  11748. * The scene the component belongs to.
  11749. */
  11750. scene: Scene;
  11751. /**
  11752. * Creates a new instance of the component for the given scene
  11753. * @param scene Defines the scene to register the component in
  11754. */
  11755. constructor(scene: Scene);
  11756. /**
  11757. * Registers the component in a given scene
  11758. */
  11759. register(): void;
  11760. /**
  11761. * Rebuilds the elements related to this component in case of
  11762. * context lost for instance.
  11763. */
  11764. rebuild(): void;
  11765. /**
  11766. * Disposes the component and the associated ressources.
  11767. */
  11768. dispose(): void;
  11769. private _beforeClear;
  11770. }
  11771. }
  11772. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11773. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11774. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11775. module "babylonjs/Engines/thinEngine" {
  11776. interface ThinEngine {
  11777. /**
  11778. * Creates a new render target cube texture
  11779. * @param size defines the size of the texture
  11780. * @param options defines the options used to create the texture
  11781. * @returns a new render target cube texture stored in an InternalTexture
  11782. */
  11783. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11784. }
  11785. }
  11786. }
  11787. declare module "babylonjs/Shaders/procedural.vertex" {
  11788. /** @hidden */
  11789. export var proceduralVertexShader: {
  11790. name: string;
  11791. shader: string;
  11792. };
  11793. }
  11794. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11795. import { Observable } from "babylonjs/Misc/observable";
  11796. import { Nullable } from "babylonjs/types";
  11797. import { Scene } from "babylonjs/scene";
  11798. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11799. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11800. import { Effect } from "babylonjs/Materials/effect";
  11801. import { Texture } from "babylonjs/Materials/Textures/texture";
  11802. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11803. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11804. import "babylonjs/Shaders/procedural.vertex";
  11805. /**
  11806. * 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.
  11807. * This is the base class of any Procedural texture and contains most of the shareable code.
  11808. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11809. */
  11810. export class ProceduralTexture extends Texture {
  11811. isCube: boolean;
  11812. /**
  11813. * Define if the texture is enabled or not (disabled texture will not render)
  11814. */
  11815. isEnabled: boolean;
  11816. /**
  11817. * Define if the texture must be cleared before rendering (default is true)
  11818. */
  11819. autoClear: boolean;
  11820. /**
  11821. * Callback called when the texture is generated
  11822. */
  11823. onGenerated: () => void;
  11824. /**
  11825. * Event raised when the texture is generated
  11826. */
  11827. onGeneratedObservable: Observable<ProceduralTexture>;
  11828. /** @hidden */
  11829. _generateMipMaps: boolean;
  11830. /** @hidden **/
  11831. _effect: Effect;
  11832. /** @hidden */
  11833. _textures: {
  11834. [key: string]: Texture;
  11835. };
  11836. /** @hidden */
  11837. protected _fallbackTexture: Nullable<Texture>;
  11838. private _size;
  11839. private _currentRefreshId;
  11840. private _frameId;
  11841. private _refreshRate;
  11842. private _vertexBuffers;
  11843. private _indexBuffer;
  11844. private _uniforms;
  11845. private _samplers;
  11846. private _fragment;
  11847. private _floats;
  11848. private _ints;
  11849. private _floatsArrays;
  11850. private _colors3;
  11851. private _colors4;
  11852. private _vectors2;
  11853. private _vectors3;
  11854. private _matrices;
  11855. private _fallbackTextureUsed;
  11856. private _fullEngine;
  11857. private _cachedDefines;
  11858. private _contentUpdateId;
  11859. private _contentData;
  11860. /**
  11861. * Instantiates a new procedural texture.
  11862. * 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.
  11863. * This is the base class of any Procedural texture and contains most of the shareable code.
  11864. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11865. * @param name Define the name of the texture
  11866. * @param size Define the size of the texture to create
  11867. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11868. * @param scene Define the scene the texture belongs to
  11869. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11870. * @param generateMipMaps Define if the texture should creates mip maps or not
  11871. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11872. */
  11873. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11874. /**
  11875. * The effect that is created when initializing the post process.
  11876. * @returns The created effect corresponding the the postprocess.
  11877. */
  11878. getEffect(): Effect;
  11879. /**
  11880. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11881. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11882. */
  11883. getContent(): Nullable<ArrayBufferView>;
  11884. private _createIndexBuffer;
  11885. /** @hidden */
  11886. _rebuild(): void;
  11887. /**
  11888. * Resets the texture in order to recreate its associated resources.
  11889. * This can be called in case of context loss
  11890. */
  11891. reset(): void;
  11892. protected _getDefines(): string;
  11893. /**
  11894. * Is the texture ready to be used ? (rendered at least once)
  11895. * @returns true if ready, otherwise, false.
  11896. */
  11897. isReady(): boolean;
  11898. /**
  11899. * Resets the refresh counter of the texture and start bak from scratch.
  11900. * Could be useful to regenerate the texture if it is setup to render only once.
  11901. */
  11902. resetRefreshCounter(): void;
  11903. /**
  11904. * Set the fragment shader to use in order to render the texture.
  11905. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11906. */
  11907. setFragment(fragment: any): void;
  11908. /**
  11909. * Define the refresh rate of the texture or the rendering frequency.
  11910. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11911. */
  11912. get refreshRate(): number;
  11913. set refreshRate(value: number);
  11914. /** @hidden */
  11915. _shouldRender(): boolean;
  11916. /**
  11917. * Get the size the texture is rendering at.
  11918. * @returns the size (texture is always squared)
  11919. */
  11920. getRenderSize(): number;
  11921. /**
  11922. * Resize the texture to new value.
  11923. * @param size Define the new size the texture should have
  11924. * @param generateMipMaps Define whether the new texture should create mip maps
  11925. */
  11926. resize(size: number, generateMipMaps: boolean): void;
  11927. private _checkUniform;
  11928. /**
  11929. * Set a texture in the shader program used to render.
  11930. * @param name Define the name of the uniform samplers as defined in the shader
  11931. * @param texture Define the texture to bind to this sampler
  11932. * @return the texture itself allowing "fluent" like uniform updates
  11933. */
  11934. setTexture(name: string, texture: Texture): ProceduralTexture;
  11935. /**
  11936. * Set a float in the shader.
  11937. * @param name Define the name of the uniform as defined in the shader
  11938. * @param value Define the value to give to the uniform
  11939. * @return the texture itself allowing "fluent" like uniform updates
  11940. */
  11941. setFloat(name: string, value: number): ProceduralTexture;
  11942. /**
  11943. * Set a int in the shader.
  11944. * @param name Define the name of the uniform as defined in the shader
  11945. * @param value Define the value to give to the uniform
  11946. * @return the texture itself allowing "fluent" like uniform updates
  11947. */
  11948. setInt(name: string, value: number): ProceduralTexture;
  11949. /**
  11950. * Set an array of floats in the shader.
  11951. * @param name Define the name of the uniform as defined in the shader
  11952. * @param value Define the value to give to the uniform
  11953. * @return the texture itself allowing "fluent" like uniform updates
  11954. */
  11955. setFloats(name: string, value: number[]): ProceduralTexture;
  11956. /**
  11957. * Set a vec3 in the shader from a Color3.
  11958. * @param name Define the name of the uniform as defined in the shader
  11959. * @param value Define the value to give to the uniform
  11960. * @return the texture itself allowing "fluent" like uniform updates
  11961. */
  11962. setColor3(name: string, value: Color3): ProceduralTexture;
  11963. /**
  11964. * Set a vec4 in the shader from a Color4.
  11965. * @param name Define the name of the uniform as defined in the shader
  11966. * @param value Define the value to give to the uniform
  11967. * @return the texture itself allowing "fluent" like uniform updates
  11968. */
  11969. setColor4(name: string, value: Color4): ProceduralTexture;
  11970. /**
  11971. * Set a vec2 in the shader from a Vector2.
  11972. * @param name Define the name of the uniform as defined in the shader
  11973. * @param value Define the value to give to the uniform
  11974. * @return the texture itself allowing "fluent" like uniform updates
  11975. */
  11976. setVector2(name: string, value: Vector2): ProceduralTexture;
  11977. /**
  11978. * Set a vec3 in the shader from a Vector3.
  11979. * @param name Define the name of the uniform as defined in the shader
  11980. * @param value Define the value to give to the uniform
  11981. * @return the texture itself allowing "fluent" like uniform updates
  11982. */
  11983. setVector3(name: string, value: Vector3): ProceduralTexture;
  11984. /**
  11985. * Set a mat4 in the shader from a MAtrix.
  11986. * @param name Define the name of the uniform as defined in the shader
  11987. * @param value Define the value to give to the uniform
  11988. * @return the texture itself allowing "fluent" like uniform updates
  11989. */
  11990. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11991. /**
  11992. * Render the texture to its associated render target.
  11993. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11994. */
  11995. render(useCameraPostProcess?: boolean): void;
  11996. /**
  11997. * Clone the texture.
  11998. * @returns the cloned texture
  11999. */
  12000. clone(): ProceduralTexture;
  12001. /**
  12002. * Dispose the texture and release its asoociated resources.
  12003. */
  12004. dispose(): void;
  12005. }
  12006. }
  12007. declare module "babylonjs/Particles/baseParticleSystem" {
  12008. import { Nullable } from "babylonjs/types";
  12009. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12011. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12012. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12013. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12014. import { Scene } from "babylonjs/scene";
  12015. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12016. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12017. import { Texture } from "babylonjs/Materials/Textures/texture";
  12018. import { Color4 } from "babylonjs/Maths/math.color";
  12019. import { Animation } from "babylonjs/Animations/animation";
  12020. /**
  12021. * This represents the base class for particle system in Babylon.
  12022. * 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.
  12023. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12024. * @example https://doc.babylonjs.com/babylon101/particles
  12025. */
  12026. export class BaseParticleSystem {
  12027. /**
  12028. * Source color is added to the destination color without alpha affecting the result
  12029. */
  12030. static BLENDMODE_ONEONE: number;
  12031. /**
  12032. * Blend current color and particle color using particle’s alpha
  12033. */
  12034. static BLENDMODE_STANDARD: number;
  12035. /**
  12036. * Add current color and particle color multiplied by particle’s alpha
  12037. */
  12038. static BLENDMODE_ADD: number;
  12039. /**
  12040. * Multiply current color with particle color
  12041. */
  12042. static BLENDMODE_MULTIPLY: number;
  12043. /**
  12044. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12045. */
  12046. static BLENDMODE_MULTIPLYADD: number;
  12047. /**
  12048. * List of animations used by the particle system.
  12049. */
  12050. animations: Animation[];
  12051. /**
  12052. * Gets or sets the unique id of the particle system
  12053. */
  12054. uniqueId: number;
  12055. /**
  12056. * The id of the Particle system.
  12057. */
  12058. id: string;
  12059. /**
  12060. * The friendly name of the Particle system.
  12061. */
  12062. name: string;
  12063. /**
  12064. * Snippet ID if the particle system was created from the snippet server
  12065. */
  12066. snippetId: string;
  12067. /**
  12068. * The rendering group used by the Particle system to chose when to render.
  12069. */
  12070. renderingGroupId: number;
  12071. /**
  12072. * The emitter represents the Mesh or position we are attaching the particle system to.
  12073. */
  12074. emitter: Nullable<AbstractMesh | Vector3>;
  12075. /**
  12076. * The maximum number of particles to emit per frame
  12077. */
  12078. emitRate: number;
  12079. /**
  12080. * If you want to launch only a few particles at once, that can be done, as well.
  12081. */
  12082. manualEmitCount: number;
  12083. /**
  12084. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12085. */
  12086. updateSpeed: number;
  12087. /**
  12088. * The amount of time the particle system is running (depends of the overall update speed).
  12089. */
  12090. targetStopDuration: number;
  12091. /**
  12092. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12093. */
  12094. disposeOnStop: boolean;
  12095. /**
  12096. * Minimum power of emitting particles.
  12097. */
  12098. minEmitPower: number;
  12099. /**
  12100. * Maximum power of emitting particles.
  12101. */
  12102. maxEmitPower: number;
  12103. /**
  12104. * Minimum life time of emitting particles.
  12105. */
  12106. minLifeTime: number;
  12107. /**
  12108. * Maximum life time of emitting particles.
  12109. */
  12110. maxLifeTime: number;
  12111. /**
  12112. * Minimum Size of emitting particles.
  12113. */
  12114. minSize: number;
  12115. /**
  12116. * Maximum Size of emitting particles.
  12117. */
  12118. maxSize: number;
  12119. /**
  12120. * Minimum scale of emitting particles on X axis.
  12121. */
  12122. minScaleX: number;
  12123. /**
  12124. * Maximum scale of emitting particles on X axis.
  12125. */
  12126. maxScaleX: number;
  12127. /**
  12128. * Minimum scale of emitting particles on Y axis.
  12129. */
  12130. minScaleY: number;
  12131. /**
  12132. * Maximum scale of emitting particles on Y axis.
  12133. */
  12134. maxScaleY: number;
  12135. /**
  12136. * Gets or sets the minimal initial rotation in radians.
  12137. */
  12138. minInitialRotation: number;
  12139. /**
  12140. * Gets or sets the maximal initial rotation in radians.
  12141. */
  12142. maxInitialRotation: number;
  12143. /**
  12144. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12145. */
  12146. minAngularSpeed: number;
  12147. /**
  12148. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12149. */
  12150. maxAngularSpeed: number;
  12151. /**
  12152. * The texture used to render each particle. (this can be a spritesheet)
  12153. */
  12154. particleTexture: Nullable<Texture>;
  12155. /**
  12156. * The layer mask we are rendering the particles through.
  12157. */
  12158. layerMask: number;
  12159. /**
  12160. * This can help using your own shader to render the particle system.
  12161. * The according effect will be created
  12162. */
  12163. customShader: any;
  12164. /**
  12165. * By default particle system starts as soon as they are created. This prevents the
  12166. * automatic start to happen and let you decide when to start emitting particles.
  12167. */
  12168. preventAutoStart: boolean;
  12169. private _noiseTexture;
  12170. /**
  12171. * Gets or sets a texture used to add random noise to particle positions
  12172. */
  12173. get noiseTexture(): Nullable<ProceduralTexture>;
  12174. set noiseTexture(value: Nullable<ProceduralTexture>);
  12175. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12176. noiseStrength: Vector3;
  12177. /**
  12178. * Callback triggered when the particle animation is ending.
  12179. */
  12180. onAnimationEnd: Nullable<() => void>;
  12181. /**
  12182. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12183. */
  12184. blendMode: number;
  12185. /**
  12186. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12187. * to override the particles.
  12188. */
  12189. forceDepthWrite: boolean;
  12190. /** 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 */
  12191. preWarmCycles: number;
  12192. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12193. preWarmStepOffset: number;
  12194. /**
  12195. * 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)
  12196. */
  12197. spriteCellChangeSpeed: number;
  12198. /**
  12199. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12200. */
  12201. startSpriteCellID: number;
  12202. /**
  12203. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12204. */
  12205. endSpriteCellID: number;
  12206. /**
  12207. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12208. */
  12209. spriteCellWidth: number;
  12210. /**
  12211. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12212. */
  12213. spriteCellHeight: number;
  12214. /**
  12215. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12216. */
  12217. spriteRandomStartCell: boolean;
  12218. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12219. translationPivot: Vector2;
  12220. /** @hidden */
  12221. protected _isAnimationSheetEnabled: boolean;
  12222. /**
  12223. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12224. */
  12225. beginAnimationOnStart: boolean;
  12226. /**
  12227. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12228. */
  12229. beginAnimationFrom: number;
  12230. /**
  12231. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12232. */
  12233. beginAnimationTo: number;
  12234. /**
  12235. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12236. */
  12237. beginAnimationLoop: boolean;
  12238. /**
  12239. * Gets or sets a world offset applied to all particles
  12240. */
  12241. worldOffset: Vector3;
  12242. /**
  12243. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12244. */
  12245. get isAnimationSheetEnabled(): boolean;
  12246. set isAnimationSheetEnabled(value: boolean);
  12247. /**
  12248. * Get hosting scene
  12249. * @returns the scene
  12250. */
  12251. getScene(): Scene;
  12252. /**
  12253. * You can use gravity if you want to give an orientation to your particles.
  12254. */
  12255. gravity: Vector3;
  12256. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12257. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12258. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12259. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12260. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12261. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12262. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12263. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12264. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12265. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12266. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12267. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12268. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12269. /**
  12270. * Defines the delay in milliseconds before starting the system (0 by default)
  12271. */
  12272. startDelay: number;
  12273. /**
  12274. * Gets the current list of drag gradients.
  12275. * You must use addDragGradient and removeDragGradient to udpate this list
  12276. * @returns the list of drag gradients
  12277. */
  12278. getDragGradients(): Nullable<Array<FactorGradient>>;
  12279. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12280. limitVelocityDamping: number;
  12281. /**
  12282. * Gets the current list of limit velocity gradients.
  12283. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12284. * @returns the list of limit velocity gradients
  12285. */
  12286. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12287. /**
  12288. * Gets the current list of color gradients.
  12289. * You must use addColorGradient and removeColorGradient to udpate this list
  12290. * @returns the list of color gradients
  12291. */
  12292. getColorGradients(): Nullable<Array<ColorGradient>>;
  12293. /**
  12294. * Gets the current list of size gradients.
  12295. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12296. * @returns the list of size gradients
  12297. */
  12298. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12299. /**
  12300. * Gets the current list of color remap gradients.
  12301. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12302. * @returns the list of color remap gradients
  12303. */
  12304. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12305. /**
  12306. * Gets the current list of alpha remap gradients.
  12307. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12308. * @returns the list of alpha remap gradients
  12309. */
  12310. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12311. /**
  12312. * Gets the current list of life time gradients.
  12313. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12314. * @returns the list of life time gradients
  12315. */
  12316. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12317. /**
  12318. * Gets the current list of angular speed gradients.
  12319. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12320. * @returns the list of angular speed gradients
  12321. */
  12322. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12323. /**
  12324. * Gets the current list of velocity gradients.
  12325. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12326. * @returns the list of velocity gradients
  12327. */
  12328. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12329. /**
  12330. * Gets the current list of start size gradients.
  12331. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12332. * @returns the list of start size gradients
  12333. */
  12334. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12335. /**
  12336. * Gets the current list of emit rate gradients.
  12337. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12338. * @returns the list of emit rate gradients
  12339. */
  12340. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12341. /**
  12342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12343. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12344. */
  12345. get direction1(): Vector3;
  12346. set direction1(value: Vector3);
  12347. /**
  12348. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12349. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12350. */
  12351. get direction2(): Vector3;
  12352. set direction2(value: Vector3);
  12353. /**
  12354. * 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.
  12355. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12356. */
  12357. get minEmitBox(): Vector3;
  12358. set minEmitBox(value: Vector3);
  12359. /**
  12360. * 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.
  12361. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12362. */
  12363. get maxEmitBox(): Vector3;
  12364. set maxEmitBox(value: Vector3);
  12365. /**
  12366. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12367. */
  12368. color1: Color4;
  12369. /**
  12370. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12371. */
  12372. color2: Color4;
  12373. /**
  12374. * Color the particle will have at the end of its lifetime
  12375. */
  12376. colorDead: Color4;
  12377. /**
  12378. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12379. */
  12380. textureMask: Color4;
  12381. /**
  12382. * The particle emitter type defines the emitter used by the particle system.
  12383. * It can be for example box, sphere, or cone...
  12384. */
  12385. particleEmitterType: IParticleEmitterType;
  12386. /** @hidden */
  12387. _isSubEmitter: boolean;
  12388. /**
  12389. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12390. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12391. */
  12392. billboardMode: number;
  12393. protected _isBillboardBased: boolean;
  12394. /**
  12395. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12396. */
  12397. get isBillboardBased(): boolean;
  12398. set isBillboardBased(value: boolean);
  12399. /**
  12400. * The scene the particle system belongs to.
  12401. */
  12402. protected _scene: Scene;
  12403. /**
  12404. * Local cache of defines for image processing.
  12405. */
  12406. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12407. /**
  12408. * Default configuration related to image processing available in the standard Material.
  12409. */
  12410. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12411. /**
  12412. * Gets the image processing configuration used either in this material.
  12413. */
  12414. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12415. /**
  12416. * Sets the Default image processing configuration used either in the this material.
  12417. *
  12418. * If sets to null, the scene one is in use.
  12419. */
  12420. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12421. /**
  12422. * Attaches a new image processing configuration to the Standard Material.
  12423. * @param configuration
  12424. */
  12425. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12426. /** @hidden */
  12427. protected _reset(): void;
  12428. /** @hidden */
  12429. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12430. /**
  12431. * Instantiates a particle system.
  12432. * 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.
  12433. * @param name The name of the particle system
  12434. */
  12435. constructor(name: string);
  12436. /**
  12437. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12438. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12439. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12440. * @returns the emitter
  12441. */
  12442. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12443. /**
  12444. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12445. * @param radius The radius of the hemisphere to emit from
  12446. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12447. * @returns the emitter
  12448. */
  12449. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12450. /**
  12451. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12452. * @param radius The radius of the sphere to emit from
  12453. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12454. * @returns the emitter
  12455. */
  12456. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12457. /**
  12458. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12459. * @param radius The radius of the sphere to emit from
  12460. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12461. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12462. * @returns the emitter
  12463. */
  12464. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12465. /**
  12466. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12467. * @param radius The radius of the emission cylinder
  12468. * @param height The height of the emission cylinder
  12469. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12470. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12471. * @returns the emitter
  12472. */
  12473. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12474. /**
  12475. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12476. * @param radius The radius of the cylinder to emit from
  12477. * @param height The height of the emission cylinder
  12478. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12479. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12480. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12481. * @returns the emitter
  12482. */
  12483. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12484. /**
  12485. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12486. * @param radius The radius of the cone to emit from
  12487. * @param angle The base angle of the cone
  12488. * @returns the emitter
  12489. */
  12490. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12491. /**
  12492. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12493. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12494. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12495. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12496. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12497. * @returns the emitter
  12498. */
  12499. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12500. }
  12501. }
  12502. declare module "babylonjs/Particles/subEmitter" {
  12503. import { Scene } from "babylonjs/scene";
  12504. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12505. /**
  12506. * Type of sub emitter
  12507. */
  12508. export enum SubEmitterType {
  12509. /**
  12510. * Attached to the particle over it's lifetime
  12511. */
  12512. ATTACHED = 0,
  12513. /**
  12514. * Created when the particle dies
  12515. */
  12516. END = 1
  12517. }
  12518. /**
  12519. * Sub emitter class used to emit particles from an existing particle
  12520. */
  12521. export class SubEmitter {
  12522. /**
  12523. * the particle system to be used by the sub emitter
  12524. */
  12525. particleSystem: ParticleSystem;
  12526. /**
  12527. * Type of the submitter (Default: END)
  12528. */
  12529. type: SubEmitterType;
  12530. /**
  12531. * 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)
  12532. * Note: This only is supported when using an emitter of type Mesh
  12533. */
  12534. inheritDirection: boolean;
  12535. /**
  12536. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12537. */
  12538. inheritedVelocityAmount: number;
  12539. /**
  12540. * Creates a sub emitter
  12541. * @param particleSystem the particle system to be used by the sub emitter
  12542. */
  12543. constructor(
  12544. /**
  12545. * the particle system to be used by the sub emitter
  12546. */
  12547. particleSystem: ParticleSystem);
  12548. /**
  12549. * Clones the sub emitter
  12550. * @returns the cloned sub emitter
  12551. */
  12552. clone(): SubEmitter;
  12553. /**
  12554. * Serialize current object to a JSON object
  12555. * @returns the serialized object
  12556. */
  12557. serialize(): any;
  12558. /** @hidden */
  12559. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12560. /**
  12561. * Creates a new SubEmitter from a serialized JSON version
  12562. * @param serializationObject defines the JSON object to read from
  12563. * @param scene defines the hosting scene
  12564. * @param rootUrl defines the rootUrl for data loading
  12565. * @returns a new SubEmitter
  12566. */
  12567. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12568. /** Release associated resources */
  12569. dispose(): void;
  12570. }
  12571. }
  12572. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12573. /** @hidden */
  12574. export var imageProcessingDeclaration: {
  12575. name: string;
  12576. shader: string;
  12577. };
  12578. }
  12579. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12580. /** @hidden */
  12581. export var imageProcessingFunctions: {
  12582. name: string;
  12583. shader: string;
  12584. };
  12585. }
  12586. declare module "babylonjs/Shaders/particles.fragment" {
  12587. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12588. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12589. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12590. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12591. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12592. /** @hidden */
  12593. export var particlesPixelShader: {
  12594. name: string;
  12595. shader: string;
  12596. };
  12597. }
  12598. declare module "babylonjs/Shaders/particles.vertex" {
  12599. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12600. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12601. /** @hidden */
  12602. export var particlesVertexShader: {
  12603. name: string;
  12604. shader: string;
  12605. };
  12606. }
  12607. declare module "babylonjs/Particles/particleSystem" {
  12608. import { Nullable } from "babylonjs/types";
  12609. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12610. import { Observable } from "babylonjs/Misc/observable";
  12611. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12612. import { Effect } from "babylonjs/Materials/effect";
  12613. import { Scene, IDisposable } from "babylonjs/scene";
  12614. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12615. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12616. import { Particle } from "babylonjs/Particles/particle";
  12617. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12618. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12619. import "babylonjs/Shaders/particles.fragment";
  12620. import "babylonjs/Shaders/particles.vertex";
  12621. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12622. /**
  12623. * This represents a particle system in Babylon.
  12624. * 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.
  12625. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12626. * @example https://doc.babylonjs.com/babylon101/particles
  12627. */
  12628. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12629. /**
  12630. * Billboard mode will only apply to Y axis
  12631. */
  12632. static readonly BILLBOARDMODE_Y: number;
  12633. /**
  12634. * Billboard mode will apply to all axes
  12635. */
  12636. static readonly BILLBOARDMODE_ALL: number;
  12637. /**
  12638. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12639. */
  12640. static readonly BILLBOARDMODE_STRETCHED: number;
  12641. /**
  12642. * This function can be defined to provide custom update for active particles.
  12643. * This function will be called instead of regular update (age, position, color, etc.).
  12644. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12645. */
  12646. updateFunction: (particles: Particle[]) => void;
  12647. private _emitterWorldMatrix;
  12648. /**
  12649. * This function can be defined to specify initial direction for every new particle.
  12650. * It by default use the emitterType defined function
  12651. */
  12652. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12653. /**
  12654. * This function can be defined to specify initial position for every new particle.
  12655. * It by default use the emitterType defined function
  12656. */
  12657. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12658. /**
  12659. * @hidden
  12660. */
  12661. _inheritedVelocityOffset: Vector3;
  12662. /**
  12663. * An event triggered when the system is disposed
  12664. */
  12665. onDisposeObservable: Observable<IParticleSystem>;
  12666. private _onDisposeObserver;
  12667. /**
  12668. * Sets a callback that will be triggered when the system is disposed
  12669. */
  12670. set onDispose(callback: () => void);
  12671. private _particles;
  12672. private _epsilon;
  12673. private _capacity;
  12674. private _stockParticles;
  12675. private _newPartsExcess;
  12676. private _vertexData;
  12677. private _vertexBuffer;
  12678. private _vertexBuffers;
  12679. private _spriteBuffer;
  12680. private _indexBuffer;
  12681. private _effect;
  12682. private _customEffect;
  12683. private _cachedDefines;
  12684. private _scaledColorStep;
  12685. private _colorDiff;
  12686. private _scaledDirection;
  12687. private _scaledGravity;
  12688. private _currentRenderId;
  12689. private _alive;
  12690. private _useInstancing;
  12691. private _started;
  12692. private _stopped;
  12693. private _actualFrame;
  12694. private _scaledUpdateSpeed;
  12695. private _vertexBufferSize;
  12696. /** @hidden */
  12697. _currentEmitRateGradient: Nullable<FactorGradient>;
  12698. /** @hidden */
  12699. _currentEmitRate1: number;
  12700. /** @hidden */
  12701. _currentEmitRate2: number;
  12702. /** @hidden */
  12703. _currentStartSizeGradient: Nullable<FactorGradient>;
  12704. /** @hidden */
  12705. _currentStartSize1: number;
  12706. /** @hidden */
  12707. _currentStartSize2: number;
  12708. private readonly _rawTextureWidth;
  12709. private _rampGradientsTexture;
  12710. private _useRampGradients;
  12711. /** Gets or sets a boolean indicating that ramp gradients must be used
  12712. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12713. */
  12714. get useRampGradients(): boolean;
  12715. set useRampGradients(value: boolean);
  12716. /**
  12717. * 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.
  12718. * 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: [])
  12719. */
  12720. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12721. private _subEmitters;
  12722. /**
  12723. * @hidden
  12724. * If the particle systems emitter should be disposed when the particle system is disposed
  12725. */
  12726. _disposeEmitterOnDispose: boolean;
  12727. /**
  12728. * The current active Sub-systems, this property is used by the root particle system only.
  12729. */
  12730. activeSubSystems: Array<ParticleSystem>;
  12731. /**
  12732. * Specifies if the particles are updated in emitter local space or world space
  12733. */
  12734. isLocal: boolean;
  12735. private _rootParticleSystem;
  12736. /**
  12737. * Gets the current list of active particles
  12738. */
  12739. get particles(): Particle[];
  12740. /**
  12741. * Gets the number of particles active at the same time.
  12742. * @returns The number of active particles.
  12743. */
  12744. getActiveCount(): number;
  12745. /**
  12746. * Returns the string "ParticleSystem"
  12747. * @returns a string containing the class name
  12748. */
  12749. getClassName(): string;
  12750. /**
  12751. * Gets a boolean indicating that the system is stopping
  12752. * @returns true if the system is currently stopping
  12753. */
  12754. isStopping(): boolean;
  12755. /**
  12756. * Gets the custom effect used to render the particles
  12757. * @param blendMode Blend mode for which the effect should be retrieved
  12758. * @returns The effect
  12759. */
  12760. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12761. /**
  12762. * Sets the custom effect used to render the particles
  12763. * @param effect The effect to set
  12764. * @param blendMode Blend mode for which the effect should be set
  12765. */
  12766. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12767. /** @hidden */
  12768. private _onBeforeDrawParticlesObservable;
  12769. /**
  12770. * Observable that will be called just before the particles are drawn
  12771. */
  12772. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12773. /**
  12774. * Gets the name of the particle vertex shader
  12775. */
  12776. get vertexShaderName(): string;
  12777. /**
  12778. * Instantiates a particle system.
  12779. * 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.
  12780. * @param name The name of the particle system
  12781. * @param capacity The max number of particles alive at the same time
  12782. * @param scene The scene the particle system belongs to
  12783. * @param customEffect a custom effect used to change the way particles are rendered by default
  12784. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12785. * @param epsilon Offset used to render the particles
  12786. */
  12787. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12788. private _addFactorGradient;
  12789. private _removeFactorGradient;
  12790. /**
  12791. * Adds a new life time gradient
  12792. * @param gradient defines the gradient to use (between 0 and 1)
  12793. * @param factor defines the life time factor to affect to the specified gradient
  12794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12795. * @returns the current particle system
  12796. */
  12797. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12798. /**
  12799. * Remove a specific life time gradient
  12800. * @param gradient defines the gradient to remove
  12801. * @returns the current particle system
  12802. */
  12803. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12804. /**
  12805. * Adds a new size gradient
  12806. * @param gradient defines the gradient to use (between 0 and 1)
  12807. * @param factor defines the size factor to affect to the specified gradient
  12808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12809. * @returns the current particle system
  12810. */
  12811. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12812. /**
  12813. * Remove a specific size gradient
  12814. * @param gradient defines the gradient to remove
  12815. * @returns the current particle system
  12816. */
  12817. removeSizeGradient(gradient: number): IParticleSystem;
  12818. /**
  12819. * Adds a new color remap gradient
  12820. * @param gradient defines the gradient to use (between 0 and 1)
  12821. * @param min defines the color remap minimal range
  12822. * @param max defines the color remap maximal range
  12823. * @returns the current particle system
  12824. */
  12825. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12826. /**
  12827. * Remove a specific color remap gradient
  12828. * @param gradient defines the gradient to remove
  12829. * @returns the current particle system
  12830. */
  12831. removeColorRemapGradient(gradient: number): IParticleSystem;
  12832. /**
  12833. * Adds a new alpha remap gradient
  12834. * @param gradient defines the gradient to use (between 0 and 1)
  12835. * @param min defines the alpha remap minimal range
  12836. * @param max defines the alpha remap maximal range
  12837. * @returns the current particle system
  12838. */
  12839. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12840. /**
  12841. * Remove a specific alpha remap gradient
  12842. * @param gradient defines the gradient to remove
  12843. * @returns the current particle system
  12844. */
  12845. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12846. /**
  12847. * Adds a new angular speed gradient
  12848. * @param gradient defines the gradient to use (between 0 and 1)
  12849. * @param factor defines the angular speed to affect to the specified gradient
  12850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12851. * @returns the current particle system
  12852. */
  12853. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12854. /**
  12855. * Remove a specific angular speed gradient
  12856. * @param gradient defines the gradient to remove
  12857. * @returns the current particle system
  12858. */
  12859. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12860. /**
  12861. * Adds a new velocity gradient
  12862. * @param gradient defines the gradient to use (between 0 and 1)
  12863. * @param factor defines the velocity to affect to the specified gradient
  12864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12865. * @returns the current particle system
  12866. */
  12867. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12868. /**
  12869. * Remove a specific velocity gradient
  12870. * @param gradient defines the gradient to remove
  12871. * @returns the current particle system
  12872. */
  12873. removeVelocityGradient(gradient: number): IParticleSystem;
  12874. /**
  12875. * Adds a new limit velocity gradient
  12876. * @param gradient defines the gradient to use (between 0 and 1)
  12877. * @param factor defines the limit velocity value to affect to the specified gradient
  12878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12879. * @returns the current particle system
  12880. */
  12881. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12882. /**
  12883. * Remove a specific limit velocity gradient
  12884. * @param gradient defines the gradient to remove
  12885. * @returns the current particle system
  12886. */
  12887. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12888. /**
  12889. * Adds a new drag gradient
  12890. * @param gradient defines the gradient to use (between 0 and 1)
  12891. * @param factor defines the drag value to affect to the specified gradient
  12892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12893. * @returns the current particle system
  12894. */
  12895. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12896. /**
  12897. * Remove a specific drag gradient
  12898. * @param gradient defines the gradient to remove
  12899. * @returns the current particle system
  12900. */
  12901. removeDragGradient(gradient: number): IParticleSystem;
  12902. /**
  12903. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12904. * @param gradient defines the gradient to use (between 0 and 1)
  12905. * @param factor defines the emit rate value to affect to the specified gradient
  12906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12907. * @returns the current particle system
  12908. */
  12909. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12910. /**
  12911. * Remove a specific emit rate gradient
  12912. * @param gradient defines the gradient to remove
  12913. * @returns the current particle system
  12914. */
  12915. removeEmitRateGradient(gradient: number): IParticleSystem;
  12916. /**
  12917. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12918. * @param gradient defines the gradient to use (between 0 and 1)
  12919. * @param factor defines the start size value to affect to the specified gradient
  12920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12921. * @returns the current particle system
  12922. */
  12923. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12924. /**
  12925. * Remove a specific start size gradient
  12926. * @param gradient defines the gradient to remove
  12927. * @returns the current particle system
  12928. */
  12929. removeStartSizeGradient(gradient: number): IParticleSystem;
  12930. private _createRampGradientTexture;
  12931. /**
  12932. * Gets the current list of ramp gradients.
  12933. * You must use addRampGradient and removeRampGradient to udpate this list
  12934. * @returns the list of ramp gradients
  12935. */
  12936. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12937. /** Force the system to rebuild all gradients that need to be resync */
  12938. forceRefreshGradients(): void;
  12939. private _syncRampGradientTexture;
  12940. /**
  12941. * Adds a new ramp gradient used to remap particle colors
  12942. * @param gradient defines the gradient to use (between 0 and 1)
  12943. * @param color defines the color to affect to the specified gradient
  12944. * @returns the current particle system
  12945. */
  12946. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12947. /**
  12948. * Remove a specific ramp gradient
  12949. * @param gradient defines the gradient to remove
  12950. * @returns the current particle system
  12951. */
  12952. removeRampGradient(gradient: number): ParticleSystem;
  12953. /**
  12954. * Adds a new color gradient
  12955. * @param gradient defines the gradient to use (between 0 and 1)
  12956. * @param color1 defines the color to affect to the specified gradient
  12957. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12958. * @returns this particle system
  12959. */
  12960. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12961. /**
  12962. * Remove a specific color gradient
  12963. * @param gradient defines the gradient to remove
  12964. * @returns this particle system
  12965. */
  12966. removeColorGradient(gradient: number): IParticleSystem;
  12967. private _fetchR;
  12968. protected _reset(): void;
  12969. private _resetEffect;
  12970. private _createVertexBuffers;
  12971. private _createIndexBuffer;
  12972. /**
  12973. * Gets the maximum number of particles active at the same time.
  12974. * @returns The max number of active particles.
  12975. */
  12976. getCapacity(): number;
  12977. /**
  12978. * Gets whether there are still active particles in the system.
  12979. * @returns True if it is alive, otherwise false.
  12980. */
  12981. isAlive(): boolean;
  12982. /**
  12983. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12984. * @returns True if it has been started, otherwise false.
  12985. */
  12986. isStarted(): boolean;
  12987. private _prepareSubEmitterInternalArray;
  12988. /**
  12989. * Starts the particle system and begins to emit
  12990. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12991. */
  12992. start(delay?: number): void;
  12993. /**
  12994. * Stops the particle system.
  12995. * @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.
  12996. */
  12997. stop(stopSubEmitters?: boolean): void;
  12998. /**
  12999. * Remove all active particles
  13000. */
  13001. reset(): void;
  13002. /**
  13003. * @hidden (for internal use only)
  13004. */
  13005. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13006. /**
  13007. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13008. * Its lifetime will start back at 0.
  13009. */
  13010. recycleParticle: (particle: Particle) => void;
  13011. private _stopSubEmitters;
  13012. private _createParticle;
  13013. private _removeFromRoot;
  13014. private _emitFromParticle;
  13015. private _update;
  13016. /** @hidden */
  13017. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13018. /** @hidden */
  13019. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13020. /**
  13021. * Fill the defines array according to the current settings of the particle system
  13022. * @param defines Array to be updated
  13023. * @param blendMode blend mode to take into account when updating the array
  13024. */
  13025. fillDefines(defines: Array<string>, blendMode: number): void;
  13026. /**
  13027. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13028. * @param uniforms Uniforms array to fill
  13029. * @param attributes Attributes array to fill
  13030. * @param samplers Samplers array to fill
  13031. */
  13032. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13033. /** @hidden */
  13034. private _getEffect;
  13035. /**
  13036. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13037. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13038. */
  13039. animate(preWarmOnly?: boolean): void;
  13040. private _appendParticleVertices;
  13041. /**
  13042. * Rebuilds the particle system.
  13043. */
  13044. rebuild(): void;
  13045. /**
  13046. * Is this system ready to be used/rendered
  13047. * @return true if the system is ready
  13048. */
  13049. isReady(): boolean;
  13050. private _render;
  13051. /**
  13052. * Renders the particle system in its current state.
  13053. * @returns the current number of particles
  13054. */
  13055. render(): number;
  13056. /**
  13057. * Disposes the particle system and free the associated resources
  13058. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13059. */
  13060. dispose(disposeTexture?: boolean): void;
  13061. /**
  13062. * Clones the particle system.
  13063. * @param name The name of the cloned object
  13064. * @param newEmitter The new emitter to use
  13065. * @returns the cloned particle system
  13066. */
  13067. clone(name: string, newEmitter: any): ParticleSystem;
  13068. /**
  13069. * Serializes the particle system to a JSON object
  13070. * @param serializeTexture defines if the texture must be serialized as well
  13071. * @returns the JSON object
  13072. */
  13073. serialize(serializeTexture?: boolean): any;
  13074. /** @hidden */
  13075. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13076. /** @hidden */
  13077. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13078. /**
  13079. * Parses a JSON object to create a particle system.
  13080. * @param parsedParticleSystem The JSON object to parse
  13081. * @param scene The scene to create the particle system in
  13082. * @param rootUrl The root url to use to load external dependencies like texture
  13083. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13084. * @returns the Parsed particle system
  13085. */
  13086. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13087. }
  13088. }
  13089. declare module "babylonjs/Particles/particle" {
  13090. import { Nullable } from "babylonjs/types";
  13091. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13092. import { Color4 } from "babylonjs/Maths/math.color";
  13093. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13094. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13095. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13096. /**
  13097. * A particle represents one of the element emitted by a particle system.
  13098. * This is mainly define by its coordinates, direction, velocity and age.
  13099. */
  13100. export class Particle {
  13101. /**
  13102. * The particle system the particle belongs to.
  13103. */
  13104. particleSystem: ParticleSystem;
  13105. private static _Count;
  13106. /**
  13107. * Unique ID of the particle
  13108. */
  13109. id: number;
  13110. /**
  13111. * The world position of the particle in the scene.
  13112. */
  13113. position: Vector3;
  13114. /**
  13115. * The world direction of the particle in the scene.
  13116. */
  13117. direction: Vector3;
  13118. /**
  13119. * The color of the particle.
  13120. */
  13121. color: Color4;
  13122. /**
  13123. * The color change of the particle per step.
  13124. */
  13125. colorStep: Color4;
  13126. /**
  13127. * Defines how long will the life of the particle be.
  13128. */
  13129. lifeTime: number;
  13130. /**
  13131. * The current age of the particle.
  13132. */
  13133. age: number;
  13134. /**
  13135. * The current size of the particle.
  13136. */
  13137. size: number;
  13138. /**
  13139. * The current scale of the particle.
  13140. */
  13141. scale: Vector2;
  13142. /**
  13143. * The current angle of the particle.
  13144. */
  13145. angle: number;
  13146. /**
  13147. * Defines how fast is the angle changing.
  13148. */
  13149. angularSpeed: number;
  13150. /**
  13151. * Defines the cell index used by the particle to be rendered from a sprite.
  13152. */
  13153. cellIndex: number;
  13154. /**
  13155. * The information required to support color remapping
  13156. */
  13157. remapData: Vector4;
  13158. /** @hidden */
  13159. _randomCellOffset?: number;
  13160. /** @hidden */
  13161. _initialDirection: Nullable<Vector3>;
  13162. /** @hidden */
  13163. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13164. /** @hidden */
  13165. _initialStartSpriteCellID: number;
  13166. /** @hidden */
  13167. _initialEndSpriteCellID: number;
  13168. /** @hidden */
  13169. _currentColorGradient: Nullable<ColorGradient>;
  13170. /** @hidden */
  13171. _currentColor1: Color4;
  13172. /** @hidden */
  13173. _currentColor2: Color4;
  13174. /** @hidden */
  13175. _currentSizeGradient: Nullable<FactorGradient>;
  13176. /** @hidden */
  13177. _currentSize1: number;
  13178. /** @hidden */
  13179. _currentSize2: number;
  13180. /** @hidden */
  13181. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13182. /** @hidden */
  13183. _currentAngularSpeed1: number;
  13184. /** @hidden */
  13185. _currentAngularSpeed2: number;
  13186. /** @hidden */
  13187. _currentVelocityGradient: Nullable<FactorGradient>;
  13188. /** @hidden */
  13189. _currentVelocity1: number;
  13190. /** @hidden */
  13191. _currentVelocity2: number;
  13192. /** @hidden */
  13193. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13194. /** @hidden */
  13195. _currentLimitVelocity1: number;
  13196. /** @hidden */
  13197. _currentLimitVelocity2: number;
  13198. /** @hidden */
  13199. _currentDragGradient: Nullable<FactorGradient>;
  13200. /** @hidden */
  13201. _currentDrag1: number;
  13202. /** @hidden */
  13203. _currentDrag2: number;
  13204. /** @hidden */
  13205. _randomNoiseCoordinates1: Vector3;
  13206. /** @hidden */
  13207. _randomNoiseCoordinates2: Vector3;
  13208. /** @hidden */
  13209. _localPosition?: Vector3;
  13210. /**
  13211. * Creates a new instance Particle
  13212. * @param particleSystem the particle system the particle belongs to
  13213. */
  13214. constructor(
  13215. /**
  13216. * The particle system the particle belongs to.
  13217. */
  13218. particleSystem: ParticleSystem);
  13219. private updateCellInfoFromSystem;
  13220. /**
  13221. * Defines how the sprite cell index is updated for the particle
  13222. */
  13223. updateCellIndex(): void;
  13224. /** @hidden */
  13225. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13226. /** @hidden */
  13227. _inheritParticleInfoToSubEmitters(): void;
  13228. /** @hidden */
  13229. _reset(): void;
  13230. /**
  13231. * Copy the properties of particle to another one.
  13232. * @param other the particle to copy the information to.
  13233. */
  13234. copyTo(other: Particle): void;
  13235. }
  13236. }
  13237. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13238. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13239. import { Effect } from "babylonjs/Materials/effect";
  13240. import { Particle } from "babylonjs/Particles/particle";
  13241. import { Scene } from "babylonjs/scene";
  13242. /**
  13243. * Particle emitter represents a volume emitting particles.
  13244. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13245. */
  13246. export interface IParticleEmitterType {
  13247. /**
  13248. * Called by the particle System when the direction is computed for the created particle.
  13249. * @param worldMatrix is the world matrix of the particle system
  13250. * @param directionToUpdate is the direction vector to update with the result
  13251. * @param particle is the particle we are computed the direction for
  13252. * @param isLocal defines if the direction should be set in local space
  13253. */
  13254. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13255. /**
  13256. * Called by the particle System when the position is computed for the created particle.
  13257. * @param worldMatrix is the world matrix of the particle system
  13258. * @param positionToUpdate is the position vector to update with the result
  13259. * @param particle is the particle we are computed the position for
  13260. * @param isLocal defines if the position should be set in local space
  13261. */
  13262. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13263. /**
  13264. * Clones the current emitter and returns a copy of it
  13265. * @returns the new emitter
  13266. */
  13267. clone(): IParticleEmitterType;
  13268. /**
  13269. * Called by the GPUParticleSystem to setup the update shader
  13270. * @param effect defines the update shader
  13271. */
  13272. applyToShader(effect: Effect): void;
  13273. /**
  13274. * Returns a string to use to update the GPU particles update shader
  13275. * @returns the effect defines string
  13276. */
  13277. getEffectDefines(): string;
  13278. /**
  13279. * Returns a string representing the class name
  13280. * @returns a string containing the class name
  13281. */
  13282. getClassName(): string;
  13283. /**
  13284. * Serializes the particle system to a JSON object.
  13285. * @returns the JSON object
  13286. */
  13287. serialize(): any;
  13288. /**
  13289. * Parse properties from a JSON object
  13290. * @param serializationObject defines the JSON object
  13291. * @param scene defines the hosting scene
  13292. */
  13293. parse(serializationObject: any, scene: Scene): void;
  13294. }
  13295. }
  13296. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13297. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13298. import { Effect } from "babylonjs/Materials/effect";
  13299. import { Particle } from "babylonjs/Particles/particle";
  13300. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13301. /**
  13302. * Particle emitter emitting particles from the inside of a box.
  13303. * It emits the particles randomly between 2 given directions.
  13304. */
  13305. export class BoxParticleEmitter implements IParticleEmitterType {
  13306. /**
  13307. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13308. */
  13309. direction1: Vector3;
  13310. /**
  13311. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13312. */
  13313. direction2: Vector3;
  13314. /**
  13315. * 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.
  13316. */
  13317. minEmitBox: Vector3;
  13318. /**
  13319. * 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.
  13320. */
  13321. maxEmitBox: Vector3;
  13322. /**
  13323. * Creates a new instance BoxParticleEmitter
  13324. */
  13325. constructor();
  13326. /**
  13327. * Called by the particle System when the direction is computed for the created particle.
  13328. * @param worldMatrix is the world matrix of the particle system
  13329. * @param directionToUpdate is the direction vector to update with the result
  13330. * @param particle is the particle we are computed the direction for
  13331. * @param isLocal defines if the direction should be set in local space
  13332. */
  13333. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13334. /**
  13335. * Called by the particle System when the position is computed for the created particle.
  13336. * @param worldMatrix is the world matrix of the particle system
  13337. * @param positionToUpdate is the position vector to update with the result
  13338. * @param particle is the particle we are computed the position for
  13339. * @param isLocal defines if the position should be set in local space
  13340. */
  13341. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13342. /**
  13343. * Clones the current emitter and returns a copy of it
  13344. * @returns the new emitter
  13345. */
  13346. clone(): BoxParticleEmitter;
  13347. /**
  13348. * Called by the GPUParticleSystem to setup the update shader
  13349. * @param effect defines the update shader
  13350. */
  13351. applyToShader(effect: Effect): void;
  13352. /**
  13353. * Returns a string to use to update the GPU particles update shader
  13354. * @returns a string containng the defines string
  13355. */
  13356. getEffectDefines(): string;
  13357. /**
  13358. * Returns the string "BoxParticleEmitter"
  13359. * @returns a string containing the class name
  13360. */
  13361. getClassName(): string;
  13362. /**
  13363. * Serializes the particle system to a JSON object.
  13364. * @returns the JSON object
  13365. */
  13366. serialize(): any;
  13367. /**
  13368. * Parse properties from a JSON object
  13369. * @param serializationObject defines the JSON object
  13370. */
  13371. parse(serializationObject: any): void;
  13372. }
  13373. }
  13374. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13375. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13376. import { Effect } from "babylonjs/Materials/effect";
  13377. import { Particle } from "babylonjs/Particles/particle";
  13378. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13379. /**
  13380. * Particle emitter emitting particles from the inside of a cone.
  13381. * It emits the particles alongside the cone volume from the base to the particle.
  13382. * The emission direction might be randomized.
  13383. */
  13384. export class ConeParticleEmitter implements IParticleEmitterType {
  13385. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13386. directionRandomizer: number;
  13387. private _radius;
  13388. private _angle;
  13389. private _height;
  13390. /**
  13391. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13392. */
  13393. radiusRange: number;
  13394. /**
  13395. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13396. */
  13397. heightRange: number;
  13398. /**
  13399. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13400. */
  13401. emitFromSpawnPointOnly: boolean;
  13402. /**
  13403. * Gets or sets the radius of the emission cone
  13404. */
  13405. get radius(): number;
  13406. set radius(value: number);
  13407. /**
  13408. * Gets or sets the angle of the emission cone
  13409. */
  13410. get angle(): number;
  13411. set angle(value: number);
  13412. private _buildHeight;
  13413. /**
  13414. * Creates a new instance ConeParticleEmitter
  13415. * @param radius the radius of the emission cone (1 by default)
  13416. * @param angle the cone base angle (PI by default)
  13417. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13418. */
  13419. constructor(radius?: number, angle?: number,
  13420. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13421. directionRandomizer?: number);
  13422. /**
  13423. * Called by the particle System when the direction is computed for the created particle.
  13424. * @param worldMatrix is the world matrix of the particle system
  13425. * @param directionToUpdate is the direction vector to update with the result
  13426. * @param particle is the particle we are computed the direction for
  13427. * @param isLocal defines if the direction should be set in local space
  13428. */
  13429. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13430. /**
  13431. * Called by the particle System when the position is computed for the created particle.
  13432. * @param worldMatrix is the world matrix of the particle system
  13433. * @param positionToUpdate is the position vector to update with the result
  13434. * @param particle is the particle we are computed the position for
  13435. * @param isLocal defines if the position should be set in local space
  13436. */
  13437. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13438. /**
  13439. * Clones the current emitter and returns a copy of it
  13440. * @returns the new emitter
  13441. */
  13442. clone(): ConeParticleEmitter;
  13443. /**
  13444. * Called by the GPUParticleSystem to setup the update shader
  13445. * @param effect defines the update shader
  13446. */
  13447. applyToShader(effect: Effect): void;
  13448. /**
  13449. * Returns a string to use to update the GPU particles update shader
  13450. * @returns a string containng the defines string
  13451. */
  13452. getEffectDefines(): string;
  13453. /**
  13454. * Returns the string "ConeParticleEmitter"
  13455. * @returns a string containing the class name
  13456. */
  13457. getClassName(): string;
  13458. /**
  13459. * Serializes the particle system to a JSON object.
  13460. * @returns the JSON object
  13461. */
  13462. serialize(): any;
  13463. /**
  13464. * Parse properties from a JSON object
  13465. * @param serializationObject defines the JSON object
  13466. */
  13467. parse(serializationObject: any): void;
  13468. }
  13469. }
  13470. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13471. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13472. import { Effect } from "babylonjs/Materials/effect";
  13473. import { Particle } from "babylonjs/Particles/particle";
  13474. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13475. /**
  13476. * Particle emitter emitting particles from the inside of a cylinder.
  13477. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13478. */
  13479. export class CylinderParticleEmitter implements IParticleEmitterType {
  13480. /**
  13481. * The radius of the emission cylinder.
  13482. */
  13483. radius: number;
  13484. /**
  13485. * The height of the emission cylinder.
  13486. */
  13487. height: number;
  13488. /**
  13489. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13490. */
  13491. radiusRange: number;
  13492. /**
  13493. * How much to randomize the particle direction [0-1].
  13494. */
  13495. directionRandomizer: number;
  13496. /**
  13497. * Creates a new instance CylinderParticleEmitter
  13498. * @param radius the radius of the emission cylinder (1 by default)
  13499. * @param height the height of the emission cylinder (1 by default)
  13500. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13501. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13502. */
  13503. constructor(
  13504. /**
  13505. * The radius of the emission cylinder.
  13506. */
  13507. radius?: number,
  13508. /**
  13509. * The height of the emission cylinder.
  13510. */
  13511. height?: number,
  13512. /**
  13513. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13514. */
  13515. radiusRange?: number,
  13516. /**
  13517. * How much to randomize the particle direction [0-1].
  13518. */
  13519. directionRandomizer?: number);
  13520. /**
  13521. * Called by the particle System when the direction is computed for the created particle.
  13522. * @param worldMatrix is the world matrix of the particle system
  13523. * @param directionToUpdate is the direction vector to update with the result
  13524. * @param particle is the particle we are computed the direction for
  13525. * @param isLocal defines if the direction should be set in local space
  13526. */
  13527. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13528. /**
  13529. * Called by the particle System when the position is computed for the created particle.
  13530. * @param worldMatrix is the world matrix of the particle system
  13531. * @param positionToUpdate is the position vector to update with the result
  13532. * @param particle is the particle we are computed the position for
  13533. * @param isLocal defines if the position should be set in local space
  13534. */
  13535. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13536. /**
  13537. * Clones the current emitter and returns a copy of it
  13538. * @returns the new emitter
  13539. */
  13540. clone(): CylinderParticleEmitter;
  13541. /**
  13542. * Called by the GPUParticleSystem to setup the update shader
  13543. * @param effect defines the update shader
  13544. */
  13545. applyToShader(effect: Effect): void;
  13546. /**
  13547. * Returns a string to use to update the GPU particles update shader
  13548. * @returns a string containng the defines string
  13549. */
  13550. getEffectDefines(): string;
  13551. /**
  13552. * Returns the string "CylinderParticleEmitter"
  13553. * @returns a string containing the class name
  13554. */
  13555. getClassName(): string;
  13556. /**
  13557. * Serializes the particle system to a JSON object.
  13558. * @returns the JSON object
  13559. */
  13560. serialize(): any;
  13561. /**
  13562. * Parse properties from a JSON object
  13563. * @param serializationObject defines the JSON object
  13564. */
  13565. parse(serializationObject: any): void;
  13566. }
  13567. /**
  13568. * Particle emitter emitting particles from the inside of a cylinder.
  13569. * It emits the particles randomly between two vectors.
  13570. */
  13571. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13572. /**
  13573. * The min limit of the emission direction.
  13574. */
  13575. direction1: Vector3;
  13576. /**
  13577. * The max limit of the emission direction.
  13578. */
  13579. direction2: Vector3;
  13580. /**
  13581. * Creates a new instance CylinderDirectedParticleEmitter
  13582. * @param radius the radius of the emission cylinder (1 by default)
  13583. * @param height the height of the emission cylinder (1 by default)
  13584. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13585. * @param direction1 the min limit of the emission direction (up vector by default)
  13586. * @param direction2 the max limit of the emission direction (up vector by default)
  13587. */
  13588. constructor(radius?: number, height?: number, radiusRange?: number,
  13589. /**
  13590. * The min limit of the emission direction.
  13591. */
  13592. direction1?: Vector3,
  13593. /**
  13594. * The max limit of the emission direction.
  13595. */
  13596. direction2?: Vector3);
  13597. /**
  13598. * Called by the particle System when the direction is computed for the created particle.
  13599. * @param worldMatrix is the world matrix of the particle system
  13600. * @param directionToUpdate is the direction vector to update with the result
  13601. * @param particle is the particle we are computed the direction for
  13602. */
  13603. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13604. /**
  13605. * Clones the current emitter and returns a copy of it
  13606. * @returns the new emitter
  13607. */
  13608. clone(): CylinderDirectedParticleEmitter;
  13609. /**
  13610. * Called by the GPUParticleSystem to setup the update shader
  13611. * @param effect defines the update shader
  13612. */
  13613. applyToShader(effect: Effect): void;
  13614. /**
  13615. * Returns a string to use to update the GPU particles update shader
  13616. * @returns a string containng the defines string
  13617. */
  13618. getEffectDefines(): string;
  13619. /**
  13620. * Returns the string "CylinderDirectedParticleEmitter"
  13621. * @returns a string containing the class name
  13622. */
  13623. getClassName(): string;
  13624. /**
  13625. * Serializes the particle system to a JSON object.
  13626. * @returns the JSON object
  13627. */
  13628. serialize(): any;
  13629. /**
  13630. * Parse properties from a JSON object
  13631. * @param serializationObject defines the JSON object
  13632. */
  13633. parse(serializationObject: any): void;
  13634. }
  13635. }
  13636. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13637. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13638. import { Effect } from "babylonjs/Materials/effect";
  13639. import { Particle } from "babylonjs/Particles/particle";
  13640. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13641. /**
  13642. * Particle emitter emitting particles from the inside of a hemisphere.
  13643. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13644. */
  13645. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13646. /**
  13647. * The radius of the emission hemisphere.
  13648. */
  13649. radius: number;
  13650. /**
  13651. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13652. */
  13653. radiusRange: number;
  13654. /**
  13655. * How much to randomize the particle direction [0-1].
  13656. */
  13657. directionRandomizer: number;
  13658. /**
  13659. * Creates a new instance HemisphericParticleEmitter
  13660. * @param radius the radius of the emission hemisphere (1 by default)
  13661. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13662. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13663. */
  13664. constructor(
  13665. /**
  13666. * The radius of the emission hemisphere.
  13667. */
  13668. radius?: number,
  13669. /**
  13670. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13671. */
  13672. radiusRange?: number,
  13673. /**
  13674. * How much to randomize the particle direction [0-1].
  13675. */
  13676. directionRandomizer?: number);
  13677. /**
  13678. * Called by the particle System when the direction is computed for the created particle.
  13679. * @param worldMatrix is the world matrix of the particle system
  13680. * @param directionToUpdate is the direction vector to update with the result
  13681. * @param particle is the particle we are computed the direction for
  13682. * @param isLocal defines if the direction should be set in local space
  13683. */
  13684. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13685. /**
  13686. * Called by the particle System when the position is computed for the created particle.
  13687. * @param worldMatrix is the world matrix of the particle system
  13688. * @param positionToUpdate is the position vector to update with the result
  13689. * @param particle is the particle we are computed the position for
  13690. * @param isLocal defines if the position should be set in local space
  13691. */
  13692. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13693. /**
  13694. * Clones the current emitter and returns a copy of it
  13695. * @returns the new emitter
  13696. */
  13697. clone(): HemisphericParticleEmitter;
  13698. /**
  13699. * Called by the GPUParticleSystem to setup the update shader
  13700. * @param effect defines the update shader
  13701. */
  13702. applyToShader(effect: Effect): void;
  13703. /**
  13704. * Returns a string to use to update the GPU particles update shader
  13705. * @returns a string containng the defines string
  13706. */
  13707. getEffectDefines(): string;
  13708. /**
  13709. * Returns the string "HemisphericParticleEmitter"
  13710. * @returns a string containing the class name
  13711. */
  13712. getClassName(): string;
  13713. /**
  13714. * Serializes the particle system to a JSON object.
  13715. * @returns the JSON object
  13716. */
  13717. serialize(): any;
  13718. /**
  13719. * Parse properties from a JSON object
  13720. * @param serializationObject defines the JSON object
  13721. */
  13722. parse(serializationObject: any): void;
  13723. }
  13724. }
  13725. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13726. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13727. import { Effect } from "babylonjs/Materials/effect";
  13728. import { Particle } from "babylonjs/Particles/particle";
  13729. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13730. /**
  13731. * Particle emitter emitting particles from a point.
  13732. * It emits the particles randomly between 2 given directions.
  13733. */
  13734. export class PointParticleEmitter implements IParticleEmitterType {
  13735. /**
  13736. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13737. */
  13738. direction1: Vector3;
  13739. /**
  13740. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13741. */
  13742. direction2: Vector3;
  13743. /**
  13744. * Creates a new instance PointParticleEmitter
  13745. */
  13746. constructor();
  13747. /**
  13748. * Called by the particle System when the direction is computed for the created particle.
  13749. * @param worldMatrix is the world matrix of the particle system
  13750. * @param directionToUpdate is the direction vector to update with the result
  13751. * @param particle is the particle we are computed the direction for
  13752. * @param isLocal defines if the direction should be set in local space
  13753. */
  13754. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13755. /**
  13756. * Called by the particle System when the position is computed for the created particle.
  13757. * @param worldMatrix is the world matrix of the particle system
  13758. * @param positionToUpdate is the position vector to update with the result
  13759. * @param particle is the particle we are computed the position for
  13760. * @param isLocal defines if the position should be set in local space
  13761. */
  13762. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13763. /**
  13764. * Clones the current emitter and returns a copy of it
  13765. * @returns the new emitter
  13766. */
  13767. clone(): PointParticleEmitter;
  13768. /**
  13769. * Called by the GPUParticleSystem to setup the update shader
  13770. * @param effect defines the update shader
  13771. */
  13772. applyToShader(effect: Effect): void;
  13773. /**
  13774. * Returns a string to use to update the GPU particles update shader
  13775. * @returns a string containng the defines string
  13776. */
  13777. getEffectDefines(): string;
  13778. /**
  13779. * Returns the string "PointParticleEmitter"
  13780. * @returns a string containing the class name
  13781. */
  13782. getClassName(): string;
  13783. /**
  13784. * Serializes the particle system to a JSON object.
  13785. * @returns the JSON object
  13786. */
  13787. serialize(): any;
  13788. /**
  13789. * Parse properties from a JSON object
  13790. * @param serializationObject defines the JSON object
  13791. */
  13792. parse(serializationObject: any): void;
  13793. }
  13794. }
  13795. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13796. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13797. import { Effect } from "babylonjs/Materials/effect";
  13798. import { Particle } from "babylonjs/Particles/particle";
  13799. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13800. /**
  13801. * Particle emitter emitting particles from the inside of a sphere.
  13802. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13803. */
  13804. export class SphereParticleEmitter implements IParticleEmitterType {
  13805. /**
  13806. * The radius of the emission sphere.
  13807. */
  13808. radius: number;
  13809. /**
  13810. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13811. */
  13812. radiusRange: number;
  13813. /**
  13814. * How much to randomize the particle direction [0-1].
  13815. */
  13816. directionRandomizer: number;
  13817. /**
  13818. * Creates a new instance SphereParticleEmitter
  13819. * @param radius the radius of the emission sphere (1 by default)
  13820. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13821. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13822. */
  13823. constructor(
  13824. /**
  13825. * The radius of the emission sphere.
  13826. */
  13827. radius?: number,
  13828. /**
  13829. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13830. */
  13831. radiusRange?: number,
  13832. /**
  13833. * How much to randomize the particle direction [0-1].
  13834. */
  13835. directionRandomizer?: number);
  13836. /**
  13837. * Called by the particle System when the direction is computed for the created particle.
  13838. * @param worldMatrix is the world matrix of the particle system
  13839. * @param directionToUpdate is the direction vector to update with the result
  13840. * @param particle is the particle we are computed the direction for
  13841. * @param isLocal defines if the direction should be set in local space
  13842. */
  13843. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13844. /**
  13845. * Called by the particle System when the position is computed for the created particle.
  13846. * @param worldMatrix is the world matrix of the particle system
  13847. * @param positionToUpdate is the position vector to update with the result
  13848. * @param particle is the particle we are computed the position for
  13849. * @param isLocal defines if the position should be set in local space
  13850. */
  13851. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13852. /**
  13853. * Clones the current emitter and returns a copy of it
  13854. * @returns the new emitter
  13855. */
  13856. clone(): SphereParticleEmitter;
  13857. /**
  13858. * Called by the GPUParticleSystem to setup the update shader
  13859. * @param effect defines the update shader
  13860. */
  13861. applyToShader(effect: Effect): void;
  13862. /**
  13863. * Returns a string to use to update the GPU particles update shader
  13864. * @returns a string containng the defines string
  13865. */
  13866. getEffectDefines(): string;
  13867. /**
  13868. * Returns the string "SphereParticleEmitter"
  13869. * @returns a string containing the class name
  13870. */
  13871. getClassName(): string;
  13872. /**
  13873. * Serializes the particle system to a JSON object.
  13874. * @returns the JSON object
  13875. */
  13876. serialize(): any;
  13877. /**
  13878. * Parse properties from a JSON object
  13879. * @param serializationObject defines the JSON object
  13880. */
  13881. parse(serializationObject: any): void;
  13882. }
  13883. /**
  13884. * Particle emitter emitting particles from the inside of a sphere.
  13885. * It emits the particles randomly between two vectors.
  13886. */
  13887. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13888. /**
  13889. * The min limit of the emission direction.
  13890. */
  13891. direction1: Vector3;
  13892. /**
  13893. * The max limit of the emission direction.
  13894. */
  13895. direction2: Vector3;
  13896. /**
  13897. * Creates a new instance SphereDirectedParticleEmitter
  13898. * @param radius the radius of the emission sphere (1 by default)
  13899. * @param direction1 the min limit of the emission direction (up vector by default)
  13900. * @param direction2 the max limit of the emission direction (up vector by default)
  13901. */
  13902. constructor(radius?: number,
  13903. /**
  13904. * The min limit of the emission direction.
  13905. */
  13906. direction1?: Vector3,
  13907. /**
  13908. * The max limit of the emission direction.
  13909. */
  13910. direction2?: Vector3);
  13911. /**
  13912. * Called by the particle System when the direction is computed for the created particle.
  13913. * @param worldMatrix is the world matrix of the particle system
  13914. * @param directionToUpdate is the direction vector to update with the result
  13915. * @param particle is the particle we are computed the direction for
  13916. */
  13917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13918. /**
  13919. * Clones the current emitter and returns a copy of it
  13920. * @returns the new emitter
  13921. */
  13922. clone(): SphereDirectedParticleEmitter;
  13923. /**
  13924. * Called by the GPUParticleSystem to setup the update shader
  13925. * @param effect defines the update shader
  13926. */
  13927. applyToShader(effect: Effect): void;
  13928. /**
  13929. * Returns a string to use to update the GPU particles update shader
  13930. * @returns a string containng the defines string
  13931. */
  13932. getEffectDefines(): string;
  13933. /**
  13934. * Returns the string "SphereDirectedParticleEmitter"
  13935. * @returns a string containing the class name
  13936. */
  13937. getClassName(): string;
  13938. /**
  13939. * Serializes the particle system to a JSON object.
  13940. * @returns the JSON object
  13941. */
  13942. serialize(): any;
  13943. /**
  13944. * Parse properties from a JSON object
  13945. * @param serializationObject defines the JSON object
  13946. */
  13947. parse(serializationObject: any): void;
  13948. }
  13949. }
  13950. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13951. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13952. import { Effect } from "babylonjs/Materials/effect";
  13953. import { Particle } from "babylonjs/Particles/particle";
  13954. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13955. import { Nullable } from "babylonjs/types";
  13956. /**
  13957. * Particle emitter emitting particles from a custom list of positions.
  13958. */
  13959. export class CustomParticleEmitter implements IParticleEmitterType {
  13960. /**
  13961. * Gets or sets the position generator that will create the inital position of each particle.
  13962. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13963. */
  13964. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13965. /**
  13966. * Gets or sets the destination generator that will create the final destination of each particle.
  13967. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13968. */
  13969. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13970. /**
  13971. * Creates a new instance CustomParticleEmitter
  13972. */
  13973. constructor();
  13974. /**
  13975. * Called by the particle System when the direction is computed for the created particle.
  13976. * @param worldMatrix is the world matrix of the particle system
  13977. * @param directionToUpdate is the direction vector to update with the result
  13978. * @param particle is the particle we are computed the direction for
  13979. * @param isLocal defines if the direction should be set in local space
  13980. */
  13981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13982. /**
  13983. * Called by the particle System when the position is computed for the created particle.
  13984. * @param worldMatrix is the world matrix of the particle system
  13985. * @param positionToUpdate is the position vector to update with the result
  13986. * @param particle is the particle we are computed the position for
  13987. * @param isLocal defines if the position should be set in local space
  13988. */
  13989. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13990. /**
  13991. * Clones the current emitter and returns a copy of it
  13992. * @returns the new emitter
  13993. */
  13994. clone(): CustomParticleEmitter;
  13995. /**
  13996. * Called by the GPUParticleSystem to setup the update shader
  13997. * @param effect defines the update shader
  13998. */
  13999. applyToShader(effect: Effect): void;
  14000. /**
  14001. * Returns a string to use to update the GPU particles update shader
  14002. * @returns a string containng the defines string
  14003. */
  14004. getEffectDefines(): string;
  14005. /**
  14006. * Returns the string "PointParticleEmitter"
  14007. * @returns a string containing the class name
  14008. */
  14009. getClassName(): string;
  14010. /**
  14011. * Serializes the particle system to a JSON object.
  14012. * @returns the JSON object
  14013. */
  14014. serialize(): any;
  14015. /**
  14016. * Parse properties from a JSON object
  14017. * @param serializationObject defines the JSON object
  14018. */
  14019. parse(serializationObject: any): void;
  14020. }
  14021. }
  14022. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14023. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14024. import { Effect } from "babylonjs/Materials/effect";
  14025. import { Particle } from "babylonjs/Particles/particle";
  14026. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14027. import { Nullable } from "babylonjs/types";
  14028. import { Scene } from "babylonjs/scene";
  14029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14030. /**
  14031. * Particle emitter emitting particles from the inside of a box.
  14032. * It emits the particles randomly between 2 given directions.
  14033. */
  14034. export class MeshParticleEmitter implements IParticleEmitterType {
  14035. private _indices;
  14036. private _positions;
  14037. private _normals;
  14038. private _storedNormal;
  14039. private _mesh;
  14040. /**
  14041. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14042. */
  14043. direction1: Vector3;
  14044. /**
  14045. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14046. */
  14047. direction2: Vector3;
  14048. /**
  14049. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14050. */
  14051. useMeshNormalsForDirection: boolean;
  14052. /** Defines the mesh to use as source */
  14053. get mesh(): Nullable<AbstractMesh>;
  14054. set mesh(value: Nullable<AbstractMesh>);
  14055. /**
  14056. * Creates a new instance MeshParticleEmitter
  14057. * @param mesh defines the mesh to use as source
  14058. */
  14059. constructor(mesh?: Nullable<AbstractMesh>);
  14060. /**
  14061. * Called by the particle System when the direction is computed for the created particle.
  14062. * @param worldMatrix is the world matrix of the particle system
  14063. * @param directionToUpdate is the direction vector to update with the result
  14064. * @param particle is the particle we are computed the direction for
  14065. * @param isLocal defines if the direction should be set in local space
  14066. */
  14067. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14068. /**
  14069. * Called by the particle System when the position is computed for the created particle.
  14070. * @param worldMatrix is the world matrix of the particle system
  14071. * @param positionToUpdate is the position vector to update with the result
  14072. * @param particle is the particle we are computed the position for
  14073. * @param isLocal defines if the position should be set in local space
  14074. */
  14075. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14076. /**
  14077. * Clones the current emitter and returns a copy of it
  14078. * @returns the new emitter
  14079. */
  14080. clone(): MeshParticleEmitter;
  14081. /**
  14082. * Called by the GPUParticleSystem to setup the update shader
  14083. * @param effect defines the update shader
  14084. */
  14085. applyToShader(effect: Effect): void;
  14086. /**
  14087. * Returns a string to use to update the GPU particles update shader
  14088. * @returns a string containng the defines string
  14089. */
  14090. getEffectDefines(): string;
  14091. /**
  14092. * Returns the string "BoxParticleEmitter"
  14093. * @returns a string containing the class name
  14094. */
  14095. getClassName(): string;
  14096. /**
  14097. * Serializes the particle system to a JSON object.
  14098. * @returns the JSON object
  14099. */
  14100. serialize(): any;
  14101. /**
  14102. * Parse properties from a JSON object
  14103. * @param serializationObject defines the JSON object
  14104. * @param scene defines the hosting scene
  14105. */
  14106. parse(serializationObject: any, scene: Scene): void;
  14107. }
  14108. }
  14109. declare module "babylonjs/Particles/EmitterTypes/index" {
  14110. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14111. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14112. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14113. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14114. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14115. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14116. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14117. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14118. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14119. }
  14120. declare module "babylonjs/Particles/IParticleSystem" {
  14121. import { Nullable } from "babylonjs/types";
  14122. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14123. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14126. import { Texture } from "babylonjs/Materials/Textures/texture";
  14127. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14128. import { Scene } from "babylonjs/scene";
  14129. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14130. import { Effect } from "babylonjs/Materials/effect";
  14131. import { Observable } from "babylonjs/Misc/observable";
  14132. import { Animation } from "babylonjs/Animations/animation";
  14133. /**
  14134. * Interface representing a particle system in Babylon.js.
  14135. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14136. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14137. */
  14138. export interface IParticleSystem {
  14139. /**
  14140. * List of animations used by the particle system.
  14141. */
  14142. animations: Animation[];
  14143. /**
  14144. * The id of the Particle system.
  14145. */
  14146. id: string;
  14147. /**
  14148. * The name of the Particle system.
  14149. */
  14150. name: string;
  14151. /**
  14152. * The emitter represents the Mesh or position we are attaching the particle system to.
  14153. */
  14154. emitter: Nullable<AbstractMesh | Vector3>;
  14155. /**
  14156. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14157. */
  14158. isBillboardBased: boolean;
  14159. /**
  14160. * The rendering group used by the Particle system to chose when to render.
  14161. */
  14162. renderingGroupId: number;
  14163. /**
  14164. * The layer mask we are rendering the particles through.
  14165. */
  14166. layerMask: number;
  14167. /**
  14168. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14169. */
  14170. updateSpeed: number;
  14171. /**
  14172. * The amount of time the particle system is running (depends of the overall update speed).
  14173. */
  14174. targetStopDuration: number;
  14175. /**
  14176. * The texture used to render each particle. (this can be a spritesheet)
  14177. */
  14178. particleTexture: Nullable<Texture>;
  14179. /**
  14180. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14181. */
  14182. blendMode: number;
  14183. /**
  14184. * Minimum life time of emitting particles.
  14185. */
  14186. minLifeTime: number;
  14187. /**
  14188. * Maximum life time of emitting particles.
  14189. */
  14190. maxLifeTime: number;
  14191. /**
  14192. * Minimum Size of emitting particles.
  14193. */
  14194. minSize: number;
  14195. /**
  14196. * Maximum Size of emitting particles.
  14197. */
  14198. maxSize: number;
  14199. /**
  14200. * Minimum scale of emitting particles on X axis.
  14201. */
  14202. minScaleX: number;
  14203. /**
  14204. * Maximum scale of emitting particles on X axis.
  14205. */
  14206. maxScaleX: number;
  14207. /**
  14208. * Minimum scale of emitting particles on Y axis.
  14209. */
  14210. minScaleY: number;
  14211. /**
  14212. * Maximum scale of emitting particles on Y axis.
  14213. */
  14214. maxScaleY: number;
  14215. /**
  14216. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14217. */
  14218. color1: Color4;
  14219. /**
  14220. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14221. */
  14222. color2: Color4;
  14223. /**
  14224. * Color the particle will have at the end of its lifetime.
  14225. */
  14226. colorDead: Color4;
  14227. /**
  14228. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14229. */
  14230. emitRate: number;
  14231. /**
  14232. * You can use gravity if you want to give an orientation to your particles.
  14233. */
  14234. gravity: Vector3;
  14235. /**
  14236. * Minimum power of emitting particles.
  14237. */
  14238. minEmitPower: number;
  14239. /**
  14240. * Maximum power of emitting particles.
  14241. */
  14242. maxEmitPower: number;
  14243. /**
  14244. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14245. */
  14246. minAngularSpeed: number;
  14247. /**
  14248. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14249. */
  14250. maxAngularSpeed: number;
  14251. /**
  14252. * Gets or sets the minimal initial rotation in radians.
  14253. */
  14254. minInitialRotation: number;
  14255. /**
  14256. * Gets or sets the maximal initial rotation in radians.
  14257. */
  14258. maxInitialRotation: number;
  14259. /**
  14260. * The particle emitter type defines the emitter used by the particle system.
  14261. * It can be for example box, sphere, or cone...
  14262. */
  14263. particleEmitterType: Nullable<IParticleEmitterType>;
  14264. /**
  14265. * Defines the delay in milliseconds before starting the system (0 by default)
  14266. */
  14267. startDelay: number;
  14268. /**
  14269. * 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
  14270. */
  14271. preWarmCycles: number;
  14272. /**
  14273. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14274. */
  14275. preWarmStepOffset: number;
  14276. /**
  14277. * 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)
  14278. */
  14279. spriteCellChangeSpeed: number;
  14280. /**
  14281. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14282. */
  14283. startSpriteCellID: number;
  14284. /**
  14285. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14286. */
  14287. endSpriteCellID: number;
  14288. /**
  14289. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14290. */
  14291. spriteCellWidth: number;
  14292. /**
  14293. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14294. */
  14295. spriteCellHeight: number;
  14296. /**
  14297. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14298. */
  14299. spriteRandomStartCell: boolean;
  14300. /**
  14301. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14302. */
  14303. isAnimationSheetEnabled: boolean;
  14304. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14305. translationPivot: Vector2;
  14306. /**
  14307. * Gets or sets a texture used to add random noise to particle positions
  14308. */
  14309. noiseTexture: Nullable<BaseTexture>;
  14310. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14311. noiseStrength: Vector3;
  14312. /**
  14313. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14314. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14315. */
  14316. billboardMode: number;
  14317. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14318. limitVelocityDamping: number;
  14319. /**
  14320. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14321. */
  14322. beginAnimationOnStart: boolean;
  14323. /**
  14324. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14325. */
  14326. beginAnimationFrom: number;
  14327. /**
  14328. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14329. */
  14330. beginAnimationTo: number;
  14331. /**
  14332. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14333. */
  14334. beginAnimationLoop: boolean;
  14335. /**
  14336. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14337. */
  14338. disposeOnStop: boolean;
  14339. /**
  14340. * Specifies if the particles are updated in emitter local space or world space
  14341. */
  14342. isLocal: boolean;
  14343. /** Snippet ID if the particle system was created from the snippet server */
  14344. snippetId: string;
  14345. /**
  14346. * Gets the maximum number of particles active at the same time.
  14347. * @returns The max number of active particles.
  14348. */
  14349. getCapacity(): number;
  14350. /**
  14351. * Gets the number of particles active at the same time.
  14352. * @returns The number of active particles.
  14353. */
  14354. getActiveCount(): number;
  14355. /**
  14356. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14357. * @returns True if it has been started, otherwise false.
  14358. */
  14359. isStarted(): boolean;
  14360. /**
  14361. * Animates the particle system for this frame.
  14362. */
  14363. animate(): void;
  14364. /**
  14365. * Renders the particle system in its current state.
  14366. * @returns the current number of particles
  14367. */
  14368. render(): number;
  14369. /**
  14370. * Dispose the particle system and frees its associated resources.
  14371. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14372. */
  14373. dispose(disposeTexture?: boolean): void;
  14374. /**
  14375. * An event triggered when the system is disposed
  14376. */
  14377. onDisposeObservable: Observable<IParticleSystem>;
  14378. /**
  14379. * Clones the particle system.
  14380. * @param name The name of the cloned object
  14381. * @param newEmitter The new emitter to use
  14382. * @returns the cloned particle system
  14383. */
  14384. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14385. /**
  14386. * Serializes the particle system to a JSON object
  14387. * @param serializeTexture defines if the texture must be serialized as well
  14388. * @returns the JSON object
  14389. */
  14390. serialize(serializeTexture: boolean): any;
  14391. /**
  14392. * Rebuild the particle system
  14393. */
  14394. rebuild(): void;
  14395. /** Force the system to rebuild all gradients that need to be resync */
  14396. forceRefreshGradients(): void;
  14397. /**
  14398. * Starts the particle system and begins to emit
  14399. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14400. */
  14401. start(delay?: number): void;
  14402. /**
  14403. * Stops the particle system.
  14404. */
  14405. stop(): void;
  14406. /**
  14407. * Remove all active particles
  14408. */
  14409. reset(): void;
  14410. /**
  14411. * Gets a boolean indicating that the system is stopping
  14412. * @returns true if the system is currently stopping
  14413. */
  14414. isStopping(): boolean;
  14415. /**
  14416. * Is this system ready to be used/rendered
  14417. * @return true if the system is ready
  14418. */
  14419. isReady(): boolean;
  14420. /**
  14421. * Returns the string "ParticleSystem"
  14422. * @returns a string containing the class name
  14423. */
  14424. getClassName(): string;
  14425. /**
  14426. * Gets the custom effect used to render the particles
  14427. * @param blendMode Blend mode for which the effect should be retrieved
  14428. * @returns The effect
  14429. */
  14430. getCustomEffect(blendMode: number): Nullable<Effect>;
  14431. /**
  14432. * Sets the custom effect used to render the particles
  14433. * @param effect The effect to set
  14434. * @param blendMode Blend mode for which the effect should be set
  14435. */
  14436. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14437. /**
  14438. * Fill the defines array according to the current settings of the particle system
  14439. * @param defines Array to be updated
  14440. * @param blendMode blend mode to take into account when updating the array
  14441. */
  14442. fillDefines(defines: Array<string>, blendMode: number): void;
  14443. /**
  14444. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14445. * @param uniforms Uniforms array to fill
  14446. * @param attributes Attributes array to fill
  14447. * @param samplers Samplers array to fill
  14448. */
  14449. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14450. /**
  14451. * Observable that will be called just before the particles are drawn
  14452. */
  14453. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14454. /**
  14455. * Gets the name of the particle vertex shader
  14456. */
  14457. vertexShaderName: string;
  14458. /**
  14459. * Adds a new color gradient
  14460. * @param gradient defines the gradient to use (between 0 and 1)
  14461. * @param color1 defines the color to affect to the specified gradient
  14462. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14463. * @returns the current particle system
  14464. */
  14465. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14466. /**
  14467. * Remove a specific color gradient
  14468. * @param gradient defines the gradient to remove
  14469. * @returns the current particle system
  14470. */
  14471. removeColorGradient(gradient: number): IParticleSystem;
  14472. /**
  14473. * Adds a new size gradient
  14474. * @param gradient defines the gradient to use (between 0 and 1)
  14475. * @param factor defines the size factor to affect to the specified gradient
  14476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14477. * @returns the current particle system
  14478. */
  14479. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14480. /**
  14481. * Remove a specific size gradient
  14482. * @param gradient defines the gradient to remove
  14483. * @returns the current particle system
  14484. */
  14485. removeSizeGradient(gradient: number): IParticleSystem;
  14486. /**
  14487. * Gets the current list of color gradients.
  14488. * You must use addColorGradient and removeColorGradient to udpate this list
  14489. * @returns the list of color gradients
  14490. */
  14491. getColorGradients(): Nullable<Array<ColorGradient>>;
  14492. /**
  14493. * Gets the current list of size gradients.
  14494. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14495. * @returns the list of size gradients
  14496. */
  14497. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14498. /**
  14499. * Gets the current list of angular speed gradients.
  14500. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14501. * @returns the list of angular speed gradients
  14502. */
  14503. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14504. /**
  14505. * Adds a new angular speed gradient
  14506. * @param gradient defines the gradient to use (between 0 and 1)
  14507. * @param factor defines the angular speed to affect to the specified gradient
  14508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14509. * @returns the current particle system
  14510. */
  14511. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14512. /**
  14513. * Remove a specific angular speed gradient
  14514. * @param gradient defines the gradient to remove
  14515. * @returns the current particle system
  14516. */
  14517. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14518. /**
  14519. * Gets the current list of velocity gradients.
  14520. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14521. * @returns the list of velocity gradients
  14522. */
  14523. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14524. /**
  14525. * Adds a new velocity gradient
  14526. * @param gradient defines the gradient to use (between 0 and 1)
  14527. * @param factor defines the velocity to affect to the specified gradient
  14528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14529. * @returns the current particle system
  14530. */
  14531. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14532. /**
  14533. * Remove a specific velocity gradient
  14534. * @param gradient defines the gradient to remove
  14535. * @returns the current particle system
  14536. */
  14537. removeVelocityGradient(gradient: number): IParticleSystem;
  14538. /**
  14539. * Gets the current list of limit velocity gradients.
  14540. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14541. * @returns the list of limit velocity gradients
  14542. */
  14543. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14544. /**
  14545. * Adds a new limit velocity gradient
  14546. * @param gradient defines the gradient to use (between 0 and 1)
  14547. * @param factor defines the limit velocity to affect to the specified gradient
  14548. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14549. * @returns the current particle system
  14550. */
  14551. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14552. /**
  14553. * Remove a specific limit velocity gradient
  14554. * @param gradient defines the gradient to remove
  14555. * @returns the current particle system
  14556. */
  14557. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14558. /**
  14559. * Adds a new drag gradient
  14560. * @param gradient defines the gradient to use (between 0 and 1)
  14561. * @param factor defines the drag to affect to the specified gradient
  14562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14563. * @returns the current particle system
  14564. */
  14565. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14566. /**
  14567. * Remove a specific drag gradient
  14568. * @param gradient defines the gradient to remove
  14569. * @returns the current particle system
  14570. */
  14571. removeDragGradient(gradient: number): IParticleSystem;
  14572. /**
  14573. * Gets the current list of drag gradients.
  14574. * You must use addDragGradient and removeDragGradient to udpate this list
  14575. * @returns the list of drag gradients
  14576. */
  14577. getDragGradients(): Nullable<Array<FactorGradient>>;
  14578. /**
  14579. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14580. * @param gradient defines the gradient to use (between 0 and 1)
  14581. * @param factor defines the emit rate to affect to the specified gradient
  14582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14583. * @returns the current particle system
  14584. */
  14585. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14586. /**
  14587. * Remove a specific emit rate gradient
  14588. * @param gradient defines the gradient to remove
  14589. * @returns the current particle system
  14590. */
  14591. removeEmitRateGradient(gradient: number): IParticleSystem;
  14592. /**
  14593. * Gets the current list of emit rate gradients.
  14594. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14595. * @returns the list of emit rate gradients
  14596. */
  14597. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14598. /**
  14599. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14600. * @param gradient defines the gradient to use (between 0 and 1)
  14601. * @param factor defines the start size to affect to the specified gradient
  14602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14603. * @returns the current particle system
  14604. */
  14605. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14606. /**
  14607. * Remove a specific start size gradient
  14608. * @param gradient defines the gradient to remove
  14609. * @returns the current particle system
  14610. */
  14611. removeStartSizeGradient(gradient: number): IParticleSystem;
  14612. /**
  14613. * Gets the current list of start size gradients.
  14614. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14615. * @returns the list of start size gradients
  14616. */
  14617. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14618. /**
  14619. * Adds a new life time gradient
  14620. * @param gradient defines the gradient to use (between 0 and 1)
  14621. * @param factor defines the life time factor to affect to the specified gradient
  14622. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14623. * @returns the current particle system
  14624. */
  14625. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14626. /**
  14627. * Remove a specific life time gradient
  14628. * @param gradient defines the gradient to remove
  14629. * @returns the current particle system
  14630. */
  14631. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14632. /**
  14633. * Gets the current list of life time gradients.
  14634. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14635. * @returns the list of life time gradients
  14636. */
  14637. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14638. /**
  14639. * Gets the current list of color gradients.
  14640. * You must use addColorGradient and removeColorGradient to udpate this list
  14641. * @returns the list of color gradients
  14642. */
  14643. getColorGradients(): Nullable<Array<ColorGradient>>;
  14644. /**
  14645. * Adds a new ramp gradient used to remap particle colors
  14646. * @param gradient defines the gradient to use (between 0 and 1)
  14647. * @param color defines the color to affect to the specified gradient
  14648. * @returns the current particle system
  14649. */
  14650. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14651. /**
  14652. * Gets the current list of ramp gradients.
  14653. * You must use addRampGradient and removeRampGradient to udpate this list
  14654. * @returns the list of ramp gradients
  14655. */
  14656. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14657. /** Gets or sets a boolean indicating that ramp gradients must be used
  14658. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14659. */
  14660. useRampGradients: boolean;
  14661. /**
  14662. * Adds a new color remap gradient
  14663. * @param gradient defines the gradient to use (between 0 and 1)
  14664. * @param min defines the color remap minimal range
  14665. * @param max defines the color remap maximal range
  14666. * @returns the current particle system
  14667. */
  14668. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14669. /**
  14670. * Gets the current list of color remap gradients.
  14671. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14672. * @returns the list of color remap gradients
  14673. */
  14674. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14675. /**
  14676. * Adds a new alpha remap gradient
  14677. * @param gradient defines the gradient to use (between 0 and 1)
  14678. * @param min defines the alpha remap minimal range
  14679. * @param max defines the alpha remap maximal range
  14680. * @returns the current particle system
  14681. */
  14682. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14683. /**
  14684. * Gets the current list of alpha remap gradients.
  14685. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14686. * @returns the list of alpha remap gradients
  14687. */
  14688. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14689. /**
  14690. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14691. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14692. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14693. * @returns the emitter
  14694. */
  14695. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14696. /**
  14697. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14698. * @param radius The radius of the hemisphere to emit from
  14699. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14700. * @returns the emitter
  14701. */
  14702. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14703. /**
  14704. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14705. * @param radius The radius of the sphere to emit from
  14706. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14707. * @returns the emitter
  14708. */
  14709. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14710. /**
  14711. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14712. * @param radius The radius of the sphere to emit from
  14713. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14714. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14715. * @returns the emitter
  14716. */
  14717. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14718. /**
  14719. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14720. * @param radius The radius of the emission cylinder
  14721. * @param height The height of the emission cylinder
  14722. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14723. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14724. * @returns the emitter
  14725. */
  14726. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14727. /**
  14728. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14729. * @param radius The radius of the cylinder to emit from
  14730. * @param height The height of the emission cylinder
  14731. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14732. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14733. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14734. * @returns the emitter
  14735. */
  14736. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14737. /**
  14738. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14739. * @param radius The radius of the cone to emit from
  14740. * @param angle The base angle of the cone
  14741. * @returns the emitter
  14742. */
  14743. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14744. /**
  14745. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14746. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14747. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14748. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14749. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14750. * @returns the emitter
  14751. */
  14752. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14753. /**
  14754. * Get hosting scene
  14755. * @returns the scene
  14756. */
  14757. getScene(): Scene;
  14758. }
  14759. }
  14760. declare module "babylonjs/Meshes/transformNode" {
  14761. import { DeepImmutable } from "babylonjs/types";
  14762. import { Observable } from "babylonjs/Misc/observable";
  14763. import { Nullable } from "babylonjs/types";
  14764. import { Camera } from "babylonjs/Cameras/camera";
  14765. import { Scene } from "babylonjs/scene";
  14766. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14767. import { Node } from "babylonjs/node";
  14768. import { Bone } from "babylonjs/Bones/bone";
  14769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14770. import { Space } from "babylonjs/Maths/math.axis";
  14771. /**
  14772. * 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.
  14773. * @see https://doc.babylonjs.com/how_to/transformnode
  14774. */
  14775. export class TransformNode extends Node {
  14776. /**
  14777. * Object will not rotate to face the camera
  14778. */
  14779. static BILLBOARDMODE_NONE: number;
  14780. /**
  14781. * Object will rotate to face the camera but only on the x axis
  14782. */
  14783. static BILLBOARDMODE_X: number;
  14784. /**
  14785. * Object will rotate to face the camera but only on the y axis
  14786. */
  14787. static BILLBOARDMODE_Y: number;
  14788. /**
  14789. * Object will rotate to face the camera but only on the z axis
  14790. */
  14791. static BILLBOARDMODE_Z: number;
  14792. /**
  14793. * Object will rotate to face the camera
  14794. */
  14795. static BILLBOARDMODE_ALL: number;
  14796. /**
  14797. * Object will rotate to face the camera's position instead of orientation
  14798. */
  14799. static BILLBOARDMODE_USE_POSITION: number;
  14800. private static _TmpRotation;
  14801. private static _TmpScaling;
  14802. private static _TmpTranslation;
  14803. private _forward;
  14804. private _forwardInverted;
  14805. private _up;
  14806. private _right;
  14807. private _rightInverted;
  14808. private _position;
  14809. private _rotation;
  14810. private _rotationQuaternion;
  14811. protected _scaling: Vector3;
  14812. protected _isDirty: boolean;
  14813. private _transformToBoneReferal;
  14814. private _isAbsoluteSynced;
  14815. private _billboardMode;
  14816. /**
  14817. * Gets or sets the billboard mode. Default is 0.
  14818. *
  14819. * | Value | Type | Description |
  14820. * | --- | --- | --- |
  14821. * | 0 | BILLBOARDMODE_NONE | |
  14822. * | 1 | BILLBOARDMODE_X | |
  14823. * | 2 | BILLBOARDMODE_Y | |
  14824. * | 4 | BILLBOARDMODE_Z | |
  14825. * | 7 | BILLBOARDMODE_ALL | |
  14826. *
  14827. */
  14828. get billboardMode(): number;
  14829. set billboardMode(value: number);
  14830. private _preserveParentRotationForBillboard;
  14831. /**
  14832. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14833. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14834. */
  14835. get preserveParentRotationForBillboard(): boolean;
  14836. set preserveParentRotationForBillboard(value: boolean);
  14837. /**
  14838. * 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
  14839. */
  14840. scalingDeterminant: number;
  14841. private _infiniteDistance;
  14842. /**
  14843. * Gets or sets the distance of the object to max, often used by skybox
  14844. */
  14845. get infiniteDistance(): boolean;
  14846. set infiniteDistance(value: boolean);
  14847. /**
  14848. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14849. * By default the system will update normals to compensate
  14850. */
  14851. ignoreNonUniformScaling: boolean;
  14852. /**
  14853. * 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
  14854. */
  14855. reIntegrateRotationIntoRotationQuaternion: boolean;
  14856. /** @hidden */
  14857. _poseMatrix: Nullable<Matrix>;
  14858. /** @hidden */
  14859. _localMatrix: Matrix;
  14860. private _usePivotMatrix;
  14861. private _absolutePosition;
  14862. private _absoluteScaling;
  14863. private _absoluteRotationQuaternion;
  14864. private _pivotMatrix;
  14865. private _pivotMatrixInverse;
  14866. protected _postMultiplyPivotMatrix: boolean;
  14867. protected _isWorldMatrixFrozen: boolean;
  14868. /** @hidden */
  14869. _indexInSceneTransformNodesArray: number;
  14870. /**
  14871. * An event triggered after the world matrix is updated
  14872. */
  14873. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14874. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14875. /**
  14876. * Gets a string identifying the name of the class
  14877. * @returns "TransformNode" string
  14878. */
  14879. getClassName(): string;
  14880. /**
  14881. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14882. */
  14883. get position(): Vector3;
  14884. set position(newPosition: Vector3);
  14885. /**
  14886. * 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)).
  14887. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14888. */
  14889. get rotation(): Vector3;
  14890. set rotation(newRotation: Vector3);
  14891. /**
  14892. * 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)).
  14893. */
  14894. get scaling(): Vector3;
  14895. set scaling(newScaling: Vector3);
  14896. /**
  14897. * 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).
  14898. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14899. */
  14900. get rotationQuaternion(): Nullable<Quaternion>;
  14901. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14902. /**
  14903. * The forward direction of that transform in world space.
  14904. */
  14905. get forward(): Vector3;
  14906. /**
  14907. * The up direction of that transform in world space.
  14908. */
  14909. get up(): Vector3;
  14910. /**
  14911. * The right direction of that transform in world space.
  14912. */
  14913. get right(): Vector3;
  14914. /**
  14915. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14916. * @param matrix the matrix to copy the pose from
  14917. * @returns this TransformNode.
  14918. */
  14919. updatePoseMatrix(matrix: Matrix): TransformNode;
  14920. /**
  14921. * Returns the mesh Pose matrix.
  14922. * @returns the pose matrix
  14923. */
  14924. getPoseMatrix(): Matrix;
  14925. /** @hidden */
  14926. _isSynchronized(): boolean;
  14927. /** @hidden */
  14928. _initCache(): void;
  14929. /**
  14930. * Flag the transform node as dirty (Forcing it to update everything)
  14931. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14932. * @returns this transform node
  14933. */
  14934. markAsDirty(property: string): TransformNode;
  14935. /**
  14936. * Returns the current mesh absolute position.
  14937. * Returns a Vector3.
  14938. */
  14939. get absolutePosition(): Vector3;
  14940. /**
  14941. * Returns the current mesh absolute scaling.
  14942. * Returns a Vector3.
  14943. */
  14944. get absoluteScaling(): Vector3;
  14945. /**
  14946. * Returns the current mesh absolute rotation.
  14947. * Returns a Quaternion.
  14948. */
  14949. get absoluteRotationQuaternion(): Quaternion;
  14950. /**
  14951. * Sets a new matrix to apply before all other transformation
  14952. * @param matrix defines the transform matrix
  14953. * @returns the current TransformNode
  14954. */
  14955. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14956. /**
  14957. * Sets a new pivot matrix to the current node
  14958. * @param matrix defines the new pivot matrix to use
  14959. * @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
  14960. * @returns the current TransformNode
  14961. */
  14962. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14963. /**
  14964. * Returns the mesh pivot matrix.
  14965. * Default : Identity.
  14966. * @returns the matrix
  14967. */
  14968. getPivotMatrix(): Matrix;
  14969. /**
  14970. * Instantiate (when possible) or clone that node with its hierarchy
  14971. * @param newParent defines the new parent to use for the instance (or clone)
  14972. * @param options defines options to configure how copy is done
  14973. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14974. * @returns an instance (or a clone) of the current node with its hiearchy
  14975. */
  14976. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14977. doNotInstantiate: boolean;
  14978. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14979. /**
  14980. * Prevents the World matrix to be computed any longer
  14981. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14982. * @returns the TransformNode.
  14983. */
  14984. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14985. /**
  14986. * Allows back the World matrix computation.
  14987. * @returns the TransformNode.
  14988. */
  14989. unfreezeWorldMatrix(): this;
  14990. /**
  14991. * True if the World matrix has been frozen.
  14992. */
  14993. get isWorldMatrixFrozen(): boolean;
  14994. /**
  14995. * Retuns the mesh absolute position in the World.
  14996. * @returns a Vector3.
  14997. */
  14998. getAbsolutePosition(): Vector3;
  14999. /**
  15000. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15001. * @param absolutePosition the absolute position to set
  15002. * @returns the TransformNode.
  15003. */
  15004. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15005. /**
  15006. * Sets the mesh position in its local space.
  15007. * @param vector3 the position to set in localspace
  15008. * @returns the TransformNode.
  15009. */
  15010. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15011. /**
  15012. * Returns the mesh position in the local space from the current World matrix values.
  15013. * @returns a new Vector3.
  15014. */
  15015. getPositionExpressedInLocalSpace(): Vector3;
  15016. /**
  15017. * Translates the mesh along the passed Vector3 in its local space.
  15018. * @param vector3 the distance to translate in localspace
  15019. * @returns the TransformNode.
  15020. */
  15021. locallyTranslate(vector3: Vector3): TransformNode;
  15022. private static _lookAtVectorCache;
  15023. /**
  15024. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15025. * @param targetPoint the position (must be in same space as current mesh) to look at
  15026. * @param yawCor optional yaw (y-axis) correction in radians
  15027. * @param pitchCor optional pitch (x-axis) correction in radians
  15028. * @param rollCor optional roll (z-axis) correction in radians
  15029. * @param space the choosen space of the target
  15030. * @returns the TransformNode.
  15031. */
  15032. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15033. /**
  15034. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15035. * This Vector3 is expressed in the World space.
  15036. * @param localAxis axis to rotate
  15037. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15038. */
  15039. getDirection(localAxis: Vector3): Vector3;
  15040. /**
  15041. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15042. * localAxis is expressed in the mesh local space.
  15043. * result is computed in the Wordl space from the mesh World matrix.
  15044. * @param localAxis axis to rotate
  15045. * @param result the resulting transformnode
  15046. * @returns this TransformNode.
  15047. */
  15048. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15049. /**
  15050. * Sets this transform node rotation to the given local axis.
  15051. * @param localAxis the axis in local space
  15052. * @param yawCor optional yaw (y-axis) correction in radians
  15053. * @param pitchCor optional pitch (x-axis) correction in radians
  15054. * @param rollCor optional roll (z-axis) correction in radians
  15055. * @returns this TransformNode
  15056. */
  15057. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15058. /**
  15059. * Sets a new pivot point to the current node
  15060. * @param point defines the new pivot point to use
  15061. * @param space defines if the point is in world or local space (local by default)
  15062. * @returns the current TransformNode
  15063. */
  15064. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15065. /**
  15066. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15067. * @returns the pivot point
  15068. */
  15069. getPivotPoint(): Vector3;
  15070. /**
  15071. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15072. * @param result the vector3 to store the result
  15073. * @returns this TransformNode.
  15074. */
  15075. getPivotPointToRef(result: Vector3): TransformNode;
  15076. /**
  15077. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15078. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15079. */
  15080. getAbsolutePivotPoint(): Vector3;
  15081. /**
  15082. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15083. * @param result vector3 to store the result
  15084. * @returns this TransformNode.
  15085. */
  15086. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15087. /**
  15088. * Defines the passed node as the parent of the current node.
  15089. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15090. * @see https://doc.babylonjs.com/how_to/parenting
  15091. * @param node the node ot set as the parent
  15092. * @returns this TransformNode.
  15093. */
  15094. setParent(node: Nullable<Node>): TransformNode;
  15095. private _nonUniformScaling;
  15096. /**
  15097. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15098. */
  15099. get nonUniformScaling(): boolean;
  15100. /** @hidden */
  15101. _updateNonUniformScalingState(value: boolean): boolean;
  15102. /**
  15103. * Attach the current TransformNode to another TransformNode associated with a bone
  15104. * @param bone Bone affecting the TransformNode
  15105. * @param affectedTransformNode TransformNode associated with the bone
  15106. * @returns this object
  15107. */
  15108. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15109. /**
  15110. * Detach the transform node if its associated with a bone
  15111. * @returns this object
  15112. */
  15113. detachFromBone(): TransformNode;
  15114. private static _rotationAxisCache;
  15115. /**
  15116. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15117. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15118. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15119. * The passed axis is also normalized.
  15120. * @param axis the axis to rotate around
  15121. * @param amount the amount to rotate in radians
  15122. * @param space Space to rotate in (Default: local)
  15123. * @returns the TransformNode.
  15124. */
  15125. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15126. /**
  15127. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15128. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15129. * The passed axis is also normalized. .
  15130. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15131. * @param point the point to rotate around
  15132. * @param axis the axis to rotate around
  15133. * @param amount the amount to rotate in radians
  15134. * @returns the TransformNode
  15135. */
  15136. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15137. /**
  15138. * Translates the mesh along the axis vector for the passed distance in the given space.
  15139. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15140. * @param axis the axis to translate in
  15141. * @param distance the distance to translate
  15142. * @param space Space to rotate in (Default: local)
  15143. * @returns the TransformNode.
  15144. */
  15145. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15146. /**
  15147. * Adds a rotation step to the mesh current rotation.
  15148. * x, y, z are Euler angles expressed in radians.
  15149. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15150. * This means this rotation is made in the mesh local space only.
  15151. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15152. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15153. * ```javascript
  15154. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15155. * ```
  15156. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15157. * 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.
  15158. * @param x Rotation to add
  15159. * @param y Rotation to add
  15160. * @param z Rotation to add
  15161. * @returns the TransformNode.
  15162. */
  15163. addRotation(x: number, y: number, z: number): TransformNode;
  15164. /**
  15165. * @hidden
  15166. */
  15167. protected _getEffectiveParent(): Nullable<Node>;
  15168. /**
  15169. * Computes the world matrix of the node
  15170. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15171. * @returns the world matrix
  15172. */
  15173. computeWorldMatrix(force?: boolean): Matrix;
  15174. /**
  15175. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15176. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15177. */
  15178. resetLocalMatrix(independentOfChildren?: boolean): void;
  15179. protected _afterComputeWorldMatrix(): void;
  15180. /**
  15181. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15182. * @param func callback function to add
  15183. *
  15184. * @returns the TransformNode.
  15185. */
  15186. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15187. /**
  15188. * Removes a registered callback function.
  15189. * @param func callback function to remove
  15190. * @returns the TransformNode.
  15191. */
  15192. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15193. /**
  15194. * Gets the position of the current mesh in camera space
  15195. * @param camera defines the camera to use
  15196. * @returns a position
  15197. */
  15198. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15199. /**
  15200. * Returns the distance from the mesh to the active camera
  15201. * @param camera defines the camera to use
  15202. * @returns the distance
  15203. */
  15204. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15205. /**
  15206. * Clone the current transform node
  15207. * @param name Name of the new clone
  15208. * @param newParent New parent for the clone
  15209. * @param doNotCloneChildren Do not clone children hierarchy
  15210. * @returns the new transform node
  15211. */
  15212. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15213. /**
  15214. * Serializes the objects information.
  15215. * @param currentSerializationObject defines the object to serialize in
  15216. * @returns the serialized object
  15217. */
  15218. serialize(currentSerializationObject?: any): any;
  15219. /**
  15220. * Returns a new TransformNode object parsed from the source provided.
  15221. * @param parsedTransformNode is the source.
  15222. * @param scene the scne the object belongs to
  15223. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15224. * @returns a new TransformNode object parsed from the source provided.
  15225. */
  15226. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15227. /**
  15228. * Get all child-transformNodes of this node
  15229. * @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
  15230. * @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
  15231. * @returns an array of TransformNode
  15232. */
  15233. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15234. /**
  15235. * Releases resources associated with this transform node.
  15236. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15237. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15238. */
  15239. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15240. /**
  15241. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15242. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15243. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15244. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15245. * @returns the current mesh
  15246. */
  15247. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15248. private _syncAbsoluteScalingAndRotation;
  15249. }
  15250. }
  15251. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15252. /**
  15253. * Class used to override all child animations of a given target
  15254. */
  15255. export class AnimationPropertiesOverride {
  15256. /**
  15257. * Gets or sets a value indicating if animation blending must be used
  15258. */
  15259. enableBlending: boolean;
  15260. /**
  15261. * Gets or sets the blending speed to use when enableBlending is true
  15262. */
  15263. blendingSpeed: number;
  15264. /**
  15265. * Gets or sets the default loop mode to use
  15266. */
  15267. loopMode: number;
  15268. }
  15269. }
  15270. declare module "babylonjs/Bones/bone" {
  15271. import { Skeleton } from "babylonjs/Bones/skeleton";
  15272. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15273. import { Nullable } from "babylonjs/types";
  15274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15275. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15276. import { Node } from "babylonjs/node";
  15277. import { Space } from "babylonjs/Maths/math.axis";
  15278. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15279. /**
  15280. * Class used to store bone information
  15281. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15282. */
  15283. export class Bone extends Node {
  15284. /**
  15285. * defines the bone name
  15286. */
  15287. name: string;
  15288. private static _tmpVecs;
  15289. private static _tmpQuat;
  15290. private static _tmpMats;
  15291. /**
  15292. * Gets the list of child bones
  15293. */
  15294. children: Bone[];
  15295. /** Gets the animations associated with this bone */
  15296. animations: import("babylonjs/Animations/animation").Animation[];
  15297. /**
  15298. * Gets or sets bone length
  15299. */
  15300. length: number;
  15301. /**
  15302. * @hidden Internal only
  15303. * Set this value to map this bone to a different index in the transform matrices
  15304. * Set this value to -1 to exclude the bone from the transform matrices
  15305. */
  15306. _index: Nullable<number>;
  15307. private _skeleton;
  15308. private _localMatrix;
  15309. private _restPose;
  15310. private _baseMatrix;
  15311. private _absoluteTransform;
  15312. private _invertedAbsoluteTransform;
  15313. private _parent;
  15314. private _scalingDeterminant;
  15315. private _worldTransform;
  15316. private _localScaling;
  15317. private _localRotation;
  15318. private _localPosition;
  15319. private _needToDecompose;
  15320. private _needToCompose;
  15321. /** @hidden */
  15322. _linkedTransformNode: Nullable<TransformNode>;
  15323. /** @hidden */
  15324. _waitingTransformNodeId: Nullable<string>;
  15325. /** @hidden */
  15326. get _matrix(): Matrix;
  15327. /** @hidden */
  15328. set _matrix(value: Matrix);
  15329. /**
  15330. * Create a new bone
  15331. * @param name defines the bone name
  15332. * @param skeleton defines the parent skeleton
  15333. * @param parentBone defines the parent (can be null if the bone is the root)
  15334. * @param localMatrix defines the local matrix
  15335. * @param restPose defines the rest pose matrix
  15336. * @param baseMatrix defines the base matrix
  15337. * @param index defines index of the bone in the hiearchy
  15338. */
  15339. constructor(
  15340. /**
  15341. * defines the bone name
  15342. */
  15343. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15344. /**
  15345. * Gets the current object class name.
  15346. * @return the class name
  15347. */
  15348. getClassName(): string;
  15349. /**
  15350. * Gets the parent skeleton
  15351. * @returns a skeleton
  15352. */
  15353. getSkeleton(): Skeleton;
  15354. /**
  15355. * Gets parent bone
  15356. * @returns a bone or null if the bone is the root of the bone hierarchy
  15357. */
  15358. getParent(): Nullable<Bone>;
  15359. /**
  15360. * Returns an array containing the root bones
  15361. * @returns an array containing the root bones
  15362. */
  15363. getChildren(): Array<Bone>;
  15364. /**
  15365. * Gets the node index in matrix array generated for rendering
  15366. * @returns the node index
  15367. */
  15368. getIndex(): number;
  15369. /**
  15370. * Sets the parent bone
  15371. * @param parent defines the parent (can be null if the bone is the root)
  15372. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15373. */
  15374. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15375. /**
  15376. * Gets the local matrix
  15377. * @returns a matrix
  15378. */
  15379. getLocalMatrix(): Matrix;
  15380. /**
  15381. * Gets the base matrix (initial matrix which remains unchanged)
  15382. * @returns a matrix
  15383. */
  15384. getBaseMatrix(): Matrix;
  15385. /**
  15386. * Gets the rest pose matrix
  15387. * @returns a matrix
  15388. */
  15389. getRestPose(): Matrix;
  15390. /**
  15391. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15392. */
  15393. getWorldMatrix(): Matrix;
  15394. /**
  15395. * Sets the local matrix to rest pose matrix
  15396. */
  15397. returnToRest(): void;
  15398. /**
  15399. * Gets the inverse of the absolute transform matrix.
  15400. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15401. * @returns a matrix
  15402. */
  15403. getInvertedAbsoluteTransform(): Matrix;
  15404. /**
  15405. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15406. * @returns a matrix
  15407. */
  15408. getAbsoluteTransform(): Matrix;
  15409. /**
  15410. * Links with the given transform node.
  15411. * The local matrix of this bone is copied from the transform node every frame.
  15412. * @param transformNode defines the transform node to link to
  15413. */
  15414. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15415. /**
  15416. * Gets the node used to drive the bone's transformation
  15417. * @returns a transform node or null
  15418. */
  15419. getTransformNode(): Nullable<TransformNode>;
  15420. /** Gets or sets current position (in local space) */
  15421. get position(): Vector3;
  15422. set position(newPosition: Vector3);
  15423. /** Gets or sets current rotation (in local space) */
  15424. get rotation(): Vector3;
  15425. set rotation(newRotation: Vector3);
  15426. /** Gets or sets current rotation quaternion (in local space) */
  15427. get rotationQuaternion(): Quaternion;
  15428. set rotationQuaternion(newRotation: Quaternion);
  15429. /** Gets or sets current scaling (in local space) */
  15430. get scaling(): Vector3;
  15431. set scaling(newScaling: Vector3);
  15432. /**
  15433. * Gets the animation properties override
  15434. */
  15435. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15436. private _decompose;
  15437. private _compose;
  15438. /**
  15439. * Update the base and local matrices
  15440. * @param matrix defines the new base or local matrix
  15441. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15442. * @param updateLocalMatrix defines if the local matrix should be updated
  15443. */
  15444. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15445. /** @hidden */
  15446. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15447. /**
  15448. * Flag the bone as dirty (Forcing it to update everything)
  15449. */
  15450. markAsDirty(): void;
  15451. /** @hidden */
  15452. _markAsDirtyAndCompose(): void;
  15453. private _markAsDirtyAndDecompose;
  15454. /**
  15455. * Translate the bone in local or world space
  15456. * @param vec The amount to translate the bone
  15457. * @param space The space that the translation is in
  15458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15459. */
  15460. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15461. /**
  15462. * Set the postion of the bone in local or world space
  15463. * @param position The position to set the bone
  15464. * @param space The space that the position is in
  15465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15466. */
  15467. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15468. /**
  15469. * Set the absolute position of the bone (world space)
  15470. * @param position The position to set the bone
  15471. * @param mesh The mesh that this bone is attached to
  15472. */
  15473. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15474. /**
  15475. * Scale the bone on the x, y and z axes (in local space)
  15476. * @param x The amount to scale the bone on the x axis
  15477. * @param y The amount to scale the bone on the y axis
  15478. * @param z The amount to scale the bone on the z axis
  15479. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15480. */
  15481. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15482. /**
  15483. * Set the bone scaling in local space
  15484. * @param scale defines the scaling vector
  15485. */
  15486. setScale(scale: Vector3): void;
  15487. /**
  15488. * Gets the current scaling in local space
  15489. * @returns the current scaling vector
  15490. */
  15491. getScale(): Vector3;
  15492. /**
  15493. * Gets the current scaling in local space and stores it in a target vector
  15494. * @param result defines the target vector
  15495. */
  15496. getScaleToRef(result: Vector3): void;
  15497. /**
  15498. * Set the yaw, pitch, and roll of the bone in local or world space
  15499. * @param yaw The rotation of the bone on the y axis
  15500. * @param pitch The rotation of the bone on the x axis
  15501. * @param roll The rotation of the bone on the z axis
  15502. * @param space The space that the axes of rotation are in
  15503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15504. */
  15505. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15506. /**
  15507. * Add a rotation to the bone on an axis in local or world space
  15508. * @param axis The axis to rotate the bone on
  15509. * @param amount The amount to rotate the bone
  15510. * @param space The space that the axis is in
  15511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15512. */
  15513. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15514. /**
  15515. * Set the rotation of the bone to a particular axis angle in local or world space
  15516. * @param axis The axis to rotate the bone on
  15517. * @param angle The angle that the bone should be rotated to
  15518. * @param space The space that the axis is in
  15519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15520. */
  15521. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15522. /**
  15523. * Set the euler rotation of the bone in local of world space
  15524. * @param rotation The euler rotation that the bone should be set to
  15525. * @param space The space that the rotation is in
  15526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15527. */
  15528. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15529. /**
  15530. * Set the quaternion rotation of the bone in local of world space
  15531. * @param quat The quaternion rotation that the bone should be set to
  15532. * @param space The space that the rotation is in
  15533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15534. */
  15535. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15536. /**
  15537. * Set the rotation matrix of the bone in local of world space
  15538. * @param rotMat The rotation matrix that the bone should be set to
  15539. * @param space The space that the rotation is in
  15540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15541. */
  15542. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15543. private _rotateWithMatrix;
  15544. private _getNegativeRotationToRef;
  15545. /**
  15546. * Get the position of the bone in local or world space
  15547. * @param space The space that the returned position is in
  15548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15549. * @returns The position of the bone
  15550. */
  15551. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15552. /**
  15553. * Copy the position of the bone to a vector3 in local or world space
  15554. * @param space The space that the returned position is in
  15555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15556. * @param result The vector3 to copy the position to
  15557. */
  15558. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15559. /**
  15560. * Get the absolute position of the bone (world space)
  15561. * @param mesh The mesh that this bone is attached to
  15562. * @returns The absolute position of the bone
  15563. */
  15564. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15565. /**
  15566. * Copy the absolute position of the bone (world space) to the result param
  15567. * @param mesh The mesh that this bone is attached to
  15568. * @param result The vector3 to copy the absolute position to
  15569. */
  15570. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15571. /**
  15572. * Compute the absolute transforms of this bone and its children
  15573. */
  15574. computeAbsoluteTransforms(): void;
  15575. /**
  15576. * Get the world direction from an axis that is in the local space of the bone
  15577. * @param localAxis The local direction that is used to compute the world direction
  15578. * @param mesh The mesh that this bone is attached to
  15579. * @returns The world direction
  15580. */
  15581. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15582. /**
  15583. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15584. * @param localAxis The local direction that is used to compute the world direction
  15585. * @param mesh The mesh that this bone is attached to
  15586. * @param result The vector3 that the world direction will be copied to
  15587. */
  15588. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15589. /**
  15590. * Get the euler rotation of the bone in local or world space
  15591. * @param space The space that the rotation should be in
  15592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15593. * @returns The euler rotation
  15594. */
  15595. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15596. /**
  15597. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15598. * @param space The space that the rotation should be in
  15599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15600. * @param result The vector3 that the rotation should be copied to
  15601. */
  15602. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15603. /**
  15604. * Get the quaternion rotation of the bone in either local or world space
  15605. * @param space The space that the rotation should be in
  15606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15607. * @returns The quaternion rotation
  15608. */
  15609. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15610. /**
  15611. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15612. * @param space The space that the rotation should be in
  15613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15614. * @param result The quaternion that the rotation should be copied to
  15615. */
  15616. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15617. /**
  15618. * Get the rotation matrix of the bone in local or world space
  15619. * @param space The space that the rotation should be in
  15620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15621. * @returns The rotation matrix
  15622. */
  15623. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15624. /**
  15625. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15626. * @param space The space that the rotation should be in
  15627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15628. * @param result The quaternion that the rotation should be copied to
  15629. */
  15630. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15631. /**
  15632. * Get the world position of a point that is in the local space of the bone
  15633. * @param position The local position
  15634. * @param mesh The mesh that this bone is attached to
  15635. * @returns The world position
  15636. */
  15637. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15638. /**
  15639. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15640. * @param position The local position
  15641. * @param mesh The mesh that this bone is attached to
  15642. * @param result The vector3 that the world position should be copied to
  15643. */
  15644. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15645. /**
  15646. * Get the local position of a point that is in world space
  15647. * @param position The world position
  15648. * @param mesh The mesh that this bone is attached to
  15649. * @returns The local position
  15650. */
  15651. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15652. /**
  15653. * Get the local position of a point that is in world space and copy it to the result param
  15654. * @param position The world position
  15655. * @param mesh The mesh that this bone is attached to
  15656. * @param result The vector3 that the local position should be copied to
  15657. */
  15658. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15659. }
  15660. }
  15661. declare module "babylonjs/Animations/runtimeAnimation" {
  15662. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15663. import { Animatable } from "babylonjs/Animations/animatable";
  15664. import { Scene } from "babylonjs/scene";
  15665. /**
  15666. * Defines a runtime animation
  15667. */
  15668. export class RuntimeAnimation {
  15669. private _events;
  15670. /**
  15671. * The current frame of the runtime animation
  15672. */
  15673. private _currentFrame;
  15674. /**
  15675. * The animation used by the runtime animation
  15676. */
  15677. private _animation;
  15678. /**
  15679. * The target of the runtime animation
  15680. */
  15681. private _target;
  15682. /**
  15683. * The initiating animatable
  15684. */
  15685. private _host;
  15686. /**
  15687. * The original value of the runtime animation
  15688. */
  15689. private _originalValue;
  15690. /**
  15691. * The original blend value of the runtime animation
  15692. */
  15693. private _originalBlendValue;
  15694. /**
  15695. * The offsets cache of the runtime animation
  15696. */
  15697. private _offsetsCache;
  15698. /**
  15699. * The high limits cache of the runtime animation
  15700. */
  15701. private _highLimitsCache;
  15702. /**
  15703. * Specifies if the runtime animation has been stopped
  15704. */
  15705. private _stopped;
  15706. /**
  15707. * The blending factor of the runtime animation
  15708. */
  15709. private _blendingFactor;
  15710. /**
  15711. * The BabylonJS scene
  15712. */
  15713. private _scene;
  15714. /**
  15715. * The current value of the runtime animation
  15716. */
  15717. private _currentValue;
  15718. /** @hidden */
  15719. _animationState: _IAnimationState;
  15720. /**
  15721. * The active target of the runtime animation
  15722. */
  15723. private _activeTargets;
  15724. private _currentActiveTarget;
  15725. private _directTarget;
  15726. /**
  15727. * The target path of the runtime animation
  15728. */
  15729. private _targetPath;
  15730. /**
  15731. * The weight of the runtime animation
  15732. */
  15733. private _weight;
  15734. /**
  15735. * The ratio offset of the runtime animation
  15736. */
  15737. private _ratioOffset;
  15738. /**
  15739. * The previous delay of the runtime animation
  15740. */
  15741. private _previousDelay;
  15742. /**
  15743. * The previous ratio of the runtime animation
  15744. */
  15745. private _previousRatio;
  15746. private _enableBlending;
  15747. private _keys;
  15748. private _minFrame;
  15749. private _maxFrame;
  15750. private _minValue;
  15751. private _maxValue;
  15752. private _targetIsArray;
  15753. /**
  15754. * Gets the current frame of the runtime animation
  15755. */
  15756. get currentFrame(): number;
  15757. /**
  15758. * Gets the weight of the runtime animation
  15759. */
  15760. get weight(): number;
  15761. /**
  15762. * Gets the current value of the runtime animation
  15763. */
  15764. get currentValue(): any;
  15765. /**
  15766. * Gets the target path of the runtime animation
  15767. */
  15768. get targetPath(): string;
  15769. /**
  15770. * Gets the actual target of the runtime animation
  15771. */
  15772. get target(): any;
  15773. /**
  15774. * Gets the additive state of the runtime animation
  15775. */
  15776. get isAdditive(): boolean;
  15777. /** @hidden */
  15778. _onLoop: () => void;
  15779. /**
  15780. * Create a new RuntimeAnimation object
  15781. * @param target defines the target of the animation
  15782. * @param animation defines the source animation object
  15783. * @param scene defines the hosting scene
  15784. * @param host defines the initiating Animatable
  15785. */
  15786. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15787. private _preparePath;
  15788. /**
  15789. * Gets the animation from the runtime animation
  15790. */
  15791. get animation(): Animation;
  15792. /**
  15793. * Resets the runtime animation to the beginning
  15794. * @param restoreOriginal defines whether to restore the target property to the original value
  15795. */
  15796. reset(restoreOriginal?: boolean): void;
  15797. /**
  15798. * Specifies if the runtime animation is stopped
  15799. * @returns Boolean specifying if the runtime animation is stopped
  15800. */
  15801. isStopped(): boolean;
  15802. /**
  15803. * Disposes of the runtime animation
  15804. */
  15805. dispose(): void;
  15806. /**
  15807. * Apply the interpolated value to the target
  15808. * @param currentValue defines the value computed by the animation
  15809. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15810. */
  15811. setValue(currentValue: any, weight: number): void;
  15812. private _getOriginalValues;
  15813. private _setValue;
  15814. /**
  15815. * Gets the loop pmode of the runtime animation
  15816. * @returns Loop Mode
  15817. */
  15818. private _getCorrectLoopMode;
  15819. /**
  15820. * Move the current animation to a given frame
  15821. * @param frame defines the frame to move to
  15822. */
  15823. goToFrame(frame: number): void;
  15824. /**
  15825. * @hidden Internal use only
  15826. */
  15827. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15828. /**
  15829. * Execute the current animation
  15830. * @param delay defines the delay to add to the current frame
  15831. * @param from defines the lower bound of the animation range
  15832. * @param to defines the upper bound of the animation range
  15833. * @param loop defines if the current animation must loop
  15834. * @param speedRatio defines the current speed ratio
  15835. * @param weight defines the weight of the animation (default is -1 so no weight)
  15836. * @param onLoop optional callback called when animation loops
  15837. * @returns a boolean indicating if the animation is running
  15838. */
  15839. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15840. }
  15841. }
  15842. declare module "babylonjs/Animations/animatable" {
  15843. import { Animation } from "babylonjs/Animations/animation";
  15844. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15845. import { Nullable } from "babylonjs/types";
  15846. import { Observable } from "babylonjs/Misc/observable";
  15847. import { Scene } from "babylonjs/scene";
  15848. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15849. import { Node } from "babylonjs/node";
  15850. /**
  15851. * Class used to store an actual running animation
  15852. */
  15853. export class Animatable {
  15854. /** defines the target object */
  15855. target: any;
  15856. /** defines the starting frame number (default is 0) */
  15857. fromFrame: number;
  15858. /** defines the ending frame number (default is 100) */
  15859. toFrame: number;
  15860. /** defines if the animation must loop (default is false) */
  15861. loopAnimation: boolean;
  15862. /** defines a callback to call when animation ends if it is not looping */
  15863. onAnimationEnd?: (() => void) | null | undefined;
  15864. /** defines a callback to call when animation loops */
  15865. onAnimationLoop?: (() => void) | null | undefined;
  15866. /** defines whether the animation should be evaluated additively */
  15867. isAdditive: boolean;
  15868. private _localDelayOffset;
  15869. private _pausedDelay;
  15870. private _runtimeAnimations;
  15871. private _paused;
  15872. private _scene;
  15873. private _speedRatio;
  15874. private _weight;
  15875. private _syncRoot;
  15876. /**
  15877. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15878. * This will only apply for non looping animation (default is true)
  15879. */
  15880. disposeOnEnd: boolean;
  15881. /**
  15882. * Gets a boolean indicating if the animation has started
  15883. */
  15884. animationStarted: boolean;
  15885. /**
  15886. * Observer raised when the animation ends
  15887. */
  15888. onAnimationEndObservable: Observable<Animatable>;
  15889. /**
  15890. * Observer raised when the animation loops
  15891. */
  15892. onAnimationLoopObservable: Observable<Animatable>;
  15893. /**
  15894. * Gets the root Animatable used to synchronize and normalize animations
  15895. */
  15896. get syncRoot(): Nullable<Animatable>;
  15897. /**
  15898. * Gets the current frame of the first RuntimeAnimation
  15899. * Used to synchronize Animatables
  15900. */
  15901. get masterFrame(): number;
  15902. /**
  15903. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15904. */
  15905. get weight(): number;
  15906. set weight(value: number);
  15907. /**
  15908. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15909. */
  15910. get speedRatio(): number;
  15911. set speedRatio(value: number);
  15912. /**
  15913. * Creates a new Animatable
  15914. * @param scene defines the hosting scene
  15915. * @param target defines the target object
  15916. * @param fromFrame defines the starting frame number (default is 0)
  15917. * @param toFrame defines the ending frame number (default is 100)
  15918. * @param loopAnimation defines if the animation must loop (default is false)
  15919. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15920. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15921. * @param animations defines a group of animation to add to the new Animatable
  15922. * @param onAnimationLoop defines a callback to call when animation loops
  15923. * @param isAdditive defines whether the animation should be evaluated additively
  15924. */
  15925. constructor(scene: Scene,
  15926. /** defines the target object */
  15927. target: any,
  15928. /** defines the starting frame number (default is 0) */
  15929. fromFrame?: number,
  15930. /** defines the ending frame number (default is 100) */
  15931. toFrame?: number,
  15932. /** defines if the animation must loop (default is false) */
  15933. loopAnimation?: boolean, speedRatio?: number,
  15934. /** defines a callback to call when animation ends if it is not looping */
  15935. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15936. /** defines a callback to call when animation loops */
  15937. onAnimationLoop?: (() => void) | null | undefined,
  15938. /** defines whether the animation should be evaluated additively */
  15939. isAdditive?: boolean);
  15940. /**
  15941. * Synchronize and normalize current Animatable with a source Animatable
  15942. * This is useful when using animation weights and when animations are not of the same length
  15943. * @param root defines the root Animatable to synchronize with
  15944. * @returns the current Animatable
  15945. */
  15946. syncWith(root: Animatable): Animatable;
  15947. /**
  15948. * Gets the list of runtime animations
  15949. * @returns an array of RuntimeAnimation
  15950. */
  15951. getAnimations(): RuntimeAnimation[];
  15952. /**
  15953. * Adds more animations to the current animatable
  15954. * @param target defines the target of the animations
  15955. * @param animations defines the new animations to add
  15956. */
  15957. appendAnimations(target: any, animations: Animation[]): void;
  15958. /**
  15959. * Gets the source animation for a specific property
  15960. * @param property defines the propertyu to look for
  15961. * @returns null or the source animation for the given property
  15962. */
  15963. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15964. /**
  15965. * Gets the runtime animation for a specific property
  15966. * @param property defines the propertyu to look for
  15967. * @returns null or the runtime animation for the given property
  15968. */
  15969. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15970. /**
  15971. * Resets the animatable to its original state
  15972. */
  15973. reset(): void;
  15974. /**
  15975. * Allows the animatable to blend with current running animations
  15976. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15977. * @param blendingSpeed defines the blending speed to use
  15978. */
  15979. enableBlending(blendingSpeed: number): void;
  15980. /**
  15981. * Disable animation blending
  15982. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15983. */
  15984. disableBlending(): void;
  15985. /**
  15986. * Jump directly to a given frame
  15987. * @param frame defines the frame to jump to
  15988. */
  15989. goToFrame(frame: number): void;
  15990. /**
  15991. * Pause the animation
  15992. */
  15993. pause(): void;
  15994. /**
  15995. * Restart the animation
  15996. */
  15997. restart(): void;
  15998. private _raiseOnAnimationEnd;
  15999. /**
  16000. * Stop and delete the current animation
  16001. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16002. * @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)
  16003. */
  16004. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16005. /**
  16006. * Wait asynchronously for the animation to end
  16007. * @returns a promise which will be fullfilled when the animation ends
  16008. */
  16009. waitAsync(): Promise<Animatable>;
  16010. /** @hidden */
  16011. _animate(delay: number): boolean;
  16012. }
  16013. module "babylonjs/scene" {
  16014. interface Scene {
  16015. /** @hidden */
  16016. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16017. /** @hidden */
  16018. _processLateAnimationBindingsForMatrices(holder: {
  16019. totalWeight: number;
  16020. totalAdditiveWeight: number;
  16021. animations: RuntimeAnimation[];
  16022. additiveAnimations: RuntimeAnimation[];
  16023. originalValue: Matrix;
  16024. }): any;
  16025. /** @hidden */
  16026. _processLateAnimationBindingsForQuaternions(holder: {
  16027. totalWeight: number;
  16028. totalAdditiveWeight: number;
  16029. animations: RuntimeAnimation[];
  16030. additiveAnimations: RuntimeAnimation[];
  16031. originalValue: Quaternion;
  16032. }, refQuaternion: Quaternion): Quaternion;
  16033. /** @hidden */
  16034. _processLateAnimationBindings(): void;
  16035. /**
  16036. * Will start the animation sequence of a given target
  16037. * @param target defines the target
  16038. * @param from defines from which frame should animation start
  16039. * @param to defines until which frame should animation run.
  16040. * @param weight defines the weight to apply to the animation (1.0 by default)
  16041. * @param loop defines if the animation loops
  16042. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16043. * @param onAnimationEnd defines the function to be executed when the animation ends
  16044. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16045. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16046. * @param onAnimationLoop defines the callback to call when an animation loops
  16047. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16048. * @returns the animatable object created for this animation
  16049. */
  16050. 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;
  16051. /**
  16052. * Will start the animation sequence of a given target
  16053. * @param target defines the target
  16054. * @param from defines from which frame should animation start
  16055. * @param to defines until which frame should animation run.
  16056. * @param loop defines if the animation loops
  16057. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16058. * @param onAnimationEnd defines the function to be executed when the animation ends
  16059. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16060. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16061. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16062. * @param onAnimationLoop defines the callback to call when an animation loops
  16063. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16064. * @returns the animatable object created for this animation
  16065. */
  16066. 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;
  16067. /**
  16068. * Will start the animation sequence of a given target and its hierarchy
  16069. * @param target defines the target
  16070. * @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.
  16071. * @param from defines from which frame should animation start
  16072. * @param to defines until which frame should animation run.
  16073. * @param loop defines if the animation loops
  16074. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16075. * @param onAnimationEnd defines the function to be executed when the animation ends
  16076. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16077. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16078. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16079. * @param onAnimationLoop defines the callback to call when an animation loops
  16080. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16081. * @returns the list of created animatables
  16082. */
  16083. 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[];
  16084. /**
  16085. * Begin a new animation on a given node
  16086. * @param target defines the target where the animation will take place
  16087. * @param animations defines the list of animations to start
  16088. * @param from defines the initial value
  16089. * @param to defines the final value
  16090. * @param loop defines if you want animation to loop (off by default)
  16091. * @param speedRatio defines the speed ratio to apply to all animations
  16092. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16093. * @param onAnimationLoop defines the callback to call when an animation loops
  16094. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16095. * @returns the list of created animatables
  16096. */
  16097. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16098. /**
  16099. * Begin a new animation on a given node and its hierarchy
  16100. * @param target defines the root node where the animation will take place
  16101. * @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.
  16102. * @param animations defines the list of animations to start
  16103. * @param from defines the initial value
  16104. * @param to defines the final value
  16105. * @param loop defines if you want animation to loop (off by default)
  16106. * @param speedRatio defines the speed ratio to apply to all animations
  16107. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16108. * @param onAnimationLoop defines the callback to call when an animation loops
  16109. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16110. * @returns the list of animatables created for all nodes
  16111. */
  16112. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16113. /**
  16114. * Gets the animatable associated with a specific target
  16115. * @param target defines the target of the animatable
  16116. * @returns the required animatable if found
  16117. */
  16118. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16119. /**
  16120. * Gets all animatables associated with a given target
  16121. * @param target defines the target to look animatables for
  16122. * @returns an array of Animatables
  16123. */
  16124. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16125. /**
  16126. * Stops and removes all animations that have been applied to the scene
  16127. */
  16128. stopAllAnimations(): void;
  16129. /**
  16130. * Gets the current delta time used by animation engine
  16131. */
  16132. deltaTime: number;
  16133. }
  16134. }
  16135. module "babylonjs/Bones/bone" {
  16136. interface Bone {
  16137. /**
  16138. * Copy an animation range from another bone
  16139. * @param source defines the source bone
  16140. * @param rangeName defines the range name to copy
  16141. * @param frameOffset defines the frame offset
  16142. * @param rescaleAsRequired defines if rescaling must be applied if required
  16143. * @param skelDimensionsRatio defines the scaling ratio
  16144. * @returns true if operation was successful
  16145. */
  16146. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16147. }
  16148. }
  16149. }
  16150. declare module "babylonjs/Bones/skeleton" {
  16151. import { Bone } from "babylonjs/Bones/bone";
  16152. import { Observable } from "babylonjs/Misc/observable";
  16153. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16154. import { Scene } from "babylonjs/scene";
  16155. import { Nullable } from "babylonjs/types";
  16156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16157. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16158. import { Animatable } from "babylonjs/Animations/animatable";
  16159. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16160. import { Animation } from "babylonjs/Animations/animation";
  16161. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16162. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16163. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16164. /**
  16165. * Class used to handle skinning animations
  16166. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16167. */
  16168. export class Skeleton implements IAnimatable {
  16169. /** defines the skeleton name */
  16170. name: string;
  16171. /** defines the skeleton Id */
  16172. id: string;
  16173. /**
  16174. * Defines the list of child bones
  16175. */
  16176. bones: Bone[];
  16177. /**
  16178. * Defines an estimate of the dimension of the skeleton at rest
  16179. */
  16180. dimensionsAtRest: Vector3;
  16181. /**
  16182. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16183. */
  16184. needInitialSkinMatrix: boolean;
  16185. /**
  16186. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16187. */
  16188. overrideMesh: Nullable<AbstractMesh>;
  16189. /**
  16190. * Gets the list of animations attached to this skeleton
  16191. */
  16192. animations: Array<Animation>;
  16193. private _scene;
  16194. private _isDirty;
  16195. private _transformMatrices;
  16196. private _transformMatrixTexture;
  16197. private _meshesWithPoseMatrix;
  16198. private _animatables;
  16199. private _identity;
  16200. private _synchronizedWithMesh;
  16201. private _ranges;
  16202. private _lastAbsoluteTransformsUpdateId;
  16203. private _canUseTextureForBones;
  16204. private _uniqueId;
  16205. /** @hidden */
  16206. _numBonesWithLinkedTransformNode: number;
  16207. /** @hidden */
  16208. _hasWaitingData: Nullable<boolean>;
  16209. /**
  16210. * Specifies if the skeleton should be serialized
  16211. */
  16212. doNotSerialize: boolean;
  16213. private _useTextureToStoreBoneMatrices;
  16214. /**
  16215. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16216. * Please note that this option is not available if the hardware does not support it
  16217. */
  16218. get useTextureToStoreBoneMatrices(): boolean;
  16219. set useTextureToStoreBoneMatrices(value: boolean);
  16220. private _animationPropertiesOverride;
  16221. /**
  16222. * Gets or sets the animation properties override
  16223. */
  16224. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16225. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16226. /**
  16227. * List of inspectable custom properties (used by the Inspector)
  16228. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16229. */
  16230. inspectableCustomProperties: IInspectable[];
  16231. /**
  16232. * An observable triggered before computing the skeleton's matrices
  16233. */
  16234. onBeforeComputeObservable: Observable<Skeleton>;
  16235. /**
  16236. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16237. */
  16238. get isUsingTextureForMatrices(): boolean;
  16239. /**
  16240. * Gets the unique ID of this skeleton
  16241. */
  16242. get uniqueId(): number;
  16243. /**
  16244. * Creates a new skeleton
  16245. * @param name defines the skeleton name
  16246. * @param id defines the skeleton Id
  16247. * @param scene defines the hosting scene
  16248. */
  16249. constructor(
  16250. /** defines the skeleton name */
  16251. name: string,
  16252. /** defines the skeleton Id */
  16253. id: string, scene: Scene);
  16254. /**
  16255. * Gets the current object class name.
  16256. * @return the class name
  16257. */
  16258. getClassName(): string;
  16259. /**
  16260. * Returns an array containing the root bones
  16261. * @returns an array containing the root bones
  16262. */
  16263. getChildren(): Array<Bone>;
  16264. /**
  16265. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16266. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16267. * @returns a Float32Array containing matrices data
  16268. */
  16269. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16270. /**
  16271. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16272. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16273. * @returns a raw texture containing the data
  16274. */
  16275. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16276. /**
  16277. * Gets the current hosting scene
  16278. * @returns a scene object
  16279. */
  16280. getScene(): Scene;
  16281. /**
  16282. * Gets a string representing the current skeleton data
  16283. * @param fullDetails defines a boolean indicating if we want a verbose version
  16284. * @returns a string representing the current skeleton data
  16285. */
  16286. toString(fullDetails?: boolean): string;
  16287. /**
  16288. * Get bone's index searching by name
  16289. * @param name defines bone's name to search for
  16290. * @return the indice of the bone. Returns -1 if not found
  16291. */
  16292. getBoneIndexByName(name: string): number;
  16293. /**
  16294. * Creater a new animation range
  16295. * @param name defines the name of the range
  16296. * @param from defines the start key
  16297. * @param to defines the end key
  16298. */
  16299. createAnimationRange(name: string, from: number, to: number): void;
  16300. /**
  16301. * Delete a specific animation range
  16302. * @param name defines the name of the range
  16303. * @param deleteFrames defines if frames must be removed as well
  16304. */
  16305. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16306. /**
  16307. * Gets a specific animation range
  16308. * @param name defines the name of the range to look for
  16309. * @returns the requested animation range or null if not found
  16310. */
  16311. getAnimationRange(name: string): Nullable<AnimationRange>;
  16312. /**
  16313. * Gets the list of all animation ranges defined on this skeleton
  16314. * @returns an array
  16315. */
  16316. getAnimationRanges(): Nullable<AnimationRange>[];
  16317. /**
  16318. * Copy animation range from a source skeleton.
  16319. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16320. * @param source defines the source skeleton
  16321. * @param name defines the name of the range to copy
  16322. * @param rescaleAsRequired defines if rescaling must be applied if required
  16323. * @returns true if operation was successful
  16324. */
  16325. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16326. /**
  16327. * Forces the skeleton to go to rest pose
  16328. */
  16329. returnToRest(): void;
  16330. private _getHighestAnimationFrame;
  16331. /**
  16332. * Begin a specific animation range
  16333. * @param name defines the name of the range to start
  16334. * @param loop defines if looping must be turned on (false by default)
  16335. * @param speedRatio defines the speed ratio to apply (1 by default)
  16336. * @param onAnimationEnd defines a callback which will be called when animation will end
  16337. * @returns a new animatable
  16338. */
  16339. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16340. /**
  16341. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16342. * @param skeleton defines the Skeleton containing the animation range to convert
  16343. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16344. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16345. * @returns the original skeleton
  16346. */
  16347. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16348. /** @hidden */
  16349. _markAsDirty(): void;
  16350. /** @hidden */
  16351. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16352. /** @hidden */
  16353. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16354. private _computeTransformMatrices;
  16355. /**
  16356. * Build all resources required to render a skeleton
  16357. */
  16358. prepare(): void;
  16359. /**
  16360. * Gets the list of animatables currently running for this skeleton
  16361. * @returns an array of animatables
  16362. */
  16363. getAnimatables(): IAnimatable[];
  16364. /**
  16365. * Clone the current skeleton
  16366. * @param name defines the name of the new skeleton
  16367. * @param id defines the id of the new skeleton
  16368. * @returns the new skeleton
  16369. */
  16370. clone(name: string, id?: string): Skeleton;
  16371. /**
  16372. * Enable animation blending for this skeleton
  16373. * @param blendingSpeed defines the blending speed to apply
  16374. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16375. */
  16376. enableBlending(blendingSpeed?: number): void;
  16377. /**
  16378. * Releases all resources associated with the current skeleton
  16379. */
  16380. dispose(): void;
  16381. /**
  16382. * Serialize the skeleton in a JSON object
  16383. * @returns a JSON object
  16384. */
  16385. serialize(): any;
  16386. /**
  16387. * Creates a new skeleton from serialized data
  16388. * @param parsedSkeleton defines the serialized data
  16389. * @param scene defines the hosting scene
  16390. * @returns a new skeleton
  16391. */
  16392. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16393. /**
  16394. * Compute all node absolute transforms
  16395. * @param forceUpdate defines if computation must be done even if cache is up to date
  16396. */
  16397. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16398. /**
  16399. * Gets the root pose matrix
  16400. * @returns a matrix
  16401. */
  16402. getPoseMatrix(): Nullable<Matrix>;
  16403. /**
  16404. * Sorts bones per internal index
  16405. */
  16406. sortBones(): void;
  16407. private _sortBones;
  16408. }
  16409. }
  16410. declare module "babylonjs/Meshes/instancedMesh" {
  16411. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16412. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16413. import { Camera } from "babylonjs/Cameras/camera";
  16414. import { Node } from "babylonjs/node";
  16415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16416. import { Mesh } from "babylonjs/Meshes/mesh";
  16417. import { Material } from "babylonjs/Materials/material";
  16418. import { Skeleton } from "babylonjs/Bones/skeleton";
  16419. import { Light } from "babylonjs/Lights/light";
  16420. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16421. /**
  16422. * Creates an instance based on a source mesh.
  16423. */
  16424. export class InstancedMesh extends AbstractMesh {
  16425. private _sourceMesh;
  16426. private _currentLOD;
  16427. /** @hidden */
  16428. _indexInSourceMeshInstanceArray: number;
  16429. constructor(name: string, source: Mesh);
  16430. /**
  16431. * Returns the string "InstancedMesh".
  16432. */
  16433. getClassName(): string;
  16434. /** Gets the list of lights affecting that mesh */
  16435. get lightSources(): Light[];
  16436. _resyncLightSources(): void;
  16437. _resyncLightSource(light: Light): void;
  16438. _removeLightSource(light: Light, dispose: boolean): void;
  16439. /**
  16440. * If the source mesh receives shadows
  16441. */
  16442. get receiveShadows(): boolean;
  16443. /**
  16444. * The material of the source mesh
  16445. */
  16446. get material(): Nullable<Material>;
  16447. /**
  16448. * Visibility of the source mesh
  16449. */
  16450. get visibility(): number;
  16451. /**
  16452. * Skeleton of the source mesh
  16453. */
  16454. get skeleton(): Nullable<Skeleton>;
  16455. /**
  16456. * Rendering ground id of the source mesh
  16457. */
  16458. get renderingGroupId(): number;
  16459. set renderingGroupId(value: number);
  16460. /**
  16461. * Returns the total number of vertices (integer).
  16462. */
  16463. getTotalVertices(): number;
  16464. /**
  16465. * Returns a positive integer : the total number of indices in this mesh geometry.
  16466. * @returns the numner of indices or zero if the mesh has no geometry.
  16467. */
  16468. getTotalIndices(): number;
  16469. /**
  16470. * The source mesh of the instance
  16471. */
  16472. get sourceMesh(): Mesh;
  16473. /**
  16474. * Creates a new InstancedMesh object from the mesh model.
  16475. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16476. * @param name defines the name of the new instance
  16477. * @returns a new InstancedMesh
  16478. */
  16479. createInstance(name: string): InstancedMesh;
  16480. /**
  16481. * Is this node ready to be used/rendered
  16482. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16483. * @return {boolean} is it ready
  16484. */
  16485. isReady(completeCheck?: boolean): boolean;
  16486. /**
  16487. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16488. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16489. * @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.
  16490. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16491. */
  16492. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16493. /**
  16494. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16495. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16496. * The `data` are either a numeric array either a Float32Array.
  16497. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16498. * 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).
  16499. * Note that a new underlying VertexBuffer object is created each call.
  16500. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16501. *
  16502. * Possible `kind` values :
  16503. * - VertexBuffer.PositionKind
  16504. * - VertexBuffer.UVKind
  16505. * - VertexBuffer.UV2Kind
  16506. * - VertexBuffer.UV3Kind
  16507. * - VertexBuffer.UV4Kind
  16508. * - VertexBuffer.UV5Kind
  16509. * - VertexBuffer.UV6Kind
  16510. * - VertexBuffer.ColorKind
  16511. * - VertexBuffer.MatricesIndicesKind
  16512. * - VertexBuffer.MatricesIndicesExtraKind
  16513. * - VertexBuffer.MatricesWeightsKind
  16514. * - VertexBuffer.MatricesWeightsExtraKind
  16515. *
  16516. * Returns the Mesh.
  16517. */
  16518. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16519. /**
  16520. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16521. * If the mesh has no geometry, it is simply returned as it is.
  16522. * The `data` are either a numeric array either a Float32Array.
  16523. * No new underlying VertexBuffer object is created.
  16524. * 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.
  16525. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16526. *
  16527. * Possible `kind` values :
  16528. * - VertexBuffer.PositionKind
  16529. * - VertexBuffer.UVKind
  16530. * - VertexBuffer.UV2Kind
  16531. * - VertexBuffer.UV3Kind
  16532. * - VertexBuffer.UV4Kind
  16533. * - VertexBuffer.UV5Kind
  16534. * - VertexBuffer.UV6Kind
  16535. * - VertexBuffer.ColorKind
  16536. * - VertexBuffer.MatricesIndicesKind
  16537. * - VertexBuffer.MatricesIndicesExtraKind
  16538. * - VertexBuffer.MatricesWeightsKind
  16539. * - VertexBuffer.MatricesWeightsExtraKind
  16540. *
  16541. * Returns the Mesh.
  16542. */
  16543. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16544. /**
  16545. * Sets the mesh indices.
  16546. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16547. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16548. * This method creates a new index buffer each call.
  16549. * Returns the Mesh.
  16550. */
  16551. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16552. /**
  16553. * Boolean : True if the mesh owns the requested kind of data.
  16554. */
  16555. isVerticesDataPresent(kind: string): boolean;
  16556. /**
  16557. * Returns an array of indices (IndicesArray).
  16558. */
  16559. getIndices(): Nullable<IndicesArray>;
  16560. get _positions(): Nullable<Vector3[]>;
  16561. /**
  16562. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16563. * This means the mesh underlying bounding box and sphere are recomputed.
  16564. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16565. * @returns the current mesh
  16566. */
  16567. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16568. /** @hidden */
  16569. _preActivate(): InstancedMesh;
  16570. /** @hidden */
  16571. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16572. /** @hidden */
  16573. _postActivate(): void;
  16574. getWorldMatrix(): Matrix;
  16575. get isAnInstance(): boolean;
  16576. /**
  16577. * Returns the current associated LOD AbstractMesh.
  16578. */
  16579. getLOD(camera: Camera): AbstractMesh;
  16580. /** @hidden */
  16581. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16582. /** @hidden */
  16583. _syncSubMeshes(): InstancedMesh;
  16584. /** @hidden */
  16585. _generatePointsArray(): boolean;
  16586. /**
  16587. * Creates a new InstancedMesh from the current mesh.
  16588. * - name (string) : the cloned mesh name
  16589. * - newParent (optional Node) : the optional Node to parent the clone to.
  16590. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16591. *
  16592. * Returns the clone.
  16593. */
  16594. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16595. /**
  16596. * Disposes the InstancedMesh.
  16597. * Returns nothing.
  16598. */
  16599. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16600. }
  16601. module "babylonjs/Meshes/mesh" {
  16602. interface Mesh {
  16603. /**
  16604. * Register a custom buffer that will be instanced
  16605. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16606. * @param kind defines the buffer kind
  16607. * @param stride defines the stride in floats
  16608. */
  16609. registerInstancedBuffer(kind: string, stride: number): void;
  16610. /**
  16611. * true to use the edge renderer for all instances of this mesh
  16612. */
  16613. edgesShareWithInstances: boolean;
  16614. /** @hidden */
  16615. _userInstancedBuffersStorage: {
  16616. data: {
  16617. [key: string]: Float32Array;
  16618. };
  16619. sizes: {
  16620. [key: string]: number;
  16621. };
  16622. vertexBuffers: {
  16623. [key: string]: Nullable<VertexBuffer>;
  16624. };
  16625. strides: {
  16626. [key: string]: number;
  16627. };
  16628. };
  16629. }
  16630. }
  16631. module "babylonjs/Meshes/abstractMesh" {
  16632. interface AbstractMesh {
  16633. /**
  16634. * Object used to store instanced buffers defined by user
  16635. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16636. */
  16637. instancedBuffers: {
  16638. [key: string]: any;
  16639. };
  16640. }
  16641. }
  16642. }
  16643. declare module "babylonjs/Materials/shaderMaterial" {
  16644. import { Nullable } from "babylonjs/types";
  16645. import { Scene } from "babylonjs/scene";
  16646. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16648. import { Mesh } from "babylonjs/Meshes/mesh";
  16649. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16650. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16651. import { Effect } from "babylonjs/Materials/effect";
  16652. import { Material } from "babylonjs/Materials/material";
  16653. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16654. /**
  16655. * Defines the options associated with the creation of a shader material.
  16656. */
  16657. export interface IShaderMaterialOptions {
  16658. /**
  16659. * Does the material work in alpha blend mode
  16660. */
  16661. needAlphaBlending: boolean;
  16662. /**
  16663. * Does the material work in alpha test mode
  16664. */
  16665. needAlphaTesting: boolean;
  16666. /**
  16667. * The list of attribute names used in the shader
  16668. */
  16669. attributes: string[];
  16670. /**
  16671. * The list of unifrom names used in the shader
  16672. */
  16673. uniforms: string[];
  16674. /**
  16675. * The list of UBO names used in the shader
  16676. */
  16677. uniformBuffers: string[];
  16678. /**
  16679. * The list of sampler names used in the shader
  16680. */
  16681. samplers: string[];
  16682. /**
  16683. * The list of defines used in the shader
  16684. */
  16685. defines: string[];
  16686. }
  16687. /**
  16688. * 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.
  16689. *
  16690. * This returned material effects how the mesh will look based on the code in the shaders.
  16691. *
  16692. * @see https://doc.babylonjs.com/how_to/shader_material
  16693. */
  16694. export class ShaderMaterial extends Material {
  16695. private _shaderPath;
  16696. private _options;
  16697. private _textures;
  16698. private _textureArrays;
  16699. private _floats;
  16700. private _ints;
  16701. private _floatsArrays;
  16702. private _colors3;
  16703. private _colors3Arrays;
  16704. private _colors4;
  16705. private _colors4Arrays;
  16706. private _vectors2;
  16707. private _vectors3;
  16708. private _vectors4;
  16709. private _matrices;
  16710. private _matrixArrays;
  16711. private _matrices3x3;
  16712. private _matrices2x2;
  16713. private _vectors2Arrays;
  16714. private _vectors3Arrays;
  16715. private _vectors4Arrays;
  16716. private _cachedWorldViewMatrix;
  16717. private _cachedWorldViewProjectionMatrix;
  16718. private _renderId;
  16719. private _multiview;
  16720. private _cachedDefines;
  16721. /** Define the Url to load snippets */
  16722. static SnippetUrl: string;
  16723. /** Snippet ID if the material was created from the snippet server */
  16724. snippetId: string;
  16725. /**
  16726. * Instantiate a new shader material.
  16727. * 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.
  16728. * This returned material effects how the mesh will look based on the code in the shaders.
  16729. * @see https://doc.babylonjs.com/how_to/shader_material
  16730. * @param name Define the name of the material in the scene
  16731. * @param scene Define the scene the material belongs to
  16732. * @param shaderPath Defines the route to the shader code in one of three ways:
  16733. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16734. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16735. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16736. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16737. * @param options Define the options used to create the shader
  16738. */
  16739. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16740. /**
  16741. * Gets the shader path used to define the shader code
  16742. * It can be modified to trigger a new compilation
  16743. */
  16744. get shaderPath(): any;
  16745. /**
  16746. * Sets the shader path used to define the shader code
  16747. * It can be modified to trigger a new compilation
  16748. */
  16749. set shaderPath(shaderPath: any);
  16750. /**
  16751. * Gets the options used to compile the shader.
  16752. * They can be modified to trigger a new compilation
  16753. */
  16754. get options(): IShaderMaterialOptions;
  16755. /**
  16756. * Gets the current class name of the material e.g. "ShaderMaterial"
  16757. * Mainly use in serialization.
  16758. * @returns the class name
  16759. */
  16760. getClassName(): string;
  16761. /**
  16762. * Specifies if the material will require alpha blending
  16763. * @returns a boolean specifying if alpha blending is needed
  16764. */
  16765. needAlphaBlending(): boolean;
  16766. /**
  16767. * Specifies if this material should be rendered in alpha test mode
  16768. * @returns a boolean specifying if an alpha test is needed.
  16769. */
  16770. needAlphaTesting(): boolean;
  16771. private _checkUniform;
  16772. /**
  16773. * Set a texture in the shader.
  16774. * @param name Define the name of the uniform samplers as defined in the shader
  16775. * @param texture Define the texture to bind to this sampler
  16776. * @return the material itself allowing "fluent" like uniform updates
  16777. */
  16778. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16779. /**
  16780. * Set a texture array in the shader.
  16781. * @param name Define the name of the uniform sampler array as defined in the shader
  16782. * @param textures Define the list of textures to bind to this sampler
  16783. * @return the material itself allowing "fluent" like uniform updates
  16784. */
  16785. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16786. /**
  16787. * Set a float in the shader.
  16788. * @param name Define the name of the uniform as defined in the shader
  16789. * @param value Define the value to give to the uniform
  16790. * @return the material itself allowing "fluent" like uniform updates
  16791. */
  16792. setFloat(name: string, value: number): ShaderMaterial;
  16793. /**
  16794. * Set a int in the shader.
  16795. * @param name Define the name of the uniform as defined in the shader
  16796. * @param value Define the value to give to the uniform
  16797. * @return the material itself allowing "fluent" like uniform updates
  16798. */
  16799. setInt(name: string, value: number): ShaderMaterial;
  16800. /**
  16801. * Set an array of floats in the shader.
  16802. * @param name Define the name of the uniform as defined in the shader
  16803. * @param value Define the value to give to the uniform
  16804. * @return the material itself allowing "fluent" like uniform updates
  16805. */
  16806. setFloats(name: string, value: number[]): ShaderMaterial;
  16807. /**
  16808. * Set a vec3 in the shader from a Color3.
  16809. * @param name Define the name of the uniform as defined in the shader
  16810. * @param value Define the value to give to the uniform
  16811. * @return the material itself allowing "fluent" like uniform updates
  16812. */
  16813. setColor3(name: string, value: Color3): ShaderMaterial;
  16814. /**
  16815. * Set a vec3 array in the shader from a Color3 array.
  16816. * @param name Define the name of the uniform as defined in the shader
  16817. * @param value Define the value to give to the uniform
  16818. * @return the material itself allowing "fluent" like uniform updates
  16819. */
  16820. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16821. /**
  16822. * Set a vec4 in the shader from a Color4.
  16823. * @param name Define the name of the uniform as defined in the shader
  16824. * @param value Define the value to give to the uniform
  16825. * @return the material itself allowing "fluent" like uniform updates
  16826. */
  16827. setColor4(name: string, value: Color4): ShaderMaterial;
  16828. /**
  16829. * Set a vec4 array in the shader from a Color4 array.
  16830. * @param name Define the name of the uniform as defined in the shader
  16831. * @param value Define the value to give to the uniform
  16832. * @return the material itself allowing "fluent" like uniform updates
  16833. */
  16834. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16835. /**
  16836. * Set a vec2 in the shader from a Vector2.
  16837. * @param name Define the name of the uniform as defined in the shader
  16838. * @param value Define the value to give to the uniform
  16839. * @return the material itself allowing "fluent" like uniform updates
  16840. */
  16841. setVector2(name: string, value: Vector2): ShaderMaterial;
  16842. /**
  16843. * Set a vec3 in the shader from a Vector3.
  16844. * @param name Define the name of the uniform as defined in the shader
  16845. * @param value Define the value to give to the uniform
  16846. * @return the material itself allowing "fluent" like uniform updates
  16847. */
  16848. setVector3(name: string, value: Vector3): ShaderMaterial;
  16849. /**
  16850. * Set a vec4 in the shader from a Vector4.
  16851. * @param name Define the name of the uniform as defined in the shader
  16852. * @param value Define the value to give to the uniform
  16853. * @return the material itself allowing "fluent" like uniform updates
  16854. */
  16855. setVector4(name: string, value: Vector4): ShaderMaterial;
  16856. /**
  16857. * Set a mat4 in the shader from a Matrix.
  16858. * @param name Define the name of the uniform as defined in the shader
  16859. * @param value Define the value to give to the uniform
  16860. * @return the material itself allowing "fluent" like uniform updates
  16861. */
  16862. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16863. /**
  16864. * Set a float32Array in the shader from a matrix array.
  16865. * @param name Define the name of the uniform as defined in the shader
  16866. * @param value Define the value to give to the uniform
  16867. * @return the material itself allowing "fluent" like uniform updates
  16868. */
  16869. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16870. /**
  16871. * Set a mat3 in the shader from a Float32Array.
  16872. * @param name Define the name of the uniform as defined in the shader
  16873. * @param value Define the value to give to the uniform
  16874. * @return the material itself allowing "fluent" like uniform updates
  16875. */
  16876. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16877. /**
  16878. * Set a mat2 in the shader from a Float32Array.
  16879. * @param name Define the name of the uniform as defined in the shader
  16880. * @param value Define the value to give to the uniform
  16881. * @return the material itself allowing "fluent" like uniform updates
  16882. */
  16883. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16884. /**
  16885. * Set a vec2 array in the shader from a number array.
  16886. * @param name Define the name of the uniform as defined in the shader
  16887. * @param value Define the value to give to the uniform
  16888. * @return the material itself allowing "fluent" like uniform updates
  16889. */
  16890. setArray2(name: string, value: number[]): ShaderMaterial;
  16891. /**
  16892. * Set a vec3 array in the shader from a number array.
  16893. * @param name Define the name of the uniform as defined in the shader
  16894. * @param value Define the value to give to the uniform
  16895. * @return the material itself allowing "fluent" like uniform updates
  16896. */
  16897. setArray3(name: string, value: number[]): ShaderMaterial;
  16898. /**
  16899. * Set a vec4 array in the shader from a number array.
  16900. * @param name Define the name of the uniform as defined in the shader
  16901. * @param value Define the value to give to the uniform
  16902. * @return the material itself allowing "fluent" like uniform updates
  16903. */
  16904. setArray4(name: string, value: number[]): ShaderMaterial;
  16905. private _checkCache;
  16906. /**
  16907. * Specifies that the submesh is ready to be used
  16908. * @param mesh defines the mesh to check
  16909. * @param subMesh defines which submesh to check
  16910. * @param useInstances specifies that instances should be used
  16911. * @returns a boolean indicating that the submesh is ready or not
  16912. */
  16913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16914. /**
  16915. * Checks if the material is ready to render the requested mesh
  16916. * @param mesh Define the mesh to render
  16917. * @param useInstances Define whether or not the material is used with instances
  16918. * @returns true if ready, otherwise false
  16919. */
  16920. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16921. /**
  16922. * Binds the world matrix to the material
  16923. * @param world defines the world transformation matrix
  16924. * @param effectOverride - If provided, use this effect instead of internal effect
  16925. */
  16926. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16927. /**
  16928. * Binds the submesh to this material by preparing the effect and shader to draw
  16929. * @param world defines the world transformation matrix
  16930. * @param mesh defines the mesh containing the submesh
  16931. * @param subMesh defines the submesh to bind the material to
  16932. */
  16933. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16934. /**
  16935. * Binds the material to the mesh
  16936. * @param world defines the world transformation matrix
  16937. * @param mesh defines the mesh to bind the material to
  16938. * @param effectOverride - If provided, use this effect instead of internal effect
  16939. */
  16940. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16941. protected _afterBind(mesh?: Mesh): void;
  16942. /**
  16943. * Gets the active textures from the material
  16944. * @returns an array of textures
  16945. */
  16946. getActiveTextures(): BaseTexture[];
  16947. /**
  16948. * Specifies if the material uses a texture
  16949. * @param texture defines the texture to check against the material
  16950. * @returns a boolean specifying if the material uses the texture
  16951. */
  16952. hasTexture(texture: BaseTexture): boolean;
  16953. /**
  16954. * Makes a duplicate of the material, and gives it a new name
  16955. * @param name defines the new name for the duplicated material
  16956. * @returns the cloned material
  16957. */
  16958. clone(name: string): ShaderMaterial;
  16959. /**
  16960. * Disposes the material
  16961. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16962. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16963. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16964. */
  16965. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16966. /**
  16967. * Serializes this material in a JSON representation
  16968. * @returns the serialized material object
  16969. */
  16970. serialize(): any;
  16971. /**
  16972. * Creates a shader material from parsed shader material data
  16973. * @param source defines the JSON represnetation of the material
  16974. * @param scene defines the hosting scene
  16975. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16976. * @returns a new material
  16977. */
  16978. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16979. /**
  16980. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16981. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16982. * @param url defines the url to load from
  16983. * @param scene defines the hosting scene
  16984. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16985. * @returns a promise that will resolve to the new ShaderMaterial
  16986. */
  16987. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16988. /**
  16989. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16990. * @param snippetId defines the snippet to load
  16991. * @param scene defines the hosting scene
  16992. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16993. * @returns a promise that will resolve to the new ShaderMaterial
  16994. */
  16995. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16996. }
  16997. }
  16998. declare module "babylonjs/Shaders/color.fragment" {
  16999. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17000. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17001. /** @hidden */
  17002. export var colorPixelShader: {
  17003. name: string;
  17004. shader: string;
  17005. };
  17006. }
  17007. declare module "babylonjs/Shaders/color.vertex" {
  17008. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17009. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17010. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17011. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17012. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17013. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17014. /** @hidden */
  17015. export var colorVertexShader: {
  17016. name: string;
  17017. shader: string;
  17018. };
  17019. }
  17020. declare module "babylonjs/Meshes/linesMesh" {
  17021. import { Nullable } from "babylonjs/types";
  17022. import { Scene } from "babylonjs/scene";
  17023. import { Color3 } from "babylonjs/Maths/math.color";
  17024. import { Node } from "babylonjs/node";
  17025. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17026. import { Mesh } from "babylonjs/Meshes/mesh";
  17027. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17028. import { Effect } from "babylonjs/Materials/effect";
  17029. import { Material } from "babylonjs/Materials/material";
  17030. import "babylonjs/Shaders/color.fragment";
  17031. import "babylonjs/Shaders/color.vertex";
  17032. /**
  17033. * Line mesh
  17034. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17035. */
  17036. export class LinesMesh extends Mesh {
  17037. /**
  17038. * If vertex color should be applied to the mesh
  17039. */
  17040. readonly useVertexColor?: boolean | undefined;
  17041. /**
  17042. * If vertex alpha should be applied to the mesh
  17043. */
  17044. readonly useVertexAlpha?: boolean | undefined;
  17045. /**
  17046. * Color of the line (Default: White)
  17047. */
  17048. color: Color3;
  17049. /**
  17050. * Alpha of the line (Default: 1)
  17051. */
  17052. alpha: number;
  17053. /**
  17054. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17055. * This margin is expressed in world space coordinates, so its value may vary.
  17056. * Default value is 0.1
  17057. */
  17058. intersectionThreshold: number;
  17059. private _colorShader;
  17060. private color4;
  17061. /**
  17062. * Creates a new LinesMesh
  17063. * @param name defines the name
  17064. * @param scene defines the hosting scene
  17065. * @param parent defines the parent mesh if any
  17066. * @param source defines the optional source LinesMesh used to clone data from
  17067. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17068. * When false, achieved by calling a clone(), also passing False.
  17069. * This will make creation of children, recursive.
  17070. * @param useVertexColor defines if this LinesMesh supports vertex color
  17071. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17072. */
  17073. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17074. /**
  17075. * If vertex color should be applied to the mesh
  17076. */
  17077. useVertexColor?: boolean | undefined,
  17078. /**
  17079. * If vertex alpha should be applied to the mesh
  17080. */
  17081. useVertexAlpha?: boolean | undefined);
  17082. private _addClipPlaneDefine;
  17083. private _removeClipPlaneDefine;
  17084. isReady(): boolean;
  17085. /**
  17086. * Returns the string "LineMesh"
  17087. */
  17088. getClassName(): string;
  17089. /**
  17090. * @hidden
  17091. */
  17092. get material(): Material;
  17093. /**
  17094. * @hidden
  17095. */
  17096. set material(value: Material);
  17097. /**
  17098. * @hidden
  17099. */
  17100. get checkCollisions(): boolean;
  17101. /** @hidden */
  17102. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17103. /** @hidden */
  17104. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17105. /**
  17106. * Disposes of the line mesh
  17107. * @param doNotRecurse If children should be disposed
  17108. */
  17109. dispose(doNotRecurse?: boolean): void;
  17110. /**
  17111. * Returns a new LineMesh object cloned from the current one.
  17112. */
  17113. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17114. /**
  17115. * Creates a new InstancedLinesMesh object from the mesh model.
  17116. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17117. * @param name defines the name of the new instance
  17118. * @returns a new InstancedLinesMesh
  17119. */
  17120. createInstance(name: string): InstancedLinesMesh;
  17121. }
  17122. /**
  17123. * Creates an instance based on a source LinesMesh
  17124. */
  17125. export class InstancedLinesMesh extends InstancedMesh {
  17126. /**
  17127. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17128. * This margin is expressed in world space coordinates, so its value may vary.
  17129. * Initilized with the intersectionThreshold value of the source LinesMesh
  17130. */
  17131. intersectionThreshold: number;
  17132. constructor(name: string, source: LinesMesh);
  17133. /**
  17134. * Returns the string "InstancedLinesMesh".
  17135. */
  17136. getClassName(): string;
  17137. }
  17138. }
  17139. declare module "babylonjs/Shaders/line.fragment" {
  17140. /** @hidden */
  17141. export var linePixelShader: {
  17142. name: string;
  17143. shader: string;
  17144. };
  17145. }
  17146. declare module "babylonjs/Shaders/line.vertex" {
  17147. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17148. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17149. /** @hidden */
  17150. export var lineVertexShader: {
  17151. name: string;
  17152. shader: string;
  17153. };
  17154. }
  17155. declare module "babylonjs/Rendering/edgesRenderer" {
  17156. import { Nullable } from "babylonjs/types";
  17157. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17159. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17160. import { IDisposable } from "babylonjs/scene";
  17161. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17162. import "babylonjs/Shaders/line.fragment";
  17163. import "babylonjs/Shaders/line.vertex";
  17164. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17165. import { SmartArray } from "babylonjs/Misc/smartArray";
  17166. module "babylonjs/scene" {
  17167. interface Scene {
  17168. /** @hidden */
  17169. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17170. }
  17171. }
  17172. module "babylonjs/Meshes/abstractMesh" {
  17173. interface AbstractMesh {
  17174. /**
  17175. * Gets the edgesRenderer associated with the mesh
  17176. */
  17177. edgesRenderer: Nullable<EdgesRenderer>;
  17178. }
  17179. }
  17180. module "babylonjs/Meshes/linesMesh" {
  17181. interface LinesMesh {
  17182. /**
  17183. * Enables the edge rendering mode on the mesh.
  17184. * This mode makes the mesh edges visible
  17185. * @param epsilon defines the maximal distance between two angles to detect a face
  17186. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17187. * @returns the currentAbstractMesh
  17188. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17189. */
  17190. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17191. }
  17192. }
  17193. module "babylonjs/Meshes/linesMesh" {
  17194. interface InstancedLinesMesh {
  17195. /**
  17196. * Enables the edge rendering mode on the mesh.
  17197. * This mode makes the mesh edges visible
  17198. * @param epsilon defines the maximal distance between two angles to detect a face
  17199. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17200. * @returns the current InstancedLinesMesh
  17201. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17202. */
  17203. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17204. }
  17205. }
  17206. /**
  17207. * Defines the minimum contract an Edges renderer should follow.
  17208. */
  17209. export interface IEdgesRenderer extends IDisposable {
  17210. /**
  17211. * Gets or sets a boolean indicating if the edgesRenderer is active
  17212. */
  17213. isEnabled: boolean;
  17214. /**
  17215. * Renders the edges of the attached mesh,
  17216. */
  17217. render(): void;
  17218. /**
  17219. * Checks wether or not the edges renderer is ready to render.
  17220. * @return true if ready, otherwise false.
  17221. */
  17222. isReady(): boolean;
  17223. /**
  17224. * List of instances to render in case the source mesh has instances
  17225. */
  17226. customInstances: SmartArray<Matrix>;
  17227. }
  17228. /**
  17229. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17230. */
  17231. export class EdgesRenderer implements IEdgesRenderer {
  17232. /**
  17233. * Define the size of the edges with an orthographic camera
  17234. */
  17235. edgesWidthScalerForOrthographic: number;
  17236. /**
  17237. * Define the size of the edges with a perspective camera
  17238. */
  17239. edgesWidthScalerForPerspective: number;
  17240. protected _source: AbstractMesh;
  17241. protected _linesPositions: number[];
  17242. protected _linesNormals: number[];
  17243. protected _linesIndices: number[];
  17244. protected _epsilon: number;
  17245. protected _indicesCount: number;
  17246. protected _lineShader: ShaderMaterial;
  17247. protected _ib: DataBuffer;
  17248. protected _buffers: {
  17249. [key: string]: Nullable<VertexBuffer>;
  17250. };
  17251. protected _buffersForInstances: {
  17252. [key: string]: Nullable<VertexBuffer>;
  17253. };
  17254. protected _checkVerticesInsteadOfIndices: boolean;
  17255. private _meshRebuildObserver;
  17256. private _meshDisposeObserver;
  17257. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17258. isEnabled: boolean;
  17259. /**
  17260. * List of instances to render in case the source mesh has instances
  17261. */
  17262. customInstances: SmartArray<Matrix>;
  17263. private static GetShader;
  17264. /**
  17265. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17266. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17267. * @param source Mesh used to create edges
  17268. * @param epsilon sum of angles in adjacency to check for edge
  17269. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17270. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17271. */
  17272. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17273. protected _prepareRessources(): void;
  17274. /** @hidden */
  17275. _rebuild(): void;
  17276. /**
  17277. * Releases the required resources for the edges renderer
  17278. */
  17279. dispose(): void;
  17280. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17281. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17282. /**
  17283. * Checks if the pair of p0 and p1 is en edge
  17284. * @param faceIndex
  17285. * @param edge
  17286. * @param faceNormals
  17287. * @param p0
  17288. * @param p1
  17289. * @private
  17290. */
  17291. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17292. /**
  17293. * push line into the position, normal and index buffer
  17294. * @protected
  17295. */
  17296. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17297. /**
  17298. * Generates lines edges from adjacencjes
  17299. * @private
  17300. */
  17301. _generateEdgesLines(): void;
  17302. /**
  17303. * Checks wether or not the edges renderer is ready to render.
  17304. * @return true if ready, otherwise false.
  17305. */
  17306. isReady(): boolean;
  17307. /**
  17308. * Renders the edges of the attached mesh,
  17309. */
  17310. render(): void;
  17311. }
  17312. /**
  17313. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17314. */
  17315. export class LineEdgesRenderer extends EdgesRenderer {
  17316. /**
  17317. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17318. * @param source LineMesh used to generate edges
  17319. * @param epsilon not important (specified angle for edge detection)
  17320. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17321. */
  17322. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17323. /**
  17324. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17325. */
  17326. _generateEdgesLines(): void;
  17327. }
  17328. }
  17329. declare module "babylonjs/Rendering/renderingGroup" {
  17330. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17333. import { Nullable } from "babylonjs/types";
  17334. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17335. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17336. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17337. import { Material } from "babylonjs/Materials/material";
  17338. import { Scene } from "babylonjs/scene";
  17339. /**
  17340. * This represents the object necessary to create a rendering group.
  17341. * This is exclusively used and created by the rendering manager.
  17342. * To modify the behavior, you use the available helpers in your scene or meshes.
  17343. * @hidden
  17344. */
  17345. export class RenderingGroup {
  17346. index: number;
  17347. private static _zeroVector;
  17348. private _scene;
  17349. private _opaqueSubMeshes;
  17350. private _transparentSubMeshes;
  17351. private _alphaTestSubMeshes;
  17352. private _depthOnlySubMeshes;
  17353. private _particleSystems;
  17354. private _spriteManagers;
  17355. private _opaqueSortCompareFn;
  17356. private _alphaTestSortCompareFn;
  17357. private _transparentSortCompareFn;
  17358. private _renderOpaque;
  17359. private _renderAlphaTest;
  17360. private _renderTransparent;
  17361. /** @hidden */
  17362. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17363. onBeforeTransparentRendering: () => void;
  17364. /**
  17365. * Set the opaque sort comparison function.
  17366. * If null the sub meshes will be render in the order they were created
  17367. */
  17368. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17369. /**
  17370. * Set the alpha test sort comparison function.
  17371. * If null the sub meshes will be render in the order they were created
  17372. */
  17373. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17374. /**
  17375. * Set the transparent sort comparison function.
  17376. * If null the sub meshes will be render in the order they were created
  17377. */
  17378. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17379. /**
  17380. * Creates a new rendering group.
  17381. * @param index The rendering group index
  17382. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17383. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17384. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17385. */
  17386. 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>);
  17387. /**
  17388. * Render all the sub meshes contained in the group.
  17389. * @param customRenderFunction Used to override the default render behaviour of the group.
  17390. * @returns true if rendered some submeshes.
  17391. */
  17392. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17393. /**
  17394. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17395. * @param subMeshes The submeshes to render
  17396. */
  17397. private renderOpaqueSorted;
  17398. /**
  17399. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17400. * @param subMeshes The submeshes to render
  17401. */
  17402. private renderAlphaTestSorted;
  17403. /**
  17404. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17405. * @param subMeshes The submeshes to render
  17406. */
  17407. private renderTransparentSorted;
  17408. /**
  17409. * Renders the submeshes in a specified order.
  17410. * @param subMeshes The submeshes to sort before render
  17411. * @param sortCompareFn The comparison function use to sort
  17412. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17413. * @param transparent Specifies to activate blending if true
  17414. */
  17415. private static renderSorted;
  17416. /**
  17417. * Renders the submeshes in the order they were dispatched (no sort applied).
  17418. * @param subMeshes The submeshes to render
  17419. */
  17420. private static renderUnsorted;
  17421. /**
  17422. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17423. * are rendered back to front if in the same alpha index.
  17424. *
  17425. * @param a The first submesh
  17426. * @param b The second submesh
  17427. * @returns The result of the comparison
  17428. */
  17429. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17430. /**
  17431. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17432. * are rendered back to front.
  17433. *
  17434. * @param a The first submesh
  17435. * @param b The second submesh
  17436. * @returns The result of the comparison
  17437. */
  17438. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17439. /**
  17440. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17441. * are rendered front to back (prevent overdraw).
  17442. *
  17443. * @param a The first submesh
  17444. * @param b The second submesh
  17445. * @returns The result of the comparison
  17446. */
  17447. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17448. /**
  17449. * Resets the different lists of submeshes to prepare a new frame.
  17450. */
  17451. prepare(): void;
  17452. dispose(): void;
  17453. /**
  17454. * Inserts the submesh in its correct queue depending on its material.
  17455. * @param subMesh The submesh to dispatch
  17456. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17457. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17458. */
  17459. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17460. dispatchSprites(spriteManager: ISpriteManager): void;
  17461. dispatchParticles(particleSystem: IParticleSystem): void;
  17462. private _renderParticles;
  17463. private _renderSprites;
  17464. }
  17465. }
  17466. declare module "babylonjs/Rendering/renderingManager" {
  17467. import { Nullable } from "babylonjs/types";
  17468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17469. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17470. import { SmartArray } from "babylonjs/Misc/smartArray";
  17471. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17472. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17473. import { Material } from "babylonjs/Materials/material";
  17474. import { Scene } from "babylonjs/scene";
  17475. import { Camera } from "babylonjs/Cameras/camera";
  17476. /**
  17477. * Interface describing the different options available in the rendering manager
  17478. * regarding Auto Clear between groups.
  17479. */
  17480. export interface IRenderingManagerAutoClearSetup {
  17481. /**
  17482. * Defines whether or not autoclear is enable.
  17483. */
  17484. autoClear: boolean;
  17485. /**
  17486. * Defines whether or not to autoclear the depth buffer.
  17487. */
  17488. depth: boolean;
  17489. /**
  17490. * Defines whether or not to autoclear the stencil buffer.
  17491. */
  17492. stencil: boolean;
  17493. }
  17494. /**
  17495. * This class is used by the onRenderingGroupObservable
  17496. */
  17497. export class RenderingGroupInfo {
  17498. /**
  17499. * The Scene that being rendered
  17500. */
  17501. scene: Scene;
  17502. /**
  17503. * The camera currently used for the rendering pass
  17504. */
  17505. camera: Nullable<Camera>;
  17506. /**
  17507. * The ID of the renderingGroup being processed
  17508. */
  17509. renderingGroupId: number;
  17510. }
  17511. /**
  17512. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17513. * It is enable to manage the different groups as well as the different necessary sort functions.
  17514. * This should not be used directly aside of the few static configurations
  17515. */
  17516. export class RenderingManager {
  17517. /**
  17518. * The max id used for rendering groups (not included)
  17519. */
  17520. static MAX_RENDERINGGROUPS: number;
  17521. /**
  17522. * The min id used for rendering groups (included)
  17523. */
  17524. static MIN_RENDERINGGROUPS: number;
  17525. /**
  17526. * Used to globally prevent autoclearing scenes.
  17527. */
  17528. static AUTOCLEAR: boolean;
  17529. /**
  17530. * @hidden
  17531. */
  17532. _useSceneAutoClearSetup: boolean;
  17533. private _scene;
  17534. private _renderingGroups;
  17535. private _depthStencilBufferAlreadyCleaned;
  17536. private _autoClearDepthStencil;
  17537. private _customOpaqueSortCompareFn;
  17538. private _customAlphaTestSortCompareFn;
  17539. private _customTransparentSortCompareFn;
  17540. private _renderingGroupInfo;
  17541. /**
  17542. * Instantiates a new rendering group for a particular scene
  17543. * @param scene Defines the scene the groups belongs to
  17544. */
  17545. constructor(scene: Scene);
  17546. private _clearDepthStencilBuffer;
  17547. /**
  17548. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17549. * @hidden
  17550. */
  17551. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17552. /**
  17553. * Resets the different information of the group to prepare a new frame
  17554. * @hidden
  17555. */
  17556. reset(): void;
  17557. /**
  17558. * Dispose and release the group and its associated resources.
  17559. * @hidden
  17560. */
  17561. dispose(): void;
  17562. /**
  17563. * Clear the info related to rendering groups preventing retention points during dispose.
  17564. */
  17565. freeRenderingGroups(): void;
  17566. private _prepareRenderingGroup;
  17567. /**
  17568. * Add a sprite manager to the rendering manager in order to render it this frame.
  17569. * @param spriteManager Define the sprite manager to render
  17570. */
  17571. dispatchSprites(spriteManager: ISpriteManager): void;
  17572. /**
  17573. * Add a particle system to the rendering manager in order to render it this frame.
  17574. * @param particleSystem Define the particle system to render
  17575. */
  17576. dispatchParticles(particleSystem: IParticleSystem): void;
  17577. /**
  17578. * Add a submesh to the manager in order to render it this frame
  17579. * @param subMesh The submesh to dispatch
  17580. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17581. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17582. */
  17583. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17584. /**
  17585. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17586. * This allowed control for front to back rendering or reversly depending of the special needs.
  17587. *
  17588. * @param renderingGroupId The rendering group id corresponding to its index
  17589. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17590. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17591. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17592. */
  17593. 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;
  17594. /**
  17595. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17596. *
  17597. * @param renderingGroupId The rendering group id corresponding to its index
  17598. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17599. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17600. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17601. */
  17602. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17603. /**
  17604. * Gets the current auto clear configuration for one rendering group of the rendering
  17605. * manager.
  17606. * @param index the rendering group index to get the information for
  17607. * @returns The auto clear setup for the requested rendering group
  17608. */
  17609. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17610. }
  17611. }
  17612. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17613. import { SmartArray } from "babylonjs/Misc/smartArray";
  17614. import { Nullable } from "babylonjs/types";
  17615. import { Scene } from "babylonjs/scene";
  17616. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17617. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17619. import { Mesh } from "babylonjs/Meshes/mesh";
  17620. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17621. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17622. import { Effect } from "babylonjs/Materials/effect";
  17623. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17624. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17625. import "babylonjs/Shaders/shadowMap.fragment";
  17626. import "babylonjs/Shaders/shadowMap.vertex";
  17627. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17628. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17629. import { Observable } from "babylonjs/Misc/observable";
  17630. /**
  17631. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17632. */
  17633. export interface ICustomShaderOptions {
  17634. /**
  17635. * Gets or sets the custom shader name to use
  17636. */
  17637. shaderName: string;
  17638. /**
  17639. * The list of attribute names used in the shader
  17640. */
  17641. attributes?: string[];
  17642. /**
  17643. * The list of unifrom names used in the shader
  17644. */
  17645. uniforms?: string[];
  17646. /**
  17647. * The list of sampler names used in the shader
  17648. */
  17649. samplers?: string[];
  17650. /**
  17651. * The list of defines used in the shader
  17652. */
  17653. defines?: string[];
  17654. }
  17655. /**
  17656. * Interface to implement to create a shadow generator compatible with BJS.
  17657. */
  17658. export interface IShadowGenerator {
  17659. /**
  17660. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17661. * @returns The render target texture if present otherwise, null
  17662. */
  17663. getShadowMap(): Nullable<RenderTargetTexture>;
  17664. /**
  17665. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17666. * @param subMesh The submesh we want to render in the shadow map
  17667. * @param useInstances Defines wether will draw in the map using instances
  17668. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17669. * @returns true if ready otherwise, false
  17670. */
  17671. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17672. /**
  17673. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17674. * @param defines Defines of the material we want to update
  17675. * @param lightIndex Index of the light in the enabled light list of the material
  17676. */
  17677. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17678. /**
  17679. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17680. * defined in the generator but impacting the effect).
  17681. * It implies the unifroms available on the materials are the standard BJS ones.
  17682. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17683. * @param effect The effect we are binfing the information for
  17684. */
  17685. bindShadowLight(lightIndex: string, effect: Effect): void;
  17686. /**
  17687. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17688. * (eq to shadow prjection matrix * light transform matrix)
  17689. * @returns The transform matrix used to create the shadow map
  17690. */
  17691. getTransformMatrix(): Matrix;
  17692. /**
  17693. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17694. * Cube and 2D textures for instance.
  17695. */
  17696. recreateShadowMap(): void;
  17697. /**
  17698. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17699. * @param onCompiled Callback triggered at the and of the effects compilation
  17700. * @param options Sets of optional options forcing the compilation with different modes
  17701. */
  17702. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17703. useInstances: boolean;
  17704. }>): void;
  17705. /**
  17706. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17707. * @param options Sets of optional options forcing the compilation with different modes
  17708. * @returns A promise that resolves when the compilation completes
  17709. */
  17710. forceCompilationAsync(options?: Partial<{
  17711. useInstances: boolean;
  17712. }>): Promise<void>;
  17713. /**
  17714. * Serializes the shadow generator setup to a json object.
  17715. * @returns The serialized JSON object
  17716. */
  17717. serialize(): any;
  17718. /**
  17719. * Disposes the Shadow map and related Textures and effects.
  17720. */
  17721. dispose(): void;
  17722. }
  17723. /**
  17724. * Default implementation IShadowGenerator.
  17725. * This is the main object responsible of generating shadows in the framework.
  17726. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17727. */
  17728. export class ShadowGenerator implements IShadowGenerator {
  17729. /**
  17730. * Name of the shadow generator class
  17731. */
  17732. static CLASSNAME: string;
  17733. /**
  17734. * Shadow generator mode None: no filtering applied.
  17735. */
  17736. static readonly FILTER_NONE: number;
  17737. /**
  17738. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17739. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17740. */
  17741. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17742. /**
  17743. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17744. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17745. */
  17746. static readonly FILTER_POISSONSAMPLING: number;
  17747. /**
  17748. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17749. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17750. */
  17751. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17752. /**
  17753. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17754. * edge artifacts on steep falloff.
  17755. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17756. */
  17757. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17758. /**
  17759. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17760. * edge artifacts on steep falloff.
  17761. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17762. */
  17763. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17764. /**
  17765. * Shadow generator mode PCF: Percentage Closer Filtering
  17766. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17767. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17768. */
  17769. static readonly FILTER_PCF: number;
  17770. /**
  17771. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17772. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17773. * Contact Hardening
  17774. */
  17775. static readonly FILTER_PCSS: number;
  17776. /**
  17777. * Reserved for PCF and PCSS
  17778. * Highest Quality.
  17779. *
  17780. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17781. *
  17782. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17783. */
  17784. static readonly QUALITY_HIGH: number;
  17785. /**
  17786. * Reserved for PCF and PCSS
  17787. * Good tradeoff for quality/perf cross devices
  17788. *
  17789. * Execute PCF on a 3*3 kernel.
  17790. *
  17791. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17792. */
  17793. static readonly QUALITY_MEDIUM: number;
  17794. /**
  17795. * Reserved for PCF and PCSS
  17796. * The lowest quality but the fastest.
  17797. *
  17798. * Execute PCF on a 1*1 kernel.
  17799. *
  17800. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17801. */
  17802. static readonly QUALITY_LOW: number;
  17803. /** Gets or sets the custom shader name to use */
  17804. customShaderOptions: ICustomShaderOptions;
  17805. /**
  17806. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17807. */
  17808. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17809. /**
  17810. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17811. */
  17812. onAfterShadowMapRenderObservable: Observable<Effect>;
  17813. /**
  17814. * Observable triggered before a mesh is rendered in the shadow map.
  17815. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17816. */
  17817. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17818. /**
  17819. * Observable triggered after a mesh is rendered in the shadow map.
  17820. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17821. */
  17822. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17823. protected _bias: number;
  17824. /**
  17825. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17826. */
  17827. get bias(): number;
  17828. /**
  17829. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17830. */
  17831. set bias(bias: number);
  17832. protected _normalBias: number;
  17833. /**
  17834. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17835. */
  17836. get normalBias(): number;
  17837. /**
  17838. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17839. */
  17840. set normalBias(normalBias: number);
  17841. protected _blurBoxOffset: number;
  17842. /**
  17843. * Gets the blur box offset: offset applied during the blur pass.
  17844. * Only useful if useKernelBlur = false
  17845. */
  17846. get blurBoxOffset(): number;
  17847. /**
  17848. * Sets the blur box offset: offset applied during the blur pass.
  17849. * Only useful if useKernelBlur = false
  17850. */
  17851. set blurBoxOffset(value: number);
  17852. protected _blurScale: number;
  17853. /**
  17854. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17855. * 2 means half of the size.
  17856. */
  17857. get blurScale(): number;
  17858. /**
  17859. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17860. * 2 means half of the size.
  17861. */
  17862. set blurScale(value: number);
  17863. protected _blurKernel: number;
  17864. /**
  17865. * Gets the blur kernel: kernel size of the blur pass.
  17866. * Only useful if useKernelBlur = true
  17867. */
  17868. get blurKernel(): number;
  17869. /**
  17870. * Sets the blur kernel: kernel size of the blur pass.
  17871. * Only useful if useKernelBlur = true
  17872. */
  17873. set blurKernel(value: number);
  17874. protected _useKernelBlur: boolean;
  17875. /**
  17876. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17877. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17878. */
  17879. get useKernelBlur(): boolean;
  17880. /**
  17881. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17882. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17883. */
  17884. set useKernelBlur(value: boolean);
  17885. protected _depthScale: number;
  17886. /**
  17887. * Gets the depth scale used in ESM mode.
  17888. */
  17889. get depthScale(): number;
  17890. /**
  17891. * Sets the depth scale used in ESM mode.
  17892. * This can override the scale stored on the light.
  17893. */
  17894. set depthScale(value: number);
  17895. protected _validateFilter(filter: number): number;
  17896. protected _filter: number;
  17897. /**
  17898. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17899. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17900. */
  17901. get filter(): number;
  17902. /**
  17903. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17904. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17905. */
  17906. set filter(value: number);
  17907. /**
  17908. * Gets if the current filter is set to Poisson Sampling.
  17909. */
  17910. get usePoissonSampling(): boolean;
  17911. /**
  17912. * Sets the current filter to Poisson Sampling.
  17913. */
  17914. set usePoissonSampling(value: boolean);
  17915. /**
  17916. * Gets if the current filter is set to ESM.
  17917. */
  17918. get useExponentialShadowMap(): boolean;
  17919. /**
  17920. * Sets the current filter is to ESM.
  17921. */
  17922. set useExponentialShadowMap(value: boolean);
  17923. /**
  17924. * Gets if the current filter is set to filtered ESM.
  17925. */
  17926. get useBlurExponentialShadowMap(): boolean;
  17927. /**
  17928. * Gets if the current filter is set to filtered ESM.
  17929. */
  17930. set useBlurExponentialShadowMap(value: boolean);
  17931. /**
  17932. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17933. * exponential to prevent steep falloff artifacts).
  17934. */
  17935. get useCloseExponentialShadowMap(): boolean;
  17936. /**
  17937. * Sets the current filter to "close ESM" (using the inverse of the
  17938. * exponential to prevent steep falloff artifacts).
  17939. */
  17940. set useCloseExponentialShadowMap(value: boolean);
  17941. /**
  17942. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17943. * exponential to prevent steep falloff artifacts).
  17944. */
  17945. get useBlurCloseExponentialShadowMap(): boolean;
  17946. /**
  17947. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17948. * exponential to prevent steep falloff artifacts).
  17949. */
  17950. set useBlurCloseExponentialShadowMap(value: boolean);
  17951. /**
  17952. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17953. */
  17954. get usePercentageCloserFiltering(): boolean;
  17955. /**
  17956. * Sets the current filter to "PCF" (percentage closer filtering).
  17957. */
  17958. set usePercentageCloserFiltering(value: boolean);
  17959. protected _filteringQuality: number;
  17960. /**
  17961. * Gets the PCF or PCSS Quality.
  17962. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17963. */
  17964. get filteringQuality(): number;
  17965. /**
  17966. * Sets the PCF or PCSS Quality.
  17967. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17968. */
  17969. set filteringQuality(filteringQuality: number);
  17970. /**
  17971. * Gets if the current filter is set to "PCSS" (contact hardening).
  17972. */
  17973. get useContactHardeningShadow(): boolean;
  17974. /**
  17975. * Sets the current filter to "PCSS" (contact hardening).
  17976. */
  17977. set useContactHardeningShadow(value: boolean);
  17978. protected _contactHardeningLightSizeUVRatio: number;
  17979. /**
  17980. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17981. * Using a ratio helps keeping shape stability independently of the map size.
  17982. *
  17983. * It does not account for the light projection as it was having too much
  17984. * instability during the light setup or during light position changes.
  17985. *
  17986. * Only valid if useContactHardeningShadow is true.
  17987. */
  17988. get contactHardeningLightSizeUVRatio(): number;
  17989. /**
  17990. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17991. * Using a ratio helps keeping shape stability independently of the map size.
  17992. *
  17993. * It does not account for the light projection as it was having too much
  17994. * instability during the light setup or during light position changes.
  17995. *
  17996. * Only valid if useContactHardeningShadow is true.
  17997. */
  17998. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17999. protected _darkness: number;
  18000. /** Gets or sets the actual darkness of a shadow */
  18001. get darkness(): number;
  18002. set darkness(value: number);
  18003. /**
  18004. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18005. * 0 means strongest and 1 would means no shadow.
  18006. * @returns the darkness.
  18007. */
  18008. getDarkness(): number;
  18009. /**
  18010. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18011. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18012. * @returns the shadow generator allowing fluent coding.
  18013. */
  18014. setDarkness(darkness: number): ShadowGenerator;
  18015. protected _transparencyShadow: boolean;
  18016. /** Gets or sets the ability to have transparent shadow */
  18017. get transparencyShadow(): boolean;
  18018. set transparencyShadow(value: boolean);
  18019. /**
  18020. * Sets the ability to have transparent shadow (boolean).
  18021. * @param transparent True if transparent else False
  18022. * @returns the shadow generator allowing fluent coding
  18023. */
  18024. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18025. /**
  18026. * Enables or disables shadows with varying strength based on the transparency
  18027. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18028. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18029. * mesh.visibility * alphaTexture.a
  18030. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18031. */
  18032. enableSoftTransparentShadow: boolean;
  18033. protected _shadowMap: Nullable<RenderTargetTexture>;
  18034. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18035. /**
  18036. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18037. * @returns The render target texture if present otherwise, null
  18038. */
  18039. getShadowMap(): Nullable<RenderTargetTexture>;
  18040. /**
  18041. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18042. * @returns The render target texture if the shadow map is present otherwise, null
  18043. */
  18044. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18045. /**
  18046. * Gets the class name of that object
  18047. * @returns "ShadowGenerator"
  18048. */
  18049. getClassName(): string;
  18050. /**
  18051. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18052. * @param mesh Mesh to add
  18053. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18054. * @returns the Shadow Generator itself
  18055. */
  18056. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18057. /**
  18058. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18059. * @param mesh Mesh to remove
  18060. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18061. * @returns the Shadow Generator itself
  18062. */
  18063. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18064. /**
  18065. * Controls the extent to which the shadows fade out at the edge of the frustum
  18066. */
  18067. frustumEdgeFalloff: number;
  18068. protected _light: IShadowLight;
  18069. /**
  18070. * Returns the associated light object.
  18071. * @returns the light generating the shadow
  18072. */
  18073. getLight(): IShadowLight;
  18074. /**
  18075. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18076. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18077. * It might on the other hand introduce peter panning.
  18078. */
  18079. forceBackFacesOnly: boolean;
  18080. protected _scene: Scene;
  18081. protected _lightDirection: Vector3;
  18082. protected _effect: Effect;
  18083. protected _viewMatrix: Matrix;
  18084. protected _projectionMatrix: Matrix;
  18085. protected _transformMatrix: Matrix;
  18086. protected _cachedPosition: Vector3;
  18087. protected _cachedDirection: Vector3;
  18088. protected _cachedDefines: string;
  18089. protected _currentRenderID: number;
  18090. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18091. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18092. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18093. protected _blurPostProcesses: PostProcess[];
  18094. protected _mapSize: number;
  18095. protected _currentFaceIndex: number;
  18096. protected _currentFaceIndexCache: number;
  18097. protected _textureType: number;
  18098. protected _defaultTextureMatrix: Matrix;
  18099. protected _storedUniqueId: Nullable<number>;
  18100. /** @hidden */
  18101. static _SceneComponentInitialization: (scene: Scene) => void;
  18102. /**
  18103. * Creates a ShadowGenerator object.
  18104. * A ShadowGenerator is the required tool to use the shadows.
  18105. * Each light casting shadows needs to use its own ShadowGenerator.
  18106. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18107. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18108. * @param light The light object generating the shadows.
  18109. * @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.
  18110. */
  18111. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18112. protected _initializeGenerator(): void;
  18113. protected _createTargetRenderTexture(): void;
  18114. protected _initializeShadowMap(): void;
  18115. protected _initializeBlurRTTAndPostProcesses(): void;
  18116. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18117. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18118. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18119. protected _applyFilterValues(): void;
  18120. /**
  18121. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18122. * @param onCompiled Callback triggered at the and of the effects compilation
  18123. * @param options Sets of optional options forcing the compilation with different modes
  18124. */
  18125. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18126. useInstances: boolean;
  18127. }>): void;
  18128. /**
  18129. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18130. * @param options Sets of optional options forcing the compilation with different modes
  18131. * @returns A promise that resolves when the compilation completes
  18132. */
  18133. forceCompilationAsync(options?: Partial<{
  18134. useInstances: boolean;
  18135. }>): Promise<void>;
  18136. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18137. private _prepareShadowDefines;
  18138. /**
  18139. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18140. * @param subMesh The submesh we want to render in the shadow map
  18141. * @param useInstances Defines wether will draw in the map using instances
  18142. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18143. * @returns true if ready otherwise, false
  18144. */
  18145. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18146. /**
  18147. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18148. * @param defines Defines of the material we want to update
  18149. * @param lightIndex Index of the light in the enabled light list of the material
  18150. */
  18151. prepareDefines(defines: any, lightIndex: number): void;
  18152. /**
  18153. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18154. * defined in the generator but impacting the effect).
  18155. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18156. * @param effect The effect we are binfing the information for
  18157. */
  18158. bindShadowLight(lightIndex: string, effect: Effect): void;
  18159. /**
  18160. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18161. * (eq to shadow prjection matrix * light transform matrix)
  18162. * @returns The transform matrix used to create the shadow map
  18163. */
  18164. getTransformMatrix(): Matrix;
  18165. /**
  18166. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18167. * Cube and 2D textures for instance.
  18168. */
  18169. recreateShadowMap(): void;
  18170. protected _disposeBlurPostProcesses(): void;
  18171. protected _disposeRTTandPostProcesses(): void;
  18172. /**
  18173. * Disposes the ShadowGenerator.
  18174. * Returns nothing.
  18175. */
  18176. dispose(): void;
  18177. /**
  18178. * Serializes the shadow generator setup to a json object.
  18179. * @returns The serialized JSON object
  18180. */
  18181. serialize(): any;
  18182. /**
  18183. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18184. * @param parsedShadowGenerator The JSON object to parse
  18185. * @param scene The scene to create the shadow map for
  18186. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18187. * @returns The parsed shadow generator
  18188. */
  18189. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18190. }
  18191. }
  18192. declare module "babylonjs/Lights/light" {
  18193. import { Nullable } from "babylonjs/types";
  18194. import { Scene } from "babylonjs/scene";
  18195. import { Vector3 } from "babylonjs/Maths/math.vector";
  18196. import { Color3 } from "babylonjs/Maths/math.color";
  18197. import { Node } from "babylonjs/node";
  18198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18199. import { Effect } from "babylonjs/Materials/effect";
  18200. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18201. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18202. /**
  18203. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18204. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18205. * 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.
  18206. */
  18207. export abstract class Light extends Node {
  18208. /**
  18209. * Falloff Default: light is falling off following the material specification:
  18210. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18211. */
  18212. static readonly FALLOFF_DEFAULT: number;
  18213. /**
  18214. * Falloff Physical: light is falling off following the inverse squared distance law.
  18215. */
  18216. static readonly FALLOFF_PHYSICAL: number;
  18217. /**
  18218. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18219. * to enhance interoperability with other engines.
  18220. */
  18221. static readonly FALLOFF_GLTF: number;
  18222. /**
  18223. * Falloff Standard: light is falling off like in the standard material
  18224. * to enhance interoperability with other materials.
  18225. */
  18226. static readonly FALLOFF_STANDARD: number;
  18227. /**
  18228. * If every light affecting the material is in this lightmapMode,
  18229. * material.lightmapTexture adds or multiplies
  18230. * (depends on material.useLightmapAsShadowmap)
  18231. * after every other light calculations.
  18232. */
  18233. static readonly LIGHTMAP_DEFAULT: number;
  18234. /**
  18235. * material.lightmapTexture as only diffuse lighting from this light
  18236. * adds only specular lighting from this light
  18237. * adds dynamic shadows
  18238. */
  18239. static readonly LIGHTMAP_SPECULAR: number;
  18240. /**
  18241. * material.lightmapTexture as only lighting
  18242. * no light calculation from this light
  18243. * only adds dynamic shadows from this light
  18244. */
  18245. static readonly LIGHTMAP_SHADOWSONLY: number;
  18246. /**
  18247. * Each light type uses the default quantity according to its type:
  18248. * point/spot lights use luminous intensity
  18249. * directional lights use illuminance
  18250. */
  18251. static readonly INTENSITYMODE_AUTOMATIC: number;
  18252. /**
  18253. * lumen (lm)
  18254. */
  18255. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18256. /**
  18257. * candela (lm/sr)
  18258. */
  18259. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18260. /**
  18261. * lux (lm/m^2)
  18262. */
  18263. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18264. /**
  18265. * nit (cd/m^2)
  18266. */
  18267. static readonly INTENSITYMODE_LUMINANCE: number;
  18268. /**
  18269. * Light type const id of the point light.
  18270. */
  18271. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18272. /**
  18273. * Light type const id of the directional light.
  18274. */
  18275. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18276. /**
  18277. * Light type const id of the spot light.
  18278. */
  18279. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18280. /**
  18281. * Light type const id of the hemispheric light.
  18282. */
  18283. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18284. /**
  18285. * Diffuse gives the basic color to an object.
  18286. */
  18287. diffuse: Color3;
  18288. /**
  18289. * Specular produces a highlight color on an object.
  18290. * Note: This is note affecting PBR materials.
  18291. */
  18292. specular: Color3;
  18293. /**
  18294. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18295. * falling off base on range or angle.
  18296. * This can be set to any values in Light.FALLOFF_x.
  18297. *
  18298. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18299. * other types of materials.
  18300. */
  18301. falloffType: number;
  18302. /**
  18303. * Strength of the light.
  18304. * Note: By default it is define in the framework own unit.
  18305. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18306. */
  18307. intensity: number;
  18308. private _range;
  18309. protected _inverseSquaredRange: number;
  18310. /**
  18311. * Defines how far from the source the light is impacting in scene units.
  18312. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18313. */
  18314. get range(): number;
  18315. /**
  18316. * Defines how far from the source the light is impacting in scene units.
  18317. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18318. */
  18319. set range(value: number);
  18320. /**
  18321. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18322. * of light.
  18323. */
  18324. private _photometricScale;
  18325. private _intensityMode;
  18326. /**
  18327. * Gets the photometric scale used to interpret the intensity.
  18328. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18329. */
  18330. get intensityMode(): number;
  18331. /**
  18332. * Sets the photometric scale used to interpret the intensity.
  18333. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18334. */
  18335. set intensityMode(value: number);
  18336. private _radius;
  18337. /**
  18338. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18339. */
  18340. get radius(): number;
  18341. /**
  18342. * sets the light radius used by PBR Materials to simulate soft area lights.
  18343. */
  18344. set radius(value: number);
  18345. private _renderPriority;
  18346. /**
  18347. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18348. * exceeding the number allowed of the materials.
  18349. */
  18350. renderPriority: number;
  18351. private _shadowEnabled;
  18352. /**
  18353. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18354. * the current shadow generator.
  18355. */
  18356. get shadowEnabled(): boolean;
  18357. /**
  18358. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18359. * the current shadow generator.
  18360. */
  18361. set shadowEnabled(value: boolean);
  18362. private _includedOnlyMeshes;
  18363. /**
  18364. * Gets the only meshes impacted by this light.
  18365. */
  18366. get includedOnlyMeshes(): AbstractMesh[];
  18367. /**
  18368. * Sets the only meshes impacted by this light.
  18369. */
  18370. set includedOnlyMeshes(value: AbstractMesh[]);
  18371. private _excludedMeshes;
  18372. /**
  18373. * Gets the meshes not impacted by this light.
  18374. */
  18375. get excludedMeshes(): AbstractMesh[];
  18376. /**
  18377. * Sets the meshes not impacted by this light.
  18378. */
  18379. set excludedMeshes(value: AbstractMesh[]);
  18380. private _excludeWithLayerMask;
  18381. /**
  18382. * Gets the layer id use to find what meshes are not impacted by the light.
  18383. * Inactive if 0
  18384. */
  18385. get excludeWithLayerMask(): number;
  18386. /**
  18387. * Sets the layer id use to find what meshes are not impacted by the light.
  18388. * Inactive if 0
  18389. */
  18390. set excludeWithLayerMask(value: number);
  18391. private _includeOnlyWithLayerMask;
  18392. /**
  18393. * Gets the layer id use to find what meshes are impacted by the light.
  18394. * Inactive if 0
  18395. */
  18396. get includeOnlyWithLayerMask(): number;
  18397. /**
  18398. * Sets the layer id use to find what meshes are impacted by the light.
  18399. * Inactive if 0
  18400. */
  18401. set includeOnlyWithLayerMask(value: number);
  18402. private _lightmapMode;
  18403. /**
  18404. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18405. */
  18406. get lightmapMode(): number;
  18407. /**
  18408. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18409. */
  18410. set lightmapMode(value: number);
  18411. /**
  18412. * Shadow generator associted to the light.
  18413. * @hidden Internal use only.
  18414. */
  18415. _shadowGenerator: Nullable<IShadowGenerator>;
  18416. /**
  18417. * @hidden Internal use only.
  18418. */
  18419. _excludedMeshesIds: string[];
  18420. /**
  18421. * @hidden Internal use only.
  18422. */
  18423. _includedOnlyMeshesIds: string[];
  18424. /**
  18425. * The current light unifom buffer.
  18426. * @hidden Internal use only.
  18427. */
  18428. _uniformBuffer: UniformBuffer;
  18429. /** @hidden */
  18430. _renderId: number;
  18431. /**
  18432. * Creates a Light object in the scene.
  18433. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18434. * @param name The firendly name of the light
  18435. * @param scene The scene the light belongs too
  18436. */
  18437. constructor(name: string, scene: Scene);
  18438. protected abstract _buildUniformLayout(): void;
  18439. /**
  18440. * Sets the passed Effect "effect" with the Light information.
  18441. * @param effect The effect to update
  18442. * @param lightIndex The index of the light in the effect to update
  18443. * @returns The light
  18444. */
  18445. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18446. /**
  18447. * Sets the passed Effect "effect" with the Light textures.
  18448. * @param effect The effect to update
  18449. * @param lightIndex The index of the light in the effect to update
  18450. * @returns The light
  18451. */
  18452. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18453. /**
  18454. * Binds the lights information from the scene to the effect for the given mesh.
  18455. * @param lightIndex Light index
  18456. * @param scene The scene where the light belongs to
  18457. * @param effect The effect we are binding the data to
  18458. * @param useSpecular Defines if specular is supported
  18459. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18460. */
  18461. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18462. /**
  18463. * Sets the passed Effect "effect" with the Light information.
  18464. * @param effect The effect to update
  18465. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18466. * @returns The light
  18467. */
  18468. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18469. /**
  18470. * Returns the string "Light".
  18471. * @returns the class name
  18472. */
  18473. getClassName(): string;
  18474. /** @hidden */
  18475. readonly _isLight: boolean;
  18476. /**
  18477. * Converts the light information to a readable string for debug purpose.
  18478. * @param fullDetails Supports for multiple levels of logging within scene loading
  18479. * @returns the human readable light info
  18480. */
  18481. toString(fullDetails?: boolean): string;
  18482. /** @hidden */
  18483. protected _syncParentEnabledState(): void;
  18484. /**
  18485. * Set the enabled state of this node.
  18486. * @param value - the new enabled state
  18487. */
  18488. setEnabled(value: boolean): void;
  18489. /**
  18490. * Returns the Light associated shadow generator if any.
  18491. * @return the associated shadow generator.
  18492. */
  18493. getShadowGenerator(): Nullable<IShadowGenerator>;
  18494. /**
  18495. * Returns a Vector3, the absolute light position in the World.
  18496. * @returns the world space position of the light
  18497. */
  18498. getAbsolutePosition(): Vector3;
  18499. /**
  18500. * Specifies if the light will affect the passed mesh.
  18501. * @param mesh The mesh to test against the light
  18502. * @return true the mesh is affected otherwise, false.
  18503. */
  18504. canAffectMesh(mesh: AbstractMesh): boolean;
  18505. /**
  18506. * Sort function to order lights for rendering.
  18507. * @param a First Light object to compare to second.
  18508. * @param b Second Light object to compare first.
  18509. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18510. */
  18511. static CompareLightsPriority(a: Light, b: Light): number;
  18512. /**
  18513. * Releases resources associated with this node.
  18514. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18515. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18516. */
  18517. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18518. /**
  18519. * Returns the light type ID (integer).
  18520. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18521. */
  18522. getTypeID(): number;
  18523. /**
  18524. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18525. * @returns the scaled intensity in intensity mode unit
  18526. */
  18527. getScaledIntensity(): number;
  18528. /**
  18529. * Returns a new Light object, named "name", from the current one.
  18530. * @param name The name of the cloned light
  18531. * @param newParent The parent of this light, if it has one
  18532. * @returns the new created light
  18533. */
  18534. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18535. /**
  18536. * Serializes the current light into a Serialization object.
  18537. * @returns the serialized object.
  18538. */
  18539. serialize(): any;
  18540. /**
  18541. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18542. * This new light is named "name" and added to the passed scene.
  18543. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18544. * @param name The friendly name of the light
  18545. * @param scene The scene the new light will belong to
  18546. * @returns the constructor function
  18547. */
  18548. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18549. /**
  18550. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18551. * @param parsedLight The JSON representation of the light
  18552. * @param scene The scene to create the parsed light in
  18553. * @returns the created light after parsing
  18554. */
  18555. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18556. private _hookArrayForExcluded;
  18557. private _hookArrayForIncludedOnly;
  18558. private _resyncMeshes;
  18559. /**
  18560. * Forces the meshes to update their light related information in their rendering used effects
  18561. * @hidden Internal Use Only
  18562. */
  18563. _markMeshesAsLightDirty(): void;
  18564. /**
  18565. * Recomputes the cached photometric scale if needed.
  18566. */
  18567. private _computePhotometricScale;
  18568. /**
  18569. * Returns the Photometric Scale according to the light type and intensity mode.
  18570. */
  18571. private _getPhotometricScale;
  18572. /**
  18573. * Reorder the light in the scene according to their defined priority.
  18574. * @hidden Internal Use Only
  18575. */
  18576. _reorderLightsInScene(): void;
  18577. /**
  18578. * Prepares the list of defines specific to the light type.
  18579. * @param defines the list of defines
  18580. * @param lightIndex defines the index of the light for the effect
  18581. */
  18582. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18583. }
  18584. }
  18585. declare module "babylonjs/Cameras/targetCamera" {
  18586. import { Nullable } from "babylonjs/types";
  18587. import { Camera } from "babylonjs/Cameras/camera";
  18588. import { Scene } from "babylonjs/scene";
  18589. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18590. /**
  18591. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18592. * This is the base of the follow, arc rotate cameras and Free camera
  18593. * @see https://doc.babylonjs.com/features/cameras
  18594. */
  18595. export class TargetCamera extends Camera {
  18596. private static _RigCamTransformMatrix;
  18597. private static _TargetTransformMatrix;
  18598. private static _TargetFocalPoint;
  18599. private _tmpUpVector;
  18600. private _tmpTargetVector;
  18601. /**
  18602. * Define the current direction the camera is moving to
  18603. */
  18604. cameraDirection: Vector3;
  18605. /**
  18606. * Define the current rotation the camera is rotating to
  18607. */
  18608. cameraRotation: Vector2;
  18609. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18610. ignoreParentScaling: boolean;
  18611. /**
  18612. * When set, the up vector of the camera will be updated by the rotation of the camera
  18613. */
  18614. updateUpVectorFromRotation: boolean;
  18615. private _tmpQuaternion;
  18616. /**
  18617. * Define the current rotation of the camera
  18618. */
  18619. rotation: Vector3;
  18620. /**
  18621. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18622. */
  18623. rotationQuaternion: Quaternion;
  18624. /**
  18625. * Define the current speed of the camera
  18626. */
  18627. speed: number;
  18628. /**
  18629. * Add constraint to the camera to prevent it to move freely in all directions and
  18630. * around all axis.
  18631. */
  18632. noRotationConstraint: boolean;
  18633. /**
  18634. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18635. * panning
  18636. */
  18637. invertRotation: boolean;
  18638. /**
  18639. * Speed multiplier for inverse camera panning
  18640. */
  18641. inverseRotationSpeed: number;
  18642. /**
  18643. * Define the current target of the camera as an object or a position.
  18644. */
  18645. lockedTarget: any;
  18646. /** @hidden */
  18647. _currentTarget: Vector3;
  18648. /** @hidden */
  18649. _initialFocalDistance: number;
  18650. /** @hidden */
  18651. _viewMatrix: Matrix;
  18652. /** @hidden */
  18653. _camMatrix: Matrix;
  18654. /** @hidden */
  18655. _cameraTransformMatrix: Matrix;
  18656. /** @hidden */
  18657. _cameraRotationMatrix: Matrix;
  18658. /** @hidden */
  18659. _referencePoint: Vector3;
  18660. /** @hidden */
  18661. _transformedReferencePoint: Vector3;
  18662. /** @hidden */
  18663. _reset: () => void;
  18664. private _defaultUp;
  18665. /**
  18666. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18667. * This is the base of the follow, arc rotate cameras and Free camera
  18668. * @see https://doc.babylonjs.com/features/cameras
  18669. * @param name Defines the name of the camera in the scene
  18670. * @param position Defines the start position of the camera in the scene
  18671. * @param scene Defines the scene the camera belongs to
  18672. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18673. */
  18674. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18675. /**
  18676. * Gets the position in front of the camera at a given distance.
  18677. * @param distance The distance from the camera we want the position to be
  18678. * @returns the position
  18679. */
  18680. getFrontPosition(distance: number): Vector3;
  18681. /** @hidden */
  18682. _getLockedTargetPosition(): Nullable<Vector3>;
  18683. private _storedPosition;
  18684. private _storedRotation;
  18685. private _storedRotationQuaternion;
  18686. /**
  18687. * Store current camera state of the camera (fov, position, rotation, etc..)
  18688. * @returns the camera
  18689. */
  18690. storeState(): Camera;
  18691. /**
  18692. * Restored camera state. You must call storeState() first
  18693. * @returns whether it was successful or not
  18694. * @hidden
  18695. */
  18696. _restoreStateValues(): boolean;
  18697. /** @hidden */
  18698. _initCache(): void;
  18699. /** @hidden */
  18700. _updateCache(ignoreParentClass?: boolean): void;
  18701. /** @hidden */
  18702. _isSynchronizedViewMatrix(): boolean;
  18703. /** @hidden */
  18704. _computeLocalCameraSpeed(): number;
  18705. /**
  18706. * Defines the target the camera should look at.
  18707. * @param target Defines the new target as a Vector or a mesh
  18708. */
  18709. setTarget(target: Vector3): void;
  18710. /**
  18711. * Return the current target position of the camera. This value is expressed in local space.
  18712. * @returns the target position
  18713. */
  18714. getTarget(): Vector3;
  18715. /** @hidden */
  18716. _decideIfNeedsToMove(): boolean;
  18717. /** @hidden */
  18718. _updatePosition(): void;
  18719. /** @hidden */
  18720. _checkInputs(): void;
  18721. protected _updateCameraRotationMatrix(): void;
  18722. /**
  18723. * 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)
  18724. * @returns the current camera
  18725. */
  18726. private _rotateUpVectorWithCameraRotationMatrix;
  18727. private _cachedRotationZ;
  18728. private _cachedQuaternionRotationZ;
  18729. /** @hidden */
  18730. _getViewMatrix(): Matrix;
  18731. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18732. /**
  18733. * @hidden
  18734. */
  18735. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18736. /**
  18737. * @hidden
  18738. */
  18739. _updateRigCameras(): void;
  18740. private _getRigCamPositionAndTarget;
  18741. /**
  18742. * Gets the current object class name.
  18743. * @return the class name
  18744. */
  18745. getClassName(): string;
  18746. }
  18747. }
  18748. declare module "babylonjs/Events/keyboardEvents" {
  18749. /**
  18750. * Gather the list of keyboard event types as constants.
  18751. */
  18752. export class KeyboardEventTypes {
  18753. /**
  18754. * The keydown event is fired when a key becomes active (pressed).
  18755. */
  18756. static readonly KEYDOWN: number;
  18757. /**
  18758. * The keyup event is fired when a key has been released.
  18759. */
  18760. static readonly KEYUP: number;
  18761. }
  18762. /**
  18763. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18764. */
  18765. export class KeyboardInfo {
  18766. /**
  18767. * Defines the type of event (KeyboardEventTypes)
  18768. */
  18769. type: number;
  18770. /**
  18771. * Defines the related dom event
  18772. */
  18773. event: KeyboardEvent;
  18774. /**
  18775. * Instantiates a new keyboard info.
  18776. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18777. * @param type Defines the type of event (KeyboardEventTypes)
  18778. * @param event Defines the related dom event
  18779. */
  18780. constructor(
  18781. /**
  18782. * Defines the type of event (KeyboardEventTypes)
  18783. */
  18784. type: number,
  18785. /**
  18786. * Defines the related dom event
  18787. */
  18788. event: KeyboardEvent);
  18789. }
  18790. /**
  18791. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18792. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18793. */
  18794. export class KeyboardInfoPre extends KeyboardInfo {
  18795. /**
  18796. * Defines the type of event (KeyboardEventTypes)
  18797. */
  18798. type: number;
  18799. /**
  18800. * Defines the related dom event
  18801. */
  18802. event: KeyboardEvent;
  18803. /**
  18804. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18805. */
  18806. skipOnPointerObservable: boolean;
  18807. /**
  18808. * Instantiates a new keyboard pre info.
  18809. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18810. * @param type Defines the type of event (KeyboardEventTypes)
  18811. * @param event Defines the related dom event
  18812. */
  18813. constructor(
  18814. /**
  18815. * Defines the type of event (KeyboardEventTypes)
  18816. */
  18817. type: number,
  18818. /**
  18819. * Defines the related dom event
  18820. */
  18821. event: KeyboardEvent);
  18822. }
  18823. }
  18824. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18825. import { Nullable } from "babylonjs/types";
  18826. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18827. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18828. /**
  18829. * Manage the keyboard inputs to control the movement of a free camera.
  18830. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18831. */
  18832. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18833. /**
  18834. * Defines the camera the input is attached to.
  18835. */
  18836. camera: FreeCamera;
  18837. /**
  18838. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18839. */
  18840. keysUp: number[];
  18841. /**
  18842. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18843. */
  18844. keysUpward: number[];
  18845. /**
  18846. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18847. */
  18848. keysDown: number[];
  18849. /**
  18850. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18851. */
  18852. keysDownward: number[];
  18853. /**
  18854. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18855. */
  18856. keysLeft: number[];
  18857. /**
  18858. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18859. */
  18860. keysRight: number[];
  18861. private _keys;
  18862. private _onCanvasBlurObserver;
  18863. private _onKeyboardObserver;
  18864. private _engine;
  18865. private _scene;
  18866. /**
  18867. * Attach the input controls to a specific dom element to get the input from.
  18868. * @param element Defines the element the controls should be listened from
  18869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18870. */
  18871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18872. /**
  18873. * Detach the current controls from the specified dom element.
  18874. * @param element Defines the element to stop listening the inputs from
  18875. */
  18876. detachControl(element: Nullable<HTMLElement>): void;
  18877. /**
  18878. * Update the current camera state depending on the inputs that have been used this frame.
  18879. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18880. */
  18881. checkInputs(): void;
  18882. /**
  18883. * Gets the class name of the current intput.
  18884. * @returns the class name
  18885. */
  18886. getClassName(): string;
  18887. /** @hidden */
  18888. _onLostFocus(): void;
  18889. /**
  18890. * Get the friendly name associated with the input class.
  18891. * @returns the input friendly name
  18892. */
  18893. getSimpleName(): string;
  18894. }
  18895. }
  18896. declare module "babylonjs/Events/pointerEvents" {
  18897. import { Nullable } from "babylonjs/types";
  18898. import { Vector2 } from "babylonjs/Maths/math.vector";
  18899. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18900. import { Ray } from "babylonjs/Culling/ray";
  18901. /**
  18902. * Gather the list of pointer event types as constants.
  18903. */
  18904. export class PointerEventTypes {
  18905. /**
  18906. * 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.
  18907. */
  18908. static readonly POINTERDOWN: number;
  18909. /**
  18910. * The pointerup event is fired when a pointer is no longer active.
  18911. */
  18912. static readonly POINTERUP: number;
  18913. /**
  18914. * The pointermove event is fired when a pointer changes coordinates.
  18915. */
  18916. static readonly POINTERMOVE: number;
  18917. /**
  18918. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18919. */
  18920. static readonly POINTERWHEEL: number;
  18921. /**
  18922. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18923. */
  18924. static readonly POINTERPICK: number;
  18925. /**
  18926. * The pointertap event is fired when a the object has been touched and released without drag.
  18927. */
  18928. static readonly POINTERTAP: number;
  18929. /**
  18930. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18931. */
  18932. static readonly POINTERDOUBLETAP: number;
  18933. }
  18934. /**
  18935. * Base class of pointer info types.
  18936. */
  18937. export class PointerInfoBase {
  18938. /**
  18939. * Defines the type of event (PointerEventTypes)
  18940. */
  18941. type: number;
  18942. /**
  18943. * Defines the related dom event
  18944. */
  18945. event: PointerEvent | MouseWheelEvent;
  18946. /**
  18947. * Instantiates the base class of pointers info.
  18948. * @param type Defines the type of event (PointerEventTypes)
  18949. * @param event Defines the related dom event
  18950. */
  18951. constructor(
  18952. /**
  18953. * Defines the type of event (PointerEventTypes)
  18954. */
  18955. type: number,
  18956. /**
  18957. * Defines the related dom event
  18958. */
  18959. event: PointerEvent | MouseWheelEvent);
  18960. }
  18961. /**
  18962. * This class is used to store pointer related info for the onPrePointerObservable event.
  18963. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18964. */
  18965. export class PointerInfoPre extends PointerInfoBase {
  18966. /**
  18967. * Ray from a pointer if availible (eg. 6dof controller)
  18968. */
  18969. ray: Nullable<Ray>;
  18970. /**
  18971. * Defines the local position of the pointer on the canvas.
  18972. */
  18973. localPosition: Vector2;
  18974. /**
  18975. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18976. */
  18977. skipOnPointerObservable: boolean;
  18978. /**
  18979. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18980. * @param type Defines the type of event (PointerEventTypes)
  18981. * @param event Defines the related dom event
  18982. * @param localX Defines the local x coordinates of the pointer when the event occured
  18983. * @param localY Defines the local y coordinates of the pointer when the event occured
  18984. */
  18985. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18986. }
  18987. /**
  18988. * This type contains all the data related to a pointer event in Babylon.js.
  18989. * 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.
  18990. */
  18991. export class PointerInfo extends PointerInfoBase {
  18992. /**
  18993. * Defines the picking info associated to the info (if any)\
  18994. */
  18995. pickInfo: Nullable<PickingInfo>;
  18996. /**
  18997. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18998. * @param type Defines the type of event (PointerEventTypes)
  18999. * @param event Defines the related dom event
  19000. * @param pickInfo Defines the picking info associated to the info (if any)\
  19001. */
  19002. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19003. /**
  19004. * Defines the picking info associated to the info (if any)\
  19005. */
  19006. pickInfo: Nullable<PickingInfo>);
  19007. }
  19008. /**
  19009. * Data relating to a touch event on the screen.
  19010. */
  19011. export interface PointerTouch {
  19012. /**
  19013. * X coordinate of touch.
  19014. */
  19015. x: number;
  19016. /**
  19017. * Y coordinate of touch.
  19018. */
  19019. y: number;
  19020. /**
  19021. * Id of touch. Unique for each finger.
  19022. */
  19023. pointerId: number;
  19024. /**
  19025. * Event type passed from DOM.
  19026. */
  19027. type: any;
  19028. }
  19029. }
  19030. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19031. import { Observable } from "babylonjs/Misc/observable";
  19032. import { Nullable } from "babylonjs/types";
  19033. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19034. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19035. /**
  19036. * Manage the mouse inputs to control the movement of a free camera.
  19037. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19038. */
  19039. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19040. /**
  19041. * Define if touch is enabled in the mouse input
  19042. */
  19043. touchEnabled: boolean;
  19044. /**
  19045. * Defines the camera the input is attached to.
  19046. */
  19047. camera: FreeCamera;
  19048. /**
  19049. * Defines the buttons associated with the input to handle camera move.
  19050. */
  19051. buttons: number[];
  19052. /**
  19053. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19054. */
  19055. angularSensibility: number;
  19056. private _pointerInput;
  19057. private _onMouseMove;
  19058. private _observer;
  19059. private previousPosition;
  19060. /**
  19061. * Observable for when a pointer move event occurs containing the move offset
  19062. */
  19063. onPointerMovedObservable: Observable<{
  19064. offsetX: number;
  19065. offsetY: number;
  19066. }>;
  19067. /**
  19068. * @hidden
  19069. * If the camera should be rotated automatically based on pointer movement
  19070. */
  19071. _allowCameraRotation: boolean;
  19072. /**
  19073. * Manage the mouse inputs to control the movement of a free camera.
  19074. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19075. * @param touchEnabled Defines if touch is enabled or not
  19076. */
  19077. constructor(
  19078. /**
  19079. * Define if touch is enabled in the mouse input
  19080. */
  19081. touchEnabled?: boolean);
  19082. /**
  19083. * Attach the input controls to a specific dom element to get the input from.
  19084. * @param element Defines the element the controls should be listened from
  19085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19086. */
  19087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19088. /**
  19089. * Called on JS contextmenu event.
  19090. * Override this method to provide functionality.
  19091. */
  19092. protected onContextMenu(evt: PointerEvent): void;
  19093. /**
  19094. * Detach the current controls from the specified dom element.
  19095. * @param element Defines the element to stop listening the inputs from
  19096. */
  19097. detachControl(element: Nullable<HTMLElement>): void;
  19098. /**
  19099. * Gets the class name of the current intput.
  19100. * @returns the class name
  19101. */
  19102. getClassName(): string;
  19103. /**
  19104. * Get the friendly name associated with the input class.
  19105. * @returns the input friendly name
  19106. */
  19107. getSimpleName(): string;
  19108. }
  19109. }
  19110. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19111. import { Nullable } from "babylonjs/types";
  19112. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19113. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19114. /**
  19115. * Manage the touch inputs to control the movement of a free camera.
  19116. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19117. */
  19118. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19119. /**
  19120. * Defines the camera the input is attached to.
  19121. */
  19122. camera: FreeCamera;
  19123. /**
  19124. * Defines the touch sensibility for rotation.
  19125. * The higher the faster.
  19126. */
  19127. touchAngularSensibility: number;
  19128. /**
  19129. * Defines the touch sensibility for move.
  19130. * The higher the faster.
  19131. */
  19132. touchMoveSensibility: number;
  19133. private _offsetX;
  19134. private _offsetY;
  19135. private _pointerPressed;
  19136. private _pointerInput;
  19137. private _observer;
  19138. private _onLostFocus;
  19139. /**
  19140. * Attach the input controls to a specific dom element to get the input from.
  19141. * @param element Defines the element the controls should be listened from
  19142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19143. */
  19144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19145. /**
  19146. * Detach the current controls from the specified dom element.
  19147. * @param element Defines the element to stop listening the inputs from
  19148. */
  19149. detachControl(element: Nullable<HTMLElement>): void;
  19150. /**
  19151. * Update the current camera state depending on the inputs that have been used this frame.
  19152. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19153. */
  19154. checkInputs(): void;
  19155. /**
  19156. * Gets the class name of the current intput.
  19157. * @returns the class name
  19158. */
  19159. getClassName(): string;
  19160. /**
  19161. * Get the friendly name associated with the input class.
  19162. * @returns the input friendly name
  19163. */
  19164. getSimpleName(): string;
  19165. }
  19166. }
  19167. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19168. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19169. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19170. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19171. import { Nullable } from "babylonjs/types";
  19172. /**
  19173. * Default Inputs manager for the FreeCamera.
  19174. * It groups all the default supported inputs for ease of use.
  19175. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19176. */
  19177. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19178. /**
  19179. * @hidden
  19180. */
  19181. _mouseInput: Nullable<FreeCameraMouseInput>;
  19182. /**
  19183. * Instantiates a new FreeCameraInputsManager.
  19184. * @param camera Defines the camera the inputs belong to
  19185. */
  19186. constructor(camera: FreeCamera);
  19187. /**
  19188. * Add keyboard input support to the input manager.
  19189. * @returns the current input manager
  19190. */
  19191. addKeyboard(): FreeCameraInputsManager;
  19192. /**
  19193. * Add mouse input support to the input manager.
  19194. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19195. * @returns the current input manager
  19196. */
  19197. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19198. /**
  19199. * Removes the mouse input support from the manager
  19200. * @returns the current input manager
  19201. */
  19202. removeMouse(): FreeCameraInputsManager;
  19203. /**
  19204. * Add touch input support to the input manager.
  19205. * @returns the current input manager
  19206. */
  19207. addTouch(): FreeCameraInputsManager;
  19208. /**
  19209. * Remove all attached input methods from a camera
  19210. */
  19211. clear(): void;
  19212. }
  19213. }
  19214. declare module "babylonjs/Cameras/freeCamera" {
  19215. import { Vector3 } from "babylonjs/Maths/math.vector";
  19216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19217. import { Scene } from "babylonjs/scene";
  19218. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19219. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19220. /**
  19221. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19222. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19223. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19224. */
  19225. export class FreeCamera extends TargetCamera {
  19226. /**
  19227. * Define the collision ellipsoid of the camera.
  19228. * This is helpful to simulate a camera body like the player body around the camera
  19229. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19230. */
  19231. ellipsoid: Vector3;
  19232. /**
  19233. * Define an offset for the position of the ellipsoid around the camera.
  19234. * This can be helpful to determine the center of the body near the gravity center of the body
  19235. * instead of its head.
  19236. */
  19237. ellipsoidOffset: Vector3;
  19238. /**
  19239. * Enable or disable collisions of the camera with the rest of the scene objects.
  19240. */
  19241. checkCollisions: boolean;
  19242. /**
  19243. * Enable or disable gravity on the camera.
  19244. */
  19245. applyGravity: boolean;
  19246. /**
  19247. * Define the input manager associated to the camera.
  19248. */
  19249. inputs: FreeCameraInputsManager;
  19250. /**
  19251. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19252. * Higher values reduce sensitivity.
  19253. */
  19254. get angularSensibility(): number;
  19255. /**
  19256. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19257. * Higher values reduce sensitivity.
  19258. */
  19259. set angularSensibility(value: number);
  19260. /**
  19261. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19262. */
  19263. get keysUp(): number[];
  19264. set keysUp(value: number[]);
  19265. /**
  19266. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19267. */
  19268. get keysUpward(): number[];
  19269. set keysUpward(value: number[]);
  19270. /**
  19271. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19272. */
  19273. get keysDown(): number[];
  19274. set keysDown(value: number[]);
  19275. /**
  19276. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19277. */
  19278. get keysDownward(): number[];
  19279. set keysDownward(value: number[]);
  19280. /**
  19281. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19282. */
  19283. get keysLeft(): number[];
  19284. set keysLeft(value: number[]);
  19285. /**
  19286. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19287. */
  19288. get keysRight(): number[];
  19289. set keysRight(value: number[]);
  19290. /**
  19291. * Event raised when the camera collide with a mesh in the scene.
  19292. */
  19293. onCollide: (collidedMesh: AbstractMesh) => void;
  19294. private _collider;
  19295. private _needMoveForGravity;
  19296. private _oldPosition;
  19297. private _diffPosition;
  19298. private _newPosition;
  19299. /** @hidden */
  19300. _localDirection: Vector3;
  19301. /** @hidden */
  19302. _transformedDirection: Vector3;
  19303. /**
  19304. * Instantiates a Free Camera.
  19305. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19306. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19307. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19308. * @param name Define the name of the camera in the scene
  19309. * @param position Define the start position of the camera in the scene
  19310. * @param scene Define the scene the camera belongs to
  19311. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19312. */
  19313. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19314. /**
  19315. * Attached controls to the current camera.
  19316. * @param element Defines the element the controls should be listened from
  19317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19318. */
  19319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19320. /**
  19321. * Detach the current controls from the camera.
  19322. * The camera will stop reacting to inputs.
  19323. * @param element Defines the element to stop listening the inputs from
  19324. */
  19325. detachControl(element: HTMLElement): void;
  19326. private _collisionMask;
  19327. /**
  19328. * Define a collision mask to limit the list of object the camera can collide with
  19329. */
  19330. get collisionMask(): number;
  19331. set collisionMask(mask: number);
  19332. /** @hidden */
  19333. _collideWithWorld(displacement: Vector3): void;
  19334. private _onCollisionPositionChange;
  19335. /** @hidden */
  19336. _checkInputs(): void;
  19337. /** @hidden */
  19338. _decideIfNeedsToMove(): boolean;
  19339. /** @hidden */
  19340. _updatePosition(): void;
  19341. /**
  19342. * Destroy the camera and release the current resources hold by it.
  19343. */
  19344. dispose(): void;
  19345. /**
  19346. * Gets the current object class name.
  19347. * @return the class name
  19348. */
  19349. getClassName(): string;
  19350. }
  19351. }
  19352. declare module "babylonjs/Gamepads/gamepad" {
  19353. import { Observable } from "babylonjs/Misc/observable";
  19354. /**
  19355. * Represents a gamepad control stick position
  19356. */
  19357. export class StickValues {
  19358. /**
  19359. * The x component of the control stick
  19360. */
  19361. x: number;
  19362. /**
  19363. * The y component of the control stick
  19364. */
  19365. y: number;
  19366. /**
  19367. * Initializes the gamepad x and y control stick values
  19368. * @param x The x component of the gamepad control stick value
  19369. * @param y The y component of the gamepad control stick value
  19370. */
  19371. constructor(
  19372. /**
  19373. * The x component of the control stick
  19374. */
  19375. x: number,
  19376. /**
  19377. * The y component of the control stick
  19378. */
  19379. y: number);
  19380. }
  19381. /**
  19382. * An interface which manages callbacks for gamepad button changes
  19383. */
  19384. export interface GamepadButtonChanges {
  19385. /**
  19386. * Called when a gamepad has been changed
  19387. */
  19388. changed: boolean;
  19389. /**
  19390. * Called when a gamepad press event has been triggered
  19391. */
  19392. pressChanged: boolean;
  19393. /**
  19394. * Called when a touch event has been triggered
  19395. */
  19396. touchChanged: boolean;
  19397. /**
  19398. * Called when a value has changed
  19399. */
  19400. valueChanged: boolean;
  19401. }
  19402. /**
  19403. * Represents a gamepad
  19404. */
  19405. export class Gamepad {
  19406. /**
  19407. * The id of the gamepad
  19408. */
  19409. id: string;
  19410. /**
  19411. * The index of the gamepad
  19412. */
  19413. index: number;
  19414. /**
  19415. * The browser gamepad
  19416. */
  19417. browserGamepad: any;
  19418. /**
  19419. * Specifies what type of gamepad this represents
  19420. */
  19421. type: number;
  19422. private _leftStick;
  19423. private _rightStick;
  19424. /** @hidden */
  19425. _isConnected: boolean;
  19426. private _leftStickAxisX;
  19427. private _leftStickAxisY;
  19428. private _rightStickAxisX;
  19429. private _rightStickAxisY;
  19430. /**
  19431. * Triggered when the left control stick has been changed
  19432. */
  19433. private _onleftstickchanged;
  19434. /**
  19435. * Triggered when the right control stick has been changed
  19436. */
  19437. private _onrightstickchanged;
  19438. /**
  19439. * Represents a gamepad controller
  19440. */
  19441. static GAMEPAD: number;
  19442. /**
  19443. * Represents a generic controller
  19444. */
  19445. static GENERIC: number;
  19446. /**
  19447. * Represents an XBox controller
  19448. */
  19449. static XBOX: number;
  19450. /**
  19451. * Represents a pose-enabled controller
  19452. */
  19453. static POSE_ENABLED: number;
  19454. /**
  19455. * Represents an Dual Shock controller
  19456. */
  19457. static DUALSHOCK: number;
  19458. /**
  19459. * Specifies whether the left control stick should be Y-inverted
  19460. */
  19461. protected _invertLeftStickY: boolean;
  19462. /**
  19463. * Specifies if the gamepad has been connected
  19464. */
  19465. get isConnected(): boolean;
  19466. /**
  19467. * Initializes the gamepad
  19468. * @param id The id of the gamepad
  19469. * @param index The index of the gamepad
  19470. * @param browserGamepad The browser gamepad
  19471. * @param leftStickX The x component of the left joystick
  19472. * @param leftStickY The y component of the left joystick
  19473. * @param rightStickX The x component of the right joystick
  19474. * @param rightStickY The y component of the right joystick
  19475. */
  19476. constructor(
  19477. /**
  19478. * The id of the gamepad
  19479. */
  19480. id: string,
  19481. /**
  19482. * The index of the gamepad
  19483. */
  19484. index: number,
  19485. /**
  19486. * The browser gamepad
  19487. */
  19488. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19489. /**
  19490. * Callback triggered when the left joystick has changed
  19491. * @param callback
  19492. */
  19493. onleftstickchanged(callback: (values: StickValues) => void): void;
  19494. /**
  19495. * Callback triggered when the right joystick has changed
  19496. * @param callback
  19497. */
  19498. onrightstickchanged(callback: (values: StickValues) => void): void;
  19499. /**
  19500. * Gets the left joystick
  19501. */
  19502. get leftStick(): StickValues;
  19503. /**
  19504. * Sets the left joystick values
  19505. */
  19506. set leftStick(newValues: StickValues);
  19507. /**
  19508. * Gets the right joystick
  19509. */
  19510. get rightStick(): StickValues;
  19511. /**
  19512. * Sets the right joystick value
  19513. */
  19514. set rightStick(newValues: StickValues);
  19515. /**
  19516. * Updates the gamepad joystick positions
  19517. */
  19518. update(): void;
  19519. /**
  19520. * Disposes the gamepad
  19521. */
  19522. dispose(): void;
  19523. }
  19524. /**
  19525. * Represents a generic gamepad
  19526. */
  19527. export class GenericPad extends Gamepad {
  19528. private _buttons;
  19529. private _onbuttondown;
  19530. private _onbuttonup;
  19531. /**
  19532. * Observable triggered when a button has been pressed
  19533. */
  19534. onButtonDownObservable: Observable<number>;
  19535. /**
  19536. * Observable triggered when a button has been released
  19537. */
  19538. onButtonUpObservable: Observable<number>;
  19539. /**
  19540. * Callback triggered when a button has been pressed
  19541. * @param callback Called when a button has been pressed
  19542. */
  19543. onbuttondown(callback: (buttonPressed: number) => void): void;
  19544. /**
  19545. * Callback triggered when a button has been released
  19546. * @param callback Called when a button has been released
  19547. */
  19548. onbuttonup(callback: (buttonReleased: number) => void): void;
  19549. /**
  19550. * Initializes the generic gamepad
  19551. * @param id The id of the generic gamepad
  19552. * @param index The index of the generic gamepad
  19553. * @param browserGamepad The browser gamepad
  19554. */
  19555. constructor(id: string, index: number, browserGamepad: any);
  19556. private _setButtonValue;
  19557. /**
  19558. * Updates the generic gamepad
  19559. */
  19560. update(): void;
  19561. /**
  19562. * Disposes the generic gamepad
  19563. */
  19564. dispose(): void;
  19565. }
  19566. }
  19567. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19568. import { Observable } from "babylonjs/Misc/observable";
  19569. import { Nullable } from "babylonjs/types";
  19570. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19571. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19573. import { Ray } from "babylonjs/Culling/ray";
  19574. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19575. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19576. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19577. /**
  19578. * Defines the types of pose enabled controllers that are supported
  19579. */
  19580. export enum PoseEnabledControllerType {
  19581. /**
  19582. * HTC Vive
  19583. */
  19584. VIVE = 0,
  19585. /**
  19586. * Oculus Rift
  19587. */
  19588. OCULUS = 1,
  19589. /**
  19590. * Windows mixed reality
  19591. */
  19592. WINDOWS = 2,
  19593. /**
  19594. * Samsung gear VR
  19595. */
  19596. GEAR_VR = 3,
  19597. /**
  19598. * Google Daydream
  19599. */
  19600. DAYDREAM = 4,
  19601. /**
  19602. * Generic
  19603. */
  19604. GENERIC = 5
  19605. }
  19606. /**
  19607. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19608. */
  19609. export interface MutableGamepadButton {
  19610. /**
  19611. * Value of the button/trigger
  19612. */
  19613. value: number;
  19614. /**
  19615. * If the button/trigger is currently touched
  19616. */
  19617. touched: boolean;
  19618. /**
  19619. * If the button/trigger is currently pressed
  19620. */
  19621. pressed: boolean;
  19622. }
  19623. /**
  19624. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19625. * @hidden
  19626. */
  19627. export interface ExtendedGamepadButton extends GamepadButton {
  19628. /**
  19629. * If the button/trigger is currently pressed
  19630. */
  19631. readonly pressed: boolean;
  19632. /**
  19633. * If the button/trigger is currently touched
  19634. */
  19635. readonly touched: boolean;
  19636. /**
  19637. * Value of the button/trigger
  19638. */
  19639. readonly value: number;
  19640. }
  19641. /** @hidden */
  19642. export interface _GamePadFactory {
  19643. /**
  19644. * Returns whether or not the current gamepad can be created for this type of controller.
  19645. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19646. * @returns true if it can be created, otherwise false
  19647. */
  19648. canCreate(gamepadInfo: any): boolean;
  19649. /**
  19650. * Creates a new instance of the Gamepad.
  19651. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19652. * @returns the new gamepad instance
  19653. */
  19654. create(gamepadInfo: any): Gamepad;
  19655. }
  19656. /**
  19657. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19658. */
  19659. export class PoseEnabledControllerHelper {
  19660. /** @hidden */
  19661. static _ControllerFactories: _GamePadFactory[];
  19662. /** @hidden */
  19663. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19664. /**
  19665. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19666. * @param vrGamepad the gamepad to initialized
  19667. * @returns a vr controller of the type the gamepad identified as
  19668. */
  19669. static InitiateController(vrGamepad: any): Gamepad;
  19670. }
  19671. /**
  19672. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19673. */
  19674. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19675. /**
  19676. * If the controller is used in a webXR session
  19677. */
  19678. isXR: boolean;
  19679. private _deviceRoomPosition;
  19680. private _deviceRoomRotationQuaternion;
  19681. /**
  19682. * The device position in babylon space
  19683. */
  19684. devicePosition: Vector3;
  19685. /**
  19686. * The device rotation in babylon space
  19687. */
  19688. deviceRotationQuaternion: Quaternion;
  19689. /**
  19690. * The scale factor of the device in babylon space
  19691. */
  19692. deviceScaleFactor: number;
  19693. /**
  19694. * (Likely devicePosition should be used instead) The device position in its room space
  19695. */
  19696. position: Vector3;
  19697. /**
  19698. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19699. */
  19700. rotationQuaternion: Quaternion;
  19701. /**
  19702. * The type of controller (Eg. Windows mixed reality)
  19703. */
  19704. controllerType: PoseEnabledControllerType;
  19705. protected _calculatedPosition: Vector3;
  19706. private _calculatedRotation;
  19707. /**
  19708. * The raw pose from the device
  19709. */
  19710. rawPose: DevicePose;
  19711. private _trackPosition;
  19712. private _maxRotationDistFromHeadset;
  19713. private _draggedRoomRotation;
  19714. /**
  19715. * @hidden
  19716. */
  19717. _disableTrackPosition(fixedPosition: Vector3): void;
  19718. /**
  19719. * Internal, the mesh attached to the controller
  19720. * @hidden
  19721. */
  19722. _mesh: Nullable<AbstractMesh>;
  19723. private _poseControlledCamera;
  19724. private _leftHandSystemQuaternion;
  19725. /**
  19726. * Internal, matrix used to convert room space to babylon space
  19727. * @hidden
  19728. */
  19729. _deviceToWorld: Matrix;
  19730. /**
  19731. * Node to be used when casting a ray from the controller
  19732. * @hidden
  19733. */
  19734. _pointingPoseNode: Nullable<TransformNode>;
  19735. /**
  19736. * Name of the child mesh that can be used to cast a ray from the controller
  19737. */
  19738. static readonly POINTING_POSE: string;
  19739. /**
  19740. * Creates a new PoseEnabledController from a gamepad
  19741. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19742. */
  19743. constructor(browserGamepad: any);
  19744. private _workingMatrix;
  19745. /**
  19746. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19747. */
  19748. update(): void;
  19749. /**
  19750. * Updates only the pose device and mesh without doing any button event checking
  19751. */
  19752. protected _updatePoseAndMesh(): void;
  19753. /**
  19754. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19755. * @param poseData raw pose fromthe device
  19756. */
  19757. updateFromDevice(poseData: DevicePose): void;
  19758. /**
  19759. * @hidden
  19760. */
  19761. _meshAttachedObservable: Observable<AbstractMesh>;
  19762. /**
  19763. * Attaches a mesh to the controller
  19764. * @param mesh the mesh to be attached
  19765. */
  19766. attachToMesh(mesh: AbstractMesh): void;
  19767. /**
  19768. * Attaches the controllers mesh to a camera
  19769. * @param camera the camera the mesh should be attached to
  19770. */
  19771. attachToPoseControlledCamera(camera: TargetCamera): void;
  19772. /**
  19773. * Disposes of the controller
  19774. */
  19775. dispose(): void;
  19776. /**
  19777. * The mesh that is attached to the controller
  19778. */
  19779. get mesh(): Nullable<AbstractMesh>;
  19780. /**
  19781. * Gets the ray of the controller in the direction the controller is pointing
  19782. * @param length the length the resulting ray should be
  19783. * @returns a ray in the direction the controller is pointing
  19784. */
  19785. getForwardRay(length?: number): Ray;
  19786. }
  19787. }
  19788. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19789. import { Observable } from "babylonjs/Misc/observable";
  19790. import { Scene } from "babylonjs/scene";
  19791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19792. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19793. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19794. import { Nullable } from "babylonjs/types";
  19795. /**
  19796. * Defines the WebVRController object that represents controllers tracked in 3D space
  19797. */
  19798. export abstract class WebVRController extends PoseEnabledController {
  19799. /**
  19800. * Internal, the default controller model for the controller
  19801. */
  19802. protected _defaultModel: Nullable<AbstractMesh>;
  19803. /**
  19804. * Fired when the trigger state has changed
  19805. */
  19806. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19807. /**
  19808. * Fired when the main button state has changed
  19809. */
  19810. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19811. /**
  19812. * Fired when the secondary button state has changed
  19813. */
  19814. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19815. /**
  19816. * Fired when the pad state has changed
  19817. */
  19818. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19819. /**
  19820. * Fired when controllers stick values have changed
  19821. */
  19822. onPadValuesChangedObservable: Observable<StickValues>;
  19823. /**
  19824. * Array of button availible on the controller
  19825. */
  19826. protected _buttons: Array<MutableGamepadButton>;
  19827. private _onButtonStateChange;
  19828. /**
  19829. * Fired when a controller button's state has changed
  19830. * @param callback the callback containing the button that was modified
  19831. */
  19832. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19833. /**
  19834. * X and Y axis corresponding to the controllers joystick
  19835. */
  19836. pad: StickValues;
  19837. /**
  19838. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19839. */
  19840. hand: string;
  19841. /**
  19842. * The default controller model for the controller
  19843. */
  19844. get defaultModel(): Nullable<AbstractMesh>;
  19845. /**
  19846. * Creates a new WebVRController from a gamepad
  19847. * @param vrGamepad the gamepad that the WebVRController should be created from
  19848. */
  19849. constructor(vrGamepad: any);
  19850. /**
  19851. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19852. */
  19853. update(): void;
  19854. /**
  19855. * Function to be called when a button is modified
  19856. */
  19857. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19858. /**
  19859. * Loads a mesh and attaches it to the controller
  19860. * @param scene the scene the mesh should be added to
  19861. * @param meshLoaded callback for when the mesh has been loaded
  19862. */
  19863. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19864. private _setButtonValue;
  19865. private _changes;
  19866. private _checkChanges;
  19867. /**
  19868. * Disposes of th webVRCOntroller
  19869. */
  19870. dispose(): void;
  19871. }
  19872. }
  19873. declare module "babylonjs/Lights/hemisphericLight" {
  19874. import { Nullable } from "babylonjs/types";
  19875. import { Scene } from "babylonjs/scene";
  19876. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19877. import { Color3 } from "babylonjs/Maths/math.color";
  19878. import { Effect } from "babylonjs/Materials/effect";
  19879. import { Light } from "babylonjs/Lights/light";
  19880. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19881. /**
  19882. * The HemisphericLight simulates the ambient environment light,
  19883. * so the passed direction is the light reflection direction, not the incoming direction.
  19884. */
  19885. export class HemisphericLight extends Light {
  19886. /**
  19887. * The groundColor is the light in the opposite direction to the one specified during creation.
  19888. * 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.
  19889. */
  19890. groundColor: Color3;
  19891. /**
  19892. * The light reflection direction, not the incoming direction.
  19893. */
  19894. direction: Vector3;
  19895. /**
  19896. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19897. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19898. * The HemisphericLight can't cast shadows.
  19899. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19900. * @param name The friendly name of the light
  19901. * @param direction The direction of the light reflection
  19902. * @param scene The scene the light belongs to
  19903. */
  19904. constructor(name: string, direction: Vector3, scene: Scene);
  19905. protected _buildUniformLayout(): void;
  19906. /**
  19907. * Returns the string "HemisphericLight".
  19908. * @return The class name
  19909. */
  19910. getClassName(): string;
  19911. /**
  19912. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19913. * Returns the updated direction.
  19914. * @param target The target the direction should point to
  19915. * @return The computed direction
  19916. */
  19917. setDirectionToTarget(target: Vector3): Vector3;
  19918. /**
  19919. * Returns the shadow generator associated to the light.
  19920. * @returns Always null for hemispheric lights because it does not support shadows.
  19921. */
  19922. getShadowGenerator(): Nullable<IShadowGenerator>;
  19923. /**
  19924. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19925. * @param effect The effect to update
  19926. * @param lightIndex The index of the light in the effect to update
  19927. * @returns The hemispheric light
  19928. */
  19929. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19930. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19931. /**
  19932. * Computes the world matrix of the node
  19933. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19934. * @param useWasUpdatedFlag defines a reserved property
  19935. * @returns the world matrix
  19936. */
  19937. computeWorldMatrix(): Matrix;
  19938. /**
  19939. * Returns the integer 3.
  19940. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19941. */
  19942. getTypeID(): number;
  19943. /**
  19944. * Prepares the list of defines specific to the light type.
  19945. * @param defines the list of defines
  19946. * @param lightIndex defines the index of the light for the effect
  19947. */
  19948. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19949. }
  19950. }
  19951. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19952. /** @hidden */
  19953. export var vrMultiviewToSingleviewPixelShader: {
  19954. name: string;
  19955. shader: string;
  19956. };
  19957. }
  19958. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19959. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19960. import { Scene } from "babylonjs/scene";
  19961. /**
  19962. * Renders to multiple views with a single draw call
  19963. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19964. */
  19965. export class MultiviewRenderTarget extends RenderTargetTexture {
  19966. /**
  19967. * Creates a multiview render target
  19968. * @param scene scene used with the render target
  19969. * @param size the size of the render target (used for each view)
  19970. */
  19971. constructor(scene: Scene, size?: number | {
  19972. width: number;
  19973. height: number;
  19974. } | {
  19975. ratio: number;
  19976. });
  19977. /**
  19978. * @hidden
  19979. * @param faceIndex the face index, if its a cube texture
  19980. */
  19981. _bindFrameBuffer(faceIndex?: number): void;
  19982. /**
  19983. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19984. * @returns the view count
  19985. */
  19986. getViewCount(): number;
  19987. }
  19988. }
  19989. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19990. import { Camera } from "babylonjs/Cameras/camera";
  19991. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19992. import { Nullable } from "babylonjs/types";
  19993. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19994. import { Matrix } from "babylonjs/Maths/math.vector";
  19995. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19996. module "babylonjs/Engines/engine" {
  19997. interface Engine {
  19998. /**
  19999. * Creates a new multiview render target
  20000. * @param width defines the width of the texture
  20001. * @param height defines the height of the texture
  20002. * @returns the created multiview texture
  20003. */
  20004. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20005. /**
  20006. * Binds a multiview framebuffer to be drawn to
  20007. * @param multiviewTexture texture to bind
  20008. */
  20009. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20010. }
  20011. }
  20012. module "babylonjs/Cameras/camera" {
  20013. interface Camera {
  20014. /**
  20015. * @hidden
  20016. * 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)
  20017. */
  20018. _useMultiviewToSingleView: boolean;
  20019. /**
  20020. * @hidden
  20021. * 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)
  20022. */
  20023. _multiviewTexture: Nullable<RenderTargetTexture>;
  20024. /**
  20025. * @hidden
  20026. * ensures the multiview texture of the camera exists and has the specified width/height
  20027. * @param width height to set on the multiview texture
  20028. * @param height width to set on the multiview texture
  20029. */
  20030. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20031. }
  20032. }
  20033. module "babylonjs/scene" {
  20034. interface Scene {
  20035. /** @hidden */
  20036. _transformMatrixR: Matrix;
  20037. /** @hidden */
  20038. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20039. /** @hidden */
  20040. _createMultiviewUbo(): void;
  20041. /** @hidden */
  20042. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20043. /** @hidden */
  20044. _renderMultiviewToSingleView(camera: Camera): void;
  20045. }
  20046. }
  20047. }
  20048. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20049. import { Camera } from "babylonjs/Cameras/camera";
  20050. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20051. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20052. import "babylonjs/Engines/Extensions/engine.multiview";
  20053. /**
  20054. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20055. * This will not be used for webXR as it supports displaying texture arrays directly
  20056. */
  20057. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20058. /**
  20059. * Initializes a VRMultiviewToSingleview
  20060. * @param name name of the post process
  20061. * @param camera camera to be applied to
  20062. * @param scaleFactor scaling factor to the size of the output texture
  20063. */
  20064. constructor(name: string, camera: Camera, scaleFactor: number);
  20065. }
  20066. }
  20067. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20068. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20069. import { Nullable } from "babylonjs/types";
  20070. import { Size } from "babylonjs/Maths/math.size";
  20071. import { Observable } from "babylonjs/Misc/observable";
  20072. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20073. /**
  20074. * Interface used to define additional presentation attributes
  20075. */
  20076. export interface IVRPresentationAttributes {
  20077. /**
  20078. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20079. */
  20080. highRefreshRate: boolean;
  20081. /**
  20082. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20083. */
  20084. foveationLevel: number;
  20085. }
  20086. module "babylonjs/Engines/engine" {
  20087. interface Engine {
  20088. /** @hidden */
  20089. _vrDisplay: any;
  20090. /** @hidden */
  20091. _vrSupported: boolean;
  20092. /** @hidden */
  20093. _oldSize: Size;
  20094. /** @hidden */
  20095. _oldHardwareScaleFactor: number;
  20096. /** @hidden */
  20097. _vrExclusivePointerMode: boolean;
  20098. /** @hidden */
  20099. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20100. /** @hidden */
  20101. _onVRDisplayPointerRestricted: () => void;
  20102. /** @hidden */
  20103. _onVRDisplayPointerUnrestricted: () => void;
  20104. /** @hidden */
  20105. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20106. /** @hidden */
  20107. _onVrDisplayDisconnect: Nullable<() => void>;
  20108. /** @hidden */
  20109. _onVrDisplayPresentChange: Nullable<() => void>;
  20110. /**
  20111. * Observable signaled when VR display mode changes
  20112. */
  20113. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20114. /**
  20115. * Observable signaled when VR request present is complete
  20116. */
  20117. onVRRequestPresentComplete: Observable<boolean>;
  20118. /**
  20119. * Observable signaled when VR request present starts
  20120. */
  20121. onVRRequestPresentStart: Observable<Engine>;
  20122. /**
  20123. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20124. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20125. */
  20126. isInVRExclusivePointerMode: boolean;
  20127. /**
  20128. * Gets a boolean indicating if a webVR device was detected
  20129. * @returns true if a webVR device was detected
  20130. */
  20131. isVRDevicePresent(): boolean;
  20132. /**
  20133. * Gets the current webVR device
  20134. * @returns the current webVR device (or null)
  20135. */
  20136. getVRDevice(): any;
  20137. /**
  20138. * Initializes a webVR display and starts listening to display change events
  20139. * The onVRDisplayChangedObservable will be notified upon these changes
  20140. * @returns A promise containing a VRDisplay and if vr is supported
  20141. */
  20142. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20143. /** @hidden */
  20144. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20145. /**
  20146. * Gets or sets the presentation attributes used to configure VR rendering
  20147. */
  20148. vrPresentationAttributes?: IVRPresentationAttributes;
  20149. /**
  20150. * Call this function to switch to webVR mode
  20151. * Will do nothing if webVR is not supported or if there is no webVR device
  20152. * @param options the webvr options provided to the camera. mainly used for multiview
  20153. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20154. */
  20155. enableVR(options: WebVROptions): void;
  20156. /** @hidden */
  20157. _onVRFullScreenTriggered(): void;
  20158. }
  20159. }
  20160. }
  20161. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20162. import { Nullable } from "babylonjs/types";
  20163. import { Observable } from "babylonjs/Misc/observable";
  20164. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20165. import { Scene } from "babylonjs/scene";
  20166. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20167. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20168. import { Node } from "babylonjs/node";
  20169. import { Ray } from "babylonjs/Culling/ray";
  20170. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20171. import "babylonjs/Engines/Extensions/engine.webVR";
  20172. /**
  20173. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20174. * IMPORTANT!! The data is right-hand data.
  20175. * @export
  20176. * @interface DevicePose
  20177. */
  20178. export interface DevicePose {
  20179. /**
  20180. * The position of the device, values in array are [x,y,z].
  20181. */
  20182. readonly position: Nullable<Float32Array>;
  20183. /**
  20184. * The linearVelocity of the device, values in array are [x,y,z].
  20185. */
  20186. readonly linearVelocity: Nullable<Float32Array>;
  20187. /**
  20188. * The linearAcceleration of the device, values in array are [x,y,z].
  20189. */
  20190. readonly linearAcceleration: Nullable<Float32Array>;
  20191. /**
  20192. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20193. */
  20194. readonly orientation: Nullable<Float32Array>;
  20195. /**
  20196. * The angularVelocity of the device, values in array are [x,y,z].
  20197. */
  20198. readonly angularVelocity: Nullable<Float32Array>;
  20199. /**
  20200. * The angularAcceleration of the device, values in array are [x,y,z].
  20201. */
  20202. readonly angularAcceleration: Nullable<Float32Array>;
  20203. }
  20204. /**
  20205. * Interface representing a pose controlled object in Babylon.
  20206. * A pose controlled object has both regular pose values as well as pose values
  20207. * from an external device such as a VR head mounted display
  20208. */
  20209. export interface PoseControlled {
  20210. /**
  20211. * The position of the object in babylon space.
  20212. */
  20213. position: Vector3;
  20214. /**
  20215. * The rotation quaternion of the object in babylon space.
  20216. */
  20217. rotationQuaternion: Quaternion;
  20218. /**
  20219. * The position of the device in babylon space.
  20220. */
  20221. devicePosition?: Vector3;
  20222. /**
  20223. * The rotation quaternion of the device in babylon space.
  20224. */
  20225. deviceRotationQuaternion: Quaternion;
  20226. /**
  20227. * The raw pose coming from the device.
  20228. */
  20229. rawPose: Nullable<DevicePose>;
  20230. /**
  20231. * The scale of the device to be used when translating from device space to babylon space.
  20232. */
  20233. deviceScaleFactor: number;
  20234. /**
  20235. * Updates the poseControlled values based on the input device pose.
  20236. * @param poseData the pose data to update the object with
  20237. */
  20238. updateFromDevice(poseData: DevicePose): void;
  20239. }
  20240. /**
  20241. * Set of options to customize the webVRCamera
  20242. */
  20243. export interface WebVROptions {
  20244. /**
  20245. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20246. */
  20247. trackPosition?: boolean;
  20248. /**
  20249. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20250. */
  20251. positionScale?: number;
  20252. /**
  20253. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20254. */
  20255. displayName?: string;
  20256. /**
  20257. * Should the native controller meshes be initialized. (default: true)
  20258. */
  20259. controllerMeshes?: boolean;
  20260. /**
  20261. * Creating a default HemiLight only on controllers. (default: true)
  20262. */
  20263. defaultLightingOnControllers?: boolean;
  20264. /**
  20265. * If you don't want to use the default VR button of the helper. (default: false)
  20266. */
  20267. useCustomVRButton?: boolean;
  20268. /**
  20269. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20270. */
  20271. customVRButton?: HTMLButtonElement;
  20272. /**
  20273. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20274. */
  20275. rayLength?: number;
  20276. /**
  20277. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20278. */
  20279. defaultHeight?: number;
  20280. /**
  20281. * If multiview should be used if availible (default: false)
  20282. */
  20283. useMultiview?: boolean;
  20284. }
  20285. /**
  20286. * This represents a WebVR camera.
  20287. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20288. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20289. */
  20290. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20291. private webVROptions;
  20292. /**
  20293. * @hidden
  20294. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20295. */
  20296. _vrDevice: any;
  20297. /**
  20298. * The rawPose of the vrDevice.
  20299. */
  20300. rawPose: Nullable<DevicePose>;
  20301. private _onVREnabled;
  20302. private _specsVersion;
  20303. private _attached;
  20304. private _frameData;
  20305. protected _descendants: Array<Node>;
  20306. private _deviceRoomPosition;
  20307. /** @hidden */
  20308. _deviceRoomRotationQuaternion: Quaternion;
  20309. private _standingMatrix;
  20310. /**
  20311. * Represents device position in babylon space.
  20312. */
  20313. devicePosition: Vector3;
  20314. /**
  20315. * Represents device rotation in babylon space.
  20316. */
  20317. deviceRotationQuaternion: Quaternion;
  20318. /**
  20319. * The scale of the device to be used when translating from device space to babylon space.
  20320. */
  20321. deviceScaleFactor: number;
  20322. private _deviceToWorld;
  20323. private _worldToDevice;
  20324. /**
  20325. * References to the webVR controllers for the vrDevice.
  20326. */
  20327. controllers: Array<WebVRController>;
  20328. /**
  20329. * Emits an event when a controller is attached.
  20330. */
  20331. onControllersAttachedObservable: Observable<WebVRController[]>;
  20332. /**
  20333. * Emits an event when a controller's mesh has been loaded;
  20334. */
  20335. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20336. /**
  20337. * Emits an event when the HMD's pose has been updated.
  20338. */
  20339. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20340. private _poseSet;
  20341. /**
  20342. * If the rig cameras be used as parent instead of this camera.
  20343. */
  20344. rigParenting: boolean;
  20345. private _lightOnControllers;
  20346. private _defaultHeight?;
  20347. /**
  20348. * Instantiates a WebVRFreeCamera.
  20349. * @param name The name of the WebVRFreeCamera
  20350. * @param position The starting anchor position for the camera
  20351. * @param scene The scene the camera belongs to
  20352. * @param webVROptions a set of customizable options for the webVRCamera
  20353. */
  20354. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20355. /**
  20356. * Gets the device distance from the ground in meters.
  20357. * @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.
  20358. */
  20359. deviceDistanceToRoomGround(): number;
  20360. /**
  20361. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20362. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20363. */
  20364. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20365. /**
  20366. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20367. * @returns A promise with a boolean set to if the standing matrix is supported.
  20368. */
  20369. useStandingMatrixAsync(): Promise<boolean>;
  20370. /**
  20371. * Disposes the camera
  20372. */
  20373. dispose(): void;
  20374. /**
  20375. * Gets a vrController by name.
  20376. * @param name The name of the controller to retreive
  20377. * @returns the controller matching the name specified or null if not found
  20378. */
  20379. getControllerByName(name: string): Nullable<WebVRController>;
  20380. private _leftController;
  20381. /**
  20382. * The controller corresponding to the users left hand.
  20383. */
  20384. get leftController(): Nullable<WebVRController>;
  20385. private _rightController;
  20386. /**
  20387. * The controller corresponding to the users right hand.
  20388. */
  20389. get rightController(): Nullable<WebVRController>;
  20390. /**
  20391. * Casts a ray forward from the vrCamera's gaze.
  20392. * @param length Length of the ray (default: 100)
  20393. * @returns the ray corresponding to the gaze
  20394. */
  20395. getForwardRay(length?: number): Ray;
  20396. /**
  20397. * @hidden
  20398. * Updates the camera based on device's frame data
  20399. */
  20400. _checkInputs(): void;
  20401. /**
  20402. * Updates the poseControlled values based on the input device pose.
  20403. * @param poseData Pose coming from the device
  20404. */
  20405. updateFromDevice(poseData: DevicePose): void;
  20406. private _htmlElementAttached;
  20407. private _detachIfAttached;
  20408. /**
  20409. * WebVR's attach control will start broadcasting frames to the device.
  20410. * Note that in certain browsers (chrome for example) this function must be called
  20411. * within a user-interaction callback. Example:
  20412. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20413. *
  20414. * @param element html element to attach the vrDevice to
  20415. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20416. */
  20417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20418. /**
  20419. * Detaches the camera from the html element and disables VR
  20420. *
  20421. * @param element html element to detach from
  20422. */
  20423. detachControl(element: HTMLElement): void;
  20424. /**
  20425. * @returns the name of this class
  20426. */
  20427. getClassName(): string;
  20428. /**
  20429. * Calls resetPose on the vrDisplay
  20430. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20431. */
  20432. resetToCurrentRotation(): void;
  20433. /**
  20434. * @hidden
  20435. * Updates the rig cameras (left and right eye)
  20436. */
  20437. _updateRigCameras(): void;
  20438. private _workingVector;
  20439. private _oneVector;
  20440. private _workingMatrix;
  20441. private updateCacheCalled;
  20442. private _correctPositionIfNotTrackPosition;
  20443. /**
  20444. * @hidden
  20445. * Updates the cached values of the camera
  20446. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20447. */
  20448. _updateCache(ignoreParentClass?: boolean): void;
  20449. /**
  20450. * @hidden
  20451. * Get current device position in babylon world
  20452. */
  20453. _computeDevicePosition(): void;
  20454. /**
  20455. * Updates the current device position and rotation in the babylon world
  20456. */
  20457. update(): void;
  20458. /**
  20459. * @hidden
  20460. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20461. * @returns an identity matrix
  20462. */
  20463. _getViewMatrix(): Matrix;
  20464. private _tmpMatrix;
  20465. /**
  20466. * This function is called by the two RIG cameras.
  20467. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20468. * @hidden
  20469. */
  20470. _getWebVRViewMatrix(): Matrix;
  20471. /** @hidden */
  20472. _getWebVRProjectionMatrix(): Matrix;
  20473. private _onGamepadConnectedObserver;
  20474. private _onGamepadDisconnectedObserver;
  20475. private _updateCacheWhenTrackingDisabledObserver;
  20476. /**
  20477. * Initializes the controllers and their meshes
  20478. */
  20479. initControllers(): void;
  20480. }
  20481. }
  20482. declare module "babylonjs/Materials/materialHelper" {
  20483. import { Nullable } from "babylonjs/types";
  20484. import { Scene } from "babylonjs/scene";
  20485. import { Engine } from "babylonjs/Engines/engine";
  20486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20487. import { Light } from "babylonjs/Lights/light";
  20488. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20489. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20490. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20491. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20492. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20493. /**
  20494. * "Static Class" containing the most commonly used helper while dealing with material for
  20495. * rendering purpose.
  20496. *
  20497. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20498. *
  20499. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20500. */
  20501. export class MaterialHelper {
  20502. /**
  20503. * Bind the current view position to an effect.
  20504. * @param effect The effect to be bound
  20505. * @param scene The scene the eyes position is used from
  20506. * @param variableName name of the shader variable that will hold the eye position
  20507. */
  20508. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20509. /**
  20510. * Helps preparing the defines values about the UVs in used in the effect.
  20511. * UVs are shared as much as we can accross channels in the shaders.
  20512. * @param texture The texture we are preparing the UVs for
  20513. * @param defines The defines to update
  20514. * @param key The channel key "diffuse", "specular"... used in the shader
  20515. */
  20516. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20517. /**
  20518. * Binds a texture matrix value to its corrsponding uniform
  20519. * @param texture The texture to bind the matrix for
  20520. * @param uniformBuffer The uniform buffer receivin the data
  20521. * @param key The channel key "diffuse", "specular"... used in the shader
  20522. */
  20523. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20524. /**
  20525. * Gets the current status of the fog (should it be enabled?)
  20526. * @param mesh defines the mesh to evaluate for fog support
  20527. * @param scene defines the hosting scene
  20528. * @returns true if fog must be enabled
  20529. */
  20530. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20531. /**
  20532. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20533. * @param mesh defines the current mesh
  20534. * @param scene defines the current scene
  20535. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20536. * @param pointsCloud defines if point cloud rendering has to be turned on
  20537. * @param fogEnabled defines if fog has to be turned on
  20538. * @param alphaTest defines if alpha testing has to be turned on
  20539. * @param defines defines the current list of defines
  20540. */
  20541. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20542. /**
  20543. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20544. * @param scene defines the current scene
  20545. * @param engine defines the current engine
  20546. * @param defines specifies the list of active defines
  20547. * @param useInstances defines if instances have to be turned on
  20548. * @param useClipPlane defines if clip plane have to be turned on
  20549. * @param useInstances defines if instances have to be turned on
  20550. * @param useThinInstances defines if thin instances have to be turned on
  20551. */
  20552. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20553. /**
  20554. * Prepares the defines for bones
  20555. * @param mesh The mesh containing the geometry data we will draw
  20556. * @param defines The defines to update
  20557. */
  20558. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20559. /**
  20560. * Prepares the defines for morph targets
  20561. * @param mesh The mesh containing the geometry data we will draw
  20562. * @param defines The defines to update
  20563. */
  20564. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20565. /**
  20566. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20567. * @param mesh The mesh containing the geometry data we will draw
  20568. * @param defines The defines to update
  20569. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20570. * @param useBones Precise whether bones should be used or not (override mesh info)
  20571. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20572. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20573. * @returns false if defines are considered not dirty and have not been checked
  20574. */
  20575. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20576. /**
  20577. * Prepares the defines related to multiview
  20578. * @param scene The scene we are intending to draw
  20579. * @param defines The defines to update
  20580. */
  20581. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20582. /**
  20583. * Prepares the defines related to the prepass
  20584. * @param scene The scene we are intending to draw
  20585. * @param defines The defines to update
  20586. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  20587. */
  20588. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  20589. /**
  20590. * Prepares the defines related to the light information passed in parameter
  20591. * @param scene The scene we are intending to draw
  20592. * @param mesh The mesh the effect is compiling for
  20593. * @param light The light the effect is compiling for
  20594. * @param lightIndex The index of the light
  20595. * @param defines The defines to update
  20596. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20597. * @param state Defines the current state regarding what is needed (normals, etc...)
  20598. */
  20599. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20600. needNormals: boolean;
  20601. needRebuild: boolean;
  20602. shadowEnabled: boolean;
  20603. specularEnabled: boolean;
  20604. lightmapMode: boolean;
  20605. }): void;
  20606. /**
  20607. * Prepares the defines related to the light information passed in parameter
  20608. * @param scene The scene we are intending to draw
  20609. * @param mesh The mesh the effect is compiling for
  20610. * @param defines The defines to update
  20611. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20612. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20613. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20614. * @returns true if normals will be required for the rest of the effect
  20615. */
  20616. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20617. /**
  20618. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20619. * @param lightIndex defines the light index
  20620. * @param uniformsList The uniform list
  20621. * @param samplersList The sampler list
  20622. * @param projectedLightTexture defines if projected texture must be used
  20623. * @param uniformBuffersList defines an optional list of uniform buffers
  20624. */
  20625. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20626. /**
  20627. * Prepares the uniforms and samplers list to be used in the effect
  20628. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20629. * @param samplersList The sampler list
  20630. * @param defines The defines helping in the list generation
  20631. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20632. */
  20633. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20634. /**
  20635. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20636. * @param defines The defines to update while falling back
  20637. * @param fallbacks The authorized effect fallbacks
  20638. * @param maxSimultaneousLights The maximum number of lights allowed
  20639. * @param rank the current rank of the Effect
  20640. * @returns The newly affected rank
  20641. */
  20642. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20643. private static _TmpMorphInfluencers;
  20644. /**
  20645. * Prepares the list of attributes required for morph targets according to the effect defines.
  20646. * @param attribs The current list of supported attribs
  20647. * @param mesh The mesh to prepare the morph targets attributes for
  20648. * @param influencers The number of influencers
  20649. */
  20650. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20651. /**
  20652. * Prepares the list of attributes required for morph targets according to the effect defines.
  20653. * @param attribs The current list of supported attribs
  20654. * @param mesh The mesh to prepare the morph targets attributes for
  20655. * @param defines The current Defines of the effect
  20656. */
  20657. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20658. /**
  20659. * Prepares the list of attributes required for bones according to the effect defines.
  20660. * @param attribs The current list of supported attribs
  20661. * @param mesh The mesh to prepare the bones attributes for
  20662. * @param defines The current Defines of the effect
  20663. * @param fallbacks The current efffect fallback strategy
  20664. */
  20665. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20666. /**
  20667. * Check and prepare the list of attributes required for instances according to the effect defines.
  20668. * @param attribs The current list of supported attribs
  20669. * @param defines The current MaterialDefines of the effect
  20670. */
  20671. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20672. /**
  20673. * Add the list of attributes required for instances to the attribs array.
  20674. * @param attribs The current list of supported attribs
  20675. */
  20676. static PushAttributesForInstances(attribs: string[]): void;
  20677. /**
  20678. * Binds the light information to the effect.
  20679. * @param light The light containing the generator
  20680. * @param effect The effect we are binding the data to
  20681. * @param lightIndex The light index in the effect used to render
  20682. */
  20683. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20684. /**
  20685. * Binds the lights information from the scene to the effect for the given mesh.
  20686. * @param light Light to bind
  20687. * @param lightIndex Light index
  20688. * @param scene The scene where the light belongs to
  20689. * @param effect The effect we are binding the data to
  20690. * @param useSpecular Defines if specular is supported
  20691. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20692. */
  20693. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20694. /**
  20695. * Binds the lights information from the scene to the effect for the given mesh.
  20696. * @param scene The scene the lights belongs to
  20697. * @param mesh The mesh we are binding the information to render
  20698. * @param effect The effect we are binding the data to
  20699. * @param defines The generated defines for the effect
  20700. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20701. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20702. */
  20703. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20704. private static _tempFogColor;
  20705. /**
  20706. * Binds the fog information from the scene to the effect for the given mesh.
  20707. * @param scene The scene the lights belongs to
  20708. * @param mesh The mesh we are binding the information to render
  20709. * @param effect The effect we are binding the data to
  20710. * @param linearSpace Defines if the fog effect is applied in linear space
  20711. */
  20712. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20713. /**
  20714. * Binds the bones information from the mesh to the effect.
  20715. * @param mesh The mesh we are binding the information to render
  20716. * @param effect The effect we are binding the data to
  20717. */
  20718. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20719. /**
  20720. * Binds the morph targets information from the mesh to the effect.
  20721. * @param abstractMesh The mesh we are binding the information to render
  20722. * @param effect The effect we are binding the data to
  20723. */
  20724. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20725. /**
  20726. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20727. * @param defines The generated defines used in the effect
  20728. * @param effect The effect we are binding the data to
  20729. * @param scene The scene we are willing to render with logarithmic scale for
  20730. */
  20731. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20732. /**
  20733. * Binds the clip plane information from the scene to the effect.
  20734. * @param scene The scene the clip plane information are extracted from
  20735. * @param effect The effect we are binding the data to
  20736. */
  20737. static BindClipPlane(effect: Effect, scene: Scene): void;
  20738. }
  20739. }
  20740. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20742. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20743. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20744. import { Nullable } from "babylonjs/types";
  20745. import { Effect } from "babylonjs/Materials/effect";
  20746. import { Matrix } from "babylonjs/Maths/math.vector";
  20747. import { Scene } from "babylonjs/scene";
  20748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20750. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20751. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20752. import { Observable } from "babylonjs/Misc/observable";
  20753. /**
  20754. * Block used to expose an input value
  20755. */
  20756. export class InputBlock extends NodeMaterialBlock {
  20757. private _mode;
  20758. private _associatedVariableName;
  20759. private _storedValue;
  20760. private _valueCallback;
  20761. private _type;
  20762. private _animationType;
  20763. /** Gets or set a value used to limit the range of float values */
  20764. min: number;
  20765. /** Gets or set a value used to limit the range of float values */
  20766. max: number;
  20767. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20768. isBoolean: boolean;
  20769. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20770. matrixMode: number;
  20771. /** @hidden */
  20772. _systemValue: Nullable<NodeMaterialSystemValues>;
  20773. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20774. visibleInInspector: boolean;
  20775. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20776. isConstant: boolean;
  20777. /** Gets or sets the group to use to display this block in the Inspector */
  20778. groupInInspector: string;
  20779. /** Gets an observable raised when the value is changed */
  20780. onValueChangedObservable: Observable<InputBlock>;
  20781. /**
  20782. * Gets or sets the connection point type (default is float)
  20783. */
  20784. get type(): NodeMaterialBlockConnectionPointTypes;
  20785. /**
  20786. * Creates a new InputBlock
  20787. * @param name defines the block name
  20788. * @param target defines the target of that block (Vertex by default)
  20789. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20790. */
  20791. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20792. /**
  20793. * Gets the output component
  20794. */
  20795. get output(): NodeMaterialConnectionPoint;
  20796. /**
  20797. * Set the source of this connection point to a vertex attribute
  20798. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20799. * @returns the current connection point
  20800. */
  20801. setAsAttribute(attributeName?: string): InputBlock;
  20802. /**
  20803. * Set the source of this connection point to a system value
  20804. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20805. * @returns the current connection point
  20806. */
  20807. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20808. /**
  20809. * Gets or sets the value of that point.
  20810. * Please note that this value will be ignored if valueCallback is defined
  20811. */
  20812. get value(): any;
  20813. set value(value: any);
  20814. /**
  20815. * Gets or sets a callback used to get the value of that point.
  20816. * Please note that setting this value will force the connection point to ignore the value property
  20817. */
  20818. get valueCallback(): () => any;
  20819. set valueCallback(value: () => any);
  20820. /**
  20821. * Gets or sets the associated variable name in the shader
  20822. */
  20823. get associatedVariableName(): string;
  20824. set associatedVariableName(value: string);
  20825. /** Gets or sets the type of animation applied to the input */
  20826. get animationType(): AnimatedInputBlockTypes;
  20827. set animationType(value: AnimatedInputBlockTypes);
  20828. /**
  20829. * Gets a boolean indicating that this connection point not defined yet
  20830. */
  20831. get isUndefined(): boolean;
  20832. /**
  20833. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20834. * In this case the connection point name must be the name of the uniform to use.
  20835. * Can only be set on inputs
  20836. */
  20837. get isUniform(): boolean;
  20838. set isUniform(value: boolean);
  20839. /**
  20840. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20841. * In this case the connection point name must be the name of the attribute to use
  20842. * Can only be set on inputs
  20843. */
  20844. get isAttribute(): boolean;
  20845. set isAttribute(value: boolean);
  20846. /**
  20847. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20848. * Can only be set on exit points
  20849. */
  20850. get isVarying(): boolean;
  20851. set isVarying(value: boolean);
  20852. /**
  20853. * Gets a boolean indicating that the current connection point is a system value
  20854. */
  20855. get isSystemValue(): boolean;
  20856. /**
  20857. * Gets or sets the current well known value or null if not defined as a system value
  20858. */
  20859. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20860. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20861. /**
  20862. * Gets the current class name
  20863. * @returns the class name
  20864. */
  20865. getClassName(): string;
  20866. /**
  20867. * Animate the input if animationType !== None
  20868. * @param scene defines the rendering scene
  20869. */
  20870. animate(scene: Scene): void;
  20871. private _emitDefine;
  20872. initialize(state: NodeMaterialBuildState): void;
  20873. /**
  20874. * Set the input block to its default value (based on its type)
  20875. */
  20876. setDefaultValue(): void;
  20877. private _emitConstant;
  20878. /** @hidden */
  20879. get _noContextSwitch(): boolean;
  20880. private _emit;
  20881. /** @hidden */
  20882. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20883. /** @hidden */
  20884. _transmit(effect: Effect, scene: Scene): void;
  20885. protected _buildBlock(state: NodeMaterialBuildState): void;
  20886. protected _dumpPropertiesCode(): string;
  20887. dispose(): void;
  20888. serialize(): any;
  20889. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20890. }
  20891. }
  20892. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20893. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20894. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20895. import { Nullable } from "babylonjs/types";
  20896. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  20897. import { Observable } from "babylonjs/Misc/observable";
  20898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20899. /**
  20900. * Enum used to define the compatibility state between two connection points
  20901. */
  20902. export enum NodeMaterialConnectionPointCompatibilityStates {
  20903. /** Points are compatibles */
  20904. Compatible = 0,
  20905. /** Points are incompatible because of their types */
  20906. TypeIncompatible = 1,
  20907. /** Points are incompatible because of their targets (vertex vs fragment) */
  20908. TargetIncompatible = 2
  20909. }
  20910. /**
  20911. * Defines the direction of a connection point
  20912. */
  20913. export enum NodeMaterialConnectionPointDirection {
  20914. /** Input */
  20915. Input = 0,
  20916. /** Output */
  20917. Output = 1
  20918. }
  20919. /**
  20920. * Defines a connection point for a block
  20921. */
  20922. export class NodeMaterialConnectionPoint {
  20923. /** @hidden */
  20924. _ownerBlock: NodeMaterialBlock;
  20925. /** @hidden */
  20926. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20927. private _endpoints;
  20928. private _associatedVariableName;
  20929. private _direction;
  20930. /** @hidden */
  20931. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20932. /** @hidden */
  20933. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20934. private _type;
  20935. /** @hidden */
  20936. _enforceAssociatedVariableName: boolean;
  20937. /** Gets the direction of the point */
  20938. get direction(): NodeMaterialConnectionPointDirection;
  20939. /** Indicates that this connection point needs dual validation before being connected to another point */
  20940. needDualDirectionValidation: boolean;
  20941. /**
  20942. * Gets or sets the additional types supported by this connection point
  20943. */
  20944. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20945. /**
  20946. * Gets or sets the additional types excluded by this connection point
  20947. */
  20948. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20949. /**
  20950. * Observable triggered when this point is connected
  20951. */
  20952. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20953. /**
  20954. * Gets or sets the associated variable name in the shader
  20955. */
  20956. get associatedVariableName(): string;
  20957. set associatedVariableName(value: string);
  20958. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20959. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20960. /**
  20961. * Gets or sets the connection point type (default is float)
  20962. */
  20963. get type(): NodeMaterialBlockConnectionPointTypes;
  20964. set type(value: NodeMaterialBlockConnectionPointTypes);
  20965. /**
  20966. * Gets or sets the connection point name
  20967. */
  20968. name: string;
  20969. /**
  20970. * Gets or sets the connection point name
  20971. */
  20972. displayName: string;
  20973. /**
  20974. * Gets or sets a boolean indicating that this connection point can be omitted
  20975. */
  20976. isOptional: boolean;
  20977. /**
  20978. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20979. */
  20980. isExposedOnFrame: boolean;
  20981. /**
  20982. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20983. */
  20984. define: string;
  20985. /** @hidden */
  20986. _prioritizeVertex: boolean;
  20987. private _target;
  20988. /** Gets or sets the target of that connection point */
  20989. get target(): NodeMaterialBlockTargets;
  20990. set target(value: NodeMaterialBlockTargets);
  20991. /**
  20992. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20993. */
  20994. get isConnected(): boolean;
  20995. /**
  20996. * Gets a boolean indicating that the current point is connected to an input block
  20997. */
  20998. get isConnectedToInputBlock(): boolean;
  20999. /**
  21000. * Gets a the connected input block (if any)
  21001. */
  21002. get connectInputBlock(): Nullable<InputBlock>;
  21003. /** Get the other side of the connection (if any) */
  21004. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21005. /** Get the block that owns this connection point */
  21006. get ownerBlock(): NodeMaterialBlock;
  21007. /** Get the block connected on the other side of this connection (if any) */
  21008. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21009. /** Get the block connected on the endpoints of this connection (if any) */
  21010. get connectedBlocks(): Array<NodeMaterialBlock>;
  21011. /** Gets the list of connected endpoints */
  21012. get endpoints(): NodeMaterialConnectionPoint[];
  21013. /** Gets a boolean indicating if that output point is connected to at least one input */
  21014. get hasEndpoints(): boolean;
  21015. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21016. get isConnectedInVertexShader(): boolean;
  21017. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21018. get isConnectedInFragmentShader(): boolean;
  21019. /**
  21020. * Creates a block suitable to be used as an input for this input point.
  21021. * If null is returned, a block based on the point type will be created.
  21022. * @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
  21023. */
  21024. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21025. /**
  21026. * Creates a new connection point
  21027. * @param name defines the connection point name
  21028. * @param ownerBlock defines the block hosting this connection point
  21029. * @param direction defines the direction of the connection point
  21030. */
  21031. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21032. /**
  21033. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21034. * @returns the class name
  21035. */
  21036. getClassName(): string;
  21037. /**
  21038. * Gets a boolean indicating if the current point can be connected to another point
  21039. * @param connectionPoint defines the other connection point
  21040. * @returns a boolean
  21041. */
  21042. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21043. /**
  21044. * Gets a number indicating if the current point can be connected to another point
  21045. * @param connectionPoint defines the other connection point
  21046. * @returns a number defining the compatibility state
  21047. */
  21048. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21049. /**
  21050. * Connect this point to another connection point
  21051. * @param connectionPoint defines the other connection point
  21052. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21053. * @returns the current connection point
  21054. */
  21055. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21056. /**
  21057. * Disconnect this point from one of his endpoint
  21058. * @param endpoint defines the other connection point
  21059. * @returns the current connection point
  21060. */
  21061. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21062. /**
  21063. * Serializes this point in a JSON representation
  21064. * @param isInput defines if the connection point is an input (default is true)
  21065. * @returns the serialized point object
  21066. */
  21067. serialize(isInput?: boolean): any;
  21068. /**
  21069. * Release resources
  21070. */
  21071. dispose(): void;
  21072. }
  21073. }
  21074. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21075. /**
  21076. * Enum used to define the material modes
  21077. */
  21078. export enum NodeMaterialModes {
  21079. /** Regular material */
  21080. Material = 0,
  21081. /** For post process */
  21082. PostProcess = 1,
  21083. /** For particle system */
  21084. Particle = 2
  21085. }
  21086. }
  21087. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21090. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21091. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21093. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21094. import { Effect } from "babylonjs/Materials/effect";
  21095. import { Mesh } from "babylonjs/Meshes/mesh";
  21096. import { Nullable } from "babylonjs/types";
  21097. import { Texture } from "babylonjs/Materials/Textures/texture";
  21098. import { Scene } from "babylonjs/scene";
  21099. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21100. /**
  21101. * Block used to read a texture from a sampler
  21102. */
  21103. export class TextureBlock extends NodeMaterialBlock {
  21104. private _defineName;
  21105. private _linearDefineName;
  21106. private _gammaDefineName;
  21107. private _tempTextureRead;
  21108. private _samplerName;
  21109. private _transformedUVName;
  21110. private _textureTransformName;
  21111. private _textureInfoName;
  21112. private _mainUVName;
  21113. private _mainUVDefineName;
  21114. private _fragmentOnly;
  21115. /**
  21116. * Gets or sets the texture associated with the node
  21117. */
  21118. texture: Nullable<Texture>;
  21119. /**
  21120. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21121. */
  21122. convertToGammaSpace: boolean;
  21123. /**
  21124. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21125. */
  21126. convertToLinearSpace: boolean;
  21127. /**
  21128. * Create a new TextureBlock
  21129. * @param name defines the block name
  21130. */
  21131. constructor(name: string, fragmentOnly?: boolean);
  21132. /**
  21133. * Gets the current class name
  21134. * @returns the class name
  21135. */
  21136. getClassName(): string;
  21137. /**
  21138. * Gets the uv input component
  21139. */
  21140. get uv(): NodeMaterialConnectionPoint;
  21141. /**
  21142. * Gets the rgba output component
  21143. */
  21144. get rgba(): NodeMaterialConnectionPoint;
  21145. /**
  21146. * Gets the rgb output component
  21147. */
  21148. get rgb(): NodeMaterialConnectionPoint;
  21149. /**
  21150. * Gets the r output component
  21151. */
  21152. get r(): NodeMaterialConnectionPoint;
  21153. /**
  21154. * Gets the g output component
  21155. */
  21156. get g(): NodeMaterialConnectionPoint;
  21157. /**
  21158. * Gets the b output component
  21159. */
  21160. get b(): NodeMaterialConnectionPoint;
  21161. /**
  21162. * Gets the a output component
  21163. */
  21164. get a(): NodeMaterialConnectionPoint;
  21165. get target(): NodeMaterialBlockTargets;
  21166. autoConfigure(material: NodeMaterial): void;
  21167. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21168. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21169. isReady(): boolean;
  21170. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21171. private get _isMixed();
  21172. private _injectVertexCode;
  21173. private _writeTextureRead;
  21174. private _writeOutput;
  21175. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21176. protected _dumpPropertiesCode(): string;
  21177. serialize(): any;
  21178. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21179. }
  21180. }
  21181. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21182. /** @hidden */
  21183. export var reflectionFunction: {
  21184. name: string;
  21185. shader: string;
  21186. };
  21187. }
  21188. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21189. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21190. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21191. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21194. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21195. import { Effect } from "babylonjs/Materials/effect";
  21196. import { Mesh } from "babylonjs/Meshes/mesh";
  21197. import { Nullable } from "babylonjs/types";
  21198. import { Scene } from "babylonjs/scene";
  21199. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21200. /**
  21201. * Base block used to read a reflection texture from a sampler
  21202. */
  21203. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21204. /** @hidden */
  21205. _define3DName: string;
  21206. /** @hidden */
  21207. _defineCubicName: string;
  21208. /** @hidden */
  21209. _defineExplicitName: string;
  21210. /** @hidden */
  21211. _defineProjectionName: string;
  21212. /** @hidden */
  21213. _defineLocalCubicName: string;
  21214. /** @hidden */
  21215. _defineSphericalName: string;
  21216. /** @hidden */
  21217. _definePlanarName: string;
  21218. /** @hidden */
  21219. _defineEquirectangularName: string;
  21220. /** @hidden */
  21221. _defineMirroredEquirectangularFixedName: string;
  21222. /** @hidden */
  21223. _defineEquirectangularFixedName: string;
  21224. /** @hidden */
  21225. _defineSkyboxName: string;
  21226. /** @hidden */
  21227. _defineOppositeZ: string;
  21228. /** @hidden */
  21229. _cubeSamplerName: string;
  21230. /** @hidden */
  21231. _2DSamplerName: string;
  21232. protected _positionUVWName: string;
  21233. protected _directionWName: string;
  21234. protected _reflectionVectorName: string;
  21235. /** @hidden */
  21236. _reflectionCoordsName: string;
  21237. /** @hidden */
  21238. _reflectionMatrixName: string;
  21239. protected _reflectionColorName: string;
  21240. /**
  21241. * Gets or sets the texture associated with the node
  21242. */
  21243. texture: Nullable<BaseTexture>;
  21244. /**
  21245. * Create a new ReflectionTextureBaseBlock
  21246. * @param name defines the block name
  21247. */
  21248. constructor(name: string);
  21249. /**
  21250. * Gets the current class name
  21251. * @returns the class name
  21252. */
  21253. getClassName(): string;
  21254. /**
  21255. * Gets the world position input component
  21256. */
  21257. abstract get position(): NodeMaterialConnectionPoint;
  21258. /**
  21259. * Gets the world position input component
  21260. */
  21261. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21262. /**
  21263. * Gets the world normal input component
  21264. */
  21265. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21266. /**
  21267. * Gets the world input component
  21268. */
  21269. abstract get world(): NodeMaterialConnectionPoint;
  21270. /**
  21271. * Gets the camera (or eye) position component
  21272. */
  21273. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21274. /**
  21275. * Gets the view input component
  21276. */
  21277. abstract get view(): NodeMaterialConnectionPoint;
  21278. protected _getTexture(): Nullable<BaseTexture>;
  21279. autoConfigure(material: NodeMaterial): void;
  21280. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21281. isReady(): boolean;
  21282. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21283. /**
  21284. * Gets the code to inject in the vertex shader
  21285. * @param state current state of the node material building
  21286. * @returns the shader code
  21287. */
  21288. handleVertexSide(state: NodeMaterialBuildState): string;
  21289. /**
  21290. * Handles the inits for the fragment code path
  21291. * @param state node material build state
  21292. */
  21293. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21294. /**
  21295. * Generates the reflection coords code for the fragment code path
  21296. * @param worldNormalVarName name of the world normal variable
  21297. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21298. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21299. * @returns the shader code
  21300. */
  21301. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21302. /**
  21303. * Generates the reflection color code for the fragment code path
  21304. * @param lodVarName name of the lod variable
  21305. * @param swizzleLookupTexture swizzle to use for the final color variable
  21306. * @returns the shader code
  21307. */
  21308. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21309. /**
  21310. * Generates the code corresponding to the connected output points
  21311. * @param state node material build state
  21312. * @param varName name of the variable to output
  21313. * @returns the shader code
  21314. */
  21315. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21316. protected _buildBlock(state: NodeMaterialBuildState): this;
  21317. protected _dumpPropertiesCode(): string;
  21318. serialize(): any;
  21319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21320. }
  21321. }
  21322. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21323. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21324. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21325. import { Nullable } from "babylonjs/types";
  21326. /**
  21327. * Defines a connection point to be used for points with a custom object type
  21328. */
  21329. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21330. private _blockType;
  21331. private _blockName;
  21332. private _nameForCheking?;
  21333. /**
  21334. * Creates a new connection point
  21335. * @param name defines the connection point name
  21336. * @param ownerBlock defines the block hosting this connection point
  21337. * @param direction defines the direction of the connection point
  21338. */
  21339. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21340. /**
  21341. * Gets a number indicating if the current point can be connected to another point
  21342. * @param connectionPoint defines the other connection point
  21343. * @returns a number defining the compatibility state
  21344. */
  21345. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21346. /**
  21347. * Creates a block suitable to be used as an input for this input point.
  21348. * If null is returned, a block based on the point type will be created.
  21349. * @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
  21350. */
  21351. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21352. }
  21353. }
  21354. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21355. /**
  21356. * Enum defining the type of properties that can be edited in the property pages in the NME
  21357. */
  21358. export enum PropertyTypeForEdition {
  21359. /** property is a boolean */
  21360. Boolean = 0,
  21361. /** property is a float */
  21362. Float = 1,
  21363. /** property is a Vector2 */
  21364. Vector2 = 2,
  21365. /** property is a list of values */
  21366. List = 3
  21367. }
  21368. /**
  21369. * Interface that defines an option in a variable of type list
  21370. */
  21371. export interface IEditablePropertyListOption {
  21372. /** label of the option */
  21373. "label": string;
  21374. /** value of the option */
  21375. "value": number;
  21376. }
  21377. /**
  21378. * Interface that defines the options available for an editable property
  21379. */
  21380. export interface IEditablePropertyOption {
  21381. /** min value */
  21382. "min"?: number;
  21383. /** max value */
  21384. "max"?: number;
  21385. /** notifiers: indicates which actions to take when the property is changed */
  21386. "notifiers"?: {
  21387. /** the material should be rebuilt */
  21388. "rebuild"?: boolean;
  21389. /** the preview should be updated */
  21390. "update"?: boolean;
  21391. };
  21392. /** list of the options for a variable of type list */
  21393. "options"?: IEditablePropertyListOption[];
  21394. }
  21395. /**
  21396. * Interface that describes an editable property
  21397. */
  21398. export interface IPropertyDescriptionForEdition {
  21399. /** name of the property */
  21400. "propertyName": string;
  21401. /** display name of the property */
  21402. "displayName": string;
  21403. /** type of the property */
  21404. "type": PropertyTypeForEdition;
  21405. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21406. "groupName": string;
  21407. /** options for the property */
  21408. "options": IEditablePropertyOption;
  21409. }
  21410. /**
  21411. * Decorator that flags a property in a node material block as being editable
  21412. */
  21413. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21414. }
  21415. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21418. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21420. import { Nullable } from "babylonjs/types";
  21421. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21422. import { Mesh } from "babylonjs/Meshes/mesh";
  21423. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21424. import { Effect } from "babylonjs/Materials/effect";
  21425. import { Scene } from "babylonjs/scene";
  21426. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21427. /**
  21428. * Block used to implement the refraction part of the sub surface module of the PBR material
  21429. */
  21430. export class RefractionBlock extends NodeMaterialBlock {
  21431. /** @hidden */
  21432. _define3DName: string;
  21433. /** @hidden */
  21434. _refractionMatrixName: string;
  21435. /** @hidden */
  21436. _defineLODRefractionAlpha: string;
  21437. /** @hidden */
  21438. _defineLinearSpecularRefraction: string;
  21439. /** @hidden */
  21440. _defineOppositeZ: string;
  21441. /** @hidden */
  21442. _cubeSamplerName: string;
  21443. /** @hidden */
  21444. _2DSamplerName: string;
  21445. /** @hidden */
  21446. _vRefractionMicrosurfaceInfosName: string;
  21447. /** @hidden */
  21448. _vRefractionInfosName: string;
  21449. private _scene;
  21450. /**
  21451. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21452. * Materials half opaque for instance using refraction could benefit from this control.
  21453. */
  21454. linkRefractionWithTransparency: boolean;
  21455. /**
  21456. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21457. */
  21458. invertRefractionY: boolean;
  21459. /**
  21460. * Gets or sets the texture associated with the node
  21461. */
  21462. texture: Nullable<BaseTexture>;
  21463. /**
  21464. * Create a new RefractionBlock
  21465. * @param name defines the block name
  21466. */
  21467. constructor(name: string);
  21468. /**
  21469. * Gets the current class name
  21470. * @returns the class name
  21471. */
  21472. getClassName(): string;
  21473. /**
  21474. * Gets the intensity input component
  21475. */
  21476. get intensity(): NodeMaterialConnectionPoint;
  21477. /**
  21478. * Gets the index of refraction input component
  21479. */
  21480. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21481. /**
  21482. * Gets the tint at distance input component
  21483. */
  21484. get tintAtDistance(): NodeMaterialConnectionPoint;
  21485. /**
  21486. * Gets the view input component
  21487. */
  21488. get view(): NodeMaterialConnectionPoint;
  21489. /**
  21490. * Gets the refraction object output component
  21491. */
  21492. get refraction(): NodeMaterialConnectionPoint;
  21493. /**
  21494. * Returns true if the block has a texture
  21495. */
  21496. get hasTexture(): boolean;
  21497. protected _getTexture(): Nullable<BaseTexture>;
  21498. autoConfigure(material: NodeMaterial): void;
  21499. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21500. isReady(): boolean;
  21501. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21502. /**
  21503. * Gets the main code of the block (fragment side)
  21504. * @param state current state of the node material building
  21505. * @returns the shader code
  21506. */
  21507. getCode(state: NodeMaterialBuildState): string;
  21508. protected _buildBlock(state: NodeMaterialBuildState): this;
  21509. protected _dumpPropertiesCode(): string;
  21510. serialize(): any;
  21511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21512. }
  21513. }
  21514. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21517. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21520. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21522. import { Nullable } from "babylonjs/types";
  21523. import { Scene } from "babylonjs/scene";
  21524. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21525. /**
  21526. * Base block used as input for post process
  21527. */
  21528. export class CurrentScreenBlock extends NodeMaterialBlock {
  21529. private _samplerName;
  21530. private _linearDefineName;
  21531. private _gammaDefineName;
  21532. private _mainUVName;
  21533. private _tempTextureRead;
  21534. /**
  21535. * Gets or sets the texture associated with the node
  21536. */
  21537. texture: Nullable<BaseTexture>;
  21538. /**
  21539. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21540. */
  21541. convertToGammaSpace: boolean;
  21542. /**
  21543. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21544. */
  21545. convertToLinearSpace: boolean;
  21546. /**
  21547. * Create a new CurrentScreenBlock
  21548. * @param name defines the block name
  21549. */
  21550. constructor(name: string);
  21551. /**
  21552. * Gets the current class name
  21553. * @returns the class name
  21554. */
  21555. getClassName(): string;
  21556. /**
  21557. * Gets the uv input component
  21558. */
  21559. get uv(): NodeMaterialConnectionPoint;
  21560. /**
  21561. * Gets the rgba output component
  21562. */
  21563. get rgba(): NodeMaterialConnectionPoint;
  21564. /**
  21565. * Gets the rgb output component
  21566. */
  21567. get rgb(): NodeMaterialConnectionPoint;
  21568. /**
  21569. * Gets the r output component
  21570. */
  21571. get r(): NodeMaterialConnectionPoint;
  21572. /**
  21573. * Gets the g output component
  21574. */
  21575. get g(): NodeMaterialConnectionPoint;
  21576. /**
  21577. * Gets the b output component
  21578. */
  21579. get b(): NodeMaterialConnectionPoint;
  21580. /**
  21581. * Gets the a output component
  21582. */
  21583. get a(): NodeMaterialConnectionPoint;
  21584. /**
  21585. * Initialize the block and prepare the context for build
  21586. * @param state defines the state that will be used for the build
  21587. */
  21588. initialize(state: NodeMaterialBuildState): void;
  21589. get target(): NodeMaterialBlockTargets;
  21590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21591. isReady(): boolean;
  21592. private _injectVertexCode;
  21593. private _writeTextureRead;
  21594. private _writeOutput;
  21595. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21596. serialize(): any;
  21597. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21598. }
  21599. }
  21600. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21601. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21602. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21603. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21605. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21607. import { Nullable } from "babylonjs/types";
  21608. import { Scene } from "babylonjs/scene";
  21609. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21610. /**
  21611. * Base block used for the particle texture
  21612. */
  21613. export class ParticleTextureBlock extends NodeMaterialBlock {
  21614. private _samplerName;
  21615. private _linearDefineName;
  21616. private _gammaDefineName;
  21617. private _tempTextureRead;
  21618. /**
  21619. * Gets or sets the texture associated with the node
  21620. */
  21621. texture: Nullable<BaseTexture>;
  21622. /**
  21623. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21624. */
  21625. convertToGammaSpace: boolean;
  21626. /**
  21627. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21628. */
  21629. convertToLinearSpace: boolean;
  21630. /**
  21631. * Create a new ParticleTextureBlock
  21632. * @param name defines the block name
  21633. */
  21634. constructor(name: string);
  21635. /**
  21636. * Gets the current class name
  21637. * @returns the class name
  21638. */
  21639. getClassName(): string;
  21640. /**
  21641. * Gets the uv input component
  21642. */
  21643. get uv(): NodeMaterialConnectionPoint;
  21644. /**
  21645. * Gets the rgba output component
  21646. */
  21647. get rgba(): NodeMaterialConnectionPoint;
  21648. /**
  21649. * Gets the rgb output component
  21650. */
  21651. get rgb(): NodeMaterialConnectionPoint;
  21652. /**
  21653. * Gets the r output component
  21654. */
  21655. get r(): NodeMaterialConnectionPoint;
  21656. /**
  21657. * Gets the g output component
  21658. */
  21659. get g(): NodeMaterialConnectionPoint;
  21660. /**
  21661. * Gets the b output component
  21662. */
  21663. get b(): NodeMaterialConnectionPoint;
  21664. /**
  21665. * Gets the a output component
  21666. */
  21667. get a(): NodeMaterialConnectionPoint;
  21668. /**
  21669. * Initialize the block and prepare the context for build
  21670. * @param state defines the state that will be used for the build
  21671. */
  21672. initialize(state: NodeMaterialBuildState): void;
  21673. autoConfigure(material: NodeMaterial): void;
  21674. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21675. isReady(): boolean;
  21676. private _writeOutput;
  21677. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21678. serialize(): any;
  21679. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21680. }
  21681. }
  21682. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21684. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21685. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21686. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21687. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21688. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21689. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21690. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21691. import { Scene } from "babylonjs/scene";
  21692. /**
  21693. * Class used to store shared data between 2 NodeMaterialBuildState
  21694. */
  21695. export class NodeMaterialBuildStateSharedData {
  21696. /**
  21697. * Gets the list of emitted varyings
  21698. */
  21699. temps: string[];
  21700. /**
  21701. * Gets the list of emitted varyings
  21702. */
  21703. varyings: string[];
  21704. /**
  21705. * Gets the varying declaration string
  21706. */
  21707. varyingDeclaration: string;
  21708. /**
  21709. * Input blocks
  21710. */
  21711. inputBlocks: InputBlock[];
  21712. /**
  21713. * Input blocks
  21714. */
  21715. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21716. /**
  21717. * Bindable blocks (Blocks that need to set data to the effect)
  21718. */
  21719. bindableBlocks: NodeMaterialBlock[];
  21720. /**
  21721. * List of blocks that can provide a compilation fallback
  21722. */
  21723. blocksWithFallbacks: NodeMaterialBlock[];
  21724. /**
  21725. * List of blocks that can provide a define update
  21726. */
  21727. blocksWithDefines: NodeMaterialBlock[];
  21728. /**
  21729. * List of blocks that can provide a repeatable content
  21730. */
  21731. repeatableContentBlocks: NodeMaterialBlock[];
  21732. /**
  21733. * List of blocks that can provide a dynamic list of uniforms
  21734. */
  21735. dynamicUniformBlocks: NodeMaterialBlock[];
  21736. /**
  21737. * List of blocks that can block the isReady function for the material
  21738. */
  21739. blockingBlocks: NodeMaterialBlock[];
  21740. /**
  21741. * Gets the list of animated inputs
  21742. */
  21743. animatedInputs: InputBlock[];
  21744. /**
  21745. * Build Id used to avoid multiple recompilations
  21746. */
  21747. buildId: number;
  21748. /** List of emitted variables */
  21749. variableNames: {
  21750. [key: string]: number;
  21751. };
  21752. /** List of emitted defines */
  21753. defineNames: {
  21754. [key: string]: number;
  21755. };
  21756. /** Should emit comments? */
  21757. emitComments: boolean;
  21758. /** Emit build activity */
  21759. verbose: boolean;
  21760. /** Gets or sets the hosting scene */
  21761. scene: Scene;
  21762. /**
  21763. * Gets the compilation hints emitted at compilation time
  21764. */
  21765. hints: {
  21766. needWorldViewMatrix: boolean;
  21767. needWorldViewProjectionMatrix: boolean;
  21768. needAlphaBlending: boolean;
  21769. needAlphaTesting: boolean;
  21770. };
  21771. /**
  21772. * List of compilation checks
  21773. */
  21774. checks: {
  21775. emitVertex: boolean;
  21776. emitFragment: boolean;
  21777. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21778. };
  21779. /**
  21780. * Is vertex program allowed to be empty?
  21781. */
  21782. allowEmptyVertexProgram: boolean;
  21783. /** Creates a new shared data */
  21784. constructor();
  21785. /**
  21786. * Emits console errors and exceptions if there is a failing check
  21787. */
  21788. emitErrors(): void;
  21789. }
  21790. }
  21791. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21792. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21793. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21794. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21795. /**
  21796. * Class used to store node based material build state
  21797. */
  21798. export class NodeMaterialBuildState {
  21799. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21800. supportUniformBuffers: boolean;
  21801. /**
  21802. * Gets the list of emitted attributes
  21803. */
  21804. attributes: string[];
  21805. /**
  21806. * Gets the list of emitted uniforms
  21807. */
  21808. uniforms: string[];
  21809. /**
  21810. * Gets the list of emitted constants
  21811. */
  21812. constants: string[];
  21813. /**
  21814. * Gets the list of emitted samplers
  21815. */
  21816. samplers: string[];
  21817. /**
  21818. * Gets the list of emitted functions
  21819. */
  21820. functions: {
  21821. [key: string]: string;
  21822. };
  21823. /**
  21824. * Gets the list of emitted extensions
  21825. */
  21826. extensions: {
  21827. [key: string]: string;
  21828. };
  21829. /**
  21830. * Gets the target of the compilation state
  21831. */
  21832. target: NodeMaterialBlockTargets;
  21833. /**
  21834. * Gets the list of emitted counters
  21835. */
  21836. counters: {
  21837. [key: string]: number;
  21838. };
  21839. /**
  21840. * Shared data between multiple NodeMaterialBuildState instances
  21841. */
  21842. sharedData: NodeMaterialBuildStateSharedData;
  21843. /** @hidden */
  21844. _vertexState: NodeMaterialBuildState;
  21845. /** @hidden */
  21846. _attributeDeclaration: string;
  21847. /** @hidden */
  21848. _uniformDeclaration: string;
  21849. /** @hidden */
  21850. _constantDeclaration: string;
  21851. /** @hidden */
  21852. _samplerDeclaration: string;
  21853. /** @hidden */
  21854. _varyingTransfer: string;
  21855. /** @hidden */
  21856. _injectAtEnd: string;
  21857. private _repeatableContentAnchorIndex;
  21858. /** @hidden */
  21859. _builtCompilationString: string;
  21860. /**
  21861. * Gets the emitted compilation strings
  21862. */
  21863. compilationString: string;
  21864. /**
  21865. * Finalize the compilation strings
  21866. * @param state defines the current compilation state
  21867. */
  21868. finalize(state: NodeMaterialBuildState): void;
  21869. /** @hidden */
  21870. get _repeatableContentAnchor(): string;
  21871. /** @hidden */
  21872. _getFreeVariableName(prefix: string): string;
  21873. /** @hidden */
  21874. _getFreeDefineName(prefix: string): string;
  21875. /** @hidden */
  21876. _excludeVariableName(name: string): void;
  21877. /** @hidden */
  21878. _emit2DSampler(name: string): void;
  21879. /** @hidden */
  21880. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21881. /** @hidden */
  21882. _emitExtension(name: string, extension: string, define?: string): void;
  21883. /** @hidden */
  21884. _emitFunction(name: string, code: string, comments: string): void;
  21885. /** @hidden */
  21886. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21887. replaceStrings?: {
  21888. search: RegExp;
  21889. replace: string;
  21890. }[];
  21891. repeatKey?: string;
  21892. }): string;
  21893. /** @hidden */
  21894. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21895. repeatKey?: string;
  21896. removeAttributes?: boolean;
  21897. removeUniforms?: boolean;
  21898. removeVaryings?: boolean;
  21899. removeIfDef?: boolean;
  21900. replaceStrings?: {
  21901. search: RegExp;
  21902. replace: string;
  21903. }[];
  21904. }, storeKey?: string): void;
  21905. /** @hidden */
  21906. _registerTempVariable(name: string): boolean;
  21907. /** @hidden */
  21908. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21909. /** @hidden */
  21910. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21911. /** @hidden */
  21912. _emitFloat(value: number): string;
  21913. }
  21914. }
  21915. declare module "babylonjs/Misc/uniqueIdGenerator" {
  21916. /**
  21917. * Helper class used to generate session unique ID
  21918. */
  21919. export class UniqueIdGenerator {
  21920. private static _UniqueIdCounter;
  21921. /**
  21922. * Gets an unique (relatively to the current scene) Id
  21923. */
  21924. static get UniqueId(): number;
  21925. }
  21926. }
  21927. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  21928. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21929. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21930. import { Nullable } from "babylonjs/types";
  21931. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21932. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21933. import { Effect } from "babylonjs/Materials/effect";
  21934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21935. import { Mesh } from "babylonjs/Meshes/mesh";
  21936. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21937. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21938. import { Scene } from "babylonjs/scene";
  21939. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21940. /**
  21941. * Defines a block that can be used inside a node based material
  21942. */
  21943. export class NodeMaterialBlock {
  21944. private _buildId;
  21945. private _buildTarget;
  21946. private _target;
  21947. private _isFinalMerger;
  21948. private _isInput;
  21949. protected _isUnique: boolean;
  21950. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21951. inputsAreExclusive: boolean;
  21952. /** @hidden */
  21953. _codeVariableName: string;
  21954. /** @hidden */
  21955. _inputs: NodeMaterialConnectionPoint[];
  21956. /** @hidden */
  21957. _outputs: NodeMaterialConnectionPoint[];
  21958. /** @hidden */
  21959. _preparationId: number;
  21960. /**
  21961. * Gets or sets the name of the block
  21962. */
  21963. name: string;
  21964. /**
  21965. * Gets or sets the unique id of the node
  21966. */
  21967. uniqueId: number;
  21968. /**
  21969. * Gets or sets the comments associated with this block
  21970. */
  21971. comments: string;
  21972. /**
  21973. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21974. */
  21975. get isUnique(): boolean;
  21976. /**
  21977. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21978. */
  21979. get isFinalMerger(): boolean;
  21980. /**
  21981. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21982. */
  21983. get isInput(): boolean;
  21984. /**
  21985. * Gets or sets the build Id
  21986. */
  21987. get buildId(): number;
  21988. set buildId(value: number);
  21989. /**
  21990. * Gets or sets the target of the block
  21991. */
  21992. get target(): NodeMaterialBlockTargets;
  21993. set target(value: NodeMaterialBlockTargets);
  21994. /**
  21995. * Gets the list of input points
  21996. */
  21997. get inputs(): NodeMaterialConnectionPoint[];
  21998. /** Gets the list of output points */
  21999. get outputs(): NodeMaterialConnectionPoint[];
  22000. /**
  22001. * Find an input by its name
  22002. * @param name defines the name of the input to look for
  22003. * @returns the input or null if not found
  22004. */
  22005. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22006. /**
  22007. * Find an output by its name
  22008. * @param name defines the name of the outputto look for
  22009. * @returns the output or null if not found
  22010. */
  22011. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22012. /**
  22013. * Creates a new NodeMaterialBlock
  22014. * @param name defines the block name
  22015. * @param target defines the target of that block (Vertex by default)
  22016. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22017. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22018. */
  22019. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22020. /**
  22021. * Initialize the block and prepare the context for build
  22022. * @param state defines the state that will be used for the build
  22023. */
  22024. initialize(state: NodeMaterialBuildState): void;
  22025. /**
  22026. * Bind data to effect. Will only be called for blocks with isBindable === true
  22027. * @param effect defines the effect to bind data to
  22028. * @param nodeMaterial defines the hosting NodeMaterial
  22029. * @param mesh defines the mesh that will be rendered
  22030. * @param subMesh defines the submesh that will be rendered
  22031. */
  22032. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22033. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22034. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22035. protected _writeFloat(value: number): string;
  22036. /**
  22037. * Gets the current class name e.g. "NodeMaterialBlock"
  22038. * @returns the class name
  22039. */
  22040. getClassName(): string;
  22041. /**
  22042. * Register a new input. Must be called inside a block constructor
  22043. * @param name defines the connection point name
  22044. * @param type defines the connection point type
  22045. * @param isOptional defines a boolean indicating that this input can be omitted
  22046. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22047. * @param point an already created connection point. If not provided, create a new one
  22048. * @returns the current block
  22049. */
  22050. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22051. /**
  22052. * Register a new output. Must be called inside a block constructor
  22053. * @param name defines the connection point name
  22054. * @param type defines the connection point type
  22055. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22056. * @param point an already created connection point. If not provided, create a new one
  22057. * @returns the current block
  22058. */
  22059. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22060. /**
  22061. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22062. * @param forOutput defines an optional connection point to check compatibility with
  22063. * @returns the first available input or null
  22064. */
  22065. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22066. /**
  22067. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22068. * @param forBlock defines an optional block to check compatibility with
  22069. * @returns the first available input or null
  22070. */
  22071. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22072. /**
  22073. * Gets the sibling of the given output
  22074. * @param current defines the current output
  22075. * @returns the next output in the list or null
  22076. */
  22077. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22078. /**
  22079. * Connect current block with another block
  22080. * @param other defines the block to connect with
  22081. * @param options define the various options to help pick the right connections
  22082. * @returns the current block
  22083. */
  22084. connectTo(other: NodeMaterialBlock, options?: {
  22085. input?: string;
  22086. output?: string;
  22087. outputSwizzle?: string;
  22088. }): this | undefined;
  22089. protected _buildBlock(state: NodeMaterialBuildState): void;
  22090. /**
  22091. * Add uniforms, samplers and uniform buffers at compilation time
  22092. * @param state defines the state to update
  22093. * @param nodeMaterial defines the node material requesting the update
  22094. * @param defines defines the material defines to update
  22095. * @param uniformBuffers defines the list of uniform buffer names
  22096. */
  22097. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22098. /**
  22099. * Add potential fallbacks if shader compilation fails
  22100. * @param mesh defines the mesh to be rendered
  22101. * @param fallbacks defines the current prioritized list of fallbacks
  22102. */
  22103. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22104. /**
  22105. * Initialize defines for shader compilation
  22106. * @param mesh defines the mesh to be rendered
  22107. * @param nodeMaterial defines the node material requesting the update
  22108. * @param defines defines the material defines to update
  22109. * @param useInstances specifies that instances should be used
  22110. */
  22111. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22112. /**
  22113. * Update defines for shader compilation
  22114. * @param mesh defines the mesh to be rendered
  22115. * @param nodeMaterial defines the node material requesting the update
  22116. * @param defines defines the material defines to update
  22117. * @param useInstances specifies that instances should be used
  22118. * @param subMesh defines which submesh to render
  22119. */
  22120. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22121. /**
  22122. * Lets the block try to connect some inputs automatically
  22123. * @param material defines the hosting NodeMaterial
  22124. */
  22125. autoConfigure(material: NodeMaterial): void;
  22126. /**
  22127. * Function called when a block is declared as repeatable content generator
  22128. * @param vertexShaderState defines the current compilation state for the vertex shader
  22129. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22130. * @param mesh defines the mesh to be rendered
  22131. * @param defines defines the material defines to update
  22132. */
  22133. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22134. /**
  22135. * Checks if the block is ready
  22136. * @param mesh defines the mesh to be rendered
  22137. * @param nodeMaterial defines the node material requesting the update
  22138. * @param defines defines the material defines to update
  22139. * @param useInstances specifies that instances should be used
  22140. * @returns true if the block is ready
  22141. */
  22142. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22143. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22144. private _processBuild;
  22145. /**
  22146. * Compile the current node and generate the shader code
  22147. * @param state defines the current compilation state (uniforms, samplers, current string)
  22148. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22149. * @returns true if already built
  22150. */
  22151. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22152. protected _inputRename(name: string): string;
  22153. protected _outputRename(name: string): string;
  22154. protected _dumpPropertiesCode(): string;
  22155. /** @hidden */
  22156. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22157. /** @hidden */
  22158. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22159. /**
  22160. * Clone the current block to a new identical block
  22161. * @param scene defines the hosting scene
  22162. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22163. * @returns a copy of the current block
  22164. */
  22165. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22166. /**
  22167. * Serializes this block in a JSON representation
  22168. * @returns the serialized block object
  22169. */
  22170. serialize(): any;
  22171. /** @hidden */
  22172. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22173. private _deserializePortDisplayNamesAndExposedOnFrame;
  22174. /**
  22175. * Release resources
  22176. */
  22177. dispose(): void;
  22178. }
  22179. }
  22180. declare module "babylonjs/Materials/pushMaterial" {
  22181. import { Nullable } from "babylonjs/types";
  22182. import { Scene } from "babylonjs/scene";
  22183. import { Matrix } from "babylonjs/Maths/math.vector";
  22184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22185. import { Mesh } from "babylonjs/Meshes/mesh";
  22186. import { Material } from "babylonjs/Materials/material";
  22187. import { Effect } from "babylonjs/Materials/effect";
  22188. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22189. /**
  22190. * Base class of materials working in push mode in babylon JS
  22191. * @hidden
  22192. */
  22193. export class PushMaterial extends Material {
  22194. protected _activeEffect: Effect;
  22195. protected _normalMatrix: Matrix;
  22196. constructor(name: string, scene: Scene);
  22197. getEffect(): Effect;
  22198. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22199. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22200. /**
  22201. * Binds the given world matrix to the active effect
  22202. *
  22203. * @param world the matrix to bind
  22204. */
  22205. bindOnlyWorldMatrix(world: Matrix): void;
  22206. /**
  22207. * Binds the given normal matrix to the active effect
  22208. *
  22209. * @param normalMatrix the matrix to bind
  22210. */
  22211. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22212. bind(world: Matrix, mesh?: Mesh): void;
  22213. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22214. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22215. }
  22216. }
  22217. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22218. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22219. /**
  22220. * Root class for all node material optimizers
  22221. */
  22222. export class NodeMaterialOptimizer {
  22223. /**
  22224. * Function used to optimize a NodeMaterial graph
  22225. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22226. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22227. */
  22228. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22229. }
  22230. }
  22231. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22232. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22233. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22234. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22235. import { Scene } from "babylonjs/scene";
  22236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22237. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22238. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22239. /**
  22240. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22241. */
  22242. export class TransformBlock extends NodeMaterialBlock {
  22243. /**
  22244. * Defines the value to use to complement W value to transform it to a Vector4
  22245. */
  22246. complementW: number;
  22247. /**
  22248. * Defines the value to use to complement z value to transform it to a Vector4
  22249. */
  22250. complementZ: number;
  22251. /**
  22252. * Creates a new TransformBlock
  22253. * @param name defines the block name
  22254. */
  22255. constructor(name: string);
  22256. /**
  22257. * Gets the current class name
  22258. * @returns the class name
  22259. */
  22260. getClassName(): string;
  22261. /**
  22262. * Gets the vector input
  22263. */
  22264. get vector(): NodeMaterialConnectionPoint;
  22265. /**
  22266. * Gets the output component
  22267. */
  22268. get output(): NodeMaterialConnectionPoint;
  22269. /**
  22270. * Gets the xyz output component
  22271. */
  22272. get xyz(): NodeMaterialConnectionPoint;
  22273. /**
  22274. * Gets the matrix transform input
  22275. */
  22276. get transform(): NodeMaterialConnectionPoint;
  22277. protected _buildBlock(state: NodeMaterialBuildState): this;
  22278. /**
  22279. * Update defines for shader compilation
  22280. * @param mesh defines the mesh to be rendered
  22281. * @param nodeMaterial defines the node material requesting the update
  22282. * @param defines defines the material defines to update
  22283. * @param useInstances specifies that instances should be used
  22284. * @param subMesh defines which submesh to render
  22285. */
  22286. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22287. serialize(): any;
  22288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22289. protected _dumpPropertiesCode(): string;
  22290. }
  22291. }
  22292. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22296. /**
  22297. * Block used to output the vertex position
  22298. */
  22299. export class VertexOutputBlock extends NodeMaterialBlock {
  22300. /**
  22301. * Creates a new VertexOutputBlock
  22302. * @param name defines the block name
  22303. */
  22304. constructor(name: string);
  22305. /**
  22306. * Gets the current class name
  22307. * @returns the class name
  22308. */
  22309. getClassName(): string;
  22310. /**
  22311. * Gets the vector input component
  22312. */
  22313. get vector(): NodeMaterialConnectionPoint;
  22314. protected _buildBlock(state: NodeMaterialBuildState): this;
  22315. }
  22316. }
  22317. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22320. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22321. /**
  22322. * Block used to output the final color
  22323. */
  22324. export class FragmentOutputBlock extends NodeMaterialBlock {
  22325. /**
  22326. * Create a new FragmentOutputBlock
  22327. * @param name defines the block name
  22328. */
  22329. constructor(name: string);
  22330. /**
  22331. * Gets the current class name
  22332. * @returns the class name
  22333. */
  22334. getClassName(): string;
  22335. /**
  22336. * Gets the rgba input component
  22337. */
  22338. get rgba(): NodeMaterialConnectionPoint;
  22339. /**
  22340. * Gets the rgb input component
  22341. */
  22342. get rgb(): NodeMaterialConnectionPoint;
  22343. /**
  22344. * Gets the a input component
  22345. */
  22346. get a(): NodeMaterialConnectionPoint;
  22347. protected _buildBlock(state: NodeMaterialBuildState): this;
  22348. }
  22349. }
  22350. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22351. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22352. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22353. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22354. /**
  22355. * Block used for the particle ramp gradient section
  22356. */
  22357. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22358. /**
  22359. * Create a new ParticleRampGradientBlock
  22360. * @param name defines the block name
  22361. */
  22362. constructor(name: string);
  22363. /**
  22364. * Gets the current class name
  22365. * @returns the class name
  22366. */
  22367. getClassName(): string;
  22368. /**
  22369. * Gets the color input component
  22370. */
  22371. get color(): NodeMaterialConnectionPoint;
  22372. /**
  22373. * Gets the rampColor output component
  22374. */
  22375. get rampColor(): NodeMaterialConnectionPoint;
  22376. /**
  22377. * Initialize the block and prepare the context for build
  22378. * @param state defines the state that will be used for the build
  22379. */
  22380. initialize(state: NodeMaterialBuildState): void;
  22381. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22382. }
  22383. }
  22384. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22385. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22386. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22387. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22388. /**
  22389. * Block used for the particle blend multiply section
  22390. */
  22391. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22392. /**
  22393. * Create a new ParticleBlendMultiplyBlock
  22394. * @param name defines the block name
  22395. */
  22396. constructor(name: string);
  22397. /**
  22398. * Gets the current class name
  22399. * @returns the class name
  22400. */
  22401. getClassName(): string;
  22402. /**
  22403. * Gets the color input component
  22404. */
  22405. get color(): NodeMaterialConnectionPoint;
  22406. /**
  22407. * Gets the alphaTexture input component
  22408. */
  22409. get alphaTexture(): NodeMaterialConnectionPoint;
  22410. /**
  22411. * Gets the alphaColor input component
  22412. */
  22413. get alphaColor(): NodeMaterialConnectionPoint;
  22414. /**
  22415. * Gets the blendColor output component
  22416. */
  22417. get blendColor(): NodeMaterialConnectionPoint;
  22418. /**
  22419. * Initialize the block and prepare the context for build
  22420. * @param state defines the state that will be used for the build
  22421. */
  22422. initialize(state: NodeMaterialBuildState): void;
  22423. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22424. }
  22425. }
  22426. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22427. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22428. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22429. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22430. /**
  22431. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22432. */
  22433. export class VectorMergerBlock extends NodeMaterialBlock {
  22434. /**
  22435. * Create a new VectorMergerBlock
  22436. * @param name defines the block name
  22437. */
  22438. constructor(name: string);
  22439. /**
  22440. * Gets the current class name
  22441. * @returns the class name
  22442. */
  22443. getClassName(): string;
  22444. /**
  22445. * Gets the xyz component (input)
  22446. */
  22447. get xyzIn(): NodeMaterialConnectionPoint;
  22448. /**
  22449. * Gets the xy component (input)
  22450. */
  22451. get xyIn(): NodeMaterialConnectionPoint;
  22452. /**
  22453. * Gets the x component (input)
  22454. */
  22455. get x(): NodeMaterialConnectionPoint;
  22456. /**
  22457. * Gets the y component (input)
  22458. */
  22459. get y(): NodeMaterialConnectionPoint;
  22460. /**
  22461. * Gets the z component (input)
  22462. */
  22463. get z(): NodeMaterialConnectionPoint;
  22464. /**
  22465. * Gets the w component (input)
  22466. */
  22467. get w(): NodeMaterialConnectionPoint;
  22468. /**
  22469. * Gets the xyzw component (output)
  22470. */
  22471. get xyzw(): NodeMaterialConnectionPoint;
  22472. /**
  22473. * Gets the xyz component (output)
  22474. */
  22475. get xyzOut(): NodeMaterialConnectionPoint;
  22476. /**
  22477. * Gets the xy component (output)
  22478. */
  22479. get xyOut(): NodeMaterialConnectionPoint;
  22480. /**
  22481. * Gets the xy component (output)
  22482. * @deprecated Please use xyOut instead.
  22483. */
  22484. get xy(): NodeMaterialConnectionPoint;
  22485. /**
  22486. * Gets the xyz component (output)
  22487. * @deprecated Please use xyzOut instead.
  22488. */
  22489. get xyz(): NodeMaterialConnectionPoint;
  22490. protected _buildBlock(state: NodeMaterialBuildState): this;
  22491. }
  22492. }
  22493. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22495. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22496. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22497. import { Vector2 } from "babylonjs/Maths/math.vector";
  22498. import { Scene } from "babylonjs/scene";
  22499. /**
  22500. * Block used to remap a float from a range to a new one
  22501. */
  22502. export class RemapBlock extends NodeMaterialBlock {
  22503. /**
  22504. * Gets or sets the source range
  22505. */
  22506. sourceRange: Vector2;
  22507. /**
  22508. * Gets or sets the target range
  22509. */
  22510. targetRange: Vector2;
  22511. /**
  22512. * Creates a new RemapBlock
  22513. * @param name defines the block name
  22514. */
  22515. constructor(name: string);
  22516. /**
  22517. * Gets the current class name
  22518. * @returns the class name
  22519. */
  22520. getClassName(): string;
  22521. /**
  22522. * Gets the input component
  22523. */
  22524. get input(): NodeMaterialConnectionPoint;
  22525. /**
  22526. * Gets the source min input component
  22527. */
  22528. get sourceMin(): NodeMaterialConnectionPoint;
  22529. /**
  22530. * Gets the source max input component
  22531. */
  22532. get sourceMax(): NodeMaterialConnectionPoint;
  22533. /**
  22534. * Gets the target min input component
  22535. */
  22536. get targetMin(): NodeMaterialConnectionPoint;
  22537. /**
  22538. * Gets the target max input component
  22539. */
  22540. get targetMax(): NodeMaterialConnectionPoint;
  22541. /**
  22542. * Gets the output component
  22543. */
  22544. get output(): NodeMaterialConnectionPoint;
  22545. protected _buildBlock(state: NodeMaterialBuildState): this;
  22546. protected _dumpPropertiesCode(): string;
  22547. serialize(): any;
  22548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22549. }
  22550. }
  22551. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22555. /**
  22556. * Block used to multiply 2 values
  22557. */
  22558. export class MultiplyBlock extends NodeMaterialBlock {
  22559. /**
  22560. * Creates a new MultiplyBlock
  22561. * @param name defines the block name
  22562. */
  22563. constructor(name: string);
  22564. /**
  22565. * Gets the current class name
  22566. * @returns the class name
  22567. */
  22568. getClassName(): string;
  22569. /**
  22570. * Gets the left operand input component
  22571. */
  22572. get left(): NodeMaterialConnectionPoint;
  22573. /**
  22574. * Gets the right operand input component
  22575. */
  22576. get right(): NodeMaterialConnectionPoint;
  22577. /**
  22578. * Gets the output component
  22579. */
  22580. get output(): NodeMaterialConnectionPoint;
  22581. protected _buildBlock(state: NodeMaterialBuildState): this;
  22582. }
  22583. }
  22584. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22588. /**
  22589. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22590. */
  22591. export class ColorSplitterBlock extends NodeMaterialBlock {
  22592. /**
  22593. * Create a new ColorSplitterBlock
  22594. * @param name defines the block name
  22595. */
  22596. constructor(name: string);
  22597. /**
  22598. * Gets the current class name
  22599. * @returns the class name
  22600. */
  22601. getClassName(): string;
  22602. /**
  22603. * Gets the rgba component (input)
  22604. */
  22605. get rgba(): NodeMaterialConnectionPoint;
  22606. /**
  22607. * Gets the rgb component (input)
  22608. */
  22609. get rgbIn(): NodeMaterialConnectionPoint;
  22610. /**
  22611. * Gets the rgb component (output)
  22612. */
  22613. get rgbOut(): NodeMaterialConnectionPoint;
  22614. /**
  22615. * Gets the r component (output)
  22616. */
  22617. get r(): NodeMaterialConnectionPoint;
  22618. /**
  22619. * Gets the g component (output)
  22620. */
  22621. get g(): NodeMaterialConnectionPoint;
  22622. /**
  22623. * Gets the b component (output)
  22624. */
  22625. get b(): NodeMaterialConnectionPoint;
  22626. /**
  22627. * Gets the a component (output)
  22628. */
  22629. get a(): NodeMaterialConnectionPoint;
  22630. protected _inputRename(name: string): string;
  22631. protected _outputRename(name: string): string;
  22632. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22633. }
  22634. }
  22635. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22636. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22637. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22638. import { Scene } from "babylonjs/scene";
  22639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22640. import { Matrix } from "babylonjs/Maths/math.vector";
  22641. import { Mesh } from "babylonjs/Meshes/mesh";
  22642. import { Engine } from "babylonjs/Engines/engine";
  22643. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22644. import { Observable } from "babylonjs/Misc/observable";
  22645. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22646. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22647. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22648. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22649. import { Nullable } from "babylonjs/types";
  22650. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22651. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22652. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22653. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22654. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22655. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22656. import { Effect } from "babylonjs/Materials/effect";
  22657. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22658. import { Camera } from "babylonjs/Cameras/camera";
  22659. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22660. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22661. /**
  22662. * Interface used to configure the node material editor
  22663. */
  22664. export interface INodeMaterialEditorOptions {
  22665. /** Define the URl to load node editor script */
  22666. editorURL?: string;
  22667. }
  22668. /** @hidden */
  22669. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22670. NORMAL: boolean;
  22671. TANGENT: boolean;
  22672. UV1: boolean;
  22673. /** BONES */
  22674. NUM_BONE_INFLUENCERS: number;
  22675. BonesPerMesh: number;
  22676. BONETEXTURE: boolean;
  22677. /** MORPH TARGETS */
  22678. MORPHTARGETS: boolean;
  22679. MORPHTARGETS_NORMAL: boolean;
  22680. MORPHTARGETS_TANGENT: boolean;
  22681. MORPHTARGETS_UV: boolean;
  22682. NUM_MORPH_INFLUENCERS: number;
  22683. /** IMAGE PROCESSING */
  22684. IMAGEPROCESSING: boolean;
  22685. VIGNETTE: boolean;
  22686. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22687. VIGNETTEBLENDMODEOPAQUE: boolean;
  22688. TONEMAPPING: boolean;
  22689. TONEMAPPING_ACES: boolean;
  22690. CONTRAST: boolean;
  22691. EXPOSURE: boolean;
  22692. COLORCURVES: boolean;
  22693. COLORGRADING: boolean;
  22694. COLORGRADING3D: boolean;
  22695. SAMPLER3DGREENDEPTH: boolean;
  22696. SAMPLER3DBGRMAP: boolean;
  22697. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22698. /** MISC. */
  22699. BUMPDIRECTUV: number;
  22700. constructor();
  22701. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22702. }
  22703. /**
  22704. * Class used to configure NodeMaterial
  22705. */
  22706. export interface INodeMaterialOptions {
  22707. /**
  22708. * Defines if blocks should emit comments
  22709. */
  22710. emitComments: boolean;
  22711. }
  22712. /**
  22713. * Class used to create a node based material built by assembling shader blocks
  22714. */
  22715. export class NodeMaterial extends PushMaterial {
  22716. private static _BuildIdGenerator;
  22717. private _options;
  22718. private _vertexCompilationState;
  22719. private _fragmentCompilationState;
  22720. private _sharedData;
  22721. private _buildId;
  22722. private _buildWasSuccessful;
  22723. private _cachedWorldViewMatrix;
  22724. private _cachedWorldViewProjectionMatrix;
  22725. private _optimizers;
  22726. private _animationFrame;
  22727. /** Define the Url to load node editor script */
  22728. static EditorURL: string;
  22729. /** Define the Url to load snippets */
  22730. static SnippetUrl: string;
  22731. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22732. static IgnoreTexturesAtLoadTime: boolean;
  22733. private BJSNODEMATERIALEDITOR;
  22734. /** Get the inspector from bundle or global */
  22735. private _getGlobalNodeMaterialEditor;
  22736. /**
  22737. * Snippet ID if the material was created from the snippet server
  22738. */
  22739. snippetId: string;
  22740. /**
  22741. * Gets or sets data used by visual editor
  22742. * @see https://nme.babylonjs.com
  22743. */
  22744. editorData: any;
  22745. /**
  22746. * 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)
  22747. */
  22748. ignoreAlpha: boolean;
  22749. /**
  22750. * Defines the maximum number of lights that can be used in the material
  22751. */
  22752. maxSimultaneousLights: number;
  22753. /**
  22754. * Observable raised when the material is built
  22755. */
  22756. onBuildObservable: Observable<NodeMaterial>;
  22757. /**
  22758. * Gets or sets the root nodes of the material vertex shader
  22759. */
  22760. _vertexOutputNodes: NodeMaterialBlock[];
  22761. /**
  22762. * Gets or sets the root nodes of the material fragment (pixel) shader
  22763. */
  22764. _fragmentOutputNodes: NodeMaterialBlock[];
  22765. /** Gets or sets options to control the node material overall behavior */
  22766. get options(): INodeMaterialOptions;
  22767. set options(options: INodeMaterialOptions);
  22768. /**
  22769. * Default configuration related to image processing available in the standard Material.
  22770. */
  22771. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22772. /**
  22773. * Gets the image processing configuration used either in this material.
  22774. */
  22775. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22776. /**
  22777. * Sets the Default image processing configuration used either in the this material.
  22778. *
  22779. * If sets to null, the scene one is in use.
  22780. */
  22781. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22782. /**
  22783. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22784. */
  22785. attachedBlocks: NodeMaterialBlock[];
  22786. /**
  22787. * Specifies the mode of the node material
  22788. * @hidden
  22789. */
  22790. _mode: NodeMaterialModes;
  22791. /**
  22792. * Gets the mode property
  22793. */
  22794. get mode(): NodeMaterialModes;
  22795. /**
  22796. * Create a new node based material
  22797. * @param name defines the material name
  22798. * @param scene defines the hosting scene
  22799. * @param options defines creation option
  22800. */
  22801. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22802. /**
  22803. * Gets the current class name of the material e.g. "NodeMaterial"
  22804. * @returns the class name
  22805. */
  22806. getClassName(): string;
  22807. /**
  22808. * Keep track of the image processing observer to allow dispose and replace.
  22809. */
  22810. private _imageProcessingObserver;
  22811. /**
  22812. * Attaches a new image processing configuration to the Standard Material.
  22813. * @param configuration
  22814. */
  22815. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22816. /**
  22817. * Get a block by its name
  22818. * @param name defines the name of the block to retrieve
  22819. * @returns the required block or null if not found
  22820. */
  22821. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22822. /**
  22823. * Get a block by its name
  22824. * @param predicate defines the predicate used to find the good candidate
  22825. * @returns the required block or null if not found
  22826. */
  22827. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22828. /**
  22829. * Get an input block by its name
  22830. * @param predicate defines the predicate used to find the good candidate
  22831. * @returns the required input block or null if not found
  22832. */
  22833. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22834. /**
  22835. * Gets the list of input blocks attached to this material
  22836. * @returns an array of InputBlocks
  22837. */
  22838. getInputBlocks(): InputBlock[];
  22839. /**
  22840. * Adds a new optimizer to the list of optimizers
  22841. * @param optimizer defines the optimizers to add
  22842. * @returns the current material
  22843. */
  22844. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22845. /**
  22846. * Remove an optimizer from the list of optimizers
  22847. * @param optimizer defines the optimizers to remove
  22848. * @returns the current material
  22849. */
  22850. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22851. /**
  22852. * Add a new block to the list of output nodes
  22853. * @param node defines the node to add
  22854. * @returns the current material
  22855. */
  22856. addOutputNode(node: NodeMaterialBlock): this;
  22857. /**
  22858. * Remove a block from the list of root nodes
  22859. * @param node defines the node to remove
  22860. * @returns the current material
  22861. */
  22862. removeOutputNode(node: NodeMaterialBlock): this;
  22863. private _addVertexOutputNode;
  22864. private _removeVertexOutputNode;
  22865. private _addFragmentOutputNode;
  22866. private _removeFragmentOutputNode;
  22867. /**
  22868. * Specifies if the material will require alpha blending
  22869. * @returns a boolean specifying if alpha blending is needed
  22870. */
  22871. needAlphaBlending(): boolean;
  22872. /**
  22873. * Specifies if this material should be rendered in alpha test mode
  22874. * @returns a boolean specifying if an alpha test is needed.
  22875. */
  22876. needAlphaTesting(): boolean;
  22877. private _initializeBlock;
  22878. private _resetDualBlocks;
  22879. /**
  22880. * Remove a block from the current node material
  22881. * @param block defines the block to remove
  22882. */
  22883. removeBlock(block: NodeMaterialBlock): void;
  22884. /**
  22885. * Build the material and generates the inner effect
  22886. * @param verbose defines if the build should log activity
  22887. */
  22888. build(verbose?: boolean): void;
  22889. /**
  22890. * Runs an otpimization phase to try to improve the shader code
  22891. */
  22892. optimize(): void;
  22893. private _prepareDefinesForAttributes;
  22894. /**
  22895. * Create a post process from the material
  22896. * @param camera The camera to apply the render pass to.
  22897. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22899. * @param engine The engine which the post process will be applied. (default: current engine)
  22900. * @param reusable If the post process can be reused on the same frame. (default: false)
  22901. * @param textureType Type of textures used when performing the post process. (default: 0)
  22902. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22903. * @returns the post process created
  22904. */
  22905. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22906. /**
  22907. * Create the post process effect from the material
  22908. * @param postProcess The post process to create the effect for
  22909. */
  22910. createEffectForPostProcess(postProcess: PostProcess): void;
  22911. private _createEffectOrPostProcess;
  22912. private _createEffectForParticles;
  22913. /**
  22914. * Create the effect to be used as the custom effect for a particle system
  22915. * @param particleSystem Particle system to create the effect for
  22916. * @param onCompiled defines a function to call when the effect creation is successful
  22917. * @param onError defines a function to call when the effect creation has failed
  22918. */
  22919. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22920. private _processDefines;
  22921. /**
  22922. * Get if the submesh is ready to be used and all its information available.
  22923. * Child classes can use it to update shaders
  22924. * @param mesh defines the mesh to check
  22925. * @param subMesh defines which submesh to check
  22926. * @param useInstances specifies that instances should be used
  22927. * @returns a boolean indicating that the submesh is ready or not
  22928. */
  22929. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22930. /**
  22931. * Get a string representing the shaders built by the current node graph
  22932. */
  22933. get compiledShaders(): string;
  22934. /**
  22935. * Binds the world matrix to the material
  22936. * @param world defines the world transformation matrix
  22937. */
  22938. bindOnlyWorldMatrix(world: Matrix): void;
  22939. /**
  22940. * Binds the submesh to this material by preparing the effect and shader to draw
  22941. * @param world defines the world transformation matrix
  22942. * @param mesh defines the mesh containing the submesh
  22943. * @param subMesh defines the submesh to bind the material to
  22944. */
  22945. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22946. /**
  22947. * Gets the active textures from the material
  22948. * @returns an array of textures
  22949. */
  22950. getActiveTextures(): BaseTexture[];
  22951. /**
  22952. * Gets the list of texture blocks
  22953. * @returns an array of texture blocks
  22954. */
  22955. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22956. /**
  22957. * Specifies if the material uses a texture
  22958. * @param texture defines the texture to check against the material
  22959. * @returns a boolean specifying if the material uses the texture
  22960. */
  22961. hasTexture(texture: BaseTexture): boolean;
  22962. /**
  22963. * Disposes the material
  22964. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22965. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22966. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22967. */
  22968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22969. /** Creates the node editor window. */
  22970. private _createNodeEditor;
  22971. /**
  22972. * Launch the node material editor
  22973. * @param config Define the configuration of the editor
  22974. * @return a promise fulfilled when the node editor is visible
  22975. */
  22976. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22977. /**
  22978. * Clear the current material
  22979. */
  22980. clear(): void;
  22981. /**
  22982. * Clear the current material and set it to a default state
  22983. */
  22984. setToDefault(): void;
  22985. /**
  22986. * Clear the current material and set it to a default state for post process
  22987. */
  22988. setToDefaultPostProcess(): void;
  22989. /**
  22990. * Clear the current material and set it to a default state for particle
  22991. */
  22992. setToDefaultParticle(): void;
  22993. /**
  22994. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22995. * @param url defines the url to load from
  22996. * @returns a promise that will fullfil when the material is fully loaded
  22997. */
  22998. loadAsync(url: string): Promise<void>;
  22999. private _gatherBlocks;
  23000. /**
  23001. * Generate a string containing the code declaration required to create an equivalent of this material
  23002. * @returns a string
  23003. */
  23004. generateCode(): string;
  23005. /**
  23006. * Serializes this material in a JSON representation
  23007. * @returns the serialized material object
  23008. */
  23009. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23010. private _restoreConnections;
  23011. /**
  23012. * Clear the current graph and load a new one from a serialization object
  23013. * @param source defines the JSON representation of the material
  23014. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23015. * @param merge defines whether or not the source must be merged or replace the current content
  23016. */
  23017. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23018. /**
  23019. * Makes a duplicate of the current material.
  23020. * @param name - name to use for the new material.
  23021. */
  23022. clone(name: string): NodeMaterial;
  23023. /**
  23024. * Creates a node material from parsed material data
  23025. * @param source defines the JSON representation of the material
  23026. * @param scene defines the hosting scene
  23027. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23028. * @returns a new node material
  23029. */
  23030. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23031. /**
  23032. * Creates a node material from a snippet saved in a remote file
  23033. * @param name defines the name of the material to create
  23034. * @param url defines the url to load from
  23035. * @param scene defines the hosting scene
  23036. * @returns a promise that will resolve to the new node material
  23037. */
  23038. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23039. /**
  23040. * Creates a node material from a snippet saved by the node material editor
  23041. * @param snippetId defines the snippet to load
  23042. * @param scene defines the hosting scene
  23043. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23044. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23045. * @returns a promise that will resolve to the new node material
  23046. */
  23047. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23048. /**
  23049. * Creates a new node material set to default basic configuration
  23050. * @param name defines the name of the material
  23051. * @param scene defines the hosting scene
  23052. * @returns a new NodeMaterial
  23053. */
  23054. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23055. }
  23056. }
  23057. declare module "babylonjs/PostProcesses/postProcess" {
  23058. import { Nullable } from "babylonjs/types";
  23059. import { SmartArray } from "babylonjs/Misc/smartArray";
  23060. import { Observable } from "babylonjs/Misc/observable";
  23061. import { Vector2 } from "babylonjs/Maths/math.vector";
  23062. import { Camera } from "babylonjs/Cameras/camera";
  23063. import { Effect } from "babylonjs/Materials/effect";
  23064. import "babylonjs/Shaders/postprocess.vertex";
  23065. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23066. import { Engine } from "babylonjs/Engines/engine";
  23067. import { Color4 } from "babylonjs/Maths/math.color";
  23068. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23069. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23070. import { Scene } from "babylonjs/scene";
  23071. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23072. /**
  23073. * Size options for a post process
  23074. */
  23075. export type PostProcessOptions = {
  23076. width: number;
  23077. height: number;
  23078. };
  23079. /**
  23080. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23081. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23082. */
  23083. export class PostProcess {
  23084. /** Name of the PostProcess. */
  23085. name: string;
  23086. /**
  23087. * Gets or sets the unique id of the post process
  23088. */
  23089. uniqueId: number;
  23090. /**
  23091. * Width of the texture to apply the post process on
  23092. */
  23093. width: number;
  23094. /**
  23095. * Height of the texture to apply the post process on
  23096. */
  23097. height: number;
  23098. /**
  23099. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23100. */
  23101. nodeMaterialSource: Nullable<NodeMaterial>;
  23102. /**
  23103. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23104. * @hidden
  23105. */
  23106. _outputTexture: Nullable<InternalTexture>;
  23107. /**
  23108. * Sampling mode used by the shader
  23109. * See https://doc.babylonjs.com/classes/3.1/texture
  23110. */
  23111. renderTargetSamplingMode: number;
  23112. /**
  23113. * Clear color to use when screen clearing
  23114. */
  23115. clearColor: Color4;
  23116. /**
  23117. * If the buffer needs to be cleared before applying the post process. (default: true)
  23118. * Should be set to false if shader will overwrite all previous pixels.
  23119. */
  23120. autoClear: boolean;
  23121. /**
  23122. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23123. */
  23124. alphaMode: number;
  23125. /**
  23126. * Sets the setAlphaBlendConstants of the babylon engine
  23127. */
  23128. alphaConstants: Color4;
  23129. /**
  23130. * Animations to be used for the post processing
  23131. */
  23132. animations: import("babylonjs/Animations/animation").Animation[];
  23133. /**
  23134. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23135. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23136. */
  23137. enablePixelPerfectMode: boolean;
  23138. /**
  23139. * Force the postprocess to be applied without taking in account viewport
  23140. */
  23141. forceFullscreenViewport: boolean;
  23142. /**
  23143. * List of inspectable custom properties (used by the Inspector)
  23144. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23145. */
  23146. inspectableCustomProperties: IInspectable[];
  23147. /**
  23148. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23149. *
  23150. * | Value | Type | Description |
  23151. * | ----- | ----------------------------------- | ----------- |
  23152. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23153. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23154. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23155. *
  23156. */
  23157. scaleMode: number;
  23158. /**
  23159. * Force textures to be a power of two (default: false)
  23160. */
  23161. alwaysForcePOT: boolean;
  23162. private _samples;
  23163. /**
  23164. * Number of sample textures (default: 1)
  23165. */
  23166. get samples(): number;
  23167. set samples(n: number);
  23168. /**
  23169. * Modify the scale of the post process to be the same as the viewport (default: false)
  23170. */
  23171. adaptScaleToCurrentViewport: boolean;
  23172. private _camera;
  23173. protected _scene: Scene;
  23174. private _engine;
  23175. private _options;
  23176. private _reusable;
  23177. private _textureType;
  23178. private _textureFormat;
  23179. /**
  23180. * Smart array of input and output textures for the post process.
  23181. * @hidden
  23182. */
  23183. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23184. /**
  23185. * The index in _textures that corresponds to the output texture.
  23186. * @hidden
  23187. */
  23188. _currentRenderTextureInd: number;
  23189. private _effect;
  23190. private _samplers;
  23191. private _fragmentUrl;
  23192. private _vertexUrl;
  23193. private _parameters;
  23194. private _scaleRatio;
  23195. protected _indexParameters: any;
  23196. private _shareOutputWithPostProcess;
  23197. private _texelSize;
  23198. private _forcedOutputTexture;
  23199. /**
  23200. * Returns the fragment url or shader name used in the post process.
  23201. * @returns the fragment url or name in the shader store.
  23202. */
  23203. getEffectName(): string;
  23204. /**
  23205. * An event triggered when the postprocess is activated.
  23206. */
  23207. onActivateObservable: Observable<Camera>;
  23208. private _onActivateObserver;
  23209. /**
  23210. * A function that is added to the onActivateObservable
  23211. */
  23212. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23213. /**
  23214. * An event triggered when the postprocess changes its size.
  23215. */
  23216. onSizeChangedObservable: Observable<PostProcess>;
  23217. private _onSizeChangedObserver;
  23218. /**
  23219. * A function that is added to the onSizeChangedObservable
  23220. */
  23221. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23222. /**
  23223. * An event triggered when the postprocess applies its effect.
  23224. */
  23225. onApplyObservable: Observable<Effect>;
  23226. private _onApplyObserver;
  23227. /**
  23228. * A function that is added to the onApplyObservable
  23229. */
  23230. set onApply(callback: (effect: Effect) => void);
  23231. /**
  23232. * An event triggered before rendering the postprocess
  23233. */
  23234. onBeforeRenderObservable: Observable<Effect>;
  23235. private _onBeforeRenderObserver;
  23236. /**
  23237. * A function that is added to the onBeforeRenderObservable
  23238. */
  23239. set onBeforeRender(callback: (effect: Effect) => void);
  23240. /**
  23241. * An event triggered after rendering the postprocess
  23242. */
  23243. onAfterRenderObservable: Observable<Effect>;
  23244. private _onAfterRenderObserver;
  23245. /**
  23246. * A function that is added to the onAfterRenderObservable
  23247. */
  23248. set onAfterRender(callback: (efect: Effect) => void);
  23249. /**
  23250. * 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
  23251. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23252. */
  23253. get inputTexture(): InternalTexture;
  23254. set inputTexture(value: InternalTexture);
  23255. /**
  23256. * Gets the camera which post process is applied to.
  23257. * @returns The camera the post process is applied to.
  23258. */
  23259. getCamera(): Camera;
  23260. /**
  23261. * Gets the texel size of the postprocess.
  23262. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23263. */
  23264. get texelSize(): Vector2;
  23265. /**
  23266. * Creates a new instance PostProcess
  23267. * @param name The name of the PostProcess.
  23268. * @param fragmentUrl The url of the fragment shader to be used.
  23269. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23270. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23271. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23272. * @param camera The camera to apply the render pass to.
  23273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23274. * @param engine The engine which the post process will be applied. (default: current engine)
  23275. * @param reusable If the post process can be reused on the same frame. (default: false)
  23276. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23277. * @param textureType Type of textures used when performing the post process. (default: 0)
  23278. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23279. * @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
  23280. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23281. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23282. */
  23283. constructor(
  23284. /** Name of the PostProcess. */
  23285. 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);
  23286. /**
  23287. * Gets a string idenfifying the name of the class
  23288. * @returns "PostProcess" string
  23289. */
  23290. getClassName(): string;
  23291. /**
  23292. * Gets the engine which this post process belongs to.
  23293. * @returns The engine the post process was enabled with.
  23294. */
  23295. getEngine(): Engine;
  23296. /**
  23297. * The effect that is created when initializing the post process.
  23298. * @returns The created effect corresponding the the postprocess.
  23299. */
  23300. getEffect(): Effect;
  23301. /**
  23302. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23303. * @param postProcess The post process to share the output with.
  23304. * @returns This post process.
  23305. */
  23306. shareOutputWith(postProcess: PostProcess): PostProcess;
  23307. /**
  23308. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23309. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23310. */
  23311. useOwnOutput(): void;
  23312. /**
  23313. * Updates the effect with the current post process compile time values and recompiles the shader.
  23314. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23315. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23316. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23317. * @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
  23318. * @param onCompiled Called when the shader has been compiled.
  23319. * @param onError Called if there is an error when compiling a shader.
  23320. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23321. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23322. */
  23323. 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;
  23324. /**
  23325. * The post process is reusable if it can be used multiple times within one frame.
  23326. * @returns If the post process is reusable
  23327. */
  23328. isReusable(): boolean;
  23329. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23330. markTextureDirty(): void;
  23331. /**
  23332. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23333. * 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.
  23334. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23335. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23336. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23337. * @returns The target texture that was bound to be written to.
  23338. */
  23339. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23340. /**
  23341. * If the post process is supported.
  23342. */
  23343. get isSupported(): boolean;
  23344. /**
  23345. * The aspect ratio of the output texture.
  23346. */
  23347. get aspectRatio(): number;
  23348. /**
  23349. * Get a value indicating if the post-process is ready to be used
  23350. * @returns true if the post-process is ready (shader is compiled)
  23351. */
  23352. isReady(): boolean;
  23353. /**
  23354. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23355. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23356. */
  23357. apply(): Nullable<Effect>;
  23358. private _disposeTextures;
  23359. /**
  23360. * Disposes the post process.
  23361. * @param camera The camera to dispose the post process on.
  23362. */
  23363. dispose(camera?: Camera): void;
  23364. }
  23365. }
  23366. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23367. /** @hidden */
  23368. export var kernelBlurVaryingDeclaration: {
  23369. name: string;
  23370. shader: string;
  23371. };
  23372. }
  23373. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23374. /** @hidden */
  23375. export var kernelBlurFragment: {
  23376. name: string;
  23377. shader: string;
  23378. };
  23379. }
  23380. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23381. /** @hidden */
  23382. export var kernelBlurFragment2: {
  23383. name: string;
  23384. shader: string;
  23385. };
  23386. }
  23387. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23388. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23389. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23390. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23391. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23392. /** @hidden */
  23393. export var kernelBlurPixelShader: {
  23394. name: string;
  23395. shader: string;
  23396. };
  23397. }
  23398. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23399. /** @hidden */
  23400. export var kernelBlurVertex: {
  23401. name: string;
  23402. shader: string;
  23403. };
  23404. }
  23405. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23406. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23407. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23408. /** @hidden */
  23409. export var kernelBlurVertexShader: {
  23410. name: string;
  23411. shader: string;
  23412. };
  23413. }
  23414. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23415. import { Vector2 } from "babylonjs/Maths/math.vector";
  23416. import { Nullable } from "babylonjs/types";
  23417. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23418. import { Camera } from "babylonjs/Cameras/camera";
  23419. import { Effect } from "babylonjs/Materials/effect";
  23420. import { Engine } from "babylonjs/Engines/engine";
  23421. import "babylonjs/Shaders/kernelBlur.fragment";
  23422. import "babylonjs/Shaders/kernelBlur.vertex";
  23423. /**
  23424. * The Blur Post Process which blurs an image based on a kernel and direction.
  23425. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23426. */
  23427. export class BlurPostProcess extends PostProcess {
  23428. /** The direction in which to blur the image. */
  23429. direction: Vector2;
  23430. private blockCompilation;
  23431. protected _kernel: number;
  23432. protected _idealKernel: number;
  23433. protected _packedFloat: boolean;
  23434. private _staticDefines;
  23435. /**
  23436. * Sets the length in pixels of the blur sample region
  23437. */
  23438. set kernel(v: number);
  23439. /**
  23440. * Gets the length in pixels of the blur sample region
  23441. */
  23442. get kernel(): number;
  23443. /**
  23444. * Sets wether or not the blur needs to unpack/repack floats
  23445. */
  23446. set packedFloat(v: boolean);
  23447. /**
  23448. * Gets wether or not the blur is unpacking/repacking floats
  23449. */
  23450. get packedFloat(): boolean;
  23451. /**
  23452. * Creates a new instance BlurPostProcess
  23453. * @param name The name of the effect.
  23454. * @param direction The direction in which to blur the image.
  23455. * @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.
  23456. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23457. * @param camera The camera to apply the render pass to.
  23458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23459. * @param engine The engine which the post process will be applied. (default: current engine)
  23460. * @param reusable If the post process can be reused on the same frame. (default: false)
  23461. * @param textureType Type of textures used when performing the post process. (default: 0)
  23462. * @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)
  23463. */
  23464. constructor(name: string,
  23465. /** The direction in which to blur the image. */
  23466. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23467. /**
  23468. * Updates the effect with the current post process compile time values and recompiles the shader.
  23469. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23470. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23471. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23472. * @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
  23473. * @param onCompiled Called when the shader has been compiled.
  23474. * @param onError Called if there is an error when compiling a shader.
  23475. */
  23476. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23477. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23478. /**
  23479. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23480. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23481. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23482. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23483. * The gaps between physical kernels are compensated for in the weighting of the samples
  23484. * @param idealKernel Ideal blur kernel.
  23485. * @return Nearest best kernel.
  23486. */
  23487. protected _nearestBestKernel(idealKernel: number): number;
  23488. /**
  23489. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23490. * @param x The point on the Gaussian distribution to sample.
  23491. * @return the value of the Gaussian function at x.
  23492. */
  23493. protected _gaussianWeight(x: number): number;
  23494. /**
  23495. * Generates a string that can be used as a floating point number in GLSL.
  23496. * @param x Value to print.
  23497. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23498. * @return GLSL float string.
  23499. */
  23500. protected _glslFloat(x: number, decimalFigures?: number): string;
  23501. }
  23502. }
  23503. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23504. import { Scene } from "babylonjs/scene";
  23505. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23506. import { Plane } from "babylonjs/Maths/math.plane";
  23507. /**
  23508. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23509. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23510. * You can then easily use it as a reflectionTexture on a flat surface.
  23511. * In case the surface is not a plane, please consider relying on reflection probes.
  23512. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23513. */
  23514. export class MirrorTexture extends RenderTargetTexture {
  23515. private scene;
  23516. /**
  23517. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23518. * 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.
  23519. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23520. */
  23521. mirrorPlane: Plane;
  23522. /**
  23523. * Define the blur ratio used to blur the reflection if needed.
  23524. */
  23525. set blurRatio(value: number);
  23526. get blurRatio(): number;
  23527. /**
  23528. * Define the adaptive blur kernel used to blur the reflection if needed.
  23529. * This will autocompute the closest best match for the `blurKernel`
  23530. */
  23531. set adaptiveBlurKernel(value: number);
  23532. /**
  23533. * Define the blur kernel used to blur the reflection if needed.
  23534. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23535. */
  23536. set blurKernel(value: number);
  23537. /**
  23538. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23539. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23540. */
  23541. set blurKernelX(value: number);
  23542. get blurKernelX(): number;
  23543. /**
  23544. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23545. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23546. */
  23547. set blurKernelY(value: number);
  23548. get blurKernelY(): number;
  23549. private _autoComputeBlurKernel;
  23550. protected _onRatioRescale(): void;
  23551. private _updateGammaSpace;
  23552. private _imageProcessingConfigChangeObserver;
  23553. private _transformMatrix;
  23554. private _mirrorMatrix;
  23555. private _savedViewMatrix;
  23556. private _blurX;
  23557. private _blurY;
  23558. private _adaptiveBlurKernel;
  23559. private _blurKernelX;
  23560. private _blurKernelY;
  23561. private _blurRatio;
  23562. /**
  23563. * Instantiates a Mirror Texture.
  23564. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23565. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23566. * You can then easily use it as a reflectionTexture on a flat surface.
  23567. * In case the surface is not a plane, please consider relying on reflection probes.
  23568. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23569. * @param name
  23570. * @param size
  23571. * @param scene
  23572. * @param generateMipMaps
  23573. * @param type
  23574. * @param samplingMode
  23575. * @param generateDepthBuffer
  23576. */
  23577. constructor(name: string, size: number | {
  23578. width: number;
  23579. height: number;
  23580. } | {
  23581. ratio: number;
  23582. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23583. private _preparePostProcesses;
  23584. /**
  23585. * Clone the mirror texture.
  23586. * @returns the cloned texture
  23587. */
  23588. clone(): MirrorTexture;
  23589. /**
  23590. * Serialize the texture to a JSON representation you could use in Parse later on
  23591. * @returns the serialized JSON representation
  23592. */
  23593. serialize(): any;
  23594. /**
  23595. * Dispose the texture and release its associated resources.
  23596. */
  23597. dispose(): void;
  23598. }
  23599. }
  23600. declare module "babylonjs/Materials/Textures/texture" {
  23601. import { Observable } from "babylonjs/Misc/observable";
  23602. import { Nullable } from "babylonjs/types";
  23603. import { Matrix } from "babylonjs/Maths/math.vector";
  23604. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23605. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23606. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23607. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23608. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23609. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23610. import { Scene } from "babylonjs/scene";
  23611. /**
  23612. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23613. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23614. */
  23615. export class Texture extends BaseTexture {
  23616. /**
  23617. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23618. */
  23619. static SerializeBuffers: boolean;
  23620. /** @hidden */
  23621. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23622. /** @hidden */
  23623. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23624. /** @hidden */
  23625. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23626. /** nearest is mag = nearest and min = nearest and mip = linear */
  23627. static readonly NEAREST_SAMPLINGMODE: number;
  23628. /** nearest is mag = nearest and min = nearest and mip = linear */
  23629. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23630. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23631. static readonly BILINEAR_SAMPLINGMODE: number;
  23632. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23633. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23634. /** Trilinear is mag = linear and min = linear and mip = linear */
  23635. static readonly TRILINEAR_SAMPLINGMODE: number;
  23636. /** Trilinear is mag = linear and min = linear and mip = linear */
  23637. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23638. /** mag = nearest and min = nearest and mip = nearest */
  23639. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23640. /** mag = nearest and min = linear and mip = nearest */
  23641. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23642. /** mag = nearest and min = linear and mip = linear */
  23643. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23644. /** mag = nearest and min = linear and mip = none */
  23645. static readonly NEAREST_LINEAR: number;
  23646. /** mag = nearest and min = nearest and mip = none */
  23647. static readonly NEAREST_NEAREST: number;
  23648. /** mag = linear and min = nearest and mip = nearest */
  23649. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23650. /** mag = linear and min = nearest and mip = linear */
  23651. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23652. /** mag = linear and min = linear and mip = none */
  23653. static readonly LINEAR_LINEAR: number;
  23654. /** mag = linear and min = nearest and mip = none */
  23655. static readonly LINEAR_NEAREST: number;
  23656. /** Explicit coordinates mode */
  23657. static readonly EXPLICIT_MODE: number;
  23658. /** Spherical coordinates mode */
  23659. static readonly SPHERICAL_MODE: number;
  23660. /** Planar coordinates mode */
  23661. static readonly PLANAR_MODE: number;
  23662. /** Cubic coordinates mode */
  23663. static readonly CUBIC_MODE: number;
  23664. /** Projection coordinates mode */
  23665. static readonly PROJECTION_MODE: number;
  23666. /** Inverse Cubic coordinates mode */
  23667. static readonly SKYBOX_MODE: number;
  23668. /** Inverse Cubic coordinates mode */
  23669. static readonly INVCUBIC_MODE: number;
  23670. /** Equirectangular coordinates mode */
  23671. static readonly EQUIRECTANGULAR_MODE: number;
  23672. /** Equirectangular Fixed coordinates mode */
  23673. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23674. /** Equirectangular Fixed Mirrored coordinates mode */
  23675. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23676. /** Texture is not repeating outside of 0..1 UVs */
  23677. static readonly CLAMP_ADDRESSMODE: number;
  23678. /** Texture is repeating outside of 0..1 UVs */
  23679. static readonly WRAP_ADDRESSMODE: number;
  23680. /** Texture is repeating and mirrored */
  23681. static readonly MIRROR_ADDRESSMODE: number;
  23682. /**
  23683. * 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
  23684. */
  23685. static UseSerializedUrlIfAny: boolean;
  23686. /**
  23687. * Define the url of the texture.
  23688. */
  23689. url: Nullable<string>;
  23690. /**
  23691. * Define an offset on the texture to offset the u coordinates of the UVs
  23692. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23693. */
  23694. uOffset: number;
  23695. /**
  23696. * Define an offset on the texture to offset the v coordinates of the UVs
  23697. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23698. */
  23699. vOffset: number;
  23700. /**
  23701. * Define an offset on the texture to scale the u coordinates of the UVs
  23702. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23703. */
  23704. uScale: number;
  23705. /**
  23706. * Define an offset on the texture to scale the v coordinates of the UVs
  23707. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23708. */
  23709. vScale: number;
  23710. /**
  23711. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23712. * @see https://doc.babylonjs.com/how_to/more_materials
  23713. */
  23714. uAng: number;
  23715. /**
  23716. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23717. * @see https://doc.babylonjs.com/how_to/more_materials
  23718. */
  23719. vAng: number;
  23720. /**
  23721. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23722. * @see https://doc.babylonjs.com/how_to/more_materials
  23723. */
  23724. wAng: number;
  23725. /**
  23726. * Defines the center of rotation (U)
  23727. */
  23728. uRotationCenter: number;
  23729. /**
  23730. * Defines the center of rotation (V)
  23731. */
  23732. vRotationCenter: number;
  23733. /**
  23734. * Defines the center of rotation (W)
  23735. */
  23736. wRotationCenter: number;
  23737. /**
  23738. * Are mip maps generated for this texture or not.
  23739. */
  23740. get noMipmap(): boolean;
  23741. /**
  23742. * List of inspectable custom properties (used by the Inspector)
  23743. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23744. */
  23745. inspectableCustomProperties: Nullable<IInspectable[]>;
  23746. private _noMipmap;
  23747. /** @hidden */
  23748. _invertY: boolean;
  23749. private _rowGenerationMatrix;
  23750. private _cachedTextureMatrix;
  23751. private _projectionModeMatrix;
  23752. private _t0;
  23753. private _t1;
  23754. private _t2;
  23755. private _cachedUOffset;
  23756. private _cachedVOffset;
  23757. private _cachedUScale;
  23758. private _cachedVScale;
  23759. private _cachedUAng;
  23760. private _cachedVAng;
  23761. private _cachedWAng;
  23762. private _cachedProjectionMatrixId;
  23763. private _cachedCoordinatesMode;
  23764. /** @hidden */
  23765. protected _initialSamplingMode: number;
  23766. /** @hidden */
  23767. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23768. private _deleteBuffer;
  23769. protected _format: Nullable<number>;
  23770. private _delayedOnLoad;
  23771. private _delayedOnError;
  23772. private _mimeType?;
  23773. /**
  23774. * Observable triggered once the texture has been loaded.
  23775. */
  23776. onLoadObservable: Observable<Texture>;
  23777. protected _isBlocking: boolean;
  23778. /**
  23779. * Is the texture preventing material to render while loading.
  23780. * If false, a default texture will be used instead of the loading one during the preparation step.
  23781. */
  23782. set isBlocking(value: boolean);
  23783. get isBlocking(): boolean;
  23784. /**
  23785. * Get the current sampling mode associated with the texture.
  23786. */
  23787. get samplingMode(): number;
  23788. /**
  23789. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23790. */
  23791. get invertY(): boolean;
  23792. /**
  23793. * Instantiates a new texture.
  23794. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23795. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23796. * @param url defines the url of the picture to load as a texture
  23797. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23798. * @param noMipmap defines if the texture will require mip maps or not
  23799. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23800. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23801. * @param onLoad defines a callback triggered when the texture has been loaded
  23802. * @param onError defines a callback triggered when an error occurred during the loading session
  23803. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23804. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23805. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23806. * @param mimeType defines an optional mime type information
  23807. */
  23808. 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);
  23809. /**
  23810. * Update the url (and optional buffer) of this texture if url was null during construction.
  23811. * @param url the url of the texture
  23812. * @param buffer the buffer of the texture (defaults to null)
  23813. * @param onLoad callback called when the texture is loaded (defaults to null)
  23814. */
  23815. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23816. /**
  23817. * Finish the loading sequence of a texture flagged as delayed load.
  23818. * @hidden
  23819. */
  23820. delayLoad(): void;
  23821. private _prepareRowForTextureGeneration;
  23822. /**
  23823. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23824. * @returns the transform matrix of the texture.
  23825. */
  23826. getTextureMatrix(uBase?: number): Matrix;
  23827. /**
  23828. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23829. * @returns The reflection texture transform
  23830. */
  23831. getReflectionTextureMatrix(): Matrix;
  23832. /**
  23833. * Clones the texture.
  23834. * @returns the cloned texture
  23835. */
  23836. clone(): Texture;
  23837. /**
  23838. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23839. * @returns The JSON representation of the texture
  23840. */
  23841. serialize(): any;
  23842. /**
  23843. * Get the current class name of the texture useful for serialization or dynamic coding.
  23844. * @returns "Texture"
  23845. */
  23846. getClassName(): string;
  23847. /**
  23848. * Dispose the texture and release its associated resources.
  23849. */
  23850. dispose(): void;
  23851. /**
  23852. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23853. * @param parsedTexture Define the JSON representation of the texture
  23854. * @param scene Define the scene the parsed texture should be instantiated in
  23855. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23856. * @returns The parsed texture if successful
  23857. */
  23858. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23859. /**
  23860. * Creates a texture from its base 64 representation.
  23861. * @param data Define the base64 payload without the data: prefix
  23862. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23863. * @param scene Define the scene the texture should belong to
  23864. * @param noMipmap Forces the texture to not create mip map information if true
  23865. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23866. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23867. * @param onLoad define a callback triggered when the texture has been loaded
  23868. * @param onError define a callback triggered when an error occurred during the loading session
  23869. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23870. * @returns the created texture
  23871. */
  23872. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23873. /**
  23874. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23875. * @param data Define the base64 payload without the data: prefix
  23876. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23877. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23878. * @param scene Define the scene the texture should belong to
  23879. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23880. * @param noMipmap Forces the texture to not create mip map information if true
  23881. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23882. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23883. * @param onLoad define a callback triggered when the texture has been loaded
  23884. * @param onError define a callback triggered when an error occurred during the loading session
  23885. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23886. * @returns the created texture
  23887. */
  23888. 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;
  23889. }
  23890. }
  23891. declare module "babylonjs/PostProcesses/postProcessManager" {
  23892. import { Nullable } from "babylonjs/types";
  23893. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23894. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23895. import { Scene } from "babylonjs/scene";
  23896. /**
  23897. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23898. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23899. */
  23900. export class PostProcessManager {
  23901. private _scene;
  23902. private _indexBuffer;
  23903. private _vertexBuffers;
  23904. /**
  23905. * Creates a new instance PostProcess
  23906. * @param scene The scene that the post process is associated with.
  23907. */
  23908. constructor(scene: Scene);
  23909. private _prepareBuffers;
  23910. private _buildIndexBuffer;
  23911. /**
  23912. * Rebuilds the vertex buffers of the manager.
  23913. * @hidden
  23914. */
  23915. _rebuild(): void;
  23916. /**
  23917. * Prepares a frame to be run through a post process.
  23918. * @param sourceTexture The input texture to the post procesess. (default: null)
  23919. * @param postProcesses An array of post processes to be run. (default: null)
  23920. * @returns True if the post processes were able to be run.
  23921. * @hidden
  23922. */
  23923. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23924. /**
  23925. * Manually render a set of post processes to a texture.
  23926. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23927. * @param postProcesses An array of post processes to be run.
  23928. * @param targetTexture The target texture to render to.
  23929. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23930. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23931. * @param lodLevel defines which lod of the texture to render to
  23932. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23933. */
  23934. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23935. /**
  23936. * Finalize the result of the output of the postprocesses.
  23937. * @param doNotPresent If true the result will not be displayed to the screen.
  23938. * @param targetTexture The target texture to render to.
  23939. * @param faceIndex The index of the face to bind the target texture to.
  23940. * @param postProcesses The array of post processes to render.
  23941. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23942. * @hidden
  23943. */
  23944. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23945. /**
  23946. * Disposes of the post process manager.
  23947. */
  23948. dispose(): void;
  23949. }
  23950. }
  23951. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  23952. import { Observable } from "babylonjs/Misc/observable";
  23953. import { SmartArray } from "babylonjs/Misc/smartArray";
  23954. import { Nullable, Immutable } from "babylonjs/types";
  23955. import { Camera } from "babylonjs/Cameras/camera";
  23956. import { Scene } from "babylonjs/scene";
  23957. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  23958. import { Color4 } from "babylonjs/Maths/math.color";
  23959. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  23960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23961. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23962. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23963. import { Texture } from "babylonjs/Materials/Textures/texture";
  23964. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23965. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  23966. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23967. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  23968. import { Engine } from "babylonjs/Engines/engine";
  23969. /**
  23970. * This Helps creating a texture that will be created from a camera in your scene.
  23971. * It is basically a dynamic texture that could be used to create special effects for instance.
  23972. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23973. */
  23974. export class RenderTargetTexture extends Texture {
  23975. isCube: boolean;
  23976. /**
  23977. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23978. */
  23979. static readonly REFRESHRATE_RENDER_ONCE: number;
  23980. /**
  23981. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23982. */
  23983. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23984. /**
  23985. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23986. * the central point of your effect and can save a lot of performances.
  23987. */
  23988. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23989. /**
  23990. * Use this predicate to dynamically define the list of mesh you want to render.
  23991. * If set, the renderList property will be overwritten.
  23992. */
  23993. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23994. private _renderList;
  23995. /**
  23996. * Use this list to define the list of mesh you want to render.
  23997. */
  23998. get renderList(): Nullable<Array<AbstractMesh>>;
  23999. set renderList(value: Nullable<Array<AbstractMesh>>);
  24000. /**
  24001. * Use this function to overload the renderList array at rendering time.
  24002. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24003. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24004. * the cube (if the RTT is a cube, else layerOrFace=0).
  24005. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24006. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24007. * hold dummy elements!
  24008. */
  24009. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24010. private _hookArray;
  24011. /**
  24012. * Define if particles should be rendered in your texture.
  24013. */
  24014. renderParticles: boolean;
  24015. /**
  24016. * Define if sprites should be rendered in your texture.
  24017. */
  24018. renderSprites: boolean;
  24019. /**
  24020. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24021. */
  24022. coordinatesMode: number;
  24023. /**
  24024. * Define the camera used to render the texture.
  24025. */
  24026. activeCamera: Nullable<Camera>;
  24027. /**
  24028. * Override the mesh isReady function with your own one.
  24029. */
  24030. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24031. /**
  24032. * Override the render function of the texture with your own one.
  24033. */
  24034. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24035. /**
  24036. * Define if camera post processes should be use while rendering the texture.
  24037. */
  24038. useCameraPostProcesses: boolean;
  24039. /**
  24040. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24041. */
  24042. ignoreCameraViewport: boolean;
  24043. private _postProcessManager;
  24044. private _postProcesses;
  24045. private _resizeObserver;
  24046. /**
  24047. * An event triggered when the texture is unbind.
  24048. */
  24049. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24050. /**
  24051. * An event triggered when the texture is unbind.
  24052. */
  24053. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24054. private _onAfterUnbindObserver;
  24055. /**
  24056. * Set a after unbind callback in the texture.
  24057. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24058. */
  24059. set onAfterUnbind(callback: () => void);
  24060. /**
  24061. * An event triggered before rendering the texture
  24062. */
  24063. onBeforeRenderObservable: Observable<number>;
  24064. private _onBeforeRenderObserver;
  24065. /**
  24066. * Set a before render callback in the texture.
  24067. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24068. */
  24069. set onBeforeRender(callback: (faceIndex: number) => void);
  24070. /**
  24071. * An event triggered after rendering the texture
  24072. */
  24073. onAfterRenderObservable: Observable<number>;
  24074. private _onAfterRenderObserver;
  24075. /**
  24076. * Set a after render callback in the texture.
  24077. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24078. */
  24079. set onAfterRender(callback: (faceIndex: number) => void);
  24080. /**
  24081. * An event triggered after the texture clear
  24082. */
  24083. onClearObservable: Observable<Engine>;
  24084. private _onClearObserver;
  24085. /**
  24086. * Set a clear callback in the texture.
  24087. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24088. */
  24089. set onClear(callback: (Engine: Engine) => void);
  24090. /**
  24091. * An event triggered when the texture is resized.
  24092. */
  24093. onResizeObservable: Observable<RenderTargetTexture>;
  24094. /**
  24095. * Define the clear color of the Render Target if it should be different from the scene.
  24096. */
  24097. clearColor: Color4;
  24098. protected _size: number | {
  24099. width: number;
  24100. height: number;
  24101. layers?: number;
  24102. };
  24103. protected _initialSizeParameter: number | {
  24104. width: number;
  24105. height: number;
  24106. } | {
  24107. ratio: number;
  24108. };
  24109. protected _sizeRatio: Nullable<number>;
  24110. /** @hidden */
  24111. _generateMipMaps: boolean;
  24112. protected _renderingManager: RenderingManager;
  24113. /** @hidden */
  24114. _waitingRenderList: string[];
  24115. protected _doNotChangeAspectRatio: boolean;
  24116. protected _currentRefreshId: number;
  24117. protected _refreshRate: number;
  24118. protected _textureMatrix: Matrix;
  24119. protected _samples: number;
  24120. protected _renderTargetOptions: RenderTargetCreationOptions;
  24121. /**
  24122. * Gets render target creation options that were used.
  24123. */
  24124. get renderTargetOptions(): RenderTargetCreationOptions;
  24125. protected _onRatioRescale(): void;
  24126. /**
  24127. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24128. * It must define where the camera used to render the texture is set
  24129. */
  24130. boundingBoxPosition: Vector3;
  24131. private _boundingBoxSize;
  24132. /**
  24133. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24134. * When defined, the cubemap will switch to local mode
  24135. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24136. * @example https://www.babylonjs-playground.com/#RNASML
  24137. */
  24138. set boundingBoxSize(value: Vector3);
  24139. get boundingBoxSize(): Vector3;
  24140. /**
  24141. * In case the RTT has been created with a depth texture, get the associated
  24142. * depth texture.
  24143. * Otherwise, return null.
  24144. */
  24145. get depthStencilTexture(): Nullable<InternalTexture>;
  24146. /**
  24147. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24148. * or used a shadow, depth texture...
  24149. * @param name The friendly name of the texture
  24150. * @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)
  24151. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24152. * @param generateMipMaps True if mip maps need to be generated after render.
  24153. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24154. * @param type The type of the buffer in the RTT (int, half float, float...)
  24155. * @param isCube True if a cube texture needs to be created
  24156. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24157. * @param generateDepthBuffer True to generate a depth buffer
  24158. * @param generateStencilBuffer True to generate a stencil buffer
  24159. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24160. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24161. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24162. */
  24163. constructor(name: string, size: number | {
  24164. width: number;
  24165. height: number;
  24166. layers?: number;
  24167. } | {
  24168. ratio: number;
  24169. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24170. /**
  24171. * Creates a depth stencil texture.
  24172. * This is only available in WebGL 2 or with the depth texture extension available.
  24173. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24174. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24175. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24176. */
  24177. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24178. private _processSizeParameter;
  24179. /**
  24180. * Define the number of samples to use in case of MSAA.
  24181. * It defaults to one meaning no MSAA has been enabled.
  24182. */
  24183. get samples(): number;
  24184. set samples(value: number);
  24185. /**
  24186. * Resets the refresh counter of the texture and start bak from scratch.
  24187. * Could be useful to regenerate the texture if it is setup to render only once.
  24188. */
  24189. resetRefreshCounter(): void;
  24190. /**
  24191. * Define the refresh rate of the texture or the rendering frequency.
  24192. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24193. */
  24194. get refreshRate(): number;
  24195. set refreshRate(value: number);
  24196. /**
  24197. * Adds a post process to the render target rendering passes.
  24198. * @param postProcess define the post process to add
  24199. */
  24200. addPostProcess(postProcess: PostProcess): void;
  24201. /**
  24202. * Clear all the post processes attached to the render target
  24203. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24204. */
  24205. clearPostProcesses(dispose?: boolean): void;
  24206. /**
  24207. * Remove one of the post process from the list of attached post processes to the texture
  24208. * @param postProcess define the post process to remove from the list
  24209. */
  24210. removePostProcess(postProcess: PostProcess): void;
  24211. /** @hidden */
  24212. _shouldRender(): boolean;
  24213. /**
  24214. * Gets the actual render size of the texture.
  24215. * @returns the width of the render size
  24216. */
  24217. getRenderSize(): number;
  24218. /**
  24219. * Gets the actual render width of the texture.
  24220. * @returns the width of the render size
  24221. */
  24222. getRenderWidth(): number;
  24223. /**
  24224. * Gets the actual render height of the texture.
  24225. * @returns the height of the render size
  24226. */
  24227. getRenderHeight(): number;
  24228. /**
  24229. * Gets the actual number of layers of the texture.
  24230. * @returns the number of layers
  24231. */
  24232. getRenderLayers(): number;
  24233. /**
  24234. * Get if the texture can be rescaled or not.
  24235. */
  24236. get canRescale(): boolean;
  24237. /**
  24238. * Resize the texture using a ratio.
  24239. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24240. */
  24241. scale(ratio: number): void;
  24242. /**
  24243. * Get the texture reflection matrix used to rotate/transform the reflection.
  24244. * @returns the reflection matrix
  24245. */
  24246. getReflectionTextureMatrix(): Matrix;
  24247. /**
  24248. * Resize the texture to a new desired size.
  24249. * Be carrefull as it will recreate all the data in the new texture.
  24250. * @param size Define the new size. It can be:
  24251. * - a number for squared texture,
  24252. * - an object containing { width: number, height: number }
  24253. * - or an object containing a ratio { ratio: number }
  24254. */
  24255. resize(size: number | {
  24256. width: number;
  24257. height: number;
  24258. } | {
  24259. ratio: number;
  24260. }): void;
  24261. private _defaultRenderListPrepared;
  24262. /**
  24263. * Renders all the objects from the render list into the texture.
  24264. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24265. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24266. */
  24267. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24268. private _bestReflectionRenderTargetDimension;
  24269. private _prepareRenderingManager;
  24270. /**
  24271. * @hidden
  24272. * @param faceIndex face index to bind to if this is a cubetexture
  24273. * @param layer defines the index of the texture to bind in the array
  24274. */
  24275. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24276. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24277. private renderToTarget;
  24278. /**
  24279. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24280. * This allowed control for front to back rendering or reversly depending of the special needs.
  24281. *
  24282. * @param renderingGroupId The rendering group id corresponding to its index
  24283. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24284. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24285. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24286. */
  24287. 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;
  24288. /**
  24289. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24290. *
  24291. * @param renderingGroupId The rendering group id corresponding to its index
  24292. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24293. */
  24294. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24295. /**
  24296. * Clones the texture.
  24297. * @returns the cloned texture
  24298. */
  24299. clone(): RenderTargetTexture;
  24300. /**
  24301. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24302. * @returns The JSON representation of the texture
  24303. */
  24304. serialize(): any;
  24305. /**
  24306. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24307. */
  24308. disposeFramebufferObjects(): void;
  24309. /**
  24310. * Dispose the texture and release its associated resources.
  24311. */
  24312. dispose(): void;
  24313. /** @hidden */
  24314. _rebuild(): void;
  24315. /**
  24316. * Clear the info related to rendering groups preventing retention point in material dispose.
  24317. */
  24318. freeRenderingGroups(): void;
  24319. /**
  24320. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24321. * @returns the view count
  24322. */
  24323. getViewCount(): number;
  24324. }
  24325. }
  24326. declare module "babylonjs/Misc/guid" {
  24327. /**
  24328. * Class used to manipulate GUIDs
  24329. */
  24330. export class GUID {
  24331. /**
  24332. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24333. * Be aware Math.random() could cause collisions, but:
  24334. * "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"
  24335. * @returns a pseudo random id
  24336. */
  24337. static RandomId(): string;
  24338. }
  24339. }
  24340. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24341. import { Nullable } from "babylonjs/types";
  24342. import { Scene } from "babylonjs/scene";
  24343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24344. import { Material } from "babylonjs/Materials/material";
  24345. import { Effect } from "babylonjs/Materials/effect";
  24346. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24347. /**
  24348. * Options to be used when creating a shadow depth material
  24349. */
  24350. export interface IIOptionShadowDepthMaterial {
  24351. /** Variables in the vertex shader code that need to have their names remapped.
  24352. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24353. * "var_name" should be either: worldPos or vNormalW
  24354. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24355. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24356. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24357. */
  24358. remappedVariables?: string[];
  24359. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24360. standalone?: boolean;
  24361. }
  24362. /**
  24363. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24364. */
  24365. export class ShadowDepthWrapper {
  24366. private _scene;
  24367. private _options?;
  24368. private _baseMaterial;
  24369. private _onEffectCreatedObserver;
  24370. private _subMeshToEffect;
  24371. private _subMeshToDepthEffect;
  24372. private _meshes;
  24373. /** @hidden */
  24374. _matriceNames: any;
  24375. /** Gets the standalone status of the wrapper */
  24376. get standalone(): boolean;
  24377. /** Gets the base material the wrapper is built upon */
  24378. get baseMaterial(): Material;
  24379. /**
  24380. * Instantiate a new shadow depth wrapper.
  24381. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24382. * generate the shadow depth map. For more information, please refer to the documentation:
  24383. * https://doc.babylonjs.com/babylon101/shadows
  24384. * @param baseMaterial Material to wrap
  24385. * @param scene Define the scene the material belongs to
  24386. * @param options Options used to create the wrapper
  24387. */
  24388. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24389. /**
  24390. * Gets the effect to use to generate the depth map
  24391. * @param subMesh subMesh to get the effect for
  24392. * @param shadowGenerator shadow generator to get the effect for
  24393. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24394. */
  24395. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24396. /**
  24397. * Specifies that the submesh is ready to be used for depth rendering
  24398. * @param subMesh submesh to check
  24399. * @param defines the list of defines to take into account when checking the effect
  24400. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24401. * @param useInstances specifies that instances should be used
  24402. * @returns a boolean indicating that the submesh is ready or not
  24403. */
  24404. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24405. /**
  24406. * Disposes the resources
  24407. */
  24408. dispose(): void;
  24409. private _makeEffect;
  24410. }
  24411. }
  24412. declare module "babylonjs/Materials/material" {
  24413. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24414. import { SmartArray } from "babylonjs/Misc/smartArray";
  24415. import { Observable } from "babylonjs/Misc/observable";
  24416. import { Nullable } from "babylonjs/types";
  24417. import { Scene } from "babylonjs/scene";
  24418. import { Matrix } from "babylonjs/Maths/math.vector";
  24419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24421. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24422. import { Effect } from "babylonjs/Materials/effect";
  24423. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24424. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24425. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24426. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24427. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24428. import { Mesh } from "babylonjs/Meshes/mesh";
  24429. import { Animation } from "babylonjs/Animations/animation";
  24430. /**
  24431. * Options for compiling materials.
  24432. */
  24433. export interface IMaterialCompilationOptions {
  24434. /**
  24435. * Defines whether clip planes are enabled.
  24436. */
  24437. clipPlane: boolean;
  24438. /**
  24439. * Defines whether instances are enabled.
  24440. */
  24441. useInstances: boolean;
  24442. }
  24443. /**
  24444. * Options passed when calling customShaderNameResolve
  24445. */
  24446. export interface ICustomShaderNameResolveOptions {
  24447. /**
  24448. * 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
  24449. */
  24450. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24451. }
  24452. /**
  24453. * Base class for the main features of a material in Babylon.js
  24454. */
  24455. export class Material implements IAnimatable {
  24456. /**
  24457. * Returns the triangle fill mode
  24458. */
  24459. static readonly TriangleFillMode: number;
  24460. /**
  24461. * Returns the wireframe mode
  24462. */
  24463. static readonly WireFrameFillMode: number;
  24464. /**
  24465. * Returns the point fill mode
  24466. */
  24467. static readonly PointFillMode: number;
  24468. /**
  24469. * Returns the point list draw mode
  24470. */
  24471. static readonly PointListDrawMode: number;
  24472. /**
  24473. * Returns the line list draw mode
  24474. */
  24475. static readonly LineListDrawMode: number;
  24476. /**
  24477. * Returns the line loop draw mode
  24478. */
  24479. static readonly LineLoopDrawMode: number;
  24480. /**
  24481. * Returns the line strip draw mode
  24482. */
  24483. static readonly LineStripDrawMode: number;
  24484. /**
  24485. * Returns the triangle strip draw mode
  24486. */
  24487. static readonly TriangleStripDrawMode: number;
  24488. /**
  24489. * Returns the triangle fan draw mode
  24490. */
  24491. static readonly TriangleFanDrawMode: number;
  24492. /**
  24493. * Stores the clock-wise side orientation
  24494. */
  24495. static readonly ClockWiseSideOrientation: number;
  24496. /**
  24497. * Stores the counter clock-wise side orientation
  24498. */
  24499. static readonly CounterClockWiseSideOrientation: number;
  24500. /**
  24501. * The dirty texture flag value
  24502. */
  24503. static readonly TextureDirtyFlag: number;
  24504. /**
  24505. * The dirty light flag value
  24506. */
  24507. static readonly LightDirtyFlag: number;
  24508. /**
  24509. * The dirty fresnel flag value
  24510. */
  24511. static readonly FresnelDirtyFlag: number;
  24512. /**
  24513. * The dirty attribute flag value
  24514. */
  24515. static readonly AttributesDirtyFlag: number;
  24516. /**
  24517. * The dirty misc flag value
  24518. */
  24519. static readonly MiscDirtyFlag: number;
  24520. /**
  24521. * The all dirty flag value
  24522. */
  24523. static readonly AllDirtyFlag: number;
  24524. /**
  24525. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24526. */
  24527. static readonly MATERIAL_OPAQUE: number;
  24528. /**
  24529. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24530. */
  24531. static readonly MATERIAL_ALPHATEST: number;
  24532. /**
  24533. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24534. */
  24535. static readonly MATERIAL_ALPHABLEND: number;
  24536. /**
  24537. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24538. * They are also discarded below the alpha cutoff threshold to improve performances.
  24539. */
  24540. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24541. /**
  24542. * The Whiteout method is used to blend normals.
  24543. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24544. */
  24545. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24546. /**
  24547. * The Reoriented Normal Mapping method is used to blend normals.
  24548. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24549. */
  24550. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24551. /**
  24552. * Custom callback helping to override the default shader used in the material.
  24553. */
  24554. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24555. /**
  24556. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24557. */
  24558. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24559. /**
  24560. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24561. * This means that the material can keep using a previous shader while a new one is being compiled.
  24562. * This is mostly used when shader parallel compilation is supported (true by default)
  24563. */
  24564. allowShaderHotSwapping: boolean;
  24565. /**
  24566. * The ID of the material
  24567. */
  24568. id: string;
  24569. /**
  24570. * Gets or sets the unique id of the material
  24571. */
  24572. uniqueId: number;
  24573. /**
  24574. * The name of the material
  24575. */
  24576. name: string;
  24577. /**
  24578. * Gets or sets user defined metadata
  24579. */
  24580. metadata: any;
  24581. /**
  24582. * For internal use only. Please do not use.
  24583. */
  24584. reservedDataStore: any;
  24585. /**
  24586. * Specifies if the ready state should be checked on each call
  24587. */
  24588. checkReadyOnEveryCall: boolean;
  24589. /**
  24590. * Specifies if the ready state should be checked once
  24591. */
  24592. checkReadyOnlyOnce: boolean;
  24593. /**
  24594. * The state of the material
  24595. */
  24596. state: string;
  24597. /**
  24598. * If the material should be rendered to several textures with MRT extension
  24599. */
  24600. get shouldRenderToMRT(): boolean;
  24601. /**
  24602. * The alpha value of the material
  24603. */
  24604. protected _alpha: number;
  24605. /**
  24606. * List of inspectable custom properties (used by the Inspector)
  24607. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24608. */
  24609. inspectableCustomProperties: IInspectable[];
  24610. /**
  24611. * Sets the alpha value of the material
  24612. */
  24613. set alpha(value: number);
  24614. /**
  24615. * Gets the alpha value of the material
  24616. */
  24617. get alpha(): number;
  24618. /**
  24619. * Specifies if back face culling is enabled
  24620. */
  24621. protected _backFaceCulling: boolean;
  24622. /**
  24623. * Sets the back-face culling state
  24624. */
  24625. set backFaceCulling(value: boolean);
  24626. /**
  24627. * Gets the back-face culling state
  24628. */
  24629. get backFaceCulling(): boolean;
  24630. /**
  24631. * Stores the value for side orientation
  24632. */
  24633. sideOrientation: number;
  24634. /**
  24635. * Callback triggered when the material is compiled
  24636. */
  24637. onCompiled: Nullable<(effect: Effect) => void>;
  24638. /**
  24639. * Callback triggered when an error occurs
  24640. */
  24641. onError: Nullable<(effect: Effect, errors: string) => void>;
  24642. /**
  24643. * Callback triggered to get the render target textures
  24644. */
  24645. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24646. /**
  24647. * Gets a boolean indicating that current material needs to register RTT
  24648. */
  24649. get hasRenderTargetTextures(): boolean;
  24650. /**
  24651. * Specifies if the material should be serialized
  24652. */
  24653. doNotSerialize: boolean;
  24654. /**
  24655. * @hidden
  24656. */
  24657. _storeEffectOnSubMeshes: boolean;
  24658. /**
  24659. * Stores the animations for the material
  24660. */
  24661. animations: Nullable<Array<Animation>>;
  24662. /**
  24663. * An event triggered when the material is disposed
  24664. */
  24665. onDisposeObservable: Observable<Material>;
  24666. /**
  24667. * An observer which watches for dispose events
  24668. */
  24669. private _onDisposeObserver;
  24670. private _onUnBindObservable;
  24671. /**
  24672. * Called during a dispose event
  24673. */
  24674. set onDispose(callback: () => void);
  24675. private _onBindObservable;
  24676. /**
  24677. * An event triggered when the material is bound
  24678. */
  24679. get onBindObservable(): Observable<AbstractMesh>;
  24680. /**
  24681. * An observer which watches for bind events
  24682. */
  24683. private _onBindObserver;
  24684. /**
  24685. * Called during a bind event
  24686. */
  24687. set onBind(callback: (Mesh: AbstractMesh) => void);
  24688. /**
  24689. * An event triggered when the material is unbound
  24690. */
  24691. get onUnBindObservable(): Observable<Material>;
  24692. protected _onEffectCreatedObservable: Nullable<Observable<{
  24693. effect: Effect;
  24694. subMesh: Nullable<SubMesh>;
  24695. }>>;
  24696. /**
  24697. * An event triggered when the effect is (re)created
  24698. */
  24699. get onEffectCreatedObservable(): Observable<{
  24700. effect: Effect;
  24701. subMesh: Nullable<SubMesh>;
  24702. }>;
  24703. /**
  24704. * Stores the value of the alpha mode
  24705. */
  24706. private _alphaMode;
  24707. /**
  24708. * Sets the value of the alpha mode.
  24709. *
  24710. * | Value | Type | Description |
  24711. * | --- | --- | --- |
  24712. * | 0 | ALPHA_DISABLE | |
  24713. * | 1 | ALPHA_ADD | |
  24714. * | 2 | ALPHA_COMBINE | |
  24715. * | 3 | ALPHA_SUBTRACT | |
  24716. * | 4 | ALPHA_MULTIPLY | |
  24717. * | 5 | ALPHA_MAXIMIZED | |
  24718. * | 6 | ALPHA_ONEONE | |
  24719. * | 7 | ALPHA_PREMULTIPLIED | |
  24720. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24721. * | 9 | ALPHA_INTERPOLATE | |
  24722. * | 10 | ALPHA_SCREENMODE | |
  24723. *
  24724. */
  24725. set alphaMode(value: number);
  24726. /**
  24727. * Gets the value of the alpha mode
  24728. */
  24729. get alphaMode(): number;
  24730. /**
  24731. * Stores the state of the need depth pre-pass value
  24732. */
  24733. private _needDepthPrePass;
  24734. /**
  24735. * Sets the need depth pre-pass value
  24736. */
  24737. set needDepthPrePass(value: boolean);
  24738. /**
  24739. * Gets the depth pre-pass value
  24740. */
  24741. get needDepthPrePass(): boolean;
  24742. /**
  24743. * Specifies if depth writing should be disabled
  24744. */
  24745. disableDepthWrite: boolean;
  24746. /**
  24747. * Specifies if color writing should be disabled
  24748. */
  24749. disableColorWrite: boolean;
  24750. /**
  24751. * Specifies if depth writing should be forced
  24752. */
  24753. forceDepthWrite: boolean;
  24754. /**
  24755. * Specifies the depth function that should be used. 0 means the default engine function
  24756. */
  24757. depthFunction: number;
  24758. /**
  24759. * Specifies if there should be a separate pass for culling
  24760. */
  24761. separateCullingPass: boolean;
  24762. /**
  24763. * Stores the state specifing if fog should be enabled
  24764. */
  24765. private _fogEnabled;
  24766. /**
  24767. * Sets the state for enabling fog
  24768. */
  24769. set fogEnabled(value: boolean);
  24770. /**
  24771. * Gets the value of the fog enabled state
  24772. */
  24773. get fogEnabled(): boolean;
  24774. /**
  24775. * Stores the size of points
  24776. */
  24777. pointSize: number;
  24778. /**
  24779. * Stores the z offset value
  24780. */
  24781. zOffset: number;
  24782. get wireframe(): boolean;
  24783. /**
  24784. * Sets the state of wireframe mode
  24785. */
  24786. set wireframe(value: boolean);
  24787. /**
  24788. * Gets the value specifying if point clouds are enabled
  24789. */
  24790. get pointsCloud(): boolean;
  24791. /**
  24792. * Sets the state of point cloud mode
  24793. */
  24794. set pointsCloud(value: boolean);
  24795. /**
  24796. * Gets the material fill mode
  24797. */
  24798. get fillMode(): number;
  24799. /**
  24800. * Sets the material fill mode
  24801. */
  24802. set fillMode(value: number);
  24803. /**
  24804. * @hidden
  24805. * Stores the effects for the material
  24806. */
  24807. _effect: Nullable<Effect>;
  24808. /**
  24809. * Specifies if uniform buffers should be used
  24810. */
  24811. private _useUBO;
  24812. /**
  24813. * Stores a reference to the scene
  24814. */
  24815. private _scene;
  24816. /**
  24817. * Stores the fill mode state
  24818. */
  24819. private _fillMode;
  24820. /**
  24821. * Specifies if the depth write state should be cached
  24822. */
  24823. private _cachedDepthWriteState;
  24824. /**
  24825. * Specifies if the color write state should be cached
  24826. */
  24827. private _cachedColorWriteState;
  24828. /**
  24829. * Specifies if the depth function state should be cached
  24830. */
  24831. private _cachedDepthFunctionState;
  24832. /**
  24833. * Stores the uniform buffer
  24834. */
  24835. protected _uniformBuffer: UniformBuffer;
  24836. /** @hidden */
  24837. _indexInSceneMaterialArray: number;
  24838. /** @hidden */
  24839. meshMap: Nullable<{
  24840. [id: string]: AbstractMesh | undefined;
  24841. }>;
  24842. /**
  24843. * Creates a material instance
  24844. * @param name defines the name of the material
  24845. * @param scene defines the scene to reference
  24846. * @param doNotAdd specifies if the material should be added to the scene
  24847. */
  24848. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24849. /**
  24850. * Returns a string representation of the current material
  24851. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24852. * @returns a string with material information
  24853. */
  24854. toString(fullDetails?: boolean): string;
  24855. /**
  24856. * Gets the class name of the material
  24857. * @returns a string with the class name of the material
  24858. */
  24859. getClassName(): string;
  24860. /**
  24861. * Specifies if updates for the material been locked
  24862. */
  24863. get isFrozen(): boolean;
  24864. /**
  24865. * Locks updates for the material
  24866. */
  24867. freeze(): void;
  24868. /**
  24869. * Unlocks updates for the material
  24870. */
  24871. unfreeze(): void;
  24872. /**
  24873. * Specifies if the material is ready to be used
  24874. * @param mesh defines the mesh to check
  24875. * @param useInstances specifies if instances should be used
  24876. * @returns a boolean indicating if the material is ready to be used
  24877. */
  24878. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24879. /**
  24880. * Specifies that the submesh is ready to be used
  24881. * @param mesh defines the mesh to check
  24882. * @param subMesh defines which submesh to check
  24883. * @param useInstances specifies that instances should be used
  24884. * @returns a boolean indicating that the submesh is ready or not
  24885. */
  24886. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24887. /**
  24888. * Returns the material effect
  24889. * @returns the effect associated with the material
  24890. */
  24891. getEffect(): Nullable<Effect>;
  24892. /**
  24893. * Returns the current scene
  24894. * @returns a Scene
  24895. */
  24896. getScene(): Scene;
  24897. /**
  24898. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24899. */
  24900. protected _forceAlphaTest: boolean;
  24901. /**
  24902. * The transparency mode of the material.
  24903. */
  24904. protected _transparencyMode: Nullable<number>;
  24905. /**
  24906. * Gets the current transparency mode.
  24907. */
  24908. get transparencyMode(): Nullable<number>;
  24909. /**
  24910. * Sets the transparency mode of the material.
  24911. *
  24912. * | Value | Type | Description |
  24913. * | ----- | ----------------------------------- | ----------- |
  24914. * | 0 | OPAQUE | |
  24915. * | 1 | ALPHATEST | |
  24916. * | 2 | ALPHABLEND | |
  24917. * | 3 | ALPHATESTANDBLEND | |
  24918. *
  24919. */
  24920. set transparencyMode(value: Nullable<number>);
  24921. /**
  24922. * Returns true if alpha blending should be disabled.
  24923. */
  24924. protected get _disableAlphaBlending(): boolean;
  24925. /**
  24926. * Specifies whether or not this material should be rendered in alpha blend mode.
  24927. * @returns a boolean specifying if alpha blending is needed
  24928. */
  24929. needAlphaBlending(): boolean;
  24930. /**
  24931. * Specifies if the mesh will require alpha blending
  24932. * @param mesh defines the mesh to check
  24933. * @returns a boolean specifying if alpha blending is needed for the mesh
  24934. */
  24935. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24936. /**
  24937. * Specifies whether or not this material should be rendered in alpha test mode.
  24938. * @returns a boolean specifying if an alpha test is needed.
  24939. */
  24940. needAlphaTesting(): boolean;
  24941. /**
  24942. * Specifies if material alpha testing should be turned on for the mesh
  24943. * @param mesh defines the mesh to check
  24944. */
  24945. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24946. /**
  24947. * Gets the texture used for the alpha test
  24948. * @returns the texture to use for alpha testing
  24949. */
  24950. getAlphaTestTexture(): Nullable<BaseTexture>;
  24951. /**
  24952. * Marks the material to indicate that it needs to be re-calculated
  24953. */
  24954. markDirty(): void;
  24955. /** @hidden */
  24956. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24957. /**
  24958. * Binds the material to the mesh
  24959. * @param world defines the world transformation matrix
  24960. * @param mesh defines the mesh to bind the material to
  24961. */
  24962. bind(world: Matrix, mesh?: Mesh): void;
  24963. /**
  24964. * Binds the submesh to the material
  24965. * @param world defines the world transformation matrix
  24966. * @param mesh defines the mesh containing the submesh
  24967. * @param subMesh defines the submesh to bind the material to
  24968. */
  24969. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24970. /**
  24971. * Binds the world matrix to the material
  24972. * @param world defines the world transformation matrix
  24973. */
  24974. bindOnlyWorldMatrix(world: Matrix): void;
  24975. /**
  24976. * Binds the scene's uniform buffer to the effect.
  24977. * @param effect defines the effect to bind to the scene uniform buffer
  24978. * @param sceneUbo defines the uniform buffer storing scene data
  24979. */
  24980. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24981. /**
  24982. * Binds the view matrix to the effect
  24983. * @param effect defines the effect to bind the view matrix to
  24984. */
  24985. bindView(effect: Effect): void;
  24986. /**
  24987. * Binds the view projection matrix to the effect
  24988. * @param effect defines the effect to bind the view projection matrix to
  24989. */
  24990. bindViewProjection(effect: Effect): void;
  24991. /**
  24992. * Processes to execute after binding the material to a mesh
  24993. * @param mesh defines the rendered mesh
  24994. */
  24995. protected _afterBind(mesh?: Mesh): void;
  24996. /**
  24997. * Unbinds the material from the mesh
  24998. */
  24999. unbind(): void;
  25000. /**
  25001. * Gets the active textures from the material
  25002. * @returns an array of textures
  25003. */
  25004. getActiveTextures(): BaseTexture[];
  25005. /**
  25006. * Specifies if the material uses a texture
  25007. * @param texture defines the texture to check against the material
  25008. * @returns a boolean specifying if the material uses the texture
  25009. */
  25010. hasTexture(texture: BaseTexture): boolean;
  25011. /**
  25012. * Makes a duplicate of the material, and gives it a new name
  25013. * @param name defines the new name for the duplicated material
  25014. * @returns the cloned material
  25015. */
  25016. clone(name: string): Nullable<Material>;
  25017. /**
  25018. * Gets the meshes bound to the material
  25019. * @returns an array of meshes bound to the material
  25020. */
  25021. getBindedMeshes(): AbstractMesh[];
  25022. /**
  25023. * Force shader compilation
  25024. * @param mesh defines the mesh associated with this material
  25025. * @param onCompiled defines a function to execute once the material is compiled
  25026. * @param options defines the options to configure the compilation
  25027. * @param onError defines a function to execute if the material fails compiling
  25028. */
  25029. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25030. /**
  25031. * Force shader compilation
  25032. * @param mesh defines the mesh that will use this material
  25033. * @param options defines additional options for compiling the shaders
  25034. * @returns a promise that resolves when the compilation completes
  25035. */
  25036. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25037. private static readonly _AllDirtyCallBack;
  25038. private static readonly _ImageProcessingDirtyCallBack;
  25039. private static readonly _TextureDirtyCallBack;
  25040. private static readonly _FresnelDirtyCallBack;
  25041. private static readonly _MiscDirtyCallBack;
  25042. private static readonly _LightsDirtyCallBack;
  25043. private static readonly _AttributeDirtyCallBack;
  25044. private static _FresnelAndMiscDirtyCallBack;
  25045. private static _TextureAndMiscDirtyCallBack;
  25046. private static readonly _DirtyCallbackArray;
  25047. private static readonly _RunDirtyCallBacks;
  25048. /**
  25049. * Marks a define in the material to indicate that it needs to be re-computed
  25050. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25051. */
  25052. markAsDirty(flag: number): void;
  25053. /**
  25054. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25055. * @param func defines a function which checks material defines against the submeshes
  25056. */
  25057. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25058. /**
  25059. * Indicates that the scene should check if the rendering now needs a prepass
  25060. */
  25061. protected _markScenePrePassDirty(): void;
  25062. /**
  25063. * Indicates that we need to re-calculated for all submeshes
  25064. */
  25065. protected _markAllSubMeshesAsAllDirty(): void;
  25066. /**
  25067. * Indicates that image processing needs to be re-calculated for all submeshes
  25068. */
  25069. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25070. /**
  25071. * Indicates that textures need to be re-calculated for all submeshes
  25072. */
  25073. protected _markAllSubMeshesAsTexturesDirty(): void;
  25074. /**
  25075. * Indicates that fresnel needs to be re-calculated for all submeshes
  25076. */
  25077. protected _markAllSubMeshesAsFresnelDirty(): void;
  25078. /**
  25079. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25080. */
  25081. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25082. /**
  25083. * Indicates that lights need to be re-calculated for all submeshes
  25084. */
  25085. protected _markAllSubMeshesAsLightsDirty(): void;
  25086. /**
  25087. * Indicates that attributes need to be re-calculated for all submeshes
  25088. */
  25089. protected _markAllSubMeshesAsAttributesDirty(): void;
  25090. /**
  25091. * Indicates that misc needs to be re-calculated for all submeshes
  25092. */
  25093. protected _markAllSubMeshesAsMiscDirty(): void;
  25094. /**
  25095. * Indicates that textures and misc need to be re-calculated for all submeshes
  25096. */
  25097. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25098. /**
  25099. * Disposes the material
  25100. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25101. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25102. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25103. */
  25104. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25105. /** @hidden */
  25106. private releaseVertexArrayObject;
  25107. /**
  25108. * Serializes this material
  25109. * @returns the serialized material object
  25110. */
  25111. serialize(): any;
  25112. /**
  25113. * Creates a material from parsed material data
  25114. * @param parsedMaterial defines parsed material data
  25115. * @param scene defines the hosting scene
  25116. * @param rootUrl defines the root URL to use to load textures
  25117. * @returns a new material
  25118. */
  25119. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25120. }
  25121. }
  25122. declare module "babylonjs/Materials/multiMaterial" {
  25123. import { Nullable } from "babylonjs/types";
  25124. import { Scene } from "babylonjs/scene";
  25125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25126. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25128. import { Material } from "babylonjs/Materials/material";
  25129. /**
  25130. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25131. * separate meshes. This can be use to improve performances.
  25132. * @see https://doc.babylonjs.com/how_to/multi_materials
  25133. */
  25134. export class MultiMaterial extends Material {
  25135. private _subMaterials;
  25136. /**
  25137. * Gets or Sets the list of Materials used within the multi material.
  25138. * They need to be ordered according to the submeshes order in the associated mesh
  25139. */
  25140. get subMaterials(): Nullable<Material>[];
  25141. set subMaterials(value: Nullable<Material>[]);
  25142. /**
  25143. * Function used to align with Node.getChildren()
  25144. * @returns the list of Materials used within the multi material
  25145. */
  25146. getChildren(): Nullable<Material>[];
  25147. /**
  25148. * Instantiates a new Multi Material
  25149. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25150. * separate meshes. This can be use to improve performances.
  25151. * @see https://doc.babylonjs.com/how_to/multi_materials
  25152. * @param name Define the name in the scene
  25153. * @param scene Define the scene the material belongs to
  25154. */
  25155. constructor(name: string, scene: Scene);
  25156. private _hookArray;
  25157. /**
  25158. * Get one of the submaterial by its index in the submaterials array
  25159. * @param index The index to look the sub material at
  25160. * @returns The Material if the index has been defined
  25161. */
  25162. getSubMaterial(index: number): Nullable<Material>;
  25163. /**
  25164. * Get the list of active textures for the whole sub materials list.
  25165. * @returns All the textures that will be used during the rendering
  25166. */
  25167. getActiveTextures(): BaseTexture[];
  25168. /**
  25169. * Gets the current class name of the material e.g. "MultiMaterial"
  25170. * Mainly use in serialization.
  25171. * @returns the class name
  25172. */
  25173. getClassName(): string;
  25174. /**
  25175. * Checks if the material is ready to render the requested sub mesh
  25176. * @param mesh Define the mesh the submesh belongs to
  25177. * @param subMesh Define the sub mesh to look readyness for
  25178. * @param useInstances Define whether or not the material is used with instances
  25179. * @returns true if ready, otherwise false
  25180. */
  25181. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25182. /**
  25183. * Clones the current material and its related sub materials
  25184. * @param name Define the name of the newly cloned material
  25185. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25186. * @returns the cloned material
  25187. */
  25188. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25189. /**
  25190. * Serializes the materials into a JSON representation.
  25191. * @returns the JSON representation
  25192. */
  25193. serialize(): any;
  25194. /**
  25195. * Dispose the material and release its associated resources
  25196. * @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)
  25197. * @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)
  25198. * @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)
  25199. */
  25200. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25201. /**
  25202. * Creates a MultiMaterial from parsed MultiMaterial data.
  25203. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25204. * @param scene defines the hosting scene
  25205. * @returns a new MultiMaterial
  25206. */
  25207. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25208. }
  25209. }
  25210. declare module "babylonjs/Meshes/subMesh" {
  25211. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25212. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25213. import { Engine } from "babylonjs/Engines/engine";
  25214. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25215. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25216. import { Effect } from "babylonjs/Materials/effect";
  25217. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25218. import { Plane } from "babylonjs/Maths/math.plane";
  25219. import { Collider } from "babylonjs/Collisions/collider";
  25220. import { Material } from "babylonjs/Materials/material";
  25221. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25223. import { Mesh } from "babylonjs/Meshes/mesh";
  25224. import { Ray } from "babylonjs/Culling/ray";
  25225. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25226. /**
  25227. * Defines a subdivision inside a mesh
  25228. */
  25229. export class SubMesh implements ICullable {
  25230. /** the material index to use */
  25231. materialIndex: number;
  25232. /** vertex index start */
  25233. verticesStart: number;
  25234. /** vertices count */
  25235. verticesCount: number;
  25236. /** index start */
  25237. indexStart: number;
  25238. /** indices count */
  25239. indexCount: number;
  25240. /** @hidden */
  25241. _materialDefines: Nullable<MaterialDefines>;
  25242. /** @hidden */
  25243. _materialEffect: Nullable<Effect>;
  25244. /** @hidden */
  25245. _effectOverride: Nullable<Effect>;
  25246. /**
  25247. * Gets material defines used by the effect associated to the sub mesh
  25248. */
  25249. get materialDefines(): Nullable<MaterialDefines>;
  25250. /**
  25251. * Sets material defines used by the effect associated to the sub mesh
  25252. */
  25253. set materialDefines(defines: Nullable<MaterialDefines>);
  25254. /**
  25255. * Gets associated effect
  25256. */
  25257. get effect(): Nullable<Effect>;
  25258. /**
  25259. * Sets associated effect (effect used to render this submesh)
  25260. * @param effect defines the effect to associate with
  25261. * @param defines defines the set of defines used to compile this effect
  25262. */
  25263. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25264. /** @hidden */
  25265. _linesIndexCount: number;
  25266. private _mesh;
  25267. private _renderingMesh;
  25268. private _boundingInfo;
  25269. private _linesIndexBuffer;
  25270. /** @hidden */
  25271. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25272. /** @hidden */
  25273. _trianglePlanes: Plane[];
  25274. /** @hidden */
  25275. _lastColliderTransformMatrix: Nullable<Matrix>;
  25276. /** @hidden */
  25277. _renderId: number;
  25278. /** @hidden */
  25279. _alphaIndex: number;
  25280. /** @hidden */
  25281. _distanceToCamera: number;
  25282. /** @hidden */
  25283. _id: number;
  25284. private _currentMaterial;
  25285. /**
  25286. * Add a new submesh to a mesh
  25287. * @param materialIndex defines the material index to use
  25288. * @param verticesStart defines vertex index start
  25289. * @param verticesCount defines vertices count
  25290. * @param indexStart defines index start
  25291. * @param indexCount defines indices count
  25292. * @param mesh defines the parent mesh
  25293. * @param renderingMesh defines an optional rendering mesh
  25294. * @param createBoundingBox defines if bounding box should be created for this submesh
  25295. * @returns the new submesh
  25296. */
  25297. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25298. /**
  25299. * Creates a new submesh
  25300. * @param materialIndex defines the material index to use
  25301. * @param verticesStart defines vertex index start
  25302. * @param verticesCount defines vertices count
  25303. * @param indexStart defines index start
  25304. * @param indexCount defines indices count
  25305. * @param mesh defines the parent mesh
  25306. * @param renderingMesh defines an optional rendering mesh
  25307. * @param createBoundingBox defines if bounding box should be created for this submesh
  25308. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25309. */
  25310. constructor(
  25311. /** the material index to use */
  25312. materialIndex: number,
  25313. /** vertex index start */
  25314. verticesStart: number,
  25315. /** vertices count */
  25316. verticesCount: number,
  25317. /** index start */
  25318. indexStart: number,
  25319. /** indices count */
  25320. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25321. /**
  25322. * Returns true if this submesh covers the entire parent mesh
  25323. * @ignorenaming
  25324. */
  25325. get IsGlobal(): boolean;
  25326. /**
  25327. * Returns the submesh BoudingInfo object
  25328. * @returns current bounding info (or mesh's one if the submesh is global)
  25329. */
  25330. getBoundingInfo(): BoundingInfo;
  25331. /**
  25332. * Sets the submesh BoundingInfo
  25333. * @param boundingInfo defines the new bounding info to use
  25334. * @returns the SubMesh
  25335. */
  25336. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25337. /**
  25338. * Returns the mesh of the current submesh
  25339. * @return the parent mesh
  25340. */
  25341. getMesh(): AbstractMesh;
  25342. /**
  25343. * Returns the rendering mesh of the submesh
  25344. * @returns the rendering mesh (could be different from parent mesh)
  25345. */
  25346. getRenderingMesh(): Mesh;
  25347. /**
  25348. * Returns the replacement mesh of the submesh
  25349. * @returns the replacement mesh (could be different from parent mesh)
  25350. */
  25351. getReplacementMesh(): Nullable<AbstractMesh>;
  25352. /**
  25353. * Returns the effective mesh of the submesh
  25354. * @returns the effective mesh (could be different from parent mesh)
  25355. */
  25356. getEffectiveMesh(): AbstractMesh;
  25357. /**
  25358. * Returns the submesh material
  25359. * @returns null or the current material
  25360. */
  25361. getMaterial(): Nullable<Material>;
  25362. private _IsMultiMaterial;
  25363. /**
  25364. * Sets a new updated BoundingInfo object to the submesh
  25365. * @param data defines an optional position array to use to determine the bounding info
  25366. * @returns the SubMesh
  25367. */
  25368. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25369. /** @hidden */
  25370. _checkCollision(collider: Collider): boolean;
  25371. /**
  25372. * Updates the submesh BoundingInfo
  25373. * @param world defines the world matrix to use to update the bounding info
  25374. * @returns the submesh
  25375. */
  25376. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25377. /**
  25378. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25379. * @param frustumPlanes defines the frustum planes
  25380. * @returns true if the submesh is intersecting with the frustum
  25381. */
  25382. isInFrustum(frustumPlanes: Plane[]): boolean;
  25383. /**
  25384. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25385. * @param frustumPlanes defines the frustum planes
  25386. * @returns true if the submesh is inside the frustum
  25387. */
  25388. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25389. /**
  25390. * Renders the submesh
  25391. * @param enableAlphaMode defines if alpha needs to be used
  25392. * @returns the submesh
  25393. */
  25394. render(enableAlphaMode: boolean): SubMesh;
  25395. /**
  25396. * @hidden
  25397. */
  25398. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25399. /**
  25400. * Checks if the submesh intersects with a ray
  25401. * @param ray defines the ray to test
  25402. * @returns true is the passed ray intersects the submesh bounding box
  25403. */
  25404. canIntersects(ray: Ray): boolean;
  25405. /**
  25406. * Intersects current submesh with a ray
  25407. * @param ray defines the ray to test
  25408. * @param positions defines mesh's positions array
  25409. * @param indices defines mesh's indices array
  25410. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25411. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25412. * @returns intersection info or null if no intersection
  25413. */
  25414. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25415. /** @hidden */
  25416. private _intersectLines;
  25417. /** @hidden */
  25418. private _intersectUnIndexedLines;
  25419. /** @hidden */
  25420. private _intersectTriangles;
  25421. /** @hidden */
  25422. private _intersectUnIndexedTriangles;
  25423. /** @hidden */
  25424. _rebuild(): void;
  25425. /**
  25426. * Creates a new submesh from the passed mesh
  25427. * @param newMesh defines the new hosting mesh
  25428. * @param newRenderingMesh defines an optional rendering mesh
  25429. * @returns the new submesh
  25430. */
  25431. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25432. /**
  25433. * Release associated resources
  25434. */
  25435. dispose(): void;
  25436. /**
  25437. * Gets the class name
  25438. * @returns the string "SubMesh".
  25439. */
  25440. getClassName(): string;
  25441. /**
  25442. * Creates a new submesh from indices data
  25443. * @param materialIndex the index of the main mesh material
  25444. * @param startIndex the index where to start the copy in the mesh indices array
  25445. * @param indexCount the number of indices to copy then from the startIndex
  25446. * @param mesh the main mesh to create the submesh from
  25447. * @param renderingMesh the optional rendering mesh
  25448. * @returns a new submesh
  25449. */
  25450. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25451. }
  25452. }
  25453. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25454. /**
  25455. * Class used to represent data loading progression
  25456. */
  25457. export class SceneLoaderFlags {
  25458. private static _ForceFullSceneLoadingForIncremental;
  25459. private static _ShowLoadingScreen;
  25460. private static _CleanBoneMatrixWeights;
  25461. private static _loggingLevel;
  25462. /**
  25463. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25464. */
  25465. static get ForceFullSceneLoadingForIncremental(): boolean;
  25466. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25467. /**
  25468. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25469. */
  25470. static get ShowLoadingScreen(): boolean;
  25471. static set ShowLoadingScreen(value: boolean);
  25472. /**
  25473. * Defines the current logging level (while loading the scene)
  25474. * @ignorenaming
  25475. */
  25476. static get loggingLevel(): number;
  25477. static set loggingLevel(value: number);
  25478. /**
  25479. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25480. */
  25481. static get CleanBoneMatrixWeights(): boolean;
  25482. static set CleanBoneMatrixWeights(value: boolean);
  25483. }
  25484. }
  25485. declare module "babylonjs/Meshes/geometry" {
  25486. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25487. import { Scene } from "babylonjs/scene";
  25488. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25489. import { Engine } from "babylonjs/Engines/engine";
  25490. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25491. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25492. import { Effect } from "babylonjs/Materials/effect";
  25493. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25494. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25495. import { Mesh } from "babylonjs/Meshes/mesh";
  25496. /**
  25497. * Class used to store geometry data (vertex buffers + index buffer)
  25498. */
  25499. export class Geometry implements IGetSetVerticesData {
  25500. /**
  25501. * Gets or sets the ID of the geometry
  25502. */
  25503. id: string;
  25504. /**
  25505. * Gets or sets the unique ID of the geometry
  25506. */
  25507. uniqueId: number;
  25508. /**
  25509. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25510. */
  25511. delayLoadState: number;
  25512. /**
  25513. * Gets the file containing the data to load when running in delay load state
  25514. */
  25515. delayLoadingFile: Nullable<string>;
  25516. /**
  25517. * Callback called when the geometry is updated
  25518. */
  25519. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25520. private _scene;
  25521. private _engine;
  25522. private _meshes;
  25523. private _totalVertices;
  25524. /** @hidden */
  25525. _indices: IndicesArray;
  25526. /** @hidden */
  25527. _vertexBuffers: {
  25528. [key: string]: VertexBuffer;
  25529. };
  25530. private _isDisposed;
  25531. private _extend;
  25532. private _boundingBias;
  25533. /** @hidden */
  25534. _delayInfo: Array<string>;
  25535. private _indexBuffer;
  25536. private _indexBufferIsUpdatable;
  25537. /** @hidden */
  25538. _boundingInfo: Nullable<BoundingInfo>;
  25539. /** @hidden */
  25540. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25541. /** @hidden */
  25542. _softwareSkinningFrameId: number;
  25543. private _vertexArrayObjects;
  25544. private _updatable;
  25545. /** @hidden */
  25546. _positions: Nullable<Vector3[]>;
  25547. /**
  25548. * 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
  25549. */
  25550. get boundingBias(): Vector2;
  25551. /**
  25552. * 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
  25553. */
  25554. set boundingBias(value: Vector2);
  25555. /**
  25556. * Static function used to attach a new empty geometry to a mesh
  25557. * @param mesh defines the mesh to attach the geometry to
  25558. * @returns the new Geometry
  25559. */
  25560. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25561. /** Get the list of meshes using this geometry */
  25562. get meshes(): Mesh[];
  25563. /**
  25564. * 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
  25565. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25566. */
  25567. useBoundingInfoFromGeometry: boolean;
  25568. /**
  25569. * Creates a new geometry
  25570. * @param id defines the unique ID
  25571. * @param scene defines the hosting scene
  25572. * @param vertexData defines the VertexData used to get geometry data
  25573. * @param updatable defines if geometry must be updatable (false by default)
  25574. * @param mesh defines the mesh that will be associated with the geometry
  25575. */
  25576. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25577. /**
  25578. * Gets the current extend of the geometry
  25579. */
  25580. get extend(): {
  25581. minimum: Vector3;
  25582. maximum: Vector3;
  25583. };
  25584. /**
  25585. * Gets the hosting scene
  25586. * @returns the hosting Scene
  25587. */
  25588. getScene(): Scene;
  25589. /**
  25590. * Gets the hosting engine
  25591. * @returns the hosting Engine
  25592. */
  25593. getEngine(): Engine;
  25594. /**
  25595. * Defines if the geometry is ready to use
  25596. * @returns true if the geometry is ready to be used
  25597. */
  25598. isReady(): boolean;
  25599. /**
  25600. * Gets a value indicating that the geometry should not be serialized
  25601. */
  25602. get doNotSerialize(): boolean;
  25603. /** @hidden */
  25604. _rebuild(): void;
  25605. /**
  25606. * Affects all geometry data in one call
  25607. * @param vertexData defines the geometry data
  25608. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25609. */
  25610. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25611. /**
  25612. * Set specific vertex data
  25613. * @param kind defines the data kind (Position, normal, etc...)
  25614. * @param data defines the vertex data to use
  25615. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25616. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25617. */
  25618. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25619. /**
  25620. * Removes a specific vertex data
  25621. * @param kind defines the data kind (Position, normal, etc...)
  25622. */
  25623. removeVerticesData(kind: string): void;
  25624. /**
  25625. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25626. * @param buffer defines the vertex buffer to use
  25627. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25628. */
  25629. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25630. /**
  25631. * Update a specific vertex buffer
  25632. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25633. * It will do nothing if the buffer is not updatable
  25634. * @param kind defines the data kind (Position, normal, etc...)
  25635. * @param data defines the data to use
  25636. * @param offset defines the offset in the target buffer where to store the data
  25637. * @param useBytes set to true if the offset is in bytes
  25638. */
  25639. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25640. /**
  25641. * Update a specific vertex buffer
  25642. * This function will create a new buffer if the current one is not updatable
  25643. * @param kind defines the data kind (Position, normal, etc...)
  25644. * @param data defines the data to use
  25645. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25646. */
  25647. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25648. private _updateBoundingInfo;
  25649. /** @hidden */
  25650. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25651. /**
  25652. * Gets total number of vertices
  25653. * @returns the total number of vertices
  25654. */
  25655. getTotalVertices(): number;
  25656. /**
  25657. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25658. * @param kind defines the data kind (Position, normal, etc...)
  25659. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25660. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25661. * @returns a float array containing vertex data
  25662. */
  25663. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25664. /**
  25665. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25666. * @param kind defines the data kind (Position, normal, etc...)
  25667. * @returns true if the vertex buffer with the specified kind is updatable
  25668. */
  25669. isVertexBufferUpdatable(kind: string): boolean;
  25670. /**
  25671. * Gets a specific vertex buffer
  25672. * @param kind defines the data kind (Position, normal, etc...)
  25673. * @returns a VertexBuffer
  25674. */
  25675. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25676. /**
  25677. * Returns all vertex buffers
  25678. * @return an object holding all vertex buffers indexed by kind
  25679. */
  25680. getVertexBuffers(): Nullable<{
  25681. [key: string]: VertexBuffer;
  25682. }>;
  25683. /**
  25684. * Gets a boolean indicating if specific vertex buffer is present
  25685. * @param kind defines the data kind (Position, normal, etc...)
  25686. * @returns true if data is present
  25687. */
  25688. isVerticesDataPresent(kind: string): boolean;
  25689. /**
  25690. * Gets a list of all attached data kinds (Position, normal, etc...)
  25691. * @returns a list of string containing all kinds
  25692. */
  25693. getVerticesDataKinds(): string[];
  25694. /**
  25695. * Update index buffer
  25696. * @param indices defines the indices to store in the index buffer
  25697. * @param offset defines the offset in the target buffer where to store the data
  25698. * @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)
  25699. */
  25700. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25701. /**
  25702. * Creates a new index buffer
  25703. * @param indices defines the indices to store in the index buffer
  25704. * @param totalVertices defines the total number of vertices (could be null)
  25705. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25706. */
  25707. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25708. /**
  25709. * Return the total number of indices
  25710. * @returns the total number of indices
  25711. */
  25712. getTotalIndices(): number;
  25713. /**
  25714. * Gets the index buffer array
  25715. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25716. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25717. * @returns the index buffer array
  25718. */
  25719. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25720. /**
  25721. * Gets the index buffer
  25722. * @return the index buffer
  25723. */
  25724. getIndexBuffer(): Nullable<DataBuffer>;
  25725. /** @hidden */
  25726. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25727. /**
  25728. * Release the associated resources for a specific mesh
  25729. * @param mesh defines the source mesh
  25730. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25731. */
  25732. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25733. /**
  25734. * Apply current geometry to a given mesh
  25735. * @param mesh defines the mesh to apply geometry to
  25736. */
  25737. applyToMesh(mesh: Mesh): void;
  25738. private _updateExtend;
  25739. private _applyToMesh;
  25740. private notifyUpdate;
  25741. /**
  25742. * Load the geometry if it was flagged as delay loaded
  25743. * @param scene defines the hosting scene
  25744. * @param onLoaded defines a callback called when the geometry is loaded
  25745. */
  25746. load(scene: Scene, onLoaded?: () => void): void;
  25747. private _queueLoad;
  25748. /**
  25749. * Invert the geometry to move from a right handed system to a left handed one.
  25750. */
  25751. toLeftHanded(): void;
  25752. /** @hidden */
  25753. _resetPointsArrayCache(): void;
  25754. /** @hidden */
  25755. _generatePointsArray(): boolean;
  25756. /**
  25757. * Gets a value indicating if the geometry is disposed
  25758. * @returns true if the geometry was disposed
  25759. */
  25760. isDisposed(): boolean;
  25761. private _disposeVertexArrayObjects;
  25762. /**
  25763. * Free all associated resources
  25764. */
  25765. dispose(): void;
  25766. /**
  25767. * Clone the current geometry into a new geometry
  25768. * @param id defines the unique ID of the new geometry
  25769. * @returns a new geometry object
  25770. */
  25771. copy(id: string): Geometry;
  25772. /**
  25773. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25774. * @return a JSON representation of the current geometry data (without the vertices data)
  25775. */
  25776. serialize(): any;
  25777. private toNumberArray;
  25778. /**
  25779. * Serialize all vertices data into a JSON oject
  25780. * @returns a JSON representation of the current geometry data
  25781. */
  25782. serializeVerticeData(): any;
  25783. /**
  25784. * Extracts a clone of a mesh geometry
  25785. * @param mesh defines the source mesh
  25786. * @param id defines the unique ID of the new geometry object
  25787. * @returns the new geometry object
  25788. */
  25789. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25790. /**
  25791. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25792. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25793. * Be aware Math.random() could cause collisions, but:
  25794. * "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"
  25795. * @returns a string containing a new GUID
  25796. */
  25797. static RandomId(): string;
  25798. /** @hidden */
  25799. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25800. private static _CleanMatricesWeights;
  25801. /**
  25802. * Create a new geometry from persisted data (Using .babylon file format)
  25803. * @param parsedVertexData defines the persisted data
  25804. * @param scene defines the hosting scene
  25805. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25806. * @returns the new geometry object
  25807. */
  25808. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25809. }
  25810. }
  25811. declare module "babylonjs/Meshes/mesh.vertexData" {
  25812. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25813. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25814. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25815. import { Geometry } from "babylonjs/Meshes/geometry";
  25816. import { Mesh } from "babylonjs/Meshes/mesh";
  25817. /**
  25818. * Define an interface for all classes that will get and set the data on vertices
  25819. */
  25820. export interface IGetSetVerticesData {
  25821. /**
  25822. * Gets a boolean indicating if specific vertex data is present
  25823. * @param kind defines the vertex data kind to use
  25824. * @returns true is data kind is present
  25825. */
  25826. isVerticesDataPresent(kind: string): boolean;
  25827. /**
  25828. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25829. * @param kind defines the data kind (Position, normal, etc...)
  25830. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25831. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25832. * @returns a float array containing vertex data
  25833. */
  25834. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25835. /**
  25836. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25837. * @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.
  25838. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25839. * @returns the indices array or an empty array if the mesh has no geometry
  25840. */
  25841. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25842. /**
  25843. * Set specific vertex data
  25844. * @param kind defines the data kind (Position, normal, etc...)
  25845. * @param data defines the vertex data to use
  25846. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25847. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25848. */
  25849. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25850. /**
  25851. * Update a specific associated vertex buffer
  25852. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25853. * - VertexBuffer.PositionKind
  25854. * - VertexBuffer.UVKind
  25855. * - VertexBuffer.UV2Kind
  25856. * - VertexBuffer.UV3Kind
  25857. * - VertexBuffer.UV4Kind
  25858. * - VertexBuffer.UV5Kind
  25859. * - VertexBuffer.UV6Kind
  25860. * - VertexBuffer.ColorKind
  25861. * - VertexBuffer.MatricesIndicesKind
  25862. * - VertexBuffer.MatricesIndicesExtraKind
  25863. * - VertexBuffer.MatricesWeightsKind
  25864. * - VertexBuffer.MatricesWeightsExtraKind
  25865. * @param data defines the data source
  25866. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25867. * @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)
  25868. */
  25869. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25870. /**
  25871. * Creates a new index buffer
  25872. * @param indices defines the indices to store in the index buffer
  25873. * @param totalVertices defines the total number of vertices (could be null)
  25874. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25875. */
  25876. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25877. }
  25878. /**
  25879. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25880. */
  25881. export class VertexData {
  25882. /**
  25883. * Mesh side orientation : usually the external or front surface
  25884. */
  25885. static readonly FRONTSIDE: number;
  25886. /**
  25887. * Mesh side orientation : usually the internal or back surface
  25888. */
  25889. static readonly BACKSIDE: number;
  25890. /**
  25891. * Mesh side orientation : both internal and external or front and back surfaces
  25892. */
  25893. static readonly DOUBLESIDE: number;
  25894. /**
  25895. * Mesh side orientation : by default, `FRONTSIDE`
  25896. */
  25897. static readonly DEFAULTSIDE: number;
  25898. /**
  25899. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25900. */
  25901. positions: Nullable<FloatArray>;
  25902. /**
  25903. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25904. */
  25905. normals: Nullable<FloatArray>;
  25906. /**
  25907. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25908. */
  25909. tangents: Nullable<FloatArray>;
  25910. /**
  25911. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25912. */
  25913. uvs: Nullable<FloatArray>;
  25914. /**
  25915. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25916. */
  25917. uvs2: Nullable<FloatArray>;
  25918. /**
  25919. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25920. */
  25921. uvs3: Nullable<FloatArray>;
  25922. /**
  25923. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25924. */
  25925. uvs4: Nullable<FloatArray>;
  25926. /**
  25927. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25928. */
  25929. uvs5: Nullable<FloatArray>;
  25930. /**
  25931. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25932. */
  25933. uvs6: Nullable<FloatArray>;
  25934. /**
  25935. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25936. */
  25937. colors: Nullable<FloatArray>;
  25938. /**
  25939. * 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).
  25940. */
  25941. matricesIndices: Nullable<FloatArray>;
  25942. /**
  25943. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25944. */
  25945. matricesWeights: Nullable<FloatArray>;
  25946. /**
  25947. * An array extending the number of possible indices
  25948. */
  25949. matricesIndicesExtra: Nullable<FloatArray>;
  25950. /**
  25951. * An array extending the number of possible weights when the number of indices is extended
  25952. */
  25953. matricesWeightsExtra: Nullable<FloatArray>;
  25954. /**
  25955. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25956. */
  25957. indices: Nullable<IndicesArray>;
  25958. /**
  25959. * Uses the passed data array to set the set the values for the specified kind of data
  25960. * @param data a linear array of floating numbers
  25961. * @param kind the type of data that is being set, eg positions, colors etc
  25962. */
  25963. set(data: FloatArray, kind: string): void;
  25964. /**
  25965. * Associates the vertexData to the passed Mesh.
  25966. * Sets it as updatable or not (default `false`)
  25967. * @param mesh the mesh the vertexData is applied to
  25968. * @param updatable when used and having the value true allows new data to update the vertexData
  25969. * @returns the VertexData
  25970. */
  25971. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25972. /**
  25973. * Associates the vertexData to the passed Geometry.
  25974. * Sets it as updatable or not (default `false`)
  25975. * @param geometry the geometry the vertexData is applied to
  25976. * @param updatable when used and having the value true allows new data to update the vertexData
  25977. * @returns VertexData
  25978. */
  25979. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25980. /**
  25981. * Updates the associated mesh
  25982. * @param mesh the mesh to be updated
  25983. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25984. * @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
  25985. * @returns VertexData
  25986. */
  25987. updateMesh(mesh: Mesh): VertexData;
  25988. /**
  25989. * Updates the associated geometry
  25990. * @param geometry the geometry to be updated
  25991. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25992. * @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
  25993. * @returns VertexData.
  25994. */
  25995. updateGeometry(geometry: Geometry): VertexData;
  25996. private _applyTo;
  25997. private _update;
  25998. /**
  25999. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26000. * @param matrix the transforming matrix
  26001. * @returns the VertexData
  26002. */
  26003. transform(matrix: Matrix): VertexData;
  26004. /**
  26005. * Merges the passed VertexData into the current one
  26006. * @param other the VertexData to be merged into the current one
  26007. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26008. * @returns the modified VertexData
  26009. */
  26010. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26011. private _mergeElement;
  26012. private _validate;
  26013. /**
  26014. * Serializes the VertexData
  26015. * @returns a serialized object
  26016. */
  26017. serialize(): any;
  26018. /**
  26019. * Extracts the vertexData from a mesh
  26020. * @param mesh the mesh from which to extract the VertexData
  26021. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26022. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26023. * @returns the object VertexData associated to the passed mesh
  26024. */
  26025. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26026. /**
  26027. * Extracts the vertexData from the geometry
  26028. * @param geometry the geometry from which to extract the VertexData
  26029. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26030. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26031. * @returns the object VertexData associated to the passed mesh
  26032. */
  26033. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26034. private static _ExtractFrom;
  26035. /**
  26036. * Creates the VertexData for a Ribbon
  26037. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26038. * * pathArray array of paths, each of which an array of successive Vector3
  26039. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26040. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26041. * * 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
  26042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26043. * * 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)
  26044. * * 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)
  26045. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26046. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26047. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26048. * @returns the VertexData of the ribbon
  26049. */
  26050. static CreateRibbon(options: {
  26051. pathArray: Vector3[][];
  26052. closeArray?: boolean;
  26053. closePath?: boolean;
  26054. offset?: number;
  26055. sideOrientation?: number;
  26056. frontUVs?: Vector4;
  26057. backUVs?: Vector4;
  26058. invertUV?: boolean;
  26059. uvs?: Vector2[];
  26060. colors?: Color4[];
  26061. }): VertexData;
  26062. /**
  26063. * Creates the VertexData for a box
  26064. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26065. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26066. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26067. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26068. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26069. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26070. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26072. * * 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)
  26073. * * 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)
  26074. * @returns the VertexData of the box
  26075. */
  26076. static CreateBox(options: {
  26077. size?: number;
  26078. width?: number;
  26079. height?: number;
  26080. depth?: number;
  26081. faceUV?: Vector4[];
  26082. faceColors?: Color4[];
  26083. sideOrientation?: number;
  26084. frontUVs?: Vector4;
  26085. backUVs?: Vector4;
  26086. }): VertexData;
  26087. /**
  26088. * Creates the VertexData for a tiled box
  26089. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26090. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26091. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26092. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26094. * @returns the VertexData of the box
  26095. */
  26096. static CreateTiledBox(options: {
  26097. pattern?: number;
  26098. width?: number;
  26099. height?: number;
  26100. depth?: number;
  26101. tileSize?: number;
  26102. tileWidth?: number;
  26103. tileHeight?: number;
  26104. alignHorizontal?: number;
  26105. alignVertical?: number;
  26106. faceUV?: Vector4[];
  26107. faceColors?: Color4[];
  26108. sideOrientation?: number;
  26109. }): VertexData;
  26110. /**
  26111. * Creates the VertexData for a tiled plane
  26112. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26113. * * pattern a limited pattern arrangement depending on the number
  26114. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26115. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26116. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26117. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26118. * * 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)
  26119. * * 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)
  26120. * @returns the VertexData of the tiled plane
  26121. */
  26122. static CreateTiledPlane(options: {
  26123. pattern?: number;
  26124. tileSize?: number;
  26125. tileWidth?: number;
  26126. tileHeight?: number;
  26127. size?: number;
  26128. width?: number;
  26129. height?: number;
  26130. alignHorizontal?: number;
  26131. alignVertical?: number;
  26132. sideOrientation?: number;
  26133. frontUVs?: Vector4;
  26134. backUVs?: Vector4;
  26135. }): VertexData;
  26136. /**
  26137. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26138. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26139. * * segments sets the number of horizontal strips optional, default 32
  26140. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26141. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26142. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26143. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26144. * * 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
  26145. * * 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
  26146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26147. * * 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)
  26148. * * 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)
  26149. * @returns the VertexData of the ellipsoid
  26150. */
  26151. static CreateSphere(options: {
  26152. segments?: number;
  26153. diameter?: number;
  26154. diameterX?: number;
  26155. diameterY?: number;
  26156. diameterZ?: number;
  26157. arc?: number;
  26158. slice?: number;
  26159. sideOrientation?: number;
  26160. frontUVs?: Vector4;
  26161. backUVs?: Vector4;
  26162. }): VertexData;
  26163. /**
  26164. * Creates the VertexData for a cylinder, cone or prism
  26165. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26166. * * height sets the height (y direction) of the cylinder, optional, default 2
  26167. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26168. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26169. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26170. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26171. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26172. * * 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
  26173. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26174. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26175. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26176. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26177. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26178. * * 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)
  26179. * * 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)
  26180. * @returns the VertexData of the cylinder, cone or prism
  26181. */
  26182. static CreateCylinder(options: {
  26183. height?: number;
  26184. diameterTop?: number;
  26185. diameterBottom?: number;
  26186. diameter?: number;
  26187. tessellation?: number;
  26188. subdivisions?: number;
  26189. arc?: number;
  26190. faceColors?: Color4[];
  26191. faceUV?: Vector4[];
  26192. hasRings?: boolean;
  26193. enclose?: boolean;
  26194. sideOrientation?: number;
  26195. frontUVs?: Vector4;
  26196. backUVs?: Vector4;
  26197. }): VertexData;
  26198. /**
  26199. * Creates the VertexData for a torus
  26200. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26201. * * diameter the diameter of the torus, optional default 1
  26202. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26203. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26204. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26205. * * 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)
  26206. * * 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)
  26207. * @returns the VertexData of the torus
  26208. */
  26209. static CreateTorus(options: {
  26210. diameter?: number;
  26211. thickness?: number;
  26212. tessellation?: number;
  26213. sideOrientation?: number;
  26214. frontUVs?: Vector4;
  26215. backUVs?: Vector4;
  26216. }): VertexData;
  26217. /**
  26218. * Creates the VertexData of the LineSystem
  26219. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26220. * - lines an array of lines, each line being an array of successive Vector3
  26221. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26222. * @returns the VertexData of the LineSystem
  26223. */
  26224. static CreateLineSystem(options: {
  26225. lines: Vector3[][];
  26226. colors?: Nullable<Color4[][]>;
  26227. }): VertexData;
  26228. /**
  26229. * Create the VertexData for a DashedLines
  26230. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26231. * - points an array successive Vector3
  26232. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26233. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26234. * - dashNb the intended total number of dashes, optional, default 200
  26235. * @returns the VertexData for the DashedLines
  26236. */
  26237. static CreateDashedLines(options: {
  26238. points: Vector3[];
  26239. dashSize?: number;
  26240. gapSize?: number;
  26241. dashNb?: number;
  26242. }): VertexData;
  26243. /**
  26244. * Creates the VertexData for a Ground
  26245. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26246. * - width the width (x direction) of the ground, optional, default 1
  26247. * - height the height (z direction) of the ground, optional, default 1
  26248. * - subdivisions the number of subdivisions per side, optional, default 1
  26249. * @returns the VertexData of the Ground
  26250. */
  26251. static CreateGround(options: {
  26252. width?: number;
  26253. height?: number;
  26254. subdivisions?: number;
  26255. subdivisionsX?: number;
  26256. subdivisionsY?: number;
  26257. }): VertexData;
  26258. /**
  26259. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26260. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26261. * * xmin the ground minimum X coordinate, optional, default -1
  26262. * * zmin the ground minimum Z coordinate, optional, default -1
  26263. * * xmax the ground maximum X coordinate, optional, default 1
  26264. * * zmax the ground maximum Z coordinate, optional, default 1
  26265. * * 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}
  26266. * * 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}
  26267. * @returns the VertexData of the TiledGround
  26268. */
  26269. static CreateTiledGround(options: {
  26270. xmin: number;
  26271. zmin: number;
  26272. xmax: number;
  26273. zmax: number;
  26274. subdivisions?: {
  26275. w: number;
  26276. h: number;
  26277. };
  26278. precision?: {
  26279. w: number;
  26280. h: number;
  26281. };
  26282. }): VertexData;
  26283. /**
  26284. * Creates the VertexData of the Ground designed from a heightmap
  26285. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26286. * * width the width (x direction) of the ground
  26287. * * height the height (z direction) of the ground
  26288. * * subdivisions the number of subdivisions per side
  26289. * * minHeight the minimum altitude on the ground, optional, default 0
  26290. * * maxHeight the maximum altitude on the ground, optional default 1
  26291. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26292. * * buffer the array holding the image color data
  26293. * * bufferWidth the width of image
  26294. * * bufferHeight the height of image
  26295. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26296. * @returns the VertexData of the Ground designed from a heightmap
  26297. */
  26298. static CreateGroundFromHeightMap(options: {
  26299. width: number;
  26300. height: number;
  26301. subdivisions: number;
  26302. minHeight: number;
  26303. maxHeight: number;
  26304. colorFilter: Color3;
  26305. buffer: Uint8Array;
  26306. bufferWidth: number;
  26307. bufferHeight: number;
  26308. alphaFilter: number;
  26309. }): VertexData;
  26310. /**
  26311. * Creates the VertexData for a Plane
  26312. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26313. * * size sets the width and height of the plane to the value of size, optional default 1
  26314. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26315. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26317. * * 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)
  26318. * * 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)
  26319. * @returns the VertexData of the box
  26320. */
  26321. static CreatePlane(options: {
  26322. size?: number;
  26323. width?: number;
  26324. height?: number;
  26325. sideOrientation?: number;
  26326. frontUVs?: Vector4;
  26327. backUVs?: Vector4;
  26328. }): VertexData;
  26329. /**
  26330. * Creates the VertexData of the Disc or regular Polygon
  26331. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26332. * * radius the radius of the disc, optional default 0.5
  26333. * * tessellation the number of polygon sides, optional, default 64
  26334. * * 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
  26335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26336. * * 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)
  26337. * * 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)
  26338. * @returns the VertexData of the box
  26339. */
  26340. static CreateDisc(options: {
  26341. radius?: number;
  26342. tessellation?: number;
  26343. arc?: number;
  26344. sideOrientation?: number;
  26345. frontUVs?: Vector4;
  26346. backUVs?: Vector4;
  26347. }): VertexData;
  26348. /**
  26349. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26350. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26351. * @param polygon a mesh built from polygonTriangulation.build()
  26352. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26353. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26354. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26355. * @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)
  26356. * @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)
  26357. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26358. * @returns the VertexData of the Polygon
  26359. */
  26360. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26361. /**
  26362. * Creates the VertexData of the IcoSphere
  26363. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26364. * * radius the radius of the IcoSphere, optional default 1
  26365. * * radiusX allows stretching in the x direction, optional, default radius
  26366. * * radiusY allows stretching in the y direction, optional, default radius
  26367. * * radiusZ allows stretching in the z direction, optional, default radius
  26368. * * flat when true creates a flat shaded mesh, optional, default true
  26369. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26371. * * 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)
  26372. * * 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)
  26373. * @returns the VertexData of the IcoSphere
  26374. */
  26375. static CreateIcoSphere(options: {
  26376. radius?: number;
  26377. radiusX?: number;
  26378. radiusY?: number;
  26379. radiusZ?: number;
  26380. flat?: boolean;
  26381. subdivisions?: number;
  26382. sideOrientation?: number;
  26383. frontUVs?: Vector4;
  26384. backUVs?: Vector4;
  26385. }): VertexData;
  26386. /**
  26387. * Creates the VertexData for a Polyhedron
  26388. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26389. * * type provided types are:
  26390. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26391. * * 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)
  26392. * * size the size of the IcoSphere, optional default 1
  26393. * * sizeX allows stretching in the x direction, optional, default size
  26394. * * sizeY allows stretching in the y direction, optional, default size
  26395. * * sizeZ allows stretching in the z direction, optional, default size
  26396. * * 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
  26397. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26398. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26399. * * flat when true creates a flat shaded mesh, optional, default true
  26400. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26402. * * 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)
  26403. * * 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)
  26404. * @returns the VertexData of the Polyhedron
  26405. */
  26406. static CreatePolyhedron(options: {
  26407. type?: number;
  26408. size?: number;
  26409. sizeX?: number;
  26410. sizeY?: number;
  26411. sizeZ?: number;
  26412. custom?: any;
  26413. faceUV?: Vector4[];
  26414. faceColors?: Color4[];
  26415. flat?: boolean;
  26416. sideOrientation?: number;
  26417. frontUVs?: Vector4;
  26418. backUVs?: Vector4;
  26419. }): VertexData;
  26420. /**
  26421. * Creates the VertexData for a TorusKnot
  26422. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26423. * * radius the radius of the torus knot, optional, default 2
  26424. * * tube the thickness of the tube, optional, default 0.5
  26425. * * radialSegments the number of sides on each tube segments, optional, default 32
  26426. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26427. * * p the number of windings around the z axis, optional, default 2
  26428. * * q the number of windings around the x axis, optional, default 3
  26429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26430. * * 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)
  26431. * * 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)
  26432. * @returns the VertexData of the Torus Knot
  26433. */
  26434. static CreateTorusKnot(options: {
  26435. radius?: number;
  26436. tube?: number;
  26437. radialSegments?: number;
  26438. tubularSegments?: number;
  26439. p?: number;
  26440. q?: number;
  26441. sideOrientation?: number;
  26442. frontUVs?: Vector4;
  26443. backUVs?: Vector4;
  26444. }): VertexData;
  26445. /**
  26446. * Compute normals for given positions and indices
  26447. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26448. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26449. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26450. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26451. * * facetNormals : optional array of facet normals (vector3)
  26452. * * facetPositions : optional array of facet positions (vector3)
  26453. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26454. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26455. * * bInfo : optional bounding info, required for facetPartitioning computation
  26456. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26457. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26458. * * useRightHandedSystem: optional boolean to for right handed system computation
  26459. * * depthSort : optional boolean to enable the facet depth sort computation
  26460. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26461. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26462. */
  26463. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26464. facetNormals?: any;
  26465. facetPositions?: any;
  26466. facetPartitioning?: any;
  26467. ratio?: number;
  26468. bInfo?: any;
  26469. bbSize?: Vector3;
  26470. subDiv?: any;
  26471. useRightHandedSystem?: boolean;
  26472. depthSort?: boolean;
  26473. distanceTo?: Vector3;
  26474. depthSortedFacets?: any;
  26475. }): void;
  26476. /** @hidden */
  26477. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26478. /**
  26479. * Applies VertexData created from the imported parameters to the geometry
  26480. * @param parsedVertexData the parsed data from an imported file
  26481. * @param geometry the geometry to apply the VertexData to
  26482. */
  26483. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26484. }
  26485. }
  26486. declare module "babylonjs/Morph/morphTarget" {
  26487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26488. import { Observable } from "babylonjs/Misc/observable";
  26489. import { Nullable, FloatArray } from "babylonjs/types";
  26490. import { Scene } from "babylonjs/scene";
  26491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26492. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26493. /**
  26494. * Defines a target to use with MorphTargetManager
  26495. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26496. */
  26497. export class MorphTarget implements IAnimatable {
  26498. /** defines the name of the target */
  26499. name: string;
  26500. /**
  26501. * Gets or sets the list of animations
  26502. */
  26503. animations: import("babylonjs/Animations/animation").Animation[];
  26504. private _scene;
  26505. private _positions;
  26506. private _normals;
  26507. private _tangents;
  26508. private _uvs;
  26509. private _influence;
  26510. private _uniqueId;
  26511. /**
  26512. * Observable raised when the influence changes
  26513. */
  26514. onInfluenceChanged: Observable<boolean>;
  26515. /** @hidden */
  26516. _onDataLayoutChanged: Observable<void>;
  26517. /**
  26518. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26519. */
  26520. get influence(): number;
  26521. set influence(influence: number);
  26522. /**
  26523. * Gets or sets the id of the morph Target
  26524. */
  26525. id: string;
  26526. private _animationPropertiesOverride;
  26527. /**
  26528. * Gets or sets the animation properties override
  26529. */
  26530. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26531. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26532. /**
  26533. * Creates a new MorphTarget
  26534. * @param name defines the name of the target
  26535. * @param influence defines the influence to use
  26536. * @param scene defines the scene the morphtarget belongs to
  26537. */
  26538. constructor(
  26539. /** defines the name of the target */
  26540. name: string, influence?: number, scene?: Nullable<Scene>);
  26541. /**
  26542. * Gets the unique ID of this manager
  26543. */
  26544. get uniqueId(): number;
  26545. /**
  26546. * Gets a boolean defining if the target contains position data
  26547. */
  26548. get hasPositions(): boolean;
  26549. /**
  26550. * Gets a boolean defining if the target contains normal data
  26551. */
  26552. get hasNormals(): boolean;
  26553. /**
  26554. * Gets a boolean defining if the target contains tangent data
  26555. */
  26556. get hasTangents(): boolean;
  26557. /**
  26558. * Gets a boolean defining if the target contains texture coordinates data
  26559. */
  26560. get hasUVs(): boolean;
  26561. /**
  26562. * Affects position data to this target
  26563. * @param data defines the position data to use
  26564. */
  26565. setPositions(data: Nullable<FloatArray>): void;
  26566. /**
  26567. * Gets the position data stored in this target
  26568. * @returns a FloatArray containing the position data (or null if not present)
  26569. */
  26570. getPositions(): Nullable<FloatArray>;
  26571. /**
  26572. * Affects normal data to this target
  26573. * @param data defines the normal data to use
  26574. */
  26575. setNormals(data: Nullable<FloatArray>): void;
  26576. /**
  26577. * Gets the normal data stored in this target
  26578. * @returns a FloatArray containing the normal data (or null if not present)
  26579. */
  26580. getNormals(): Nullable<FloatArray>;
  26581. /**
  26582. * Affects tangent data to this target
  26583. * @param data defines the tangent data to use
  26584. */
  26585. setTangents(data: Nullable<FloatArray>): void;
  26586. /**
  26587. * Gets the tangent data stored in this target
  26588. * @returns a FloatArray containing the tangent data (or null if not present)
  26589. */
  26590. getTangents(): Nullable<FloatArray>;
  26591. /**
  26592. * Affects texture coordinates data to this target
  26593. * @param data defines the texture coordinates data to use
  26594. */
  26595. setUVs(data: Nullable<FloatArray>): void;
  26596. /**
  26597. * Gets the texture coordinates data stored in this target
  26598. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26599. */
  26600. getUVs(): Nullable<FloatArray>;
  26601. /**
  26602. * Clone the current target
  26603. * @returns a new MorphTarget
  26604. */
  26605. clone(): MorphTarget;
  26606. /**
  26607. * Serializes the current target into a Serialization object
  26608. * @returns the serialized object
  26609. */
  26610. serialize(): any;
  26611. /**
  26612. * Returns the string "MorphTarget"
  26613. * @returns "MorphTarget"
  26614. */
  26615. getClassName(): string;
  26616. /**
  26617. * Creates a new target from serialized data
  26618. * @param serializationObject defines the serialized data to use
  26619. * @returns a new MorphTarget
  26620. */
  26621. static Parse(serializationObject: any): MorphTarget;
  26622. /**
  26623. * Creates a MorphTarget from mesh data
  26624. * @param mesh defines the source mesh
  26625. * @param name defines the name to use for the new target
  26626. * @param influence defines the influence to attach to the target
  26627. * @returns a new MorphTarget
  26628. */
  26629. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26630. }
  26631. }
  26632. declare module "babylonjs/Morph/morphTargetManager" {
  26633. import { Nullable } from "babylonjs/types";
  26634. import { Scene } from "babylonjs/scene";
  26635. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26636. /**
  26637. * This class is used to deform meshes using morphing between different targets
  26638. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26639. */
  26640. export class MorphTargetManager {
  26641. private _targets;
  26642. private _targetInfluenceChangedObservers;
  26643. private _targetDataLayoutChangedObservers;
  26644. private _activeTargets;
  26645. private _scene;
  26646. private _influences;
  26647. private _supportsNormals;
  26648. private _supportsTangents;
  26649. private _supportsUVs;
  26650. private _vertexCount;
  26651. private _uniqueId;
  26652. private _tempInfluences;
  26653. /**
  26654. * Gets or sets a boolean indicating if normals must be morphed
  26655. */
  26656. enableNormalMorphing: boolean;
  26657. /**
  26658. * Gets or sets a boolean indicating if tangents must be morphed
  26659. */
  26660. enableTangentMorphing: boolean;
  26661. /**
  26662. * Gets or sets a boolean indicating if UV must be morphed
  26663. */
  26664. enableUVMorphing: boolean;
  26665. /**
  26666. * Creates a new MorphTargetManager
  26667. * @param scene defines the current scene
  26668. */
  26669. constructor(scene?: Nullable<Scene>);
  26670. /**
  26671. * Gets the unique ID of this manager
  26672. */
  26673. get uniqueId(): number;
  26674. /**
  26675. * Gets the number of vertices handled by this manager
  26676. */
  26677. get vertexCount(): number;
  26678. /**
  26679. * Gets a boolean indicating if this manager supports morphing of normals
  26680. */
  26681. get supportsNormals(): boolean;
  26682. /**
  26683. * Gets a boolean indicating if this manager supports morphing of tangents
  26684. */
  26685. get supportsTangents(): boolean;
  26686. /**
  26687. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26688. */
  26689. get supportsUVs(): boolean;
  26690. /**
  26691. * Gets the number of targets stored in this manager
  26692. */
  26693. get numTargets(): number;
  26694. /**
  26695. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26696. */
  26697. get numInfluencers(): number;
  26698. /**
  26699. * Gets the list of influences (one per target)
  26700. */
  26701. get influences(): Float32Array;
  26702. /**
  26703. * Gets the active target at specified index. An active target is a target with an influence > 0
  26704. * @param index defines the index to check
  26705. * @returns the requested target
  26706. */
  26707. getActiveTarget(index: number): MorphTarget;
  26708. /**
  26709. * Gets the target at specified index
  26710. * @param index defines the index to check
  26711. * @returns the requested target
  26712. */
  26713. getTarget(index: number): MorphTarget;
  26714. /**
  26715. * Add a new target to this manager
  26716. * @param target defines the target to add
  26717. */
  26718. addTarget(target: MorphTarget): void;
  26719. /**
  26720. * Removes a target from the manager
  26721. * @param target defines the target to remove
  26722. */
  26723. removeTarget(target: MorphTarget): void;
  26724. /**
  26725. * Clone the current manager
  26726. * @returns a new MorphTargetManager
  26727. */
  26728. clone(): MorphTargetManager;
  26729. /**
  26730. * Serializes the current manager into a Serialization object
  26731. * @returns the serialized object
  26732. */
  26733. serialize(): any;
  26734. private _syncActiveTargets;
  26735. /**
  26736. * Syncrhonize the targets with all the meshes using this morph target manager
  26737. */
  26738. synchronize(): void;
  26739. /**
  26740. * Creates a new MorphTargetManager from serialized data
  26741. * @param serializationObject defines the serialized data
  26742. * @param scene defines the hosting scene
  26743. * @returns the new MorphTargetManager
  26744. */
  26745. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26746. }
  26747. }
  26748. declare module "babylonjs/Meshes/meshLODLevel" {
  26749. import { Mesh } from "babylonjs/Meshes/mesh";
  26750. import { Nullable } from "babylonjs/types";
  26751. /**
  26752. * Class used to represent a specific level of detail of a mesh
  26753. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26754. */
  26755. export class MeshLODLevel {
  26756. /** Defines the distance where this level should start being displayed */
  26757. distance: number;
  26758. /** Defines the mesh to use to render this level */
  26759. mesh: Nullable<Mesh>;
  26760. /**
  26761. * Creates a new LOD level
  26762. * @param distance defines the distance where this level should star being displayed
  26763. * @param mesh defines the mesh to use to render this level
  26764. */
  26765. constructor(
  26766. /** Defines the distance where this level should start being displayed */
  26767. distance: number,
  26768. /** Defines the mesh to use to render this level */
  26769. mesh: Nullable<Mesh>);
  26770. }
  26771. }
  26772. declare module "babylonjs/Misc/canvasGenerator" {
  26773. /**
  26774. * Helper class used to generate a canvas to manipulate images
  26775. */
  26776. export class CanvasGenerator {
  26777. /**
  26778. * Create a new canvas (or offscreen canvas depending on the context)
  26779. * @param width defines the expected width
  26780. * @param height defines the expected height
  26781. * @return a new canvas or offscreen canvas
  26782. */
  26783. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26784. }
  26785. }
  26786. declare module "babylonjs/Meshes/groundMesh" {
  26787. import { Scene } from "babylonjs/scene";
  26788. import { Vector3 } from "babylonjs/Maths/math.vector";
  26789. import { Mesh } from "babylonjs/Meshes/mesh";
  26790. /**
  26791. * Mesh representing the gorund
  26792. */
  26793. export class GroundMesh extends Mesh {
  26794. /** If octree should be generated */
  26795. generateOctree: boolean;
  26796. private _heightQuads;
  26797. /** @hidden */
  26798. _subdivisionsX: number;
  26799. /** @hidden */
  26800. _subdivisionsY: number;
  26801. /** @hidden */
  26802. _width: number;
  26803. /** @hidden */
  26804. _height: number;
  26805. /** @hidden */
  26806. _minX: number;
  26807. /** @hidden */
  26808. _maxX: number;
  26809. /** @hidden */
  26810. _minZ: number;
  26811. /** @hidden */
  26812. _maxZ: number;
  26813. constructor(name: string, scene: Scene);
  26814. /**
  26815. * "GroundMesh"
  26816. * @returns "GroundMesh"
  26817. */
  26818. getClassName(): string;
  26819. /**
  26820. * The minimum of x and y subdivisions
  26821. */
  26822. get subdivisions(): number;
  26823. /**
  26824. * X subdivisions
  26825. */
  26826. get subdivisionsX(): number;
  26827. /**
  26828. * Y subdivisions
  26829. */
  26830. get subdivisionsY(): number;
  26831. /**
  26832. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26833. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26834. * @param chunksCount the number of subdivisions for x and y
  26835. * @param octreeBlocksSize (Default: 32)
  26836. */
  26837. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26838. /**
  26839. * Returns a height (y) value in the Worl system :
  26840. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26841. * @param x x coordinate
  26842. * @param z z coordinate
  26843. * @returns the ground y position if (x, z) are outside the ground surface.
  26844. */
  26845. getHeightAtCoordinates(x: number, z: number): number;
  26846. /**
  26847. * Returns a normalized vector (Vector3) orthogonal to the ground
  26848. * at the ground coordinates (x, z) expressed in the World system.
  26849. * @param x x coordinate
  26850. * @param z z coordinate
  26851. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26852. */
  26853. getNormalAtCoordinates(x: number, z: number): Vector3;
  26854. /**
  26855. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26856. * at the ground coordinates (x, z) expressed in the World system.
  26857. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26858. * @param x x coordinate
  26859. * @param z z coordinate
  26860. * @param ref vector to store the result
  26861. * @returns the GroundMesh.
  26862. */
  26863. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26864. /**
  26865. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26866. * if the ground has been updated.
  26867. * This can be used in the render loop.
  26868. * @returns the GroundMesh.
  26869. */
  26870. updateCoordinateHeights(): GroundMesh;
  26871. private _getFacetAt;
  26872. private _initHeightQuads;
  26873. private _computeHeightQuads;
  26874. /**
  26875. * Serializes this ground mesh
  26876. * @param serializationObject object to write serialization to
  26877. */
  26878. serialize(serializationObject: any): void;
  26879. /**
  26880. * Parses a serialized ground mesh
  26881. * @param parsedMesh the serialized mesh
  26882. * @param scene the scene to create the ground mesh in
  26883. * @returns the created ground mesh
  26884. */
  26885. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26886. }
  26887. }
  26888. declare module "babylonjs/Physics/physicsJoint" {
  26889. import { Vector3 } from "babylonjs/Maths/math.vector";
  26890. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26891. /**
  26892. * Interface for Physics-Joint data
  26893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26894. */
  26895. export interface PhysicsJointData {
  26896. /**
  26897. * The main pivot of the joint
  26898. */
  26899. mainPivot?: Vector3;
  26900. /**
  26901. * The connected pivot of the joint
  26902. */
  26903. connectedPivot?: Vector3;
  26904. /**
  26905. * The main axis of the joint
  26906. */
  26907. mainAxis?: Vector3;
  26908. /**
  26909. * The connected axis of the joint
  26910. */
  26911. connectedAxis?: Vector3;
  26912. /**
  26913. * The collision of the joint
  26914. */
  26915. collision?: boolean;
  26916. /**
  26917. * Native Oimo/Cannon/Energy data
  26918. */
  26919. nativeParams?: any;
  26920. }
  26921. /**
  26922. * This is a holder class for the physics joint created by the physics plugin
  26923. * It holds a set of functions to control the underlying joint
  26924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26925. */
  26926. export class PhysicsJoint {
  26927. /**
  26928. * The type of the physics joint
  26929. */
  26930. type: number;
  26931. /**
  26932. * The data for the physics joint
  26933. */
  26934. jointData: PhysicsJointData;
  26935. private _physicsJoint;
  26936. protected _physicsPlugin: IPhysicsEnginePlugin;
  26937. /**
  26938. * Initializes the physics joint
  26939. * @param type The type of the physics joint
  26940. * @param jointData The data for the physics joint
  26941. */
  26942. constructor(
  26943. /**
  26944. * The type of the physics joint
  26945. */
  26946. type: number,
  26947. /**
  26948. * The data for the physics joint
  26949. */
  26950. jointData: PhysicsJointData);
  26951. /**
  26952. * Gets the physics joint
  26953. */
  26954. get physicsJoint(): any;
  26955. /**
  26956. * Sets the physics joint
  26957. */
  26958. set physicsJoint(newJoint: any);
  26959. /**
  26960. * Sets the physics plugin
  26961. */
  26962. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26963. /**
  26964. * Execute a function that is physics-plugin specific.
  26965. * @param {Function} func the function that will be executed.
  26966. * It accepts two parameters: the physics world and the physics joint
  26967. */
  26968. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26969. /**
  26970. * Distance-Joint type
  26971. */
  26972. static DistanceJoint: number;
  26973. /**
  26974. * Hinge-Joint type
  26975. */
  26976. static HingeJoint: number;
  26977. /**
  26978. * Ball-and-Socket joint type
  26979. */
  26980. static BallAndSocketJoint: number;
  26981. /**
  26982. * Wheel-Joint type
  26983. */
  26984. static WheelJoint: number;
  26985. /**
  26986. * Slider-Joint type
  26987. */
  26988. static SliderJoint: number;
  26989. /**
  26990. * Prismatic-Joint type
  26991. */
  26992. static PrismaticJoint: number;
  26993. /**
  26994. * Universal-Joint type
  26995. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26996. */
  26997. static UniversalJoint: number;
  26998. /**
  26999. * Hinge-Joint 2 type
  27000. */
  27001. static Hinge2Joint: number;
  27002. /**
  27003. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27004. */
  27005. static PointToPointJoint: number;
  27006. /**
  27007. * Spring-Joint type
  27008. */
  27009. static SpringJoint: number;
  27010. /**
  27011. * Lock-Joint type
  27012. */
  27013. static LockJoint: number;
  27014. }
  27015. /**
  27016. * A class representing a physics distance joint
  27017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27018. */
  27019. export class DistanceJoint extends PhysicsJoint {
  27020. /**
  27021. *
  27022. * @param jointData The data for the Distance-Joint
  27023. */
  27024. constructor(jointData: DistanceJointData);
  27025. /**
  27026. * Update the predefined distance.
  27027. * @param maxDistance The maximum preferred distance
  27028. * @param minDistance The minimum preferred distance
  27029. */
  27030. updateDistance(maxDistance: number, minDistance?: number): void;
  27031. }
  27032. /**
  27033. * Represents a Motor-Enabled Joint
  27034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27035. */
  27036. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27037. /**
  27038. * Initializes the Motor-Enabled Joint
  27039. * @param type The type of the joint
  27040. * @param jointData The physica joint data for the joint
  27041. */
  27042. constructor(type: number, jointData: PhysicsJointData);
  27043. /**
  27044. * Set the motor values.
  27045. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27046. * @param force the force to apply
  27047. * @param maxForce max force for this motor.
  27048. */
  27049. setMotor(force?: number, maxForce?: number): void;
  27050. /**
  27051. * Set the motor's limits.
  27052. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27053. * @param upperLimit The upper limit of the motor
  27054. * @param lowerLimit The lower limit of the motor
  27055. */
  27056. setLimit(upperLimit: number, lowerLimit?: number): void;
  27057. }
  27058. /**
  27059. * This class represents a single physics Hinge-Joint
  27060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27061. */
  27062. export class HingeJoint extends MotorEnabledJoint {
  27063. /**
  27064. * Initializes the Hinge-Joint
  27065. * @param jointData The joint data for the Hinge-Joint
  27066. */
  27067. constructor(jointData: PhysicsJointData);
  27068. /**
  27069. * Set the motor values.
  27070. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27071. * @param {number} force the force to apply
  27072. * @param {number} maxForce max force for this motor.
  27073. */
  27074. setMotor(force?: number, maxForce?: number): void;
  27075. /**
  27076. * Set the motor's limits.
  27077. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27078. * @param upperLimit The upper limit of the motor
  27079. * @param lowerLimit The lower limit of the motor
  27080. */
  27081. setLimit(upperLimit: number, lowerLimit?: number): void;
  27082. }
  27083. /**
  27084. * This class represents a dual hinge physics joint (same as wheel joint)
  27085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27086. */
  27087. export class Hinge2Joint extends MotorEnabledJoint {
  27088. /**
  27089. * Initializes the Hinge2-Joint
  27090. * @param jointData The joint data for the Hinge2-Joint
  27091. */
  27092. constructor(jointData: PhysicsJointData);
  27093. /**
  27094. * Set the motor values.
  27095. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27096. * @param {number} targetSpeed the speed the motor is to reach
  27097. * @param {number} maxForce max force for this motor.
  27098. * @param {motorIndex} the motor's index, 0 or 1.
  27099. */
  27100. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27101. /**
  27102. * Set the motor limits.
  27103. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27104. * @param {number} upperLimit the upper limit
  27105. * @param {number} lowerLimit lower limit
  27106. * @param {motorIndex} the motor's index, 0 or 1.
  27107. */
  27108. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27109. }
  27110. /**
  27111. * Interface for a motor enabled joint
  27112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27113. */
  27114. export interface IMotorEnabledJoint {
  27115. /**
  27116. * Physics joint
  27117. */
  27118. physicsJoint: any;
  27119. /**
  27120. * Sets the motor of the motor-enabled joint
  27121. * @param force The force of the motor
  27122. * @param maxForce The maximum force of the motor
  27123. * @param motorIndex The index of the motor
  27124. */
  27125. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27126. /**
  27127. * Sets the limit of the motor
  27128. * @param upperLimit The upper limit of the motor
  27129. * @param lowerLimit The lower limit of the motor
  27130. * @param motorIndex The index of the motor
  27131. */
  27132. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27133. }
  27134. /**
  27135. * Joint data for a Distance-Joint
  27136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27137. */
  27138. export interface DistanceJointData extends PhysicsJointData {
  27139. /**
  27140. * Max distance the 2 joint objects can be apart
  27141. */
  27142. maxDistance: number;
  27143. }
  27144. /**
  27145. * Joint data from a spring joint
  27146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27147. */
  27148. export interface SpringJointData extends PhysicsJointData {
  27149. /**
  27150. * Length of the spring
  27151. */
  27152. length: number;
  27153. /**
  27154. * Stiffness of the spring
  27155. */
  27156. stiffness: number;
  27157. /**
  27158. * Damping of the spring
  27159. */
  27160. damping: number;
  27161. /** this callback will be called when applying the force to the impostors. */
  27162. forceApplicationCallback: () => void;
  27163. }
  27164. }
  27165. declare module "babylonjs/Physics/physicsRaycastResult" {
  27166. import { Vector3 } from "babylonjs/Maths/math.vector";
  27167. /**
  27168. * Holds the data for the raycast result
  27169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27170. */
  27171. export class PhysicsRaycastResult {
  27172. private _hasHit;
  27173. private _hitDistance;
  27174. private _hitNormalWorld;
  27175. private _hitPointWorld;
  27176. private _rayFromWorld;
  27177. private _rayToWorld;
  27178. /**
  27179. * Gets if there was a hit
  27180. */
  27181. get hasHit(): boolean;
  27182. /**
  27183. * Gets the distance from the hit
  27184. */
  27185. get hitDistance(): number;
  27186. /**
  27187. * Gets the hit normal/direction in the world
  27188. */
  27189. get hitNormalWorld(): Vector3;
  27190. /**
  27191. * Gets the hit point in the world
  27192. */
  27193. get hitPointWorld(): Vector3;
  27194. /**
  27195. * Gets the ray "start point" of the ray in the world
  27196. */
  27197. get rayFromWorld(): Vector3;
  27198. /**
  27199. * Gets the ray "end point" of the ray in the world
  27200. */
  27201. get rayToWorld(): Vector3;
  27202. /**
  27203. * Sets the hit data (normal & point in world space)
  27204. * @param hitNormalWorld defines the normal in world space
  27205. * @param hitPointWorld defines the point in world space
  27206. */
  27207. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27208. /**
  27209. * Sets the distance from the start point to the hit point
  27210. * @param distance
  27211. */
  27212. setHitDistance(distance: number): void;
  27213. /**
  27214. * Calculates the distance manually
  27215. */
  27216. calculateHitDistance(): void;
  27217. /**
  27218. * Resets all the values to default
  27219. * @param from The from point on world space
  27220. * @param to The to point on world space
  27221. */
  27222. reset(from?: Vector3, to?: Vector3): void;
  27223. }
  27224. /**
  27225. * Interface for the size containing width and height
  27226. */
  27227. interface IXYZ {
  27228. /**
  27229. * X
  27230. */
  27231. x: number;
  27232. /**
  27233. * Y
  27234. */
  27235. y: number;
  27236. /**
  27237. * Z
  27238. */
  27239. z: number;
  27240. }
  27241. }
  27242. declare module "babylonjs/Physics/IPhysicsEngine" {
  27243. import { Nullable } from "babylonjs/types";
  27244. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27246. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27247. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27248. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27249. /**
  27250. * Interface used to describe a physics joint
  27251. */
  27252. export interface PhysicsImpostorJoint {
  27253. /** Defines the main impostor to which the joint is linked */
  27254. mainImpostor: PhysicsImpostor;
  27255. /** Defines the impostor that is connected to the main impostor using this joint */
  27256. connectedImpostor: PhysicsImpostor;
  27257. /** Defines the joint itself */
  27258. joint: PhysicsJoint;
  27259. }
  27260. /** @hidden */
  27261. export interface IPhysicsEnginePlugin {
  27262. world: any;
  27263. name: string;
  27264. setGravity(gravity: Vector3): void;
  27265. setTimeStep(timeStep: number): void;
  27266. getTimeStep(): number;
  27267. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27268. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27269. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27270. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27271. removePhysicsBody(impostor: PhysicsImpostor): void;
  27272. generateJoint(joint: PhysicsImpostorJoint): void;
  27273. removeJoint(joint: PhysicsImpostorJoint): void;
  27274. isSupported(): boolean;
  27275. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27276. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27277. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27278. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27279. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27280. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27281. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27282. getBodyMass(impostor: PhysicsImpostor): number;
  27283. getBodyFriction(impostor: PhysicsImpostor): number;
  27284. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27285. getBodyRestitution(impostor: PhysicsImpostor): number;
  27286. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27287. getBodyPressure?(impostor: PhysicsImpostor): number;
  27288. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27289. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27290. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27291. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27292. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27293. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27294. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27295. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27296. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27297. sleepBody(impostor: PhysicsImpostor): void;
  27298. wakeUpBody(impostor: PhysicsImpostor): void;
  27299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27300. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27301. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27302. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27303. getRadius(impostor: PhysicsImpostor): number;
  27304. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27305. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27306. dispose(): void;
  27307. }
  27308. /**
  27309. * Interface used to define a physics engine
  27310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27311. */
  27312. export interface IPhysicsEngine {
  27313. /**
  27314. * Gets the gravity vector used by the simulation
  27315. */
  27316. gravity: Vector3;
  27317. /**
  27318. * Sets the gravity vector used by the simulation
  27319. * @param gravity defines the gravity vector to use
  27320. */
  27321. setGravity(gravity: Vector3): void;
  27322. /**
  27323. * Set the time step of the physics engine.
  27324. * Default is 1/60.
  27325. * To slow it down, enter 1/600 for example.
  27326. * To speed it up, 1/30
  27327. * @param newTimeStep the new timestep to apply to this world.
  27328. */
  27329. setTimeStep(newTimeStep: number): void;
  27330. /**
  27331. * Get the time step of the physics engine.
  27332. * @returns the current time step
  27333. */
  27334. getTimeStep(): number;
  27335. /**
  27336. * Set the sub time step of the physics engine.
  27337. * Default is 0 meaning there is no sub steps
  27338. * To increase physics resolution precision, set a small value (like 1 ms)
  27339. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27340. */
  27341. setSubTimeStep(subTimeStep: number): void;
  27342. /**
  27343. * Get the sub time step of the physics engine.
  27344. * @returns the current sub time step
  27345. */
  27346. getSubTimeStep(): number;
  27347. /**
  27348. * Release all resources
  27349. */
  27350. dispose(): void;
  27351. /**
  27352. * Gets the name of the current physics plugin
  27353. * @returns the name of the plugin
  27354. */
  27355. getPhysicsPluginName(): string;
  27356. /**
  27357. * Adding a new impostor for the impostor tracking.
  27358. * This will be done by the impostor itself.
  27359. * @param impostor the impostor to add
  27360. */
  27361. addImpostor(impostor: PhysicsImpostor): void;
  27362. /**
  27363. * Remove an impostor from the engine.
  27364. * This impostor and its mesh will not longer be updated by the physics engine.
  27365. * @param impostor the impostor to remove
  27366. */
  27367. removeImpostor(impostor: PhysicsImpostor): void;
  27368. /**
  27369. * Add a joint to the physics engine
  27370. * @param mainImpostor defines the main impostor to which the joint is added.
  27371. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27372. * @param joint defines the joint that will connect both impostors.
  27373. */
  27374. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27375. /**
  27376. * Removes a joint from the simulation
  27377. * @param mainImpostor defines the impostor used with the joint
  27378. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27379. * @param joint defines the joint to remove
  27380. */
  27381. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27382. /**
  27383. * Gets the current plugin used to run the simulation
  27384. * @returns current plugin
  27385. */
  27386. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27387. /**
  27388. * Gets the list of physic impostors
  27389. * @returns an array of PhysicsImpostor
  27390. */
  27391. getImpostors(): Array<PhysicsImpostor>;
  27392. /**
  27393. * Gets the impostor for a physics enabled object
  27394. * @param object defines the object impersonated by the impostor
  27395. * @returns the PhysicsImpostor or null if not found
  27396. */
  27397. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27398. /**
  27399. * Gets the impostor for a physics body object
  27400. * @param body defines physics body used by the impostor
  27401. * @returns the PhysicsImpostor or null if not found
  27402. */
  27403. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27404. /**
  27405. * Does a raycast in the physics world
  27406. * @param from when should the ray start?
  27407. * @param to when should the ray end?
  27408. * @returns PhysicsRaycastResult
  27409. */
  27410. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27411. /**
  27412. * Called by the scene. No need to call it.
  27413. * @param delta defines the timespam between frames
  27414. */
  27415. _step(delta: number): void;
  27416. }
  27417. }
  27418. declare module "babylonjs/Physics/physicsImpostor" {
  27419. import { Nullable, IndicesArray } from "babylonjs/types";
  27420. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27421. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27423. import { Scene } from "babylonjs/scene";
  27424. import { Bone } from "babylonjs/Bones/bone";
  27425. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27426. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27427. import { Space } from "babylonjs/Maths/math.axis";
  27428. /**
  27429. * The interface for the physics imposter parameters
  27430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27431. */
  27432. export interface PhysicsImpostorParameters {
  27433. /**
  27434. * The mass of the physics imposter
  27435. */
  27436. mass: number;
  27437. /**
  27438. * The friction of the physics imposter
  27439. */
  27440. friction?: number;
  27441. /**
  27442. * The coefficient of restitution of the physics imposter
  27443. */
  27444. restitution?: number;
  27445. /**
  27446. * The native options of the physics imposter
  27447. */
  27448. nativeOptions?: any;
  27449. /**
  27450. * Specifies if the parent should be ignored
  27451. */
  27452. ignoreParent?: boolean;
  27453. /**
  27454. * Specifies if bi-directional transformations should be disabled
  27455. */
  27456. disableBidirectionalTransformation?: boolean;
  27457. /**
  27458. * The pressure inside the physics imposter, soft object only
  27459. */
  27460. pressure?: number;
  27461. /**
  27462. * The stiffness the physics imposter, soft object only
  27463. */
  27464. stiffness?: number;
  27465. /**
  27466. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27467. */
  27468. velocityIterations?: number;
  27469. /**
  27470. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27471. */
  27472. positionIterations?: number;
  27473. /**
  27474. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27475. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27476. * Add to fix multiple points
  27477. */
  27478. fixedPoints?: number;
  27479. /**
  27480. * The collision margin around a soft object
  27481. */
  27482. margin?: number;
  27483. /**
  27484. * The collision margin around a soft object
  27485. */
  27486. damping?: number;
  27487. /**
  27488. * The path for a rope based on an extrusion
  27489. */
  27490. path?: any;
  27491. /**
  27492. * The shape of an extrusion used for a rope based on an extrusion
  27493. */
  27494. shape?: any;
  27495. }
  27496. /**
  27497. * Interface for a physics-enabled object
  27498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27499. */
  27500. export interface IPhysicsEnabledObject {
  27501. /**
  27502. * The position of the physics-enabled object
  27503. */
  27504. position: Vector3;
  27505. /**
  27506. * The rotation of the physics-enabled object
  27507. */
  27508. rotationQuaternion: Nullable<Quaternion>;
  27509. /**
  27510. * The scale of the physics-enabled object
  27511. */
  27512. scaling: Vector3;
  27513. /**
  27514. * The rotation of the physics-enabled object
  27515. */
  27516. rotation?: Vector3;
  27517. /**
  27518. * The parent of the physics-enabled object
  27519. */
  27520. parent?: any;
  27521. /**
  27522. * The bounding info of the physics-enabled object
  27523. * @returns The bounding info of the physics-enabled object
  27524. */
  27525. getBoundingInfo(): BoundingInfo;
  27526. /**
  27527. * Computes the world matrix
  27528. * @param force Specifies if the world matrix should be computed by force
  27529. * @returns A world matrix
  27530. */
  27531. computeWorldMatrix(force: boolean): Matrix;
  27532. /**
  27533. * Gets the world matrix
  27534. * @returns A world matrix
  27535. */
  27536. getWorldMatrix?(): Matrix;
  27537. /**
  27538. * Gets the child meshes
  27539. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27540. * @returns An array of abstract meshes
  27541. */
  27542. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27543. /**
  27544. * Gets the vertex data
  27545. * @param kind The type of vertex data
  27546. * @returns A nullable array of numbers, or a float32 array
  27547. */
  27548. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27549. /**
  27550. * Gets the indices from the mesh
  27551. * @returns A nullable array of index arrays
  27552. */
  27553. getIndices?(): Nullable<IndicesArray>;
  27554. /**
  27555. * Gets the scene from the mesh
  27556. * @returns the indices array or null
  27557. */
  27558. getScene?(): Scene;
  27559. /**
  27560. * Gets the absolute position from the mesh
  27561. * @returns the absolute position
  27562. */
  27563. getAbsolutePosition(): Vector3;
  27564. /**
  27565. * Gets the absolute pivot point from the mesh
  27566. * @returns the absolute pivot point
  27567. */
  27568. getAbsolutePivotPoint(): Vector3;
  27569. /**
  27570. * Rotates the mesh
  27571. * @param axis The axis of rotation
  27572. * @param amount The amount of rotation
  27573. * @param space The space of the rotation
  27574. * @returns The rotation transform node
  27575. */
  27576. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27577. /**
  27578. * Translates the mesh
  27579. * @param axis The axis of translation
  27580. * @param distance The distance of translation
  27581. * @param space The space of the translation
  27582. * @returns The transform node
  27583. */
  27584. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27585. /**
  27586. * Sets the absolute position of the mesh
  27587. * @param absolutePosition The absolute position of the mesh
  27588. * @returns The transform node
  27589. */
  27590. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27591. /**
  27592. * Gets the class name of the mesh
  27593. * @returns The class name
  27594. */
  27595. getClassName(): string;
  27596. }
  27597. /**
  27598. * Represents a physics imposter
  27599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27600. */
  27601. export class PhysicsImpostor {
  27602. /**
  27603. * The physics-enabled object used as the physics imposter
  27604. */
  27605. object: IPhysicsEnabledObject;
  27606. /**
  27607. * The type of the physics imposter
  27608. */
  27609. type: number;
  27610. private _options;
  27611. private _scene?;
  27612. /**
  27613. * The default object size of the imposter
  27614. */
  27615. static DEFAULT_OBJECT_SIZE: Vector3;
  27616. /**
  27617. * The identity quaternion of the imposter
  27618. */
  27619. static IDENTITY_QUATERNION: Quaternion;
  27620. /** @hidden */
  27621. _pluginData: any;
  27622. private _physicsEngine;
  27623. private _physicsBody;
  27624. private _bodyUpdateRequired;
  27625. private _onBeforePhysicsStepCallbacks;
  27626. private _onAfterPhysicsStepCallbacks;
  27627. /** @hidden */
  27628. _onPhysicsCollideCallbacks: Array<{
  27629. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27630. otherImpostors: Array<PhysicsImpostor>;
  27631. }>;
  27632. private _deltaPosition;
  27633. private _deltaRotation;
  27634. private _deltaRotationConjugated;
  27635. /** @hidden */
  27636. _isFromLine: boolean;
  27637. private _parent;
  27638. private _isDisposed;
  27639. private static _tmpVecs;
  27640. private static _tmpQuat;
  27641. /**
  27642. * Specifies if the physics imposter is disposed
  27643. */
  27644. get isDisposed(): boolean;
  27645. /**
  27646. * Gets the mass of the physics imposter
  27647. */
  27648. get mass(): number;
  27649. set mass(value: number);
  27650. /**
  27651. * Gets the coefficient of friction
  27652. */
  27653. get friction(): number;
  27654. /**
  27655. * Sets the coefficient of friction
  27656. */
  27657. set friction(value: number);
  27658. /**
  27659. * Gets the coefficient of restitution
  27660. */
  27661. get restitution(): number;
  27662. /**
  27663. * Sets the coefficient of restitution
  27664. */
  27665. set restitution(value: number);
  27666. /**
  27667. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27668. */
  27669. get pressure(): number;
  27670. /**
  27671. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27672. */
  27673. set pressure(value: number);
  27674. /**
  27675. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27676. */
  27677. get stiffness(): number;
  27678. /**
  27679. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27680. */
  27681. set stiffness(value: number);
  27682. /**
  27683. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27684. */
  27685. get velocityIterations(): number;
  27686. /**
  27687. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27688. */
  27689. set velocityIterations(value: number);
  27690. /**
  27691. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27692. */
  27693. get positionIterations(): number;
  27694. /**
  27695. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27696. */
  27697. set positionIterations(value: number);
  27698. /**
  27699. * The unique id of the physics imposter
  27700. * set by the physics engine when adding this impostor to the array
  27701. */
  27702. uniqueId: number;
  27703. /**
  27704. * @hidden
  27705. */
  27706. soft: boolean;
  27707. /**
  27708. * @hidden
  27709. */
  27710. segments: number;
  27711. private _joints;
  27712. /**
  27713. * Initializes the physics imposter
  27714. * @param object The physics-enabled object used as the physics imposter
  27715. * @param type The type of the physics imposter
  27716. * @param _options The options for the physics imposter
  27717. * @param _scene The Babylon scene
  27718. */
  27719. constructor(
  27720. /**
  27721. * The physics-enabled object used as the physics imposter
  27722. */
  27723. object: IPhysicsEnabledObject,
  27724. /**
  27725. * The type of the physics imposter
  27726. */
  27727. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27728. /**
  27729. * This function will completly initialize this impostor.
  27730. * It will create a new body - but only if this mesh has no parent.
  27731. * If it has, this impostor will not be used other than to define the impostor
  27732. * of the child mesh.
  27733. * @hidden
  27734. */
  27735. _init(): void;
  27736. private _getPhysicsParent;
  27737. /**
  27738. * Should a new body be generated.
  27739. * @returns boolean specifying if body initialization is required
  27740. */
  27741. isBodyInitRequired(): boolean;
  27742. /**
  27743. * Sets the updated scaling
  27744. * @param updated Specifies if the scaling is updated
  27745. */
  27746. setScalingUpdated(): void;
  27747. /**
  27748. * Force a regeneration of this or the parent's impostor's body.
  27749. * Use under cautious - This will remove all joints already implemented.
  27750. */
  27751. forceUpdate(): void;
  27752. /**
  27753. * Gets the body that holds this impostor. Either its own, or its parent.
  27754. */
  27755. get physicsBody(): any;
  27756. /**
  27757. * Get the parent of the physics imposter
  27758. * @returns Physics imposter or null
  27759. */
  27760. get parent(): Nullable<PhysicsImpostor>;
  27761. /**
  27762. * Sets the parent of the physics imposter
  27763. */
  27764. set parent(value: Nullable<PhysicsImpostor>);
  27765. /**
  27766. * Set the physics body. Used mainly by the physics engine/plugin
  27767. */
  27768. set physicsBody(physicsBody: any);
  27769. /**
  27770. * Resets the update flags
  27771. */
  27772. resetUpdateFlags(): void;
  27773. /**
  27774. * Gets the object extend size
  27775. * @returns the object extend size
  27776. */
  27777. getObjectExtendSize(): Vector3;
  27778. /**
  27779. * Gets the object center
  27780. * @returns The object center
  27781. */
  27782. getObjectCenter(): Vector3;
  27783. /**
  27784. * Get a specific parameter from the options parameters
  27785. * @param paramName The object parameter name
  27786. * @returns The object parameter
  27787. */
  27788. getParam(paramName: string): any;
  27789. /**
  27790. * Sets a specific parameter in the options given to the physics plugin
  27791. * @param paramName The parameter name
  27792. * @param value The value of the parameter
  27793. */
  27794. setParam(paramName: string, value: number): void;
  27795. /**
  27796. * Specifically change the body's mass option. Won't recreate the physics body object
  27797. * @param mass The mass of the physics imposter
  27798. */
  27799. setMass(mass: number): void;
  27800. /**
  27801. * Gets the linear velocity
  27802. * @returns linear velocity or null
  27803. */
  27804. getLinearVelocity(): Nullable<Vector3>;
  27805. /**
  27806. * Sets the linear velocity
  27807. * @param velocity linear velocity or null
  27808. */
  27809. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27810. /**
  27811. * Gets the angular velocity
  27812. * @returns angular velocity or null
  27813. */
  27814. getAngularVelocity(): Nullable<Vector3>;
  27815. /**
  27816. * Sets the angular velocity
  27817. * @param velocity The velocity or null
  27818. */
  27819. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27820. /**
  27821. * Execute a function with the physics plugin native code
  27822. * Provide a function the will have two variables - the world object and the physics body object
  27823. * @param func The function to execute with the physics plugin native code
  27824. */
  27825. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27826. /**
  27827. * Register a function that will be executed before the physics world is stepping forward
  27828. * @param func The function to execute before the physics world is stepped forward
  27829. */
  27830. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27831. /**
  27832. * Unregister a function that will be executed before the physics world is stepping forward
  27833. * @param func The function to execute before the physics world is stepped forward
  27834. */
  27835. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27836. /**
  27837. * Register a function that will be executed after the physics step
  27838. * @param func The function to execute after physics step
  27839. */
  27840. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27841. /**
  27842. * Unregisters a function that will be executed after the physics step
  27843. * @param func The function to execute after physics step
  27844. */
  27845. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27846. /**
  27847. * register a function that will be executed when this impostor collides against a different body
  27848. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27849. * @param func Callback that is executed on collision
  27850. */
  27851. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27852. /**
  27853. * Unregisters the physics imposter on contact
  27854. * @param collideAgainst The physics object to collide against
  27855. * @param func Callback to execute on collision
  27856. */
  27857. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27858. private _tmpQuat;
  27859. private _tmpQuat2;
  27860. /**
  27861. * Get the parent rotation
  27862. * @returns The parent rotation
  27863. */
  27864. getParentsRotation(): Quaternion;
  27865. /**
  27866. * this function is executed by the physics engine.
  27867. */
  27868. beforeStep: () => void;
  27869. /**
  27870. * this function is executed by the physics engine
  27871. */
  27872. afterStep: () => void;
  27873. /**
  27874. * Legacy collision detection event support
  27875. */
  27876. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27877. /**
  27878. * event and body object due to cannon's event-based architecture.
  27879. */
  27880. onCollide: (e: {
  27881. body: any;
  27882. }) => void;
  27883. /**
  27884. * Apply a force
  27885. * @param force The force to apply
  27886. * @param contactPoint The contact point for the force
  27887. * @returns The physics imposter
  27888. */
  27889. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27890. /**
  27891. * Apply an impulse
  27892. * @param force The impulse force
  27893. * @param contactPoint The contact point for the impulse force
  27894. * @returns The physics imposter
  27895. */
  27896. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27897. /**
  27898. * A help function to create a joint
  27899. * @param otherImpostor A physics imposter used to create a joint
  27900. * @param jointType The type of joint
  27901. * @param jointData The data for the joint
  27902. * @returns The physics imposter
  27903. */
  27904. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27905. /**
  27906. * Add a joint to this impostor with a different impostor
  27907. * @param otherImpostor A physics imposter used to add a joint
  27908. * @param joint The joint to add
  27909. * @returns The physics imposter
  27910. */
  27911. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27912. /**
  27913. * Add an anchor to a cloth impostor
  27914. * @param otherImpostor rigid impostor to anchor to
  27915. * @param width ratio across width from 0 to 1
  27916. * @param height ratio up height from 0 to 1
  27917. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27918. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27919. * @returns impostor the soft imposter
  27920. */
  27921. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27922. /**
  27923. * Add a hook to a rope impostor
  27924. * @param otherImpostor rigid impostor to anchor to
  27925. * @param length ratio across rope from 0 to 1
  27926. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27927. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27928. * @returns impostor the rope imposter
  27929. */
  27930. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27931. /**
  27932. * Will keep this body still, in a sleep mode.
  27933. * @returns the physics imposter
  27934. */
  27935. sleep(): PhysicsImpostor;
  27936. /**
  27937. * Wake the body up.
  27938. * @returns The physics imposter
  27939. */
  27940. wakeUp(): PhysicsImpostor;
  27941. /**
  27942. * Clones the physics imposter
  27943. * @param newObject The physics imposter clones to this physics-enabled object
  27944. * @returns A nullable physics imposter
  27945. */
  27946. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27947. /**
  27948. * Disposes the physics imposter
  27949. */
  27950. dispose(): void;
  27951. /**
  27952. * Sets the delta position
  27953. * @param position The delta position amount
  27954. */
  27955. setDeltaPosition(position: Vector3): void;
  27956. /**
  27957. * Sets the delta rotation
  27958. * @param rotation The delta rotation amount
  27959. */
  27960. setDeltaRotation(rotation: Quaternion): void;
  27961. /**
  27962. * Gets the box size of the physics imposter and stores the result in the input parameter
  27963. * @param result Stores the box size
  27964. * @returns The physics imposter
  27965. */
  27966. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27967. /**
  27968. * Gets the radius of the physics imposter
  27969. * @returns Radius of the physics imposter
  27970. */
  27971. getRadius(): number;
  27972. /**
  27973. * Sync a bone with this impostor
  27974. * @param bone The bone to sync to the impostor.
  27975. * @param boneMesh The mesh that the bone is influencing.
  27976. * @param jointPivot The pivot of the joint / bone in local space.
  27977. * @param distToJoint Optional distance from the impostor to the joint.
  27978. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27979. */
  27980. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27981. /**
  27982. * Sync impostor to a bone
  27983. * @param bone The bone that the impostor will be synced to.
  27984. * @param boneMesh The mesh that the bone is influencing.
  27985. * @param jointPivot The pivot of the joint / bone in local space.
  27986. * @param distToJoint Optional distance from the impostor to the joint.
  27987. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27988. * @param boneAxis Optional vector3 axis the bone is aligned with
  27989. */
  27990. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27991. /**
  27992. * No-Imposter type
  27993. */
  27994. static NoImpostor: number;
  27995. /**
  27996. * Sphere-Imposter type
  27997. */
  27998. static SphereImpostor: number;
  27999. /**
  28000. * Box-Imposter type
  28001. */
  28002. static BoxImpostor: number;
  28003. /**
  28004. * Plane-Imposter type
  28005. */
  28006. static PlaneImpostor: number;
  28007. /**
  28008. * Mesh-imposter type
  28009. */
  28010. static MeshImpostor: number;
  28011. /**
  28012. * Capsule-Impostor type (Ammo.js plugin only)
  28013. */
  28014. static CapsuleImpostor: number;
  28015. /**
  28016. * Cylinder-Imposter type
  28017. */
  28018. static CylinderImpostor: number;
  28019. /**
  28020. * Particle-Imposter type
  28021. */
  28022. static ParticleImpostor: number;
  28023. /**
  28024. * Heightmap-Imposter type
  28025. */
  28026. static HeightmapImpostor: number;
  28027. /**
  28028. * ConvexHull-Impostor type (Ammo.js plugin only)
  28029. */
  28030. static ConvexHullImpostor: number;
  28031. /**
  28032. * Custom-Imposter type (Ammo.js plugin only)
  28033. */
  28034. static CustomImpostor: number;
  28035. /**
  28036. * Rope-Imposter type
  28037. */
  28038. static RopeImpostor: number;
  28039. /**
  28040. * Cloth-Imposter type
  28041. */
  28042. static ClothImpostor: number;
  28043. /**
  28044. * Softbody-Imposter type
  28045. */
  28046. static SoftbodyImpostor: number;
  28047. }
  28048. }
  28049. declare module "babylonjs/Meshes/mesh" {
  28050. import { Observable } from "babylonjs/Misc/observable";
  28051. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28052. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28053. import { Camera } from "babylonjs/Cameras/camera";
  28054. import { Scene } from "babylonjs/scene";
  28055. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28056. import { Color4 } from "babylonjs/Maths/math.color";
  28057. import { Engine } from "babylonjs/Engines/engine";
  28058. import { Node } from "babylonjs/node";
  28059. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28060. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28061. import { Buffer } from "babylonjs/Meshes/buffer";
  28062. import { Geometry } from "babylonjs/Meshes/geometry";
  28063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28064. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28065. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28066. import { Effect } from "babylonjs/Materials/effect";
  28067. import { Material } from "babylonjs/Materials/material";
  28068. import { Skeleton } from "babylonjs/Bones/skeleton";
  28069. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28070. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28071. import { Path3D } from "babylonjs/Maths/math.path";
  28072. import { Plane } from "babylonjs/Maths/math.plane";
  28073. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28074. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28075. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28076. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28077. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28078. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28079. /**
  28080. * @hidden
  28081. **/
  28082. export class _CreationDataStorage {
  28083. closePath?: boolean;
  28084. closeArray?: boolean;
  28085. idx: number[];
  28086. dashSize: number;
  28087. gapSize: number;
  28088. path3D: Path3D;
  28089. pathArray: Vector3[][];
  28090. arc: number;
  28091. radius: number;
  28092. cap: number;
  28093. tessellation: number;
  28094. }
  28095. /**
  28096. * @hidden
  28097. **/
  28098. class _InstanceDataStorage {
  28099. visibleInstances: any;
  28100. batchCache: _InstancesBatch;
  28101. instancesBufferSize: number;
  28102. instancesBuffer: Nullable<Buffer>;
  28103. instancesData: Float32Array;
  28104. overridenInstanceCount: number;
  28105. isFrozen: boolean;
  28106. previousBatch: Nullable<_InstancesBatch>;
  28107. hardwareInstancedRendering: boolean;
  28108. sideOrientation: number;
  28109. manualUpdate: boolean;
  28110. }
  28111. /**
  28112. * @hidden
  28113. **/
  28114. export class _InstancesBatch {
  28115. mustReturn: boolean;
  28116. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28117. renderSelf: boolean[];
  28118. hardwareInstancedRendering: boolean[];
  28119. }
  28120. /**
  28121. * @hidden
  28122. **/
  28123. class _ThinInstanceDataStorage {
  28124. instancesCount: number;
  28125. matrixBuffer: Nullable<Buffer>;
  28126. matrixBufferSize: number;
  28127. matrixData: Nullable<Float32Array>;
  28128. boundingVectors: Array<Vector3>;
  28129. }
  28130. /**
  28131. * Class used to represent renderable models
  28132. */
  28133. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28134. /**
  28135. * Mesh side orientation : usually the external or front surface
  28136. */
  28137. static readonly FRONTSIDE: number;
  28138. /**
  28139. * Mesh side orientation : usually the internal or back surface
  28140. */
  28141. static readonly BACKSIDE: number;
  28142. /**
  28143. * Mesh side orientation : both internal and external or front and back surfaces
  28144. */
  28145. static readonly DOUBLESIDE: number;
  28146. /**
  28147. * Mesh side orientation : by default, `FRONTSIDE`
  28148. */
  28149. static readonly DEFAULTSIDE: number;
  28150. /**
  28151. * Mesh cap setting : no cap
  28152. */
  28153. static readonly NO_CAP: number;
  28154. /**
  28155. * Mesh cap setting : one cap at the beginning of the mesh
  28156. */
  28157. static readonly CAP_START: number;
  28158. /**
  28159. * Mesh cap setting : one cap at the end of the mesh
  28160. */
  28161. static readonly CAP_END: number;
  28162. /**
  28163. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28164. */
  28165. static readonly CAP_ALL: number;
  28166. /**
  28167. * Mesh pattern setting : no flip or rotate
  28168. */
  28169. static readonly NO_FLIP: number;
  28170. /**
  28171. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28172. */
  28173. static readonly FLIP_TILE: number;
  28174. /**
  28175. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28176. */
  28177. static readonly ROTATE_TILE: number;
  28178. /**
  28179. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28180. */
  28181. static readonly FLIP_ROW: number;
  28182. /**
  28183. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28184. */
  28185. static readonly ROTATE_ROW: number;
  28186. /**
  28187. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28188. */
  28189. static readonly FLIP_N_ROTATE_TILE: number;
  28190. /**
  28191. * Mesh pattern setting : rotate pattern and rotate
  28192. */
  28193. static readonly FLIP_N_ROTATE_ROW: number;
  28194. /**
  28195. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28196. */
  28197. static readonly CENTER: number;
  28198. /**
  28199. * Mesh tile positioning : part tiles on left
  28200. */
  28201. static readonly LEFT: number;
  28202. /**
  28203. * Mesh tile positioning : part tiles on right
  28204. */
  28205. static readonly RIGHT: number;
  28206. /**
  28207. * Mesh tile positioning : part tiles on top
  28208. */
  28209. static readonly TOP: number;
  28210. /**
  28211. * Mesh tile positioning : part tiles on bottom
  28212. */
  28213. static readonly BOTTOM: number;
  28214. /**
  28215. * Gets the default side orientation.
  28216. * @param orientation the orientation to value to attempt to get
  28217. * @returns the default orientation
  28218. * @hidden
  28219. */
  28220. static _GetDefaultSideOrientation(orientation?: number): number;
  28221. private _internalMeshDataInfo;
  28222. /**
  28223. * An event triggered before rendering the mesh
  28224. */
  28225. get onBeforeRenderObservable(): Observable<Mesh>;
  28226. /**
  28227. * An event triggered before binding the mesh
  28228. */
  28229. get onBeforeBindObservable(): Observable<Mesh>;
  28230. /**
  28231. * An event triggered after rendering the mesh
  28232. */
  28233. get onAfterRenderObservable(): Observable<Mesh>;
  28234. /**
  28235. * An event triggered before drawing the mesh
  28236. */
  28237. get onBeforeDrawObservable(): Observable<Mesh>;
  28238. private _onBeforeDrawObserver;
  28239. /**
  28240. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28241. */
  28242. set onBeforeDraw(callback: () => void);
  28243. get hasInstances(): boolean;
  28244. get hasThinInstances(): boolean;
  28245. /**
  28246. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28247. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28248. */
  28249. delayLoadState: number;
  28250. /**
  28251. * Gets the list of instances created from this mesh
  28252. * it is not supposed to be modified manually.
  28253. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28254. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28255. */
  28256. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28257. /**
  28258. * Gets the file containing delay loading data for this mesh
  28259. */
  28260. delayLoadingFile: string;
  28261. /** @hidden */
  28262. _binaryInfo: any;
  28263. /**
  28264. * User defined function used to change how LOD level selection is done
  28265. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28266. */
  28267. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28268. /**
  28269. * Gets or sets the morph target manager
  28270. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28271. */
  28272. get morphTargetManager(): Nullable<MorphTargetManager>;
  28273. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28274. /** @hidden */
  28275. _creationDataStorage: Nullable<_CreationDataStorage>;
  28276. /** @hidden */
  28277. _geometry: Nullable<Geometry>;
  28278. /** @hidden */
  28279. _delayInfo: Array<string>;
  28280. /** @hidden */
  28281. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28282. /** @hidden */
  28283. _instanceDataStorage: _InstanceDataStorage;
  28284. /** @hidden */
  28285. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28286. private _effectiveMaterial;
  28287. /** @hidden */
  28288. _shouldGenerateFlatShading: boolean;
  28289. /** @hidden */
  28290. _originalBuilderSideOrientation: number;
  28291. /**
  28292. * Use this property to change the original side orientation defined at construction time
  28293. */
  28294. overrideMaterialSideOrientation: Nullable<number>;
  28295. /**
  28296. * Gets the source mesh (the one used to clone this one from)
  28297. */
  28298. get source(): Nullable<Mesh>;
  28299. /**
  28300. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28301. */
  28302. get isUnIndexed(): boolean;
  28303. set isUnIndexed(value: boolean);
  28304. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28305. get worldMatrixInstancedBuffer(): Float32Array;
  28306. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28307. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28308. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28309. /**
  28310. * @constructor
  28311. * @param name The value used by scene.getMeshByName() to do a lookup.
  28312. * @param scene The scene to add this mesh to.
  28313. * @param parent The parent of this mesh, if it has one
  28314. * @param source An optional Mesh from which geometry is shared, cloned.
  28315. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28316. * When false, achieved by calling a clone(), also passing False.
  28317. * This will make creation of children, recursive.
  28318. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28319. */
  28320. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28321. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28322. doNotInstantiate: boolean;
  28323. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28324. /**
  28325. * Gets the class name
  28326. * @returns the string "Mesh".
  28327. */
  28328. getClassName(): string;
  28329. /** @hidden */
  28330. get _isMesh(): boolean;
  28331. /**
  28332. * Returns a description of this mesh
  28333. * @param fullDetails define if full details about this mesh must be used
  28334. * @returns a descriptive string representing this mesh
  28335. */
  28336. toString(fullDetails?: boolean): string;
  28337. /** @hidden */
  28338. _unBindEffect(): void;
  28339. /**
  28340. * Gets a boolean indicating if this mesh has LOD
  28341. */
  28342. get hasLODLevels(): boolean;
  28343. /**
  28344. * Gets the list of MeshLODLevel associated with the current mesh
  28345. * @returns an array of MeshLODLevel
  28346. */
  28347. getLODLevels(): MeshLODLevel[];
  28348. private _sortLODLevels;
  28349. /**
  28350. * Add a mesh as LOD level triggered at the given distance.
  28351. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28352. * @param distance The distance from the center of the object to show this level
  28353. * @param mesh The mesh to be added as LOD level (can be null)
  28354. * @return This mesh (for chaining)
  28355. */
  28356. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28357. /**
  28358. * Returns the LOD level mesh at the passed distance or null if not found.
  28359. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28360. * @param distance The distance from the center of the object to show this level
  28361. * @returns a Mesh or `null`
  28362. */
  28363. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28364. /**
  28365. * Remove a mesh from the LOD array
  28366. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28367. * @param mesh defines the mesh to be removed
  28368. * @return This mesh (for chaining)
  28369. */
  28370. removeLODLevel(mesh: Mesh): Mesh;
  28371. /**
  28372. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28373. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28374. * @param camera defines the camera to use to compute distance
  28375. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28376. * @return This mesh (for chaining)
  28377. */
  28378. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28379. /**
  28380. * Gets the mesh internal Geometry object
  28381. */
  28382. get geometry(): Nullable<Geometry>;
  28383. /**
  28384. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28385. * @returns the total number of vertices
  28386. */
  28387. getTotalVertices(): number;
  28388. /**
  28389. * Returns the content of an associated vertex buffer
  28390. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28391. * - VertexBuffer.PositionKind
  28392. * - VertexBuffer.UVKind
  28393. * - VertexBuffer.UV2Kind
  28394. * - VertexBuffer.UV3Kind
  28395. * - VertexBuffer.UV4Kind
  28396. * - VertexBuffer.UV5Kind
  28397. * - VertexBuffer.UV6Kind
  28398. * - VertexBuffer.ColorKind
  28399. * - VertexBuffer.MatricesIndicesKind
  28400. * - VertexBuffer.MatricesIndicesExtraKind
  28401. * - VertexBuffer.MatricesWeightsKind
  28402. * - VertexBuffer.MatricesWeightsExtraKind
  28403. * @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
  28404. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28405. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28406. */
  28407. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28408. /**
  28409. * Returns the mesh VertexBuffer object from the requested `kind`
  28410. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28411. * - VertexBuffer.PositionKind
  28412. * - VertexBuffer.NormalKind
  28413. * - VertexBuffer.UVKind
  28414. * - VertexBuffer.UV2Kind
  28415. * - VertexBuffer.UV3Kind
  28416. * - VertexBuffer.UV4Kind
  28417. * - VertexBuffer.UV5Kind
  28418. * - VertexBuffer.UV6Kind
  28419. * - VertexBuffer.ColorKind
  28420. * - VertexBuffer.MatricesIndicesKind
  28421. * - VertexBuffer.MatricesIndicesExtraKind
  28422. * - VertexBuffer.MatricesWeightsKind
  28423. * - VertexBuffer.MatricesWeightsExtraKind
  28424. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28425. */
  28426. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28427. /**
  28428. * Tests if a specific vertex buffer is associated with this mesh
  28429. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28430. * - VertexBuffer.PositionKind
  28431. * - VertexBuffer.NormalKind
  28432. * - VertexBuffer.UVKind
  28433. * - VertexBuffer.UV2Kind
  28434. * - VertexBuffer.UV3Kind
  28435. * - VertexBuffer.UV4Kind
  28436. * - VertexBuffer.UV5Kind
  28437. * - VertexBuffer.UV6Kind
  28438. * - VertexBuffer.ColorKind
  28439. * - VertexBuffer.MatricesIndicesKind
  28440. * - VertexBuffer.MatricesIndicesExtraKind
  28441. * - VertexBuffer.MatricesWeightsKind
  28442. * - VertexBuffer.MatricesWeightsExtraKind
  28443. * @returns a boolean
  28444. */
  28445. isVerticesDataPresent(kind: string): boolean;
  28446. /**
  28447. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28448. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28449. * - VertexBuffer.PositionKind
  28450. * - VertexBuffer.UVKind
  28451. * - VertexBuffer.UV2Kind
  28452. * - VertexBuffer.UV3Kind
  28453. * - VertexBuffer.UV4Kind
  28454. * - VertexBuffer.UV5Kind
  28455. * - VertexBuffer.UV6Kind
  28456. * - VertexBuffer.ColorKind
  28457. * - VertexBuffer.MatricesIndicesKind
  28458. * - VertexBuffer.MatricesIndicesExtraKind
  28459. * - VertexBuffer.MatricesWeightsKind
  28460. * - VertexBuffer.MatricesWeightsExtraKind
  28461. * @returns a boolean
  28462. */
  28463. isVertexBufferUpdatable(kind: string): boolean;
  28464. /**
  28465. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28466. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28467. * - VertexBuffer.PositionKind
  28468. * - VertexBuffer.NormalKind
  28469. * - VertexBuffer.UVKind
  28470. * - VertexBuffer.UV2Kind
  28471. * - VertexBuffer.UV3Kind
  28472. * - VertexBuffer.UV4Kind
  28473. * - VertexBuffer.UV5Kind
  28474. * - VertexBuffer.UV6Kind
  28475. * - VertexBuffer.ColorKind
  28476. * - VertexBuffer.MatricesIndicesKind
  28477. * - VertexBuffer.MatricesIndicesExtraKind
  28478. * - VertexBuffer.MatricesWeightsKind
  28479. * - VertexBuffer.MatricesWeightsExtraKind
  28480. * @returns an array of strings
  28481. */
  28482. getVerticesDataKinds(): string[];
  28483. /**
  28484. * Returns a positive integer : the total number of indices in this mesh geometry.
  28485. * @returns the numner of indices or zero if the mesh has no geometry.
  28486. */
  28487. getTotalIndices(): number;
  28488. /**
  28489. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28490. * @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.
  28491. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28492. * @returns the indices array or an empty array if the mesh has no geometry
  28493. */
  28494. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28495. get isBlocked(): boolean;
  28496. /**
  28497. * Determine if the current mesh is ready to be rendered
  28498. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28499. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28500. * @returns true if all associated assets are ready (material, textures, shaders)
  28501. */
  28502. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28503. /**
  28504. * 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.
  28505. */
  28506. get areNormalsFrozen(): boolean;
  28507. /**
  28508. * 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.
  28509. * @returns the current mesh
  28510. */
  28511. freezeNormals(): Mesh;
  28512. /**
  28513. * 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
  28514. * @returns the current mesh
  28515. */
  28516. unfreezeNormals(): Mesh;
  28517. /**
  28518. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28519. */
  28520. set overridenInstanceCount(count: number);
  28521. /** @hidden */
  28522. _preActivate(): Mesh;
  28523. /** @hidden */
  28524. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28525. /** @hidden */
  28526. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28527. protected _afterComputeWorldMatrix(): void;
  28528. /** @hidden */
  28529. _postActivate(): void;
  28530. /**
  28531. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28532. * This means the mesh underlying bounding box and sphere are recomputed.
  28533. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28534. * @returns the current mesh
  28535. */
  28536. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28537. /** @hidden */
  28538. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28539. /**
  28540. * This function will subdivide the mesh into multiple submeshes
  28541. * @param count defines the expected number of submeshes
  28542. */
  28543. subdivide(count: number): void;
  28544. /**
  28545. * Copy a FloatArray into a specific associated vertex buffer
  28546. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28547. * - VertexBuffer.PositionKind
  28548. * - VertexBuffer.UVKind
  28549. * - VertexBuffer.UV2Kind
  28550. * - VertexBuffer.UV3Kind
  28551. * - VertexBuffer.UV4Kind
  28552. * - VertexBuffer.UV5Kind
  28553. * - VertexBuffer.UV6Kind
  28554. * - VertexBuffer.ColorKind
  28555. * - VertexBuffer.MatricesIndicesKind
  28556. * - VertexBuffer.MatricesIndicesExtraKind
  28557. * - VertexBuffer.MatricesWeightsKind
  28558. * - VertexBuffer.MatricesWeightsExtraKind
  28559. * @param data defines the data source
  28560. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28561. * @param stride defines the data stride size (can be null)
  28562. * @returns the current mesh
  28563. */
  28564. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28565. /**
  28566. * Delete a vertex buffer associated with this mesh
  28567. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28568. * - VertexBuffer.PositionKind
  28569. * - VertexBuffer.UVKind
  28570. * - VertexBuffer.UV2Kind
  28571. * - VertexBuffer.UV3Kind
  28572. * - VertexBuffer.UV4Kind
  28573. * - VertexBuffer.UV5Kind
  28574. * - VertexBuffer.UV6Kind
  28575. * - VertexBuffer.ColorKind
  28576. * - VertexBuffer.MatricesIndicesKind
  28577. * - VertexBuffer.MatricesIndicesExtraKind
  28578. * - VertexBuffer.MatricesWeightsKind
  28579. * - VertexBuffer.MatricesWeightsExtraKind
  28580. */
  28581. removeVerticesData(kind: string): void;
  28582. /**
  28583. * Flags an associated vertex buffer as updatable
  28584. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28585. * - VertexBuffer.PositionKind
  28586. * - VertexBuffer.UVKind
  28587. * - VertexBuffer.UV2Kind
  28588. * - VertexBuffer.UV3Kind
  28589. * - VertexBuffer.UV4Kind
  28590. * - VertexBuffer.UV5Kind
  28591. * - VertexBuffer.UV6Kind
  28592. * - VertexBuffer.ColorKind
  28593. * - VertexBuffer.MatricesIndicesKind
  28594. * - VertexBuffer.MatricesIndicesExtraKind
  28595. * - VertexBuffer.MatricesWeightsKind
  28596. * - VertexBuffer.MatricesWeightsExtraKind
  28597. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28598. */
  28599. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28600. /**
  28601. * Sets the mesh global Vertex Buffer
  28602. * @param buffer defines the buffer to use
  28603. * @returns the current mesh
  28604. */
  28605. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28606. /**
  28607. * Update a specific associated vertex buffer
  28608. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28609. * - VertexBuffer.PositionKind
  28610. * - VertexBuffer.UVKind
  28611. * - VertexBuffer.UV2Kind
  28612. * - VertexBuffer.UV3Kind
  28613. * - VertexBuffer.UV4Kind
  28614. * - VertexBuffer.UV5Kind
  28615. * - VertexBuffer.UV6Kind
  28616. * - VertexBuffer.ColorKind
  28617. * - VertexBuffer.MatricesIndicesKind
  28618. * - VertexBuffer.MatricesIndicesExtraKind
  28619. * - VertexBuffer.MatricesWeightsKind
  28620. * - VertexBuffer.MatricesWeightsExtraKind
  28621. * @param data defines the data source
  28622. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28623. * @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)
  28624. * @returns the current mesh
  28625. */
  28626. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28627. /**
  28628. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28629. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28630. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28631. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28632. * @returns the current mesh
  28633. */
  28634. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28635. /**
  28636. * Creates a un-shared specific occurence of the geometry for the mesh.
  28637. * @returns the current mesh
  28638. */
  28639. makeGeometryUnique(): Mesh;
  28640. /**
  28641. * Set the index buffer of this mesh
  28642. * @param indices defines the source data
  28643. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28644. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28645. * @returns the current mesh
  28646. */
  28647. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28648. /**
  28649. * Update the current index buffer
  28650. * @param indices defines the source data
  28651. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28652. * @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)
  28653. * @returns the current mesh
  28654. */
  28655. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28656. /**
  28657. * Invert the geometry to move from a right handed system to a left handed one.
  28658. * @returns the current mesh
  28659. */
  28660. toLeftHanded(): Mesh;
  28661. /** @hidden */
  28662. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28663. /** @hidden */
  28664. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28665. /**
  28666. * Registers for this mesh a javascript function called just before the rendering process
  28667. * @param func defines the function to call before rendering this mesh
  28668. * @returns the current mesh
  28669. */
  28670. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28671. /**
  28672. * Disposes a previously registered javascript function called before the rendering
  28673. * @param func defines the function to remove
  28674. * @returns the current mesh
  28675. */
  28676. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28677. /**
  28678. * Registers for this mesh a javascript function called just after the rendering is complete
  28679. * @param func defines the function to call after rendering this mesh
  28680. * @returns the current mesh
  28681. */
  28682. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28683. /**
  28684. * Disposes a previously registered javascript function called after the rendering.
  28685. * @param func defines the function to remove
  28686. * @returns the current mesh
  28687. */
  28688. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28689. /** @hidden */
  28690. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28691. /** @hidden */
  28692. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28693. /** @hidden */
  28694. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28695. /** @hidden */
  28696. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28697. /** @hidden */
  28698. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28699. /** @hidden */
  28700. _rebuild(): void;
  28701. /** @hidden */
  28702. _freeze(): void;
  28703. /** @hidden */
  28704. _unFreeze(): void;
  28705. /**
  28706. * 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
  28707. * @param subMesh defines the subMesh to render
  28708. * @param enableAlphaMode defines if alpha mode can be changed
  28709. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28710. * @returns the current mesh
  28711. */
  28712. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28713. private _onBeforeDraw;
  28714. /**
  28715. * Renormalize the mesh and patch it up if there are no weights
  28716. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28717. * However in the case of zero weights then we set just a single influence to 1.
  28718. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28719. */
  28720. cleanMatrixWeights(): void;
  28721. private normalizeSkinFourWeights;
  28722. private normalizeSkinWeightsAndExtra;
  28723. /**
  28724. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28725. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28726. * the user know there was an issue with importing the mesh
  28727. * @returns a validation object with skinned, valid and report string
  28728. */
  28729. validateSkinning(): {
  28730. skinned: boolean;
  28731. valid: boolean;
  28732. report: string;
  28733. };
  28734. /** @hidden */
  28735. _checkDelayState(): Mesh;
  28736. private _queueLoad;
  28737. /**
  28738. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28739. * A mesh is in the frustum if its bounding box intersects the frustum
  28740. * @param frustumPlanes defines the frustum to test
  28741. * @returns true if the mesh is in the frustum planes
  28742. */
  28743. isInFrustum(frustumPlanes: Plane[]): boolean;
  28744. /**
  28745. * Sets the mesh material by the material or multiMaterial `id` property
  28746. * @param id is a string identifying the material or the multiMaterial
  28747. * @returns the current mesh
  28748. */
  28749. setMaterialByID(id: string): Mesh;
  28750. /**
  28751. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28752. * @returns an array of IAnimatable
  28753. */
  28754. getAnimatables(): IAnimatable[];
  28755. /**
  28756. * Modifies the mesh geometry according to the passed transformation matrix.
  28757. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28758. * The mesh normals are modified using the same transformation.
  28759. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28760. * @param transform defines the transform matrix to use
  28761. * @see https://doc.babylonjs.com/resources/baking_transformations
  28762. * @returns the current mesh
  28763. */
  28764. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28765. /**
  28766. * Modifies the mesh geometry according to its own current World Matrix.
  28767. * The mesh World Matrix is then reset.
  28768. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28769. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28770. * @see https://doc.babylonjs.com/resources/baking_transformations
  28771. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28772. * @returns the current mesh
  28773. */
  28774. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28775. /** @hidden */
  28776. get _positions(): Nullable<Vector3[]>;
  28777. /** @hidden */
  28778. _resetPointsArrayCache(): Mesh;
  28779. /** @hidden */
  28780. _generatePointsArray(): boolean;
  28781. /**
  28782. * Returns a new Mesh object generated from the current mesh properties.
  28783. * This method must not get confused with createInstance()
  28784. * @param name is a string, the name given to the new mesh
  28785. * @param newParent can be any Node object (default `null`)
  28786. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28787. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28788. * @returns a new mesh
  28789. */
  28790. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28791. /**
  28792. * Releases resources associated with this mesh.
  28793. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28794. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28795. */
  28796. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28797. /** @hidden */
  28798. _disposeInstanceSpecificData(): void;
  28799. /** @hidden */
  28800. _disposeThinInstanceSpecificData(): void;
  28801. /**
  28802. * Modifies the mesh geometry according to a displacement map.
  28803. * 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.
  28804. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28805. * @param url is a string, the URL from the image file is to be downloaded.
  28806. * @param minHeight is the lower limit of the displacement.
  28807. * @param maxHeight is the upper limit of the displacement.
  28808. * @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.
  28809. * @param uvOffset is an optional vector2 used to offset UV.
  28810. * @param uvScale is an optional vector2 used to scale UV.
  28811. * @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.
  28812. * @returns the Mesh.
  28813. */
  28814. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28815. /**
  28816. * Modifies the mesh geometry according to a displacementMap buffer.
  28817. * 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.
  28818. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28819. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28820. * @param heightMapWidth is the width of the buffer image.
  28821. * @param heightMapHeight is the height of the buffer image.
  28822. * @param minHeight is the lower limit of the displacement.
  28823. * @param maxHeight is the upper limit of the displacement.
  28824. * @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.
  28825. * @param uvOffset is an optional vector2 used to offset UV.
  28826. * @param uvScale is an optional vector2 used to scale UV.
  28827. * @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.
  28828. * @returns the Mesh.
  28829. */
  28830. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28831. /**
  28832. * Modify the mesh to get a flat shading rendering.
  28833. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28834. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28835. * @returns current mesh
  28836. */
  28837. convertToFlatShadedMesh(): Mesh;
  28838. /**
  28839. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28840. * In other words, more vertices, no more indices and a single bigger VBO.
  28841. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28842. * @returns current mesh
  28843. */
  28844. convertToUnIndexedMesh(): Mesh;
  28845. /**
  28846. * Inverses facet orientations.
  28847. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28848. * @param flipNormals will also inverts the normals
  28849. * @returns current mesh
  28850. */
  28851. flipFaces(flipNormals?: boolean): Mesh;
  28852. /**
  28853. * Increase the number of facets and hence vertices in a mesh
  28854. * Vertex normals are interpolated from existing vertex normals
  28855. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28856. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28857. */
  28858. increaseVertices(numberPerEdge: number): void;
  28859. /**
  28860. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28861. * This will undo any application of covertToFlatShadedMesh
  28862. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28863. */
  28864. forceSharedVertices(): void;
  28865. /** @hidden */
  28866. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28867. /** @hidden */
  28868. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28869. /**
  28870. * Creates a new InstancedMesh object from the mesh model.
  28871. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28872. * @param name defines the name of the new instance
  28873. * @returns a new InstancedMesh
  28874. */
  28875. createInstance(name: string): InstancedMesh;
  28876. /**
  28877. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28878. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28879. * @returns the current mesh
  28880. */
  28881. synchronizeInstances(): Mesh;
  28882. /**
  28883. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28884. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28885. * This should be used together with the simplification to avoid disappearing triangles.
  28886. * @param successCallback an optional success callback to be called after the optimization finished.
  28887. * @returns the current mesh
  28888. */
  28889. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28890. /**
  28891. * Serialize current mesh
  28892. * @param serializationObject defines the object which will receive the serialization data
  28893. */
  28894. serialize(serializationObject: any): void;
  28895. /** @hidden */
  28896. _syncGeometryWithMorphTargetManager(): void;
  28897. /** @hidden */
  28898. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28899. /**
  28900. * Returns a new Mesh object parsed from the source provided.
  28901. * @param parsedMesh is the source
  28902. * @param scene defines the hosting scene
  28903. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28904. * @returns a new Mesh
  28905. */
  28906. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28907. /**
  28908. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28909. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28910. * @param name defines the name of the mesh to create
  28911. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28912. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28913. * @param closePath creates a seam between the first and the last points of each path of the path array
  28914. * @param offset is taken in account only if the `pathArray` is containing a single path
  28915. * @param scene defines the hosting scene
  28916. * @param updatable defines if the mesh must be flagged as updatable
  28917. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28918. * @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)
  28919. * @returns a new Mesh
  28920. */
  28921. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28922. /**
  28923. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28924. * @param name defines the name of the mesh to create
  28925. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28926. * @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
  28927. * @param scene defines the hosting scene
  28928. * @param updatable defines if the mesh must be flagged as updatable
  28929. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28930. * @returns a new Mesh
  28931. */
  28932. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28933. /**
  28934. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28935. * @param name defines the name of the mesh to create
  28936. * @param size sets the size (float) of each box side (default 1)
  28937. * @param scene defines the hosting scene
  28938. * @param updatable defines if the mesh must be flagged as updatable
  28939. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28940. * @returns a new Mesh
  28941. */
  28942. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28943. /**
  28944. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28945. * @param name defines the name of the mesh to create
  28946. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28947. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28948. * @param scene defines the hosting scene
  28949. * @param updatable defines if the mesh must be flagged as updatable
  28950. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28951. * @returns a new Mesh
  28952. */
  28953. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28954. /**
  28955. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28956. * @param name defines the name of the mesh to create
  28957. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28958. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28959. * @param scene defines the hosting scene
  28960. * @returns a new Mesh
  28961. */
  28962. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28963. /**
  28964. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28965. * @param name defines the name of the mesh to create
  28966. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28967. * @param diameterTop set the top cap diameter (floats, default 1)
  28968. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28969. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28970. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28971. * @param scene defines the hosting scene
  28972. * @param updatable defines if the mesh must be flagged as updatable
  28973. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28974. * @returns a new Mesh
  28975. */
  28976. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28977. /**
  28978. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28979. * @param name defines the name of the mesh to create
  28980. * @param diameter sets the diameter size (float) of the torus (default 1)
  28981. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28982. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28983. * @param scene defines the hosting scene
  28984. * @param updatable defines if the mesh must be flagged as updatable
  28985. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28986. * @returns a new Mesh
  28987. */
  28988. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28989. /**
  28990. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28991. * @param name defines the name of the mesh to create
  28992. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28993. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28994. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28995. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28996. * @param p the number of windings on X axis (positive integers, default 2)
  28997. * @param q the number of windings on Y axis (positive integers, default 3)
  28998. * @param scene defines the hosting scene
  28999. * @param updatable defines if the mesh must be flagged as updatable
  29000. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29001. * @returns a new Mesh
  29002. */
  29003. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29004. /**
  29005. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29006. * @param name defines the name of the mesh to create
  29007. * @param points is an array successive Vector3
  29008. * @param scene defines the hosting scene
  29009. * @param updatable defines if the mesh must be flagged as updatable
  29010. * @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).
  29011. * @returns a new Mesh
  29012. */
  29013. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29014. /**
  29015. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29016. * @param name defines the name of the mesh to create
  29017. * @param points is an array successive Vector3
  29018. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29019. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29020. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29021. * @param scene defines the hosting scene
  29022. * @param updatable defines if the mesh must be flagged as updatable
  29023. * @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)
  29024. * @returns a new Mesh
  29025. */
  29026. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29027. /**
  29028. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29029. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29030. * 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.
  29031. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29032. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29033. * Remember you can only change the shape positions, not their number when updating a polygon.
  29034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29035. * @param name defines the name of the mesh to create
  29036. * @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
  29037. * @param scene defines the hosting scene
  29038. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29039. * @param updatable defines if the mesh must be flagged as updatable
  29040. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29041. * @param earcutInjection can be used to inject your own earcut reference
  29042. * @returns a new Mesh
  29043. */
  29044. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29045. /**
  29046. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29047. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29048. * @param name defines the name of the mesh to create
  29049. * @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
  29050. * @param depth defines the height of extrusion
  29051. * @param scene defines the hosting scene
  29052. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29053. * @param updatable defines if the mesh must be flagged as updatable
  29054. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29055. * @param earcutInjection can be used to inject your own earcut reference
  29056. * @returns a new Mesh
  29057. */
  29058. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29059. /**
  29060. * Creates an extruded shape mesh.
  29061. * 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
  29062. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29063. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29064. * @param name defines the name of the mesh to create
  29065. * @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
  29066. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29067. * @param scale is the value to scale the shape
  29068. * @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
  29069. * @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
  29070. * @param scene defines the hosting scene
  29071. * @param updatable defines if the mesh must be flagged as updatable
  29072. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29073. * @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)
  29074. * @returns a new Mesh
  29075. */
  29076. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29077. /**
  29078. * Creates an custom extruded shape mesh.
  29079. * The custom extrusion is a parametric shape.
  29080. * It has no predefined shape. Its final shape will depend on the input parameters.
  29081. * Please consider using the same method from the MeshBuilder class instead
  29082. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29083. * @param name defines the name of the mesh to create
  29084. * @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
  29085. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29086. * @param scaleFunction is a custom Javascript function called on each path point
  29087. * @param rotationFunction is a custom Javascript function called on each path point
  29088. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29089. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29090. * @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
  29091. * @param scene defines the hosting scene
  29092. * @param updatable defines if the mesh must be flagged as updatable
  29093. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29094. * @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)
  29095. * @returns a new Mesh
  29096. */
  29097. 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;
  29098. /**
  29099. * Creates lathe mesh.
  29100. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29101. * Please consider using the same method from the MeshBuilder class instead
  29102. * @param name defines the name of the mesh to create
  29103. * @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
  29104. * @param radius is the radius value of the lathe
  29105. * @param tessellation is the side number of the lathe.
  29106. * @param scene defines the hosting scene
  29107. * @param updatable defines if the mesh must be flagged as updatable
  29108. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29109. * @returns a new Mesh
  29110. */
  29111. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29112. /**
  29113. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29114. * @param name defines the name of the mesh to create
  29115. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29116. * @param scene defines the hosting scene
  29117. * @param updatable defines if the mesh must be flagged as updatable
  29118. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29119. * @returns a new Mesh
  29120. */
  29121. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29122. /**
  29123. * Creates a ground mesh.
  29124. * Please consider using the same method from the MeshBuilder class instead
  29125. * @param name defines the name of the mesh to create
  29126. * @param width set the width of the ground
  29127. * @param height set the height of the ground
  29128. * @param subdivisions sets the number of subdivisions per side
  29129. * @param scene defines the hosting scene
  29130. * @param updatable defines if the mesh must be flagged as updatable
  29131. * @returns a new Mesh
  29132. */
  29133. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29134. /**
  29135. * Creates a tiled ground mesh.
  29136. * Please consider using the same method from the MeshBuilder class instead
  29137. * @param name defines the name of the mesh to create
  29138. * @param xmin set the ground minimum X coordinate
  29139. * @param zmin set the ground minimum Y coordinate
  29140. * @param xmax set the ground maximum X coordinate
  29141. * @param zmax set the ground maximum Z coordinate
  29142. * @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
  29143. * @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
  29144. * @param scene defines the hosting scene
  29145. * @param updatable defines if the mesh must be flagged as updatable
  29146. * @returns a new Mesh
  29147. */
  29148. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29149. w: number;
  29150. h: number;
  29151. }, precision: {
  29152. w: number;
  29153. h: number;
  29154. }, scene: Scene, updatable?: boolean): Mesh;
  29155. /**
  29156. * Creates a ground mesh from a height map.
  29157. * Please consider using the same method from the MeshBuilder class instead
  29158. * @see https://doc.babylonjs.com/babylon101/height_map
  29159. * @param name defines the name of the mesh to create
  29160. * @param url sets the URL of the height map image resource
  29161. * @param width set the ground width size
  29162. * @param height set the ground height size
  29163. * @param subdivisions sets the number of subdivision per side
  29164. * @param minHeight is the minimum altitude on the ground
  29165. * @param maxHeight is the maximum altitude on the ground
  29166. * @param scene defines the hosting scene
  29167. * @param updatable defines if the mesh must be flagged as updatable
  29168. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29169. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29170. * @returns a new Mesh
  29171. */
  29172. 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;
  29173. /**
  29174. * Creates a tube mesh.
  29175. * The tube is a parametric shape.
  29176. * It has no predefined shape. Its final shape will depend on the input parameters.
  29177. * Please consider using the same method from the MeshBuilder class instead
  29178. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29179. * @param name defines the name of the mesh to create
  29180. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29181. * @param radius sets the tube radius size
  29182. * @param tessellation is the number of sides on the tubular surface
  29183. * @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
  29184. * @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
  29185. * @param scene defines the hosting scene
  29186. * @param updatable defines if the mesh must be flagged as updatable
  29187. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29188. * @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)
  29189. * @returns a new Mesh
  29190. */
  29191. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29192. (i: number, distance: number): number;
  29193. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29194. /**
  29195. * Creates a polyhedron mesh.
  29196. * Please consider using the same method from the MeshBuilder class instead.
  29197. * * 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
  29198. * * The parameter `size` (positive float, default 1) sets the polygon size
  29199. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29200. * * 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`
  29201. * * 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
  29202. * * 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)`)
  29203. * * 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
  29204. * * 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
  29205. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29208. * @param name defines the name of the mesh to create
  29209. * @param options defines the options used to create the mesh
  29210. * @param scene defines the hosting scene
  29211. * @returns a new Mesh
  29212. */
  29213. static CreatePolyhedron(name: string, options: {
  29214. type?: number;
  29215. size?: number;
  29216. sizeX?: number;
  29217. sizeY?: number;
  29218. sizeZ?: number;
  29219. custom?: any;
  29220. faceUV?: Vector4[];
  29221. faceColors?: Color4[];
  29222. updatable?: boolean;
  29223. sideOrientation?: number;
  29224. }, scene: Scene): Mesh;
  29225. /**
  29226. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29227. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29228. * * 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`)
  29229. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29230. * * 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
  29231. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29234. * @param name defines the name of the mesh
  29235. * @param options defines the options used to create the mesh
  29236. * @param scene defines the hosting scene
  29237. * @returns a new Mesh
  29238. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29239. */
  29240. static CreateIcoSphere(name: string, options: {
  29241. radius?: number;
  29242. flat?: boolean;
  29243. subdivisions?: number;
  29244. sideOrientation?: number;
  29245. updatable?: boolean;
  29246. }, scene: Scene): Mesh;
  29247. /**
  29248. * Creates a decal mesh.
  29249. * Please consider using the same method from the MeshBuilder class instead.
  29250. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29251. * @param name defines the name of the mesh
  29252. * @param sourceMesh defines the mesh receiving the decal
  29253. * @param position sets the position of the decal in world coordinates
  29254. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29255. * @param size sets the decal scaling
  29256. * @param angle sets the angle to rotate the decal
  29257. * @returns a new Mesh
  29258. */
  29259. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29260. /**
  29261. * Prepare internal position array for software CPU skinning
  29262. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29263. */
  29264. setPositionsForCPUSkinning(): Float32Array;
  29265. /**
  29266. * Prepare internal normal array for software CPU skinning
  29267. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29268. */
  29269. setNormalsForCPUSkinning(): Float32Array;
  29270. /**
  29271. * Updates the vertex buffer by applying transformation from the bones
  29272. * @param skeleton defines the skeleton to apply to current mesh
  29273. * @returns the current mesh
  29274. */
  29275. applySkeleton(skeleton: Skeleton): Mesh;
  29276. /**
  29277. * 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
  29278. * @param meshes defines the list of meshes to scan
  29279. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29280. */
  29281. static MinMax(meshes: AbstractMesh[]): {
  29282. min: Vector3;
  29283. max: Vector3;
  29284. };
  29285. /**
  29286. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29287. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29288. * @returns a vector3
  29289. */
  29290. static Center(meshesOrMinMaxVector: {
  29291. min: Vector3;
  29292. max: Vector3;
  29293. } | AbstractMesh[]): Vector3;
  29294. /**
  29295. * Merge the array of meshes into a single mesh for performance reasons.
  29296. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29297. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29298. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29299. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29300. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29301. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29302. * @returns a new mesh
  29303. */
  29304. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29305. /** @hidden */
  29306. addInstance(instance: InstancedMesh): void;
  29307. /** @hidden */
  29308. removeInstance(instance: InstancedMesh): void;
  29309. }
  29310. }
  29311. declare module "babylonjs/Cameras/camera" {
  29312. import { SmartArray } from "babylonjs/Misc/smartArray";
  29313. import { Observable } from "babylonjs/Misc/observable";
  29314. import { Nullable } from "babylonjs/types";
  29315. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29316. import { Scene } from "babylonjs/scene";
  29317. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29318. import { Node } from "babylonjs/node";
  29319. import { Mesh } from "babylonjs/Meshes/mesh";
  29320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29321. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29322. import { Viewport } from "babylonjs/Maths/math.viewport";
  29323. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29324. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29325. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29326. import { Ray } from "babylonjs/Culling/ray";
  29327. /**
  29328. * This is the base class of all the camera used in the application.
  29329. * @see https://doc.babylonjs.com/features/cameras
  29330. */
  29331. export class Camera extends Node {
  29332. /** @hidden */
  29333. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29334. /**
  29335. * This is the default projection mode used by the cameras.
  29336. * It helps recreating a feeling of perspective and better appreciate depth.
  29337. * This is the best way to simulate real life cameras.
  29338. */
  29339. static readonly PERSPECTIVE_CAMERA: number;
  29340. /**
  29341. * This helps creating camera with an orthographic mode.
  29342. * 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.
  29343. */
  29344. static readonly ORTHOGRAPHIC_CAMERA: number;
  29345. /**
  29346. * This is the default FOV mode for perspective cameras.
  29347. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29348. */
  29349. static readonly FOVMODE_VERTICAL_FIXED: number;
  29350. /**
  29351. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29352. */
  29353. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29354. /**
  29355. * This specifies ther is no need for a camera rig.
  29356. * Basically only one eye is rendered corresponding to the camera.
  29357. */
  29358. static readonly RIG_MODE_NONE: number;
  29359. /**
  29360. * Simulates a camera Rig with one blue eye and one red eye.
  29361. * This can be use with 3d blue and red glasses.
  29362. */
  29363. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29364. /**
  29365. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29366. */
  29367. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29368. /**
  29369. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29370. */
  29371. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29372. /**
  29373. * Defines that both eyes of the camera will be rendered over under each other.
  29374. */
  29375. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29376. /**
  29377. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29378. */
  29379. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29380. /**
  29381. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29382. */
  29383. static readonly RIG_MODE_VR: number;
  29384. /**
  29385. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29386. */
  29387. static readonly RIG_MODE_WEBVR: number;
  29388. /**
  29389. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29390. */
  29391. static readonly RIG_MODE_CUSTOM: number;
  29392. /**
  29393. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29394. */
  29395. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29396. /**
  29397. * Define the input manager associated with the camera.
  29398. */
  29399. inputs: CameraInputsManager<Camera>;
  29400. /** @hidden */
  29401. _position: Vector3;
  29402. /**
  29403. * Define the current local position of the camera in the scene
  29404. */
  29405. get position(): Vector3;
  29406. set position(newPosition: Vector3);
  29407. /**
  29408. * The vector the camera should consider as up.
  29409. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29410. */
  29411. upVector: Vector3;
  29412. /**
  29413. * Define the current limit on the left side for an orthographic camera
  29414. * In scene unit
  29415. */
  29416. orthoLeft: Nullable<number>;
  29417. /**
  29418. * Define the current limit on the right side for an orthographic camera
  29419. * In scene unit
  29420. */
  29421. orthoRight: Nullable<number>;
  29422. /**
  29423. * Define the current limit on the bottom side for an orthographic camera
  29424. * In scene unit
  29425. */
  29426. orthoBottom: Nullable<number>;
  29427. /**
  29428. * Define the current limit on the top side for an orthographic camera
  29429. * In scene unit
  29430. */
  29431. orthoTop: Nullable<number>;
  29432. /**
  29433. * Field Of View is set in Radians. (default is 0.8)
  29434. */
  29435. fov: number;
  29436. /**
  29437. * Define the minimum distance the camera can see from.
  29438. * This is important to note that the depth buffer are not infinite and the closer it starts
  29439. * the more your scene might encounter depth fighting issue.
  29440. */
  29441. minZ: number;
  29442. /**
  29443. * Define the maximum distance the camera can see to.
  29444. * This is important to note that the depth buffer are not infinite and the further it end
  29445. * the more your scene might encounter depth fighting issue.
  29446. */
  29447. maxZ: number;
  29448. /**
  29449. * Define the default inertia of the camera.
  29450. * This helps giving a smooth feeling to the camera movement.
  29451. */
  29452. inertia: number;
  29453. /**
  29454. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29455. */
  29456. mode: number;
  29457. /**
  29458. * Define whether the camera is intermediate.
  29459. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29460. */
  29461. isIntermediate: boolean;
  29462. /**
  29463. * Define the viewport of the camera.
  29464. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29465. */
  29466. viewport: Viewport;
  29467. /**
  29468. * Restricts the camera to viewing objects with the same layerMask.
  29469. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29470. */
  29471. layerMask: number;
  29472. /**
  29473. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29474. */
  29475. fovMode: number;
  29476. /**
  29477. * Rig mode of the camera.
  29478. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29479. * This is normally controlled byt the camera themselves as internal use.
  29480. */
  29481. cameraRigMode: number;
  29482. /**
  29483. * Defines the distance between both "eyes" in case of a RIG
  29484. */
  29485. interaxialDistance: number;
  29486. /**
  29487. * Defines if stereoscopic rendering is done side by side or over under.
  29488. */
  29489. isStereoscopicSideBySide: boolean;
  29490. /**
  29491. * 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
  29492. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29493. * else in the scene. (Eg. security camera)
  29494. *
  29495. * 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)
  29496. */
  29497. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29498. /**
  29499. * When set, the camera will render to this render target instead of the default canvas
  29500. *
  29501. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29502. */
  29503. outputRenderTarget: Nullable<RenderTargetTexture>;
  29504. /**
  29505. * Observable triggered when the camera view matrix has changed.
  29506. */
  29507. onViewMatrixChangedObservable: Observable<Camera>;
  29508. /**
  29509. * Observable triggered when the camera Projection matrix has changed.
  29510. */
  29511. onProjectionMatrixChangedObservable: Observable<Camera>;
  29512. /**
  29513. * Observable triggered when the inputs have been processed.
  29514. */
  29515. onAfterCheckInputsObservable: Observable<Camera>;
  29516. /**
  29517. * Observable triggered when reset has been called and applied to the camera.
  29518. */
  29519. onRestoreStateObservable: Observable<Camera>;
  29520. /**
  29521. * Is this camera a part of a rig system?
  29522. */
  29523. isRigCamera: boolean;
  29524. /**
  29525. * If isRigCamera set to true this will be set with the parent camera.
  29526. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29527. */
  29528. rigParent?: Camera;
  29529. /** @hidden */
  29530. _cameraRigParams: any;
  29531. /** @hidden */
  29532. _rigCameras: Camera[];
  29533. /** @hidden */
  29534. _rigPostProcess: Nullable<PostProcess>;
  29535. protected _webvrViewMatrix: Matrix;
  29536. /** @hidden */
  29537. _skipRendering: boolean;
  29538. /** @hidden */
  29539. _projectionMatrix: Matrix;
  29540. /** @hidden */
  29541. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29542. /** @hidden */
  29543. _activeMeshes: SmartArray<AbstractMesh>;
  29544. protected _globalPosition: Vector3;
  29545. /** @hidden */
  29546. _computedViewMatrix: Matrix;
  29547. private _doNotComputeProjectionMatrix;
  29548. private _transformMatrix;
  29549. private _frustumPlanes;
  29550. private _refreshFrustumPlanes;
  29551. private _storedFov;
  29552. private _stateStored;
  29553. /**
  29554. * Instantiates a new camera object.
  29555. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29556. * @see https://doc.babylonjs.com/features/cameras
  29557. * @param name Defines the name of the camera in the scene
  29558. * @param position Defines the position of the camera
  29559. * @param scene Defines the scene the camera belongs too
  29560. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29561. */
  29562. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29563. /**
  29564. * Store current camera state (fov, position, etc..)
  29565. * @returns the camera
  29566. */
  29567. storeState(): Camera;
  29568. /**
  29569. * Restores the camera state values if it has been stored. You must call storeState() first
  29570. */
  29571. protected _restoreStateValues(): boolean;
  29572. /**
  29573. * Restored camera state. You must call storeState() first.
  29574. * @returns true if restored and false otherwise
  29575. */
  29576. restoreState(): boolean;
  29577. /**
  29578. * Gets the class name of the camera.
  29579. * @returns the class name
  29580. */
  29581. getClassName(): string;
  29582. /** @hidden */
  29583. readonly _isCamera: boolean;
  29584. /**
  29585. * Gets a string representation of the camera useful for debug purpose.
  29586. * @param fullDetails Defines that a more verboe level of logging is required
  29587. * @returns the string representation
  29588. */
  29589. toString(fullDetails?: boolean): string;
  29590. /**
  29591. * Gets the current world space position of the camera.
  29592. */
  29593. get globalPosition(): Vector3;
  29594. /**
  29595. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29596. * @returns the active meshe list
  29597. */
  29598. getActiveMeshes(): SmartArray<AbstractMesh>;
  29599. /**
  29600. * Check whether a mesh is part of the current active mesh list of the camera
  29601. * @param mesh Defines the mesh to check
  29602. * @returns true if active, false otherwise
  29603. */
  29604. isActiveMesh(mesh: Mesh): boolean;
  29605. /**
  29606. * Is this camera ready to be used/rendered
  29607. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29608. * @return true if the camera is ready
  29609. */
  29610. isReady(completeCheck?: boolean): boolean;
  29611. /** @hidden */
  29612. _initCache(): void;
  29613. /** @hidden */
  29614. _updateCache(ignoreParentClass?: boolean): void;
  29615. /** @hidden */
  29616. _isSynchronized(): boolean;
  29617. /** @hidden */
  29618. _isSynchronizedViewMatrix(): boolean;
  29619. /** @hidden */
  29620. _isSynchronizedProjectionMatrix(): boolean;
  29621. /**
  29622. * Attach the input controls to a specific dom element to get the input from.
  29623. * @param element Defines the element the controls should be listened from
  29624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29625. */
  29626. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29627. /**
  29628. * Detach the current controls from the specified dom element.
  29629. * @param element Defines the element to stop listening the inputs from
  29630. */
  29631. detachControl(element: HTMLElement): void;
  29632. /**
  29633. * Update the camera state according to the different inputs gathered during the frame.
  29634. */
  29635. update(): void;
  29636. /** @hidden */
  29637. _checkInputs(): void;
  29638. /** @hidden */
  29639. get rigCameras(): Camera[];
  29640. /**
  29641. * Gets the post process used by the rig cameras
  29642. */
  29643. get rigPostProcess(): Nullable<PostProcess>;
  29644. /**
  29645. * Internal, gets the first post proces.
  29646. * @returns the first post process to be run on this camera.
  29647. */
  29648. _getFirstPostProcess(): Nullable<PostProcess>;
  29649. private _cascadePostProcessesToRigCams;
  29650. /**
  29651. * Attach a post process to the camera.
  29652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29653. * @param postProcess The post process to attach to the camera
  29654. * @param insertAt The position of the post process in case several of them are in use in the scene
  29655. * @returns the position the post process has been inserted at
  29656. */
  29657. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29658. /**
  29659. * Detach a post process to the camera.
  29660. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29661. * @param postProcess The post process to detach from the camera
  29662. */
  29663. detachPostProcess(postProcess: PostProcess): void;
  29664. /**
  29665. * Gets the current world matrix of the camera
  29666. */
  29667. getWorldMatrix(): Matrix;
  29668. /** @hidden */
  29669. _getViewMatrix(): Matrix;
  29670. /**
  29671. * Gets the current view matrix of the camera.
  29672. * @param force forces the camera to recompute the matrix without looking at the cached state
  29673. * @returns the view matrix
  29674. */
  29675. getViewMatrix(force?: boolean): Matrix;
  29676. /**
  29677. * Freeze the projection matrix.
  29678. * It will prevent the cache check of the camera projection compute and can speed up perf
  29679. * if no parameter of the camera are meant to change
  29680. * @param projection Defines manually a projection if necessary
  29681. */
  29682. freezeProjectionMatrix(projection?: Matrix): void;
  29683. /**
  29684. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29685. */
  29686. unfreezeProjectionMatrix(): void;
  29687. /**
  29688. * Gets the current projection matrix of the camera.
  29689. * @param force forces the camera to recompute the matrix without looking at the cached state
  29690. * @returns the projection matrix
  29691. */
  29692. getProjectionMatrix(force?: boolean): Matrix;
  29693. /**
  29694. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29695. * @returns a Matrix
  29696. */
  29697. getTransformationMatrix(): Matrix;
  29698. private _updateFrustumPlanes;
  29699. /**
  29700. * Checks if a cullable object (mesh...) is in the camera frustum
  29701. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29702. * @param target The object to check
  29703. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29704. * @returns true if the object is in frustum otherwise false
  29705. */
  29706. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29707. /**
  29708. * Checks if a cullable object (mesh...) is in the camera frustum
  29709. * Unlike isInFrustum this cheks the full bounding box
  29710. * @param target The object to check
  29711. * @returns true if the object is in frustum otherwise false
  29712. */
  29713. isCompletelyInFrustum(target: ICullable): boolean;
  29714. /**
  29715. * Gets a ray in the forward direction from the camera.
  29716. * @param length Defines the length of the ray to create
  29717. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29718. * @param origin Defines the start point of the ray which defaults to the camera position
  29719. * @returns the forward ray
  29720. */
  29721. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29722. /**
  29723. * Releases resources associated with this node.
  29724. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29725. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29726. */
  29727. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29728. /** @hidden */
  29729. _isLeftCamera: boolean;
  29730. /**
  29731. * Gets the left camera of a rig setup in case of Rigged Camera
  29732. */
  29733. get isLeftCamera(): boolean;
  29734. /** @hidden */
  29735. _isRightCamera: boolean;
  29736. /**
  29737. * Gets the right camera of a rig setup in case of Rigged Camera
  29738. */
  29739. get isRightCamera(): boolean;
  29740. /**
  29741. * Gets the left camera of a rig setup in case of Rigged Camera
  29742. */
  29743. get leftCamera(): Nullable<FreeCamera>;
  29744. /**
  29745. * Gets the right camera of a rig setup in case of Rigged Camera
  29746. */
  29747. get rightCamera(): Nullable<FreeCamera>;
  29748. /**
  29749. * Gets the left camera target of a rig setup in case of Rigged Camera
  29750. * @returns the target position
  29751. */
  29752. getLeftTarget(): Nullable<Vector3>;
  29753. /**
  29754. * Gets the right camera target of a rig setup in case of Rigged Camera
  29755. * @returns the target position
  29756. */
  29757. getRightTarget(): Nullable<Vector3>;
  29758. /**
  29759. * @hidden
  29760. */
  29761. setCameraRigMode(mode: number, rigParams: any): void;
  29762. /** @hidden */
  29763. static _setStereoscopicRigMode(camera: Camera): void;
  29764. /** @hidden */
  29765. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29766. /** @hidden */
  29767. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29768. /** @hidden */
  29769. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29770. /** @hidden */
  29771. _getVRProjectionMatrix(): Matrix;
  29772. protected _updateCameraRotationMatrix(): void;
  29773. protected _updateWebVRCameraRotationMatrix(): void;
  29774. /**
  29775. * This function MUST be overwritten by the different WebVR cameras available.
  29776. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29777. * @hidden
  29778. */
  29779. _getWebVRProjectionMatrix(): Matrix;
  29780. /**
  29781. * This function MUST be overwritten by the different WebVR cameras available.
  29782. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29783. * @hidden
  29784. */
  29785. _getWebVRViewMatrix(): Matrix;
  29786. /** @hidden */
  29787. setCameraRigParameter(name: string, value: any): void;
  29788. /**
  29789. * needs to be overridden by children so sub has required properties to be copied
  29790. * @hidden
  29791. */
  29792. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29793. /**
  29794. * May need to be overridden by children
  29795. * @hidden
  29796. */
  29797. _updateRigCameras(): void;
  29798. /** @hidden */
  29799. _setupInputs(): void;
  29800. /**
  29801. * Serialiaze the camera setup to a json represention
  29802. * @returns the JSON representation
  29803. */
  29804. serialize(): any;
  29805. /**
  29806. * Clones the current camera.
  29807. * @param name The cloned camera name
  29808. * @returns the cloned camera
  29809. */
  29810. clone(name: string): Camera;
  29811. /**
  29812. * Gets the direction of the camera relative to a given local axis.
  29813. * @param localAxis Defines the reference axis to provide a relative direction.
  29814. * @return the direction
  29815. */
  29816. getDirection(localAxis: Vector3): Vector3;
  29817. /**
  29818. * Returns the current camera absolute rotation
  29819. */
  29820. get absoluteRotation(): Quaternion;
  29821. /**
  29822. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29823. * @param localAxis Defines the reference axis to provide a relative direction.
  29824. * @param result Defines the vector to store the result in
  29825. */
  29826. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29827. /**
  29828. * Gets a camera constructor for a given camera type
  29829. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29830. * @param name The name of the camera the result will be able to instantiate
  29831. * @param scene The scene the result will construct the camera in
  29832. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29833. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29834. * @returns a factory method to construc the camera
  29835. */
  29836. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29837. /**
  29838. * Compute the world matrix of the camera.
  29839. * @returns the camera world matrix
  29840. */
  29841. computeWorldMatrix(): Matrix;
  29842. /**
  29843. * Parse a JSON and creates the camera from the parsed information
  29844. * @param parsedCamera The JSON to parse
  29845. * @param scene The scene to instantiate the camera in
  29846. * @returns the newly constructed camera
  29847. */
  29848. static Parse(parsedCamera: any, scene: Scene): Camera;
  29849. }
  29850. }
  29851. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29852. import { Nullable } from "babylonjs/types";
  29853. import { Scene } from "babylonjs/scene";
  29854. import { Vector4 } from "babylonjs/Maths/math.vector";
  29855. import { Mesh } from "babylonjs/Meshes/mesh";
  29856. /**
  29857. * Class containing static functions to help procedurally build meshes
  29858. */
  29859. export class DiscBuilder {
  29860. /**
  29861. * Creates a plane polygonal mesh. By default, this is a disc
  29862. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29863. * * 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
  29864. * * 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
  29865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29868. * @param name defines the name of the mesh
  29869. * @param options defines the options used to create the mesh
  29870. * @param scene defines the hosting scene
  29871. * @returns the plane polygonal mesh
  29872. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29873. */
  29874. static CreateDisc(name: string, options: {
  29875. radius?: number;
  29876. tessellation?: number;
  29877. arc?: number;
  29878. updatable?: boolean;
  29879. sideOrientation?: number;
  29880. frontUVs?: Vector4;
  29881. backUVs?: Vector4;
  29882. }, scene?: Nullable<Scene>): Mesh;
  29883. }
  29884. }
  29885. declare module "babylonjs/Materials/fresnelParameters" {
  29886. import { DeepImmutable } from "babylonjs/types";
  29887. import { Color3 } from "babylonjs/Maths/math.color";
  29888. /**
  29889. * Options to be used when creating a FresnelParameters.
  29890. */
  29891. export type IFresnelParametersCreationOptions = {
  29892. /**
  29893. * Define the color used on edges (grazing angle)
  29894. */
  29895. leftColor?: Color3;
  29896. /**
  29897. * Define the color used on center
  29898. */
  29899. rightColor?: Color3;
  29900. /**
  29901. * Define bias applied to computed fresnel term
  29902. */
  29903. bias?: number;
  29904. /**
  29905. * Defined the power exponent applied to fresnel term
  29906. */
  29907. power?: number;
  29908. /**
  29909. * Define if the fresnel effect is enable or not.
  29910. */
  29911. isEnabled?: boolean;
  29912. };
  29913. /**
  29914. * Serialized format for FresnelParameters.
  29915. */
  29916. export type IFresnelParametersSerialized = {
  29917. /**
  29918. * Define the color used on edges (grazing angle) [as an array]
  29919. */
  29920. leftColor: number[];
  29921. /**
  29922. * Define the color used on center [as an array]
  29923. */
  29924. rightColor: number[];
  29925. /**
  29926. * Define bias applied to computed fresnel term
  29927. */
  29928. bias: number;
  29929. /**
  29930. * Defined the power exponent applied to fresnel term
  29931. */
  29932. power?: number;
  29933. /**
  29934. * Define if the fresnel effect is enable or not.
  29935. */
  29936. isEnabled: boolean;
  29937. };
  29938. /**
  29939. * This represents all the required information to add a fresnel effect on a material:
  29940. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29941. */
  29942. export class FresnelParameters {
  29943. private _isEnabled;
  29944. /**
  29945. * Define if the fresnel effect is enable or not.
  29946. */
  29947. get isEnabled(): boolean;
  29948. set isEnabled(value: boolean);
  29949. /**
  29950. * Define the color used on edges (grazing angle)
  29951. */
  29952. leftColor: Color3;
  29953. /**
  29954. * Define the color used on center
  29955. */
  29956. rightColor: Color3;
  29957. /**
  29958. * Define bias applied to computed fresnel term
  29959. */
  29960. bias: number;
  29961. /**
  29962. * Defined the power exponent applied to fresnel term
  29963. */
  29964. power: number;
  29965. /**
  29966. * Creates a new FresnelParameters object.
  29967. *
  29968. * @param options provide your own settings to optionally to override defaults
  29969. */
  29970. constructor(options?: IFresnelParametersCreationOptions);
  29971. /**
  29972. * Clones the current fresnel and its valuues
  29973. * @returns a clone fresnel configuration
  29974. */
  29975. clone(): FresnelParameters;
  29976. /**
  29977. * Determines equality between FresnelParameters objects
  29978. * @param otherFresnelParameters defines the second operand
  29979. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29980. */
  29981. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29982. /**
  29983. * Serializes the current fresnel parameters to a JSON representation.
  29984. * @return the JSON serialization
  29985. */
  29986. serialize(): IFresnelParametersSerialized;
  29987. /**
  29988. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29989. * @param parsedFresnelParameters Define the JSON representation
  29990. * @returns the parsed parameters
  29991. */
  29992. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29993. }
  29994. }
  29995. declare module "babylonjs/Materials/materialFlags" {
  29996. /**
  29997. * This groups all the flags used to control the materials channel.
  29998. */
  29999. export class MaterialFlags {
  30000. private static _DiffuseTextureEnabled;
  30001. /**
  30002. * Are diffuse textures enabled in the application.
  30003. */
  30004. static get DiffuseTextureEnabled(): boolean;
  30005. static set DiffuseTextureEnabled(value: boolean);
  30006. private static _DetailTextureEnabled;
  30007. /**
  30008. * Are detail textures enabled in the application.
  30009. */
  30010. static get DetailTextureEnabled(): boolean;
  30011. static set DetailTextureEnabled(value: boolean);
  30012. private static _AmbientTextureEnabled;
  30013. /**
  30014. * Are ambient textures enabled in the application.
  30015. */
  30016. static get AmbientTextureEnabled(): boolean;
  30017. static set AmbientTextureEnabled(value: boolean);
  30018. private static _OpacityTextureEnabled;
  30019. /**
  30020. * Are opacity textures enabled in the application.
  30021. */
  30022. static get OpacityTextureEnabled(): boolean;
  30023. static set OpacityTextureEnabled(value: boolean);
  30024. private static _ReflectionTextureEnabled;
  30025. /**
  30026. * Are reflection textures enabled in the application.
  30027. */
  30028. static get ReflectionTextureEnabled(): boolean;
  30029. static set ReflectionTextureEnabled(value: boolean);
  30030. private static _EmissiveTextureEnabled;
  30031. /**
  30032. * Are emissive textures enabled in the application.
  30033. */
  30034. static get EmissiveTextureEnabled(): boolean;
  30035. static set EmissiveTextureEnabled(value: boolean);
  30036. private static _SpecularTextureEnabled;
  30037. /**
  30038. * Are specular textures enabled in the application.
  30039. */
  30040. static get SpecularTextureEnabled(): boolean;
  30041. static set SpecularTextureEnabled(value: boolean);
  30042. private static _BumpTextureEnabled;
  30043. /**
  30044. * Are bump textures enabled in the application.
  30045. */
  30046. static get BumpTextureEnabled(): boolean;
  30047. static set BumpTextureEnabled(value: boolean);
  30048. private static _LightmapTextureEnabled;
  30049. /**
  30050. * Are lightmap textures enabled in the application.
  30051. */
  30052. static get LightmapTextureEnabled(): boolean;
  30053. static set LightmapTextureEnabled(value: boolean);
  30054. private static _RefractionTextureEnabled;
  30055. /**
  30056. * Are refraction textures enabled in the application.
  30057. */
  30058. static get RefractionTextureEnabled(): boolean;
  30059. static set RefractionTextureEnabled(value: boolean);
  30060. private static _ColorGradingTextureEnabled;
  30061. /**
  30062. * Are color grading textures enabled in the application.
  30063. */
  30064. static get ColorGradingTextureEnabled(): boolean;
  30065. static set ColorGradingTextureEnabled(value: boolean);
  30066. private static _FresnelEnabled;
  30067. /**
  30068. * Are fresnels enabled in the application.
  30069. */
  30070. static get FresnelEnabled(): boolean;
  30071. static set FresnelEnabled(value: boolean);
  30072. private static _ClearCoatTextureEnabled;
  30073. /**
  30074. * Are clear coat textures enabled in the application.
  30075. */
  30076. static get ClearCoatTextureEnabled(): boolean;
  30077. static set ClearCoatTextureEnabled(value: boolean);
  30078. private static _ClearCoatBumpTextureEnabled;
  30079. /**
  30080. * Are clear coat bump textures enabled in the application.
  30081. */
  30082. static get ClearCoatBumpTextureEnabled(): boolean;
  30083. static set ClearCoatBumpTextureEnabled(value: boolean);
  30084. private static _ClearCoatTintTextureEnabled;
  30085. /**
  30086. * Are clear coat tint textures enabled in the application.
  30087. */
  30088. static get ClearCoatTintTextureEnabled(): boolean;
  30089. static set ClearCoatTintTextureEnabled(value: boolean);
  30090. private static _SheenTextureEnabled;
  30091. /**
  30092. * Are sheen textures enabled in the application.
  30093. */
  30094. static get SheenTextureEnabled(): boolean;
  30095. static set SheenTextureEnabled(value: boolean);
  30096. private static _AnisotropicTextureEnabled;
  30097. /**
  30098. * Are anisotropic textures enabled in the application.
  30099. */
  30100. static get AnisotropicTextureEnabled(): boolean;
  30101. static set AnisotropicTextureEnabled(value: boolean);
  30102. private static _ThicknessTextureEnabled;
  30103. /**
  30104. * Are thickness textures enabled in the application.
  30105. */
  30106. static get ThicknessTextureEnabled(): boolean;
  30107. static set ThicknessTextureEnabled(value: boolean);
  30108. }
  30109. }
  30110. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30111. /** @hidden */
  30112. export var defaultFragmentDeclaration: {
  30113. name: string;
  30114. shader: string;
  30115. };
  30116. }
  30117. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30118. /** @hidden */
  30119. export var defaultUboDeclaration: {
  30120. name: string;
  30121. shader: string;
  30122. };
  30123. }
  30124. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30125. /** @hidden */
  30126. export var lightFragmentDeclaration: {
  30127. name: string;
  30128. shader: string;
  30129. };
  30130. }
  30131. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30132. /** @hidden */
  30133. export var lightUboDeclaration: {
  30134. name: string;
  30135. shader: string;
  30136. };
  30137. }
  30138. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30139. /** @hidden */
  30140. export var lightsFragmentFunctions: {
  30141. name: string;
  30142. shader: string;
  30143. };
  30144. }
  30145. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30146. /** @hidden */
  30147. export var shadowsFragmentFunctions: {
  30148. name: string;
  30149. shader: string;
  30150. };
  30151. }
  30152. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30153. /** @hidden */
  30154. export var fresnelFunction: {
  30155. name: string;
  30156. shader: string;
  30157. };
  30158. }
  30159. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30160. /** @hidden */
  30161. export var bumpFragmentMainFunctions: {
  30162. name: string;
  30163. shader: string;
  30164. };
  30165. }
  30166. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30167. /** @hidden */
  30168. export var bumpFragmentFunctions: {
  30169. name: string;
  30170. shader: string;
  30171. };
  30172. }
  30173. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30174. /** @hidden */
  30175. export var logDepthDeclaration: {
  30176. name: string;
  30177. shader: string;
  30178. };
  30179. }
  30180. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30181. /** @hidden */
  30182. export var bumpFragment: {
  30183. name: string;
  30184. shader: string;
  30185. };
  30186. }
  30187. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30188. /** @hidden */
  30189. export var depthPrePass: {
  30190. name: string;
  30191. shader: string;
  30192. };
  30193. }
  30194. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30195. /** @hidden */
  30196. export var lightFragment: {
  30197. name: string;
  30198. shader: string;
  30199. };
  30200. }
  30201. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30202. /** @hidden */
  30203. export var logDepthFragment: {
  30204. name: string;
  30205. shader: string;
  30206. };
  30207. }
  30208. declare module "babylonjs/Shaders/default.fragment" {
  30209. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30210. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30211. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30212. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30213. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30214. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30215. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30216. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30217. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30218. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30219. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30220. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30221. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30222. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30223. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30224. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30225. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30226. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30227. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30228. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30229. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30230. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30231. /** @hidden */
  30232. export var defaultPixelShader: {
  30233. name: string;
  30234. shader: string;
  30235. };
  30236. }
  30237. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30238. /** @hidden */
  30239. export var defaultVertexDeclaration: {
  30240. name: string;
  30241. shader: string;
  30242. };
  30243. }
  30244. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30245. /** @hidden */
  30246. export var bumpVertexDeclaration: {
  30247. name: string;
  30248. shader: string;
  30249. };
  30250. }
  30251. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30252. /** @hidden */
  30253. export var bumpVertex: {
  30254. name: string;
  30255. shader: string;
  30256. };
  30257. }
  30258. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30259. /** @hidden */
  30260. export var fogVertex: {
  30261. name: string;
  30262. shader: string;
  30263. };
  30264. }
  30265. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30266. /** @hidden */
  30267. export var shadowsVertex: {
  30268. name: string;
  30269. shader: string;
  30270. };
  30271. }
  30272. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30273. /** @hidden */
  30274. export var pointCloudVertex: {
  30275. name: string;
  30276. shader: string;
  30277. };
  30278. }
  30279. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30280. /** @hidden */
  30281. export var logDepthVertex: {
  30282. name: string;
  30283. shader: string;
  30284. };
  30285. }
  30286. declare module "babylonjs/Shaders/default.vertex" {
  30287. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30288. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30289. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30290. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30291. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30292. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30293. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30294. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30295. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30296. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30297. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30298. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30299. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30300. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30301. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30302. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30303. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30304. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30305. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30306. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30307. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30308. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30309. /** @hidden */
  30310. export var defaultVertexShader: {
  30311. name: string;
  30312. shader: string;
  30313. };
  30314. }
  30315. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  30316. import { Nullable } from "babylonjs/types";
  30317. import { Scene } from "babylonjs/scene";
  30318. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30319. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30320. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30321. /**
  30322. * @hidden
  30323. */
  30324. export interface IMaterialDetailMapDefines {
  30325. DETAIL: boolean;
  30326. DETAILDIRECTUV: number;
  30327. DETAIL_NORMALBLENDMETHOD: number;
  30328. /** @hidden */
  30329. _areTexturesDirty: boolean;
  30330. }
  30331. /**
  30332. * Define the code related to the detail map parameters of a material
  30333. *
  30334. * Inspired from:
  30335. * 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
  30336. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30337. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30338. */
  30339. export class DetailMapConfiguration {
  30340. private _texture;
  30341. /**
  30342. * The detail texture of the material.
  30343. */
  30344. texture: Nullable<BaseTexture>;
  30345. /**
  30346. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30347. * Bigger values mean stronger blending
  30348. */
  30349. diffuseBlendLevel: number;
  30350. /**
  30351. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30352. * Bigger values mean stronger blending. Only used with PBR materials
  30353. */
  30354. roughnessBlendLevel: number;
  30355. /**
  30356. * Defines how strong the bump effect from the detail map is
  30357. * Bigger values mean stronger effect
  30358. */
  30359. bumpLevel: number;
  30360. private _normalBlendMethod;
  30361. /**
  30362. * The method used to blend the bump and detail normals together
  30363. */
  30364. normalBlendMethod: number;
  30365. private _isEnabled;
  30366. /**
  30367. * Enable or disable the detail map on this material
  30368. */
  30369. isEnabled: boolean;
  30370. /** @hidden */
  30371. private _internalMarkAllSubMeshesAsTexturesDirty;
  30372. /** @hidden */
  30373. _markAllSubMeshesAsTexturesDirty(): void;
  30374. /**
  30375. * Instantiate a new detail map
  30376. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30377. */
  30378. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30379. /**
  30380. * Gets whether the submesh is ready to be used or not.
  30381. * @param defines the list of "defines" to update.
  30382. * @param scene defines the scene the material belongs to.
  30383. * @returns - boolean indicating that the submesh is ready or not.
  30384. */
  30385. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30386. /**
  30387. * Update the defines for detail map usage
  30388. * @param defines the list of "defines" to update.
  30389. * @param scene defines the scene the material belongs to.
  30390. */
  30391. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30392. /**
  30393. * Binds the material data.
  30394. * @param uniformBuffer defines the Uniform buffer to fill in.
  30395. * @param scene defines the scene the material belongs to.
  30396. * @param isFrozen defines whether the material is frozen or not.
  30397. */
  30398. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30399. /**
  30400. * Checks to see if a texture is used in the material.
  30401. * @param texture - Base texture to use.
  30402. * @returns - Boolean specifying if a texture is used in the material.
  30403. */
  30404. hasTexture(texture: BaseTexture): boolean;
  30405. /**
  30406. * Returns an array of the actively used textures.
  30407. * @param activeTextures Array of BaseTextures
  30408. */
  30409. getActiveTextures(activeTextures: BaseTexture[]): void;
  30410. /**
  30411. * Returns the animatable textures.
  30412. * @param animatables Array of animatable textures.
  30413. */
  30414. getAnimatables(animatables: IAnimatable[]): void;
  30415. /**
  30416. * Disposes the resources of the material.
  30417. * @param forceDisposeTextures - Forces the disposal of all textures.
  30418. */
  30419. dispose(forceDisposeTextures?: boolean): void;
  30420. /**
  30421. * Get the current class name useful for serialization or dynamic coding.
  30422. * @returns "DetailMap"
  30423. */
  30424. getClassName(): string;
  30425. /**
  30426. * Add the required uniforms to the current list.
  30427. * @param uniforms defines the current uniform list.
  30428. */
  30429. static AddUniforms(uniforms: string[]): void;
  30430. /**
  30431. * Add the required samplers to the current list.
  30432. * @param samplers defines the current sampler list.
  30433. */
  30434. static AddSamplers(samplers: string[]): void;
  30435. /**
  30436. * Add the required uniforms to the current buffer.
  30437. * @param uniformBuffer defines the current uniform buffer.
  30438. */
  30439. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30440. /**
  30441. * Makes a duplicate of the current instance into another one.
  30442. * @param detailMap define the instance where to copy the info
  30443. */
  30444. copyTo(detailMap: DetailMapConfiguration): void;
  30445. /**
  30446. * Serializes this detail map instance
  30447. * @returns - An object with the serialized instance.
  30448. */
  30449. serialize(): any;
  30450. /**
  30451. * Parses a detail map setting from a serialized object.
  30452. * @param source - Serialized object.
  30453. * @param scene Defines the scene we are parsing for
  30454. * @param rootUrl Defines the rootUrl to load from
  30455. */
  30456. parse(source: any, scene: Scene, rootUrl: string): void;
  30457. }
  30458. }
  30459. declare module "babylonjs/Materials/standardMaterial" {
  30460. import { SmartArray } from "babylonjs/Misc/smartArray";
  30461. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30462. import { Nullable } from "babylonjs/types";
  30463. import { Scene } from "babylonjs/scene";
  30464. import { Matrix } from "babylonjs/Maths/math.vector";
  30465. import { Color3 } from "babylonjs/Maths/math.color";
  30466. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30468. import { Mesh } from "babylonjs/Meshes/mesh";
  30469. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30470. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30471. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30472. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30473. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30474. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30475. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30476. import "babylonjs/Shaders/default.fragment";
  30477. import "babylonjs/Shaders/default.vertex";
  30478. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  30479. /** @hidden */
  30480. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30481. MAINUV1: boolean;
  30482. MAINUV2: boolean;
  30483. DIFFUSE: boolean;
  30484. DIFFUSEDIRECTUV: number;
  30485. DETAIL: boolean;
  30486. DETAILDIRECTUV: number;
  30487. DETAIL_NORMALBLENDMETHOD: number;
  30488. AMBIENT: boolean;
  30489. AMBIENTDIRECTUV: number;
  30490. OPACITY: boolean;
  30491. OPACITYDIRECTUV: number;
  30492. OPACITYRGB: boolean;
  30493. REFLECTION: boolean;
  30494. EMISSIVE: boolean;
  30495. EMISSIVEDIRECTUV: number;
  30496. SPECULAR: boolean;
  30497. SPECULARDIRECTUV: number;
  30498. BUMP: boolean;
  30499. BUMPDIRECTUV: number;
  30500. PARALLAX: boolean;
  30501. PARALLAXOCCLUSION: boolean;
  30502. SPECULAROVERALPHA: boolean;
  30503. CLIPPLANE: boolean;
  30504. CLIPPLANE2: boolean;
  30505. CLIPPLANE3: boolean;
  30506. CLIPPLANE4: boolean;
  30507. CLIPPLANE5: boolean;
  30508. CLIPPLANE6: boolean;
  30509. ALPHATEST: boolean;
  30510. DEPTHPREPASS: boolean;
  30511. ALPHAFROMDIFFUSE: boolean;
  30512. POINTSIZE: boolean;
  30513. FOG: boolean;
  30514. SPECULARTERM: boolean;
  30515. DIFFUSEFRESNEL: boolean;
  30516. OPACITYFRESNEL: boolean;
  30517. REFLECTIONFRESNEL: boolean;
  30518. REFRACTIONFRESNEL: boolean;
  30519. EMISSIVEFRESNEL: boolean;
  30520. FRESNEL: boolean;
  30521. NORMAL: boolean;
  30522. UV1: boolean;
  30523. UV2: boolean;
  30524. VERTEXCOLOR: boolean;
  30525. VERTEXALPHA: boolean;
  30526. NUM_BONE_INFLUENCERS: number;
  30527. BonesPerMesh: number;
  30528. BONETEXTURE: boolean;
  30529. INSTANCES: boolean;
  30530. THIN_INSTANCES: boolean;
  30531. GLOSSINESS: boolean;
  30532. ROUGHNESS: boolean;
  30533. EMISSIVEASILLUMINATION: boolean;
  30534. LINKEMISSIVEWITHDIFFUSE: boolean;
  30535. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30536. LIGHTMAP: boolean;
  30537. LIGHTMAPDIRECTUV: number;
  30538. OBJECTSPACE_NORMALMAP: boolean;
  30539. USELIGHTMAPASSHADOWMAP: boolean;
  30540. REFLECTIONMAP_3D: boolean;
  30541. REFLECTIONMAP_SPHERICAL: boolean;
  30542. REFLECTIONMAP_PLANAR: boolean;
  30543. REFLECTIONMAP_CUBIC: boolean;
  30544. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30545. REFLECTIONMAP_PROJECTION: boolean;
  30546. REFLECTIONMAP_SKYBOX: boolean;
  30547. REFLECTIONMAP_EXPLICIT: boolean;
  30548. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30549. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30550. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30551. INVERTCUBICMAP: boolean;
  30552. LOGARITHMICDEPTH: boolean;
  30553. REFRACTION: boolean;
  30554. REFRACTIONMAP_3D: boolean;
  30555. REFLECTIONOVERALPHA: boolean;
  30556. TWOSIDEDLIGHTING: boolean;
  30557. SHADOWFLOAT: boolean;
  30558. MORPHTARGETS: boolean;
  30559. MORPHTARGETS_NORMAL: boolean;
  30560. MORPHTARGETS_TANGENT: boolean;
  30561. MORPHTARGETS_UV: boolean;
  30562. NUM_MORPH_INFLUENCERS: number;
  30563. NONUNIFORMSCALING: boolean;
  30564. PREMULTIPLYALPHA: boolean;
  30565. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30566. ALPHABLEND: boolean;
  30567. PREPASS: boolean;
  30568. SCENE_MRT_COUNT: number;
  30569. RGBDLIGHTMAP: boolean;
  30570. RGBDREFLECTION: boolean;
  30571. RGBDREFRACTION: boolean;
  30572. IMAGEPROCESSING: boolean;
  30573. VIGNETTE: boolean;
  30574. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30575. VIGNETTEBLENDMODEOPAQUE: boolean;
  30576. TONEMAPPING: boolean;
  30577. TONEMAPPING_ACES: boolean;
  30578. CONTRAST: boolean;
  30579. COLORCURVES: boolean;
  30580. COLORGRADING: boolean;
  30581. COLORGRADING3D: boolean;
  30582. SAMPLER3DGREENDEPTH: boolean;
  30583. SAMPLER3DBGRMAP: boolean;
  30584. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30585. MULTIVIEW: boolean;
  30586. /**
  30587. * If the reflection texture on this material is in linear color space
  30588. * @hidden
  30589. */
  30590. IS_REFLECTION_LINEAR: boolean;
  30591. /**
  30592. * If the refraction texture on this material is in linear color space
  30593. * @hidden
  30594. */
  30595. IS_REFRACTION_LINEAR: boolean;
  30596. EXPOSURE: boolean;
  30597. constructor();
  30598. setReflectionMode(modeToEnable: string): void;
  30599. }
  30600. /**
  30601. * This is the default material used in Babylon. It is the best trade off between quality
  30602. * and performances.
  30603. * @see https://doc.babylonjs.com/babylon101/materials
  30604. */
  30605. export class StandardMaterial extends PushMaterial {
  30606. private _diffuseTexture;
  30607. /**
  30608. * The basic texture of the material as viewed under a light.
  30609. */
  30610. diffuseTexture: Nullable<BaseTexture>;
  30611. private _ambientTexture;
  30612. /**
  30613. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30614. */
  30615. ambientTexture: Nullable<BaseTexture>;
  30616. private _opacityTexture;
  30617. /**
  30618. * Define the transparency of the material from a texture.
  30619. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30620. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30621. */
  30622. opacityTexture: Nullable<BaseTexture>;
  30623. private _reflectionTexture;
  30624. /**
  30625. * Define the texture used to display the reflection.
  30626. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30627. */
  30628. reflectionTexture: Nullable<BaseTexture>;
  30629. private _emissiveTexture;
  30630. /**
  30631. * Define texture of the material as if self lit.
  30632. * This will be mixed in the final result even in the absence of light.
  30633. */
  30634. emissiveTexture: Nullable<BaseTexture>;
  30635. private _specularTexture;
  30636. /**
  30637. * Define how the color and intensity of the highlight given by the light in the material.
  30638. */
  30639. specularTexture: Nullable<BaseTexture>;
  30640. private _bumpTexture;
  30641. /**
  30642. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30643. * 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.
  30644. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30645. */
  30646. bumpTexture: Nullable<BaseTexture>;
  30647. private _lightmapTexture;
  30648. /**
  30649. * Complex lighting can be computationally expensive to compute at runtime.
  30650. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30651. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30652. */
  30653. lightmapTexture: Nullable<BaseTexture>;
  30654. private _refractionTexture;
  30655. /**
  30656. * Define the texture used to display the refraction.
  30657. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30658. */
  30659. refractionTexture: Nullable<BaseTexture>;
  30660. /**
  30661. * The color of the material lit by the environmental background lighting.
  30662. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30663. */
  30664. ambientColor: Color3;
  30665. /**
  30666. * The basic color of the material as viewed under a light.
  30667. */
  30668. diffuseColor: Color3;
  30669. /**
  30670. * Define how the color and intensity of the highlight given by the light in the material.
  30671. */
  30672. specularColor: Color3;
  30673. /**
  30674. * Define the color of the material as if self lit.
  30675. * This will be mixed in the final result even in the absence of light.
  30676. */
  30677. emissiveColor: Color3;
  30678. /**
  30679. * Defines how sharp are the highlights in the material.
  30680. * The bigger the value the sharper giving a more glossy feeling to the result.
  30681. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30682. */
  30683. specularPower: number;
  30684. private _useAlphaFromDiffuseTexture;
  30685. /**
  30686. * Does the transparency come from the diffuse texture alpha channel.
  30687. */
  30688. useAlphaFromDiffuseTexture: boolean;
  30689. private _useEmissiveAsIllumination;
  30690. /**
  30691. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30692. */
  30693. useEmissiveAsIllumination: boolean;
  30694. private _linkEmissiveWithDiffuse;
  30695. /**
  30696. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30697. * the emissive level when the final color is close to one.
  30698. */
  30699. linkEmissiveWithDiffuse: boolean;
  30700. private _useSpecularOverAlpha;
  30701. /**
  30702. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30703. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30704. */
  30705. useSpecularOverAlpha: boolean;
  30706. private _useReflectionOverAlpha;
  30707. /**
  30708. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30709. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30710. */
  30711. useReflectionOverAlpha: boolean;
  30712. private _disableLighting;
  30713. /**
  30714. * Does lights from the scene impacts this material.
  30715. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30716. */
  30717. disableLighting: boolean;
  30718. private _useObjectSpaceNormalMap;
  30719. /**
  30720. * Allows using an object space normal map (instead of tangent space).
  30721. */
  30722. useObjectSpaceNormalMap: boolean;
  30723. private _useParallax;
  30724. /**
  30725. * Is parallax enabled or not.
  30726. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30727. */
  30728. useParallax: boolean;
  30729. private _useParallaxOcclusion;
  30730. /**
  30731. * Is parallax occlusion enabled or not.
  30732. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30733. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30734. */
  30735. useParallaxOcclusion: boolean;
  30736. /**
  30737. * 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.
  30738. */
  30739. parallaxScaleBias: number;
  30740. private _roughness;
  30741. /**
  30742. * Helps to define how blurry the reflections should appears in the material.
  30743. */
  30744. roughness: number;
  30745. /**
  30746. * In case of refraction, define the value of the index of refraction.
  30747. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30748. */
  30749. indexOfRefraction: number;
  30750. /**
  30751. * Invert the refraction texture alongside the y axis.
  30752. * It can be useful with procedural textures or probe for instance.
  30753. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30754. */
  30755. invertRefractionY: boolean;
  30756. /**
  30757. * Defines the alpha limits in alpha test mode.
  30758. */
  30759. alphaCutOff: number;
  30760. private _useLightmapAsShadowmap;
  30761. /**
  30762. * In case of light mapping, define whether the map contains light or shadow informations.
  30763. */
  30764. useLightmapAsShadowmap: boolean;
  30765. private _diffuseFresnelParameters;
  30766. /**
  30767. * Define the diffuse fresnel parameters of the material.
  30768. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30769. */
  30770. diffuseFresnelParameters: FresnelParameters;
  30771. private _opacityFresnelParameters;
  30772. /**
  30773. * Define the opacity fresnel parameters of the material.
  30774. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30775. */
  30776. opacityFresnelParameters: FresnelParameters;
  30777. private _reflectionFresnelParameters;
  30778. /**
  30779. * Define the reflection fresnel parameters of the material.
  30780. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30781. */
  30782. reflectionFresnelParameters: FresnelParameters;
  30783. private _refractionFresnelParameters;
  30784. /**
  30785. * Define the refraction fresnel parameters of the material.
  30786. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30787. */
  30788. refractionFresnelParameters: FresnelParameters;
  30789. private _emissiveFresnelParameters;
  30790. /**
  30791. * Define the emissive fresnel parameters of the material.
  30792. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30793. */
  30794. emissiveFresnelParameters: FresnelParameters;
  30795. private _useReflectionFresnelFromSpecular;
  30796. /**
  30797. * If true automatically deducts the fresnels values from the material specularity.
  30798. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30799. */
  30800. useReflectionFresnelFromSpecular: boolean;
  30801. private _useGlossinessFromSpecularMapAlpha;
  30802. /**
  30803. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30804. */
  30805. useGlossinessFromSpecularMapAlpha: boolean;
  30806. private _maxSimultaneousLights;
  30807. /**
  30808. * Defines the maximum number of lights that can be used in the material
  30809. */
  30810. maxSimultaneousLights: number;
  30811. private _invertNormalMapX;
  30812. /**
  30813. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30814. */
  30815. invertNormalMapX: boolean;
  30816. private _invertNormalMapY;
  30817. /**
  30818. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30819. */
  30820. invertNormalMapY: boolean;
  30821. private _twoSidedLighting;
  30822. /**
  30823. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30824. */
  30825. twoSidedLighting: boolean;
  30826. /**
  30827. * Default configuration related to image processing available in the standard Material.
  30828. */
  30829. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30830. /**
  30831. * Gets the image processing configuration used either in this material.
  30832. */
  30833. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30834. /**
  30835. * Sets the Default image processing configuration used either in the this material.
  30836. *
  30837. * If sets to null, the scene one is in use.
  30838. */
  30839. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30840. /**
  30841. * Keep track of the image processing observer to allow dispose and replace.
  30842. */
  30843. private _imageProcessingObserver;
  30844. /**
  30845. * Attaches a new image processing configuration to the Standard Material.
  30846. * @param configuration
  30847. */
  30848. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30849. /**
  30850. * Gets wether the color curves effect is enabled.
  30851. */
  30852. get cameraColorCurvesEnabled(): boolean;
  30853. /**
  30854. * Sets wether the color curves effect is enabled.
  30855. */
  30856. set cameraColorCurvesEnabled(value: boolean);
  30857. /**
  30858. * Gets wether the color grading effect is enabled.
  30859. */
  30860. get cameraColorGradingEnabled(): boolean;
  30861. /**
  30862. * Gets wether the color grading effect is enabled.
  30863. */
  30864. set cameraColorGradingEnabled(value: boolean);
  30865. /**
  30866. * Gets wether tonemapping is enabled or not.
  30867. */
  30868. get cameraToneMappingEnabled(): boolean;
  30869. /**
  30870. * Sets wether tonemapping is enabled or not
  30871. */
  30872. set cameraToneMappingEnabled(value: boolean);
  30873. /**
  30874. * The camera exposure used on this material.
  30875. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30876. * This corresponds to a photographic exposure.
  30877. */
  30878. get cameraExposure(): number;
  30879. /**
  30880. * The camera exposure used on this material.
  30881. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30882. * This corresponds to a photographic exposure.
  30883. */
  30884. set cameraExposure(value: number);
  30885. /**
  30886. * Gets The camera contrast used on this material.
  30887. */
  30888. get cameraContrast(): number;
  30889. /**
  30890. * Sets The camera contrast used on this material.
  30891. */
  30892. set cameraContrast(value: number);
  30893. /**
  30894. * Gets the Color Grading 2D Lookup Texture.
  30895. */
  30896. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30897. /**
  30898. * Sets the Color Grading 2D Lookup Texture.
  30899. */
  30900. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30901. /**
  30902. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30903. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30904. * 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;
  30905. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30906. */
  30907. get cameraColorCurves(): Nullable<ColorCurves>;
  30908. /**
  30909. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30910. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30911. * 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;
  30912. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30913. */
  30914. set cameraColorCurves(value: Nullable<ColorCurves>);
  30915. /**
  30916. * Defines the detail map parameters for the material.
  30917. */
  30918. readonly detailMap: DetailMapConfiguration;
  30919. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30920. protected _worldViewProjectionMatrix: Matrix;
  30921. protected _globalAmbientColor: Color3;
  30922. protected _useLogarithmicDepth: boolean;
  30923. protected _rebuildInParallel: boolean;
  30924. /**
  30925. * Instantiates a new standard material.
  30926. * This is the default material used in Babylon. It is the best trade off between quality
  30927. * and performances.
  30928. * @see https://doc.babylonjs.com/babylon101/materials
  30929. * @param name Define the name of the material in the scene
  30930. * @param scene Define the scene the material belong to
  30931. */
  30932. constructor(name: string, scene: Scene);
  30933. /**
  30934. * Gets a boolean indicating that current material needs to register RTT
  30935. */
  30936. get hasRenderTargetTextures(): boolean;
  30937. /**
  30938. * Gets the current class name of the material e.g. "StandardMaterial"
  30939. * Mainly use in serialization.
  30940. * @returns the class name
  30941. */
  30942. getClassName(): string;
  30943. /**
  30944. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30945. * You can try switching to logarithmic depth.
  30946. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30947. */
  30948. get useLogarithmicDepth(): boolean;
  30949. set useLogarithmicDepth(value: boolean);
  30950. /**
  30951. * Specifies if the material will require alpha blending
  30952. * @returns a boolean specifying if alpha blending is needed
  30953. */
  30954. needAlphaBlending(): boolean;
  30955. /**
  30956. * Specifies if this material should be rendered in alpha test mode
  30957. * @returns a boolean specifying if an alpha test is needed.
  30958. */
  30959. needAlphaTesting(): boolean;
  30960. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30961. /**
  30962. * Get the texture used for alpha test purpose.
  30963. * @returns the diffuse texture in case of the standard material.
  30964. */
  30965. getAlphaTestTexture(): Nullable<BaseTexture>;
  30966. /**
  30967. * Get if the submesh is ready to be used and all its information available.
  30968. * Child classes can use it to update shaders
  30969. * @param mesh defines the mesh to check
  30970. * @param subMesh defines which submesh to check
  30971. * @param useInstances specifies that instances should be used
  30972. * @returns a boolean indicating that the submesh is ready or not
  30973. */
  30974. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30975. /**
  30976. * Builds the material UBO layouts.
  30977. * Used internally during the effect preparation.
  30978. */
  30979. buildUniformLayout(): void;
  30980. /**
  30981. * Unbinds the material from the mesh
  30982. */
  30983. unbind(): void;
  30984. /**
  30985. * Binds the submesh to this material by preparing the effect and shader to draw
  30986. * @param world defines the world transformation matrix
  30987. * @param mesh defines the mesh containing the submesh
  30988. * @param subMesh defines the submesh to bind the material to
  30989. */
  30990. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30991. /**
  30992. * Get the list of animatables in the material.
  30993. * @returns the list of animatables object used in the material
  30994. */
  30995. getAnimatables(): IAnimatable[];
  30996. /**
  30997. * Gets the active textures from the material
  30998. * @returns an array of textures
  30999. */
  31000. getActiveTextures(): BaseTexture[];
  31001. /**
  31002. * Specifies if the material uses a texture
  31003. * @param texture defines the texture to check against the material
  31004. * @returns a boolean specifying if the material uses the texture
  31005. */
  31006. hasTexture(texture: BaseTexture): boolean;
  31007. /**
  31008. * Disposes the material
  31009. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31010. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31011. */
  31012. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31013. /**
  31014. * Makes a duplicate of the material, and gives it a new name
  31015. * @param name defines the new name for the duplicated material
  31016. * @returns the cloned material
  31017. */
  31018. clone(name: string): StandardMaterial;
  31019. /**
  31020. * Serializes this material in a JSON representation
  31021. * @returns the serialized material object
  31022. */
  31023. serialize(): any;
  31024. /**
  31025. * Creates a standard material from parsed material data
  31026. * @param source defines the JSON representation of the material
  31027. * @param scene defines the hosting scene
  31028. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31029. * @returns a new standard material
  31030. */
  31031. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31032. /**
  31033. * Are diffuse textures enabled in the application.
  31034. */
  31035. static get DiffuseTextureEnabled(): boolean;
  31036. static set DiffuseTextureEnabled(value: boolean);
  31037. /**
  31038. * Are detail textures enabled in the application.
  31039. */
  31040. static get DetailTextureEnabled(): boolean;
  31041. static set DetailTextureEnabled(value: boolean);
  31042. /**
  31043. * Are ambient textures enabled in the application.
  31044. */
  31045. static get AmbientTextureEnabled(): boolean;
  31046. static set AmbientTextureEnabled(value: boolean);
  31047. /**
  31048. * Are opacity textures enabled in the application.
  31049. */
  31050. static get OpacityTextureEnabled(): boolean;
  31051. static set OpacityTextureEnabled(value: boolean);
  31052. /**
  31053. * Are reflection textures enabled in the application.
  31054. */
  31055. static get ReflectionTextureEnabled(): boolean;
  31056. static set ReflectionTextureEnabled(value: boolean);
  31057. /**
  31058. * Are emissive textures enabled in the application.
  31059. */
  31060. static get EmissiveTextureEnabled(): boolean;
  31061. static set EmissiveTextureEnabled(value: boolean);
  31062. /**
  31063. * Are specular textures enabled in the application.
  31064. */
  31065. static get SpecularTextureEnabled(): boolean;
  31066. static set SpecularTextureEnabled(value: boolean);
  31067. /**
  31068. * Are bump textures enabled in the application.
  31069. */
  31070. static get BumpTextureEnabled(): boolean;
  31071. static set BumpTextureEnabled(value: boolean);
  31072. /**
  31073. * Are lightmap textures enabled in the application.
  31074. */
  31075. static get LightmapTextureEnabled(): boolean;
  31076. static set LightmapTextureEnabled(value: boolean);
  31077. /**
  31078. * Are refraction textures enabled in the application.
  31079. */
  31080. static get RefractionTextureEnabled(): boolean;
  31081. static set RefractionTextureEnabled(value: boolean);
  31082. /**
  31083. * Are color grading textures enabled in the application.
  31084. */
  31085. static get ColorGradingTextureEnabled(): boolean;
  31086. static set ColorGradingTextureEnabled(value: boolean);
  31087. /**
  31088. * Are fresnels enabled in the application.
  31089. */
  31090. static get FresnelEnabled(): boolean;
  31091. static set FresnelEnabled(value: boolean);
  31092. }
  31093. }
  31094. declare module "babylonjs/Particles/solidParticleSystem" {
  31095. import { Nullable } from "babylonjs/types";
  31096. import { Mesh } from "babylonjs/Meshes/mesh";
  31097. import { Scene, IDisposable } from "babylonjs/scene";
  31098. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31099. import { Material } from "babylonjs/Materials/material";
  31100. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31101. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31102. /**
  31103. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31104. *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.
  31105. * The SPS is also a particle system. It provides some methods to manage the particles.
  31106. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31107. *
  31108. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31109. */
  31110. export class SolidParticleSystem implements IDisposable {
  31111. /**
  31112. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31113. * Example : var p = SPS.particles[i];
  31114. */
  31115. particles: SolidParticle[];
  31116. /**
  31117. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31118. */
  31119. nbParticles: number;
  31120. /**
  31121. * If the particles must ever face the camera (default false). Useful for planar particles.
  31122. */
  31123. billboard: boolean;
  31124. /**
  31125. * Recompute normals when adding a shape
  31126. */
  31127. recomputeNormals: boolean;
  31128. /**
  31129. * This a counter ofr your own usage. It's not set by any SPS functions.
  31130. */
  31131. counter: number;
  31132. /**
  31133. * The SPS name. This name is also given to the underlying mesh.
  31134. */
  31135. name: string;
  31136. /**
  31137. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31138. */
  31139. mesh: Mesh;
  31140. /**
  31141. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31142. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31143. */
  31144. vars: any;
  31145. /**
  31146. * This array is populated when the SPS is set as 'pickable'.
  31147. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31148. * Each element of this array is an object `{idx: int, faceId: int}`.
  31149. * `idx` is the picked particle index in the `SPS.particles` array
  31150. * `faceId` is the picked face index counted within this particle.
  31151. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31152. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31153. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31154. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31155. */
  31156. pickedParticles: {
  31157. idx: number;
  31158. faceId: number;
  31159. }[];
  31160. /**
  31161. * This array is populated when the SPS is set as 'pickable'
  31162. * Each key of this array is a submesh index.
  31163. * Each element of this array is a second array defined like this :
  31164. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31165. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31166. * `idx` is the picked particle index in the `SPS.particles` array
  31167. * `faceId` is the picked face index counted within this particle.
  31168. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31169. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31170. */
  31171. pickedBySubMesh: {
  31172. idx: number;
  31173. faceId: number;
  31174. }[][];
  31175. /**
  31176. * This array is populated when `enableDepthSort` is set to true.
  31177. * Each element of this array is an instance of the class DepthSortedParticle.
  31178. */
  31179. depthSortedParticles: DepthSortedParticle[];
  31180. /**
  31181. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31182. * @hidden
  31183. */
  31184. _bSphereOnly: boolean;
  31185. /**
  31186. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31187. * @hidden
  31188. */
  31189. _bSphereRadiusFactor: number;
  31190. private _scene;
  31191. private _positions;
  31192. private _indices;
  31193. private _normals;
  31194. private _colors;
  31195. private _uvs;
  31196. private _indices32;
  31197. private _positions32;
  31198. private _normals32;
  31199. private _fixedNormal32;
  31200. private _colors32;
  31201. private _uvs32;
  31202. private _index;
  31203. private _updatable;
  31204. private _pickable;
  31205. private _isVisibilityBoxLocked;
  31206. private _alwaysVisible;
  31207. private _depthSort;
  31208. private _expandable;
  31209. private _shapeCounter;
  31210. private _copy;
  31211. private _color;
  31212. private _computeParticleColor;
  31213. private _computeParticleTexture;
  31214. private _computeParticleRotation;
  31215. private _computeParticleVertex;
  31216. private _computeBoundingBox;
  31217. private _depthSortParticles;
  31218. private _camera;
  31219. private _mustUnrotateFixedNormals;
  31220. private _particlesIntersect;
  31221. private _needs32Bits;
  31222. private _isNotBuilt;
  31223. private _lastParticleId;
  31224. private _idxOfId;
  31225. private _multimaterialEnabled;
  31226. private _useModelMaterial;
  31227. private _indicesByMaterial;
  31228. private _materialIndexes;
  31229. private _depthSortFunction;
  31230. private _materialSortFunction;
  31231. private _materials;
  31232. private _multimaterial;
  31233. private _materialIndexesById;
  31234. private _defaultMaterial;
  31235. private _autoUpdateSubMeshes;
  31236. private _tmpVertex;
  31237. /**
  31238. * Creates a SPS (Solid Particle System) object.
  31239. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31240. * @param scene (Scene) is the scene in which the SPS is added.
  31241. * @param options defines the options of the sps e.g.
  31242. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31243. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31244. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31245. * * 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.
  31246. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31247. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31248. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31249. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31250. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31251. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31252. */
  31253. constructor(name: string, scene: Scene, options?: {
  31254. updatable?: boolean;
  31255. isPickable?: boolean;
  31256. enableDepthSort?: boolean;
  31257. particleIntersection?: boolean;
  31258. boundingSphereOnly?: boolean;
  31259. bSphereRadiusFactor?: number;
  31260. expandable?: boolean;
  31261. useModelMaterial?: boolean;
  31262. enableMultiMaterial?: boolean;
  31263. });
  31264. /**
  31265. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31266. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31267. * @returns the created mesh
  31268. */
  31269. buildMesh(): Mesh;
  31270. /**
  31271. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31272. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31273. * Thus the particles generated from `digest()` have their property `position` set yet.
  31274. * @param mesh ( Mesh ) is the mesh to be digested
  31275. * @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
  31276. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31277. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31278. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31279. * @returns the current SPS
  31280. */
  31281. digest(mesh: Mesh, options?: {
  31282. facetNb?: number;
  31283. number?: number;
  31284. delta?: number;
  31285. storage?: [];
  31286. }): SolidParticleSystem;
  31287. /**
  31288. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31289. * @hidden
  31290. */
  31291. private _unrotateFixedNormals;
  31292. /**
  31293. * Resets the temporary working copy particle
  31294. * @hidden
  31295. */
  31296. private _resetCopy;
  31297. /**
  31298. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31299. * @param p the current index in the positions array to be updated
  31300. * @param ind the current index in the indices array
  31301. * @param shape a Vector3 array, the shape geometry
  31302. * @param positions the positions array to be updated
  31303. * @param meshInd the shape indices array
  31304. * @param indices the indices array to be updated
  31305. * @param meshUV the shape uv array
  31306. * @param uvs the uv array to be updated
  31307. * @param meshCol the shape color array
  31308. * @param colors the color array to be updated
  31309. * @param meshNor the shape normals array
  31310. * @param normals the normals array to be updated
  31311. * @param idx the particle index
  31312. * @param idxInShape the particle index in its shape
  31313. * @param options the addShape() method passed options
  31314. * @model the particle model
  31315. * @hidden
  31316. */
  31317. private _meshBuilder;
  31318. /**
  31319. * Returns a shape Vector3 array from positions float array
  31320. * @param positions float array
  31321. * @returns a vector3 array
  31322. * @hidden
  31323. */
  31324. private _posToShape;
  31325. /**
  31326. * Returns a shapeUV array from a float uvs (array deep copy)
  31327. * @param uvs as a float array
  31328. * @returns a shapeUV array
  31329. * @hidden
  31330. */
  31331. private _uvsToShapeUV;
  31332. /**
  31333. * Adds a new particle object in the particles array
  31334. * @param idx particle index in particles array
  31335. * @param id particle id
  31336. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31337. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31338. * @param model particle ModelShape object
  31339. * @param shapeId model shape identifier
  31340. * @param idxInShape index of the particle in the current model
  31341. * @param bInfo model bounding info object
  31342. * @param storage target storage array, if any
  31343. * @hidden
  31344. */
  31345. private _addParticle;
  31346. /**
  31347. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31348. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31349. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31350. * @param nb (positive integer) the number of particles to be created from this model
  31351. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31352. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31353. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31354. * @returns the number of shapes in the system
  31355. */
  31356. addShape(mesh: Mesh, nb: number, options?: {
  31357. positionFunction?: any;
  31358. vertexFunction?: any;
  31359. storage?: [];
  31360. }): number;
  31361. /**
  31362. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31363. * @hidden
  31364. */
  31365. private _rebuildParticle;
  31366. /**
  31367. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31368. * @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.
  31369. * @returns the SPS.
  31370. */
  31371. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31372. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31373. * Returns an array with the removed particles.
  31374. * 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.
  31375. * The SPS can't be empty so at least one particle needs to remain in place.
  31376. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31377. * @param start index of the first particle to remove
  31378. * @param end index of the last particle to remove (included)
  31379. * @returns an array populated with the removed particles
  31380. */
  31381. removeParticles(start: number, end: number): SolidParticle[];
  31382. /**
  31383. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31384. * @param solidParticleArray an array populated with Solid Particles objects
  31385. * @returns the SPS
  31386. */
  31387. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31388. /**
  31389. * Creates a new particle and modifies the SPS mesh geometry :
  31390. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31391. * - calls _addParticle() to populate the particle array
  31392. * factorized code from addShape() and insertParticlesFromArray()
  31393. * @param idx particle index in the particles array
  31394. * @param i particle index in its shape
  31395. * @param modelShape particle ModelShape object
  31396. * @param shape shape vertex array
  31397. * @param meshInd shape indices array
  31398. * @param meshUV shape uv array
  31399. * @param meshCol shape color array
  31400. * @param meshNor shape normals array
  31401. * @param bbInfo shape bounding info
  31402. * @param storage target particle storage
  31403. * @options addShape() passed options
  31404. * @hidden
  31405. */
  31406. private _insertNewParticle;
  31407. /**
  31408. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31409. * This method calls `updateParticle()` for each particle of the SPS.
  31410. * For an animated SPS, it is usually called within the render loop.
  31411. * 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.
  31412. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31413. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31414. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31415. * @returns the SPS.
  31416. */
  31417. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31418. /**
  31419. * Disposes the SPS.
  31420. */
  31421. dispose(): void;
  31422. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31423. * idx is the particle index in the SPS
  31424. * faceId is the picked face index counted within this particle.
  31425. * Returns null if the pickInfo can't identify a picked particle.
  31426. * @param pickingInfo (PickingInfo object)
  31427. * @returns {idx: number, faceId: number} or null
  31428. */
  31429. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31430. idx: number;
  31431. faceId: number;
  31432. }>;
  31433. /**
  31434. * Returns a SolidParticle object from its identifier : particle.id
  31435. * @param id (integer) the particle Id
  31436. * @returns the searched particle or null if not found in the SPS.
  31437. */
  31438. getParticleById(id: number): Nullable<SolidParticle>;
  31439. /**
  31440. * Returns a new array populated with the particles having the passed shapeId.
  31441. * @param shapeId (integer) the shape identifier
  31442. * @returns a new solid particle array
  31443. */
  31444. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31445. /**
  31446. * Populates the passed array "ref" with the particles having the passed shapeId.
  31447. * @param shapeId the shape identifier
  31448. * @returns the SPS
  31449. * @param ref
  31450. */
  31451. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31452. /**
  31453. * Computes the required SubMeshes according the materials assigned to the particles.
  31454. * @returns the solid particle system.
  31455. * Does nothing if called before the SPS mesh is built.
  31456. */
  31457. computeSubMeshes(): SolidParticleSystem;
  31458. /**
  31459. * Sorts the solid particles by material when MultiMaterial is enabled.
  31460. * Updates the indices32 array.
  31461. * Updates the indicesByMaterial array.
  31462. * Updates the mesh indices array.
  31463. * @returns the SPS
  31464. * @hidden
  31465. */
  31466. private _sortParticlesByMaterial;
  31467. /**
  31468. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31469. * @hidden
  31470. */
  31471. private _setMaterialIndexesById;
  31472. /**
  31473. * Returns an array with unique values of Materials from the passed array
  31474. * @param array the material array to be checked and filtered
  31475. * @hidden
  31476. */
  31477. private _filterUniqueMaterialId;
  31478. /**
  31479. * Sets a new Standard Material as _defaultMaterial if not already set.
  31480. * @hidden
  31481. */
  31482. private _setDefaultMaterial;
  31483. /**
  31484. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31485. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31486. * @returns the SPS.
  31487. */
  31488. refreshVisibleSize(): SolidParticleSystem;
  31489. /**
  31490. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31491. * @param size the size (float) of the visibility box
  31492. * note : this doesn't lock the SPS mesh bounding box.
  31493. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31494. */
  31495. setVisibilityBox(size: number): void;
  31496. /**
  31497. * Gets whether the SPS as always visible or not
  31498. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31499. */
  31500. get isAlwaysVisible(): boolean;
  31501. /**
  31502. * Sets the SPS as always visible or not
  31503. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31504. */
  31505. set isAlwaysVisible(val: boolean);
  31506. /**
  31507. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31508. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31509. */
  31510. set isVisibilityBoxLocked(val: boolean);
  31511. /**
  31512. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31513. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31514. */
  31515. get isVisibilityBoxLocked(): boolean;
  31516. /**
  31517. * Tells to `setParticles()` to compute the particle rotations or not.
  31518. * Default value : true. The SPS is faster when it's set to false.
  31519. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31520. */
  31521. set computeParticleRotation(val: boolean);
  31522. /**
  31523. * Tells to `setParticles()` to compute the particle colors or not.
  31524. * Default value : true. The SPS is faster when it's set to false.
  31525. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31526. */
  31527. set computeParticleColor(val: boolean);
  31528. set computeParticleTexture(val: boolean);
  31529. /**
  31530. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31531. * Default value : false. The SPS is faster when it's set to false.
  31532. * Note : the particle custom vertex positions aren't stored values.
  31533. */
  31534. set computeParticleVertex(val: boolean);
  31535. /**
  31536. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31537. */
  31538. set computeBoundingBox(val: boolean);
  31539. /**
  31540. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31541. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31542. * Default : `true`
  31543. */
  31544. set depthSortParticles(val: boolean);
  31545. /**
  31546. * Gets if `setParticles()` computes the particle rotations or not.
  31547. * Default value : true. The SPS is faster when it's set to false.
  31548. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31549. */
  31550. get computeParticleRotation(): boolean;
  31551. /**
  31552. * Gets if `setParticles()` computes the particle colors or not.
  31553. * Default value : true. The SPS is faster when it's set to false.
  31554. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31555. */
  31556. get computeParticleColor(): boolean;
  31557. /**
  31558. * Gets if `setParticles()` computes the particle textures or not.
  31559. * Default value : true. The SPS is faster when it's set to false.
  31560. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31561. */
  31562. get computeParticleTexture(): boolean;
  31563. /**
  31564. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31565. * Default value : false. The SPS is faster when it's set to false.
  31566. * Note : the particle custom vertex positions aren't stored values.
  31567. */
  31568. get computeParticleVertex(): boolean;
  31569. /**
  31570. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31571. */
  31572. get computeBoundingBox(): boolean;
  31573. /**
  31574. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31575. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31576. * Default : `true`
  31577. */
  31578. get depthSortParticles(): boolean;
  31579. /**
  31580. * Gets if the SPS is created as expandable at construction time.
  31581. * Default : `false`
  31582. */
  31583. get expandable(): boolean;
  31584. /**
  31585. * Gets if the SPS supports the Multi Materials
  31586. */
  31587. get multimaterialEnabled(): boolean;
  31588. /**
  31589. * Gets if the SPS uses the model materials for its own multimaterial.
  31590. */
  31591. get useModelMaterial(): boolean;
  31592. /**
  31593. * The SPS used material array.
  31594. */
  31595. get materials(): Material[];
  31596. /**
  31597. * Sets the SPS MultiMaterial from the passed materials.
  31598. * Note : the passed array is internally copied and not used then by reference.
  31599. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31600. */
  31601. setMultiMaterial(materials: Material[]): void;
  31602. /**
  31603. * The SPS computed multimaterial object
  31604. */
  31605. get multimaterial(): MultiMaterial;
  31606. set multimaterial(mm: MultiMaterial);
  31607. /**
  31608. * If the subMeshes must be updated on the next call to setParticles()
  31609. */
  31610. get autoUpdateSubMeshes(): boolean;
  31611. set autoUpdateSubMeshes(val: boolean);
  31612. /**
  31613. * This function does nothing. It may be overwritten to set all the particle first values.
  31614. * The SPS doesn't call this function, you may have to call it by your own.
  31615. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31616. */
  31617. initParticles(): void;
  31618. /**
  31619. * This function does nothing. It may be overwritten to recycle a particle.
  31620. * The SPS doesn't call this function, you may have to call it by your own.
  31621. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31622. * @param particle The particle to recycle
  31623. * @returns the recycled particle
  31624. */
  31625. recycleParticle(particle: SolidParticle): SolidParticle;
  31626. /**
  31627. * Updates a particle : this function should be overwritten by the user.
  31628. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31629. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31630. * @example : just set a particle position or velocity and recycle conditions
  31631. * @param particle The particle to update
  31632. * @returns the updated particle
  31633. */
  31634. updateParticle(particle: SolidParticle): SolidParticle;
  31635. /**
  31636. * Updates a vertex of a particle : it can be overwritten by the user.
  31637. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31638. * @param particle the current particle
  31639. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31640. * @param pt the index of the current vertex in the particle shape
  31641. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31642. * @example : just set a vertex particle position or color
  31643. * @returns the sps
  31644. */
  31645. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31646. /**
  31647. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31648. * This does nothing and may be overwritten by the user.
  31649. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31650. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31651. * @param update the boolean update value actually passed to setParticles()
  31652. */
  31653. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31654. /**
  31655. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31656. * This will be passed three parameters.
  31657. * This does nothing and may be overwritten by the user.
  31658. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31659. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31660. * @param update the boolean update value actually passed to setParticles()
  31661. */
  31662. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31663. }
  31664. }
  31665. declare module "babylonjs/Particles/solidParticle" {
  31666. import { Nullable } from "babylonjs/types";
  31667. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31668. import { Color4 } from "babylonjs/Maths/math.color";
  31669. import { Mesh } from "babylonjs/Meshes/mesh";
  31670. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31671. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31672. import { Plane } from "babylonjs/Maths/math.plane";
  31673. import { Material } from "babylonjs/Materials/material";
  31674. /**
  31675. * Represents one particle of a solid particle system.
  31676. */
  31677. export class SolidParticle {
  31678. /**
  31679. * particle global index
  31680. */
  31681. idx: number;
  31682. /**
  31683. * particle identifier
  31684. */
  31685. id: number;
  31686. /**
  31687. * The color of the particle
  31688. */
  31689. color: Nullable<Color4>;
  31690. /**
  31691. * The world space position of the particle.
  31692. */
  31693. position: Vector3;
  31694. /**
  31695. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31696. */
  31697. rotation: Vector3;
  31698. /**
  31699. * The world space rotation quaternion of the particle.
  31700. */
  31701. rotationQuaternion: Nullable<Quaternion>;
  31702. /**
  31703. * The scaling of the particle.
  31704. */
  31705. scaling: Vector3;
  31706. /**
  31707. * The uvs of the particle.
  31708. */
  31709. uvs: Vector4;
  31710. /**
  31711. * The current speed of the particle.
  31712. */
  31713. velocity: Vector3;
  31714. /**
  31715. * The pivot point in the particle local space.
  31716. */
  31717. pivot: Vector3;
  31718. /**
  31719. * Must the particle be translated from its pivot point in its local space ?
  31720. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31721. * Default : false
  31722. */
  31723. translateFromPivot: boolean;
  31724. /**
  31725. * Is the particle active or not ?
  31726. */
  31727. alive: boolean;
  31728. /**
  31729. * Is the particle visible or not ?
  31730. */
  31731. isVisible: boolean;
  31732. /**
  31733. * Index of this particle in the global "positions" array (Internal use)
  31734. * @hidden
  31735. */
  31736. _pos: number;
  31737. /**
  31738. * @hidden Index of this particle in the global "indices" array (Internal use)
  31739. */
  31740. _ind: number;
  31741. /**
  31742. * @hidden ModelShape of this particle (Internal use)
  31743. */
  31744. _model: ModelShape;
  31745. /**
  31746. * ModelShape id of this particle
  31747. */
  31748. shapeId: number;
  31749. /**
  31750. * Index of the particle in its shape id
  31751. */
  31752. idxInShape: number;
  31753. /**
  31754. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31755. */
  31756. _modelBoundingInfo: BoundingInfo;
  31757. /**
  31758. * @hidden Particle BoundingInfo object (Internal use)
  31759. */
  31760. _boundingInfo: BoundingInfo;
  31761. /**
  31762. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31763. */
  31764. _sps: SolidParticleSystem;
  31765. /**
  31766. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31767. */
  31768. _stillInvisible: boolean;
  31769. /**
  31770. * @hidden Last computed particle rotation matrix
  31771. */
  31772. _rotationMatrix: number[];
  31773. /**
  31774. * Parent particle Id, if any.
  31775. * Default null.
  31776. */
  31777. parentId: Nullable<number>;
  31778. /**
  31779. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31780. */
  31781. materialIndex: Nullable<number>;
  31782. /**
  31783. * Custom object or properties.
  31784. */
  31785. props: Nullable<any>;
  31786. /**
  31787. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31788. * The possible values are :
  31789. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31790. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31791. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31792. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31793. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31794. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31795. * */
  31796. cullingStrategy: number;
  31797. /**
  31798. * @hidden Internal global position in the SPS.
  31799. */
  31800. _globalPosition: Vector3;
  31801. /**
  31802. * Creates a Solid Particle object.
  31803. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31804. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31805. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31806. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31807. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31808. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31809. * @param shapeId (integer) is the model shape identifier in the SPS.
  31810. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31811. * @param sps defines the sps it is associated to
  31812. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31813. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31814. */
  31815. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31816. /**
  31817. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31818. * @param target the particle target
  31819. * @returns the current particle
  31820. */
  31821. copyToRef(target: SolidParticle): SolidParticle;
  31822. /**
  31823. * Legacy support, changed scale to scaling
  31824. */
  31825. get scale(): Vector3;
  31826. /**
  31827. * Legacy support, changed scale to scaling
  31828. */
  31829. set scale(scale: Vector3);
  31830. /**
  31831. * Legacy support, changed quaternion to rotationQuaternion
  31832. */
  31833. get quaternion(): Nullable<Quaternion>;
  31834. /**
  31835. * Legacy support, changed quaternion to rotationQuaternion
  31836. */
  31837. set quaternion(q: Nullable<Quaternion>);
  31838. /**
  31839. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31840. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31841. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31842. * @returns true if it intersects
  31843. */
  31844. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31845. /**
  31846. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31847. * A particle is in the frustum if its bounding box intersects the frustum
  31848. * @param frustumPlanes defines the frustum to test
  31849. * @returns true if the particle is in the frustum planes
  31850. */
  31851. isInFrustum(frustumPlanes: Plane[]): boolean;
  31852. /**
  31853. * get the rotation matrix of the particle
  31854. * @hidden
  31855. */
  31856. getRotationMatrix(m: Matrix): void;
  31857. }
  31858. /**
  31859. * Represents the shape of the model used by one particle of a solid particle system.
  31860. * SPS internal tool, don't use it manually.
  31861. */
  31862. export class ModelShape {
  31863. /**
  31864. * The shape id
  31865. * @hidden
  31866. */
  31867. shapeID: number;
  31868. /**
  31869. * flat array of model positions (internal use)
  31870. * @hidden
  31871. */
  31872. _shape: Vector3[];
  31873. /**
  31874. * flat array of model UVs (internal use)
  31875. * @hidden
  31876. */
  31877. _shapeUV: number[];
  31878. /**
  31879. * color array of the model
  31880. * @hidden
  31881. */
  31882. _shapeColors: number[];
  31883. /**
  31884. * indices array of the model
  31885. * @hidden
  31886. */
  31887. _indices: number[];
  31888. /**
  31889. * normals array of the model
  31890. * @hidden
  31891. */
  31892. _normals: number[];
  31893. /**
  31894. * length of the shape in the model indices array (internal use)
  31895. * @hidden
  31896. */
  31897. _indicesLength: number;
  31898. /**
  31899. * Custom position function (internal use)
  31900. * @hidden
  31901. */
  31902. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31903. /**
  31904. * Custom vertex function (internal use)
  31905. * @hidden
  31906. */
  31907. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31908. /**
  31909. * Model material (internal use)
  31910. * @hidden
  31911. */
  31912. _material: Nullable<Material>;
  31913. /**
  31914. * 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.
  31915. * SPS internal tool, don't use it manually.
  31916. * @hidden
  31917. */
  31918. 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>);
  31919. }
  31920. /**
  31921. * Represents a Depth Sorted Particle in the solid particle system.
  31922. * @hidden
  31923. */
  31924. export class DepthSortedParticle {
  31925. /**
  31926. * Particle index
  31927. */
  31928. idx: number;
  31929. /**
  31930. * Index of the particle in the "indices" array
  31931. */
  31932. ind: number;
  31933. /**
  31934. * Length of the particle shape in the "indices" array
  31935. */
  31936. indicesLength: number;
  31937. /**
  31938. * Squared distance from the particle to the camera
  31939. */
  31940. sqDistance: number;
  31941. /**
  31942. * Material index when used with MultiMaterials
  31943. */
  31944. materialIndex: number;
  31945. /**
  31946. * Creates a new sorted particle
  31947. * @param materialIndex
  31948. */
  31949. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31950. }
  31951. /**
  31952. * Represents a solid particle vertex
  31953. */
  31954. export class SolidParticleVertex {
  31955. /**
  31956. * Vertex position
  31957. */
  31958. position: Vector3;
  31959. /**
  31960. * Vertex color
  31961. */
  31962. color: Color4;
  31963. /**
  31964. * Vertex UV
  31965. */
  31966. uv: Vector2;
  31967. /**
  31968. * Creates a new solid particle vertex
  31969. */
  31970. constructor();
  31971. /** Vertex x coordinate */
  31972. get x(): number;
  31973. set x(val: number);
  31974. /** Vertex y coordinate */
  31975. get y(): number;
  31976. set y(val: number);
  31977. /** Vertex z coordinate */
  31978. get z(): number;
  31979. set z(val: number);
  31980. }
  31981. }
  31982. declare module "babylonjs/Collisions/meshCollisionData" {
  31983. import { Collider } from "babylonjs/Collisions/collider";
  31984. import { Vector3 } from "babylonjs/Maths/math.vector";
  31985. import { Nullable } from "babylonjs/types";
  31986. import { Observer } from "babylonjs/Misc/observable";
  31987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31988. /**
  31989. * @hidden
  31990. */
  31991. export class _MeshCollisionData {
  31992. _checkCollisions: boolean;
  31993. _collisionMask: number;
  31994. _collisionGroup: number;
  31995. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31996. _collider: Nullable<Collider>;
  31997. _oldPositionForCollisions: Vector3;
  31998. _diffPositionForCollisions: Vector3;
  31999. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32000. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32001. }
  32002. }
  32003. declare module "babylonjs/Meshes/abstractMesh" {
  32004. import { Observable } from "babylonjs/Misc/observable";
  32005. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32006. import { Camera } from "babylonjs/Cameras/camera";
  32007. import { Scene, IDisposable } from "babylonjs/scene";
  32008. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32009. import { Node } from "babylonjs/node";
  32010. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32011. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32012. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32013. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32014. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32015. import { Material } from "babylonjs/Materials/material";
  32016. import { Light } from "babylonjs/Lights/light";
  32017. import { Skeleton } from "babylonjs/Bones/skeleton";
  32018. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32019. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32020. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32021. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32022. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32023. import { Plane } from "babylonjs/Maths/math.plane";
  32024. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32025. import { Ray } from "babylonjs/Culling/ray";
  32026. import { Collider } from "babylonjs/Collisions/collider";
  32027. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32028. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32029. /** @hidden */
  32030. class _FacetDataStorage {
  32031. facetPositions: Vector3[];
  32032. facetNormals: Vector3[];
  32033. facetPartitioning: number[][];
  32034. facetNb: number;
  32035. partitioningSubdivisions: number;
  32036. partitioningBBoxRatio: number;
  32037. facetDataEnabled: boolean;
  32038. facetParameters: any;
  32039. bbSize: Vector3;
  32040. subDiv: {
  32041. max: number;
  32042. X: number;
  32043. Y: number;
  32044. Z: number;
  32045. };
  32046. facetDepthSort: boolean;
  32047. facetDepthSortEnabled: boolean;
  32048. depthSortedIndices: IndicesArray;
  32049. depthSortedFacets: {
  32050. ind: number;
  32051. sqDistance: number;
  32052. }[];
  32053. facetDepthSortFunction: (f1: {
  32054. ind: number;
  32055. sqDistance: number;
  32056. }, f2: {
  32057. ind: number;
  32058. sqDistance: number;
  32059. }) => number;
  32060. facetDepthSortFrom: Vector3;
  32061. facetDepthSortOrigin: Vector3;
  32062. invertedMatrix: Matrix;
  32063. }
  32064. /**
  32065. * @hidden
  32066. **/
  32067. class _InternalAbstractMeshDataInfo {
  32068. _hasVertexAlpha: boolean;
  32069. _useVertexColors: boolean;
  32070. _numBoneInfluencers: number;
  32071. _applyFog: boolean;
  32072. _receiveShadows: boolean;
  32073. _facetData: _FacetDataStorage;
  32074. _visibility: number;
  32075. _skeleton: Nullable<Skeleton>;
  32076. _layerMask: number;
  32077. _computeBonesUsingShaders: boolean;
  32078. _isActive: boolean;
  32079. _onlyForInstances: boolean;
  32080. _isActiveIntermediate: boolean;
  32081. _onlyForInstancesIntermediate: boolean;
  32082. _actAsRegularMesh: boolean;
  32083. }
  32084. /**
  32085. * Class used to store all common mesh properties
  32086. */
  32087. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32088. /** No occlusion */
  32089. static OCCLUSION_TYPE_NONE: number;
  32090. /** Occlusion set to optimisitic */
  32091. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32092. /** Occlusion set to strict */
  32093. static OCCLUSION_TYPE_STRICT: number;
  32094. /** Use an accurante occlusion algorithm */
  32095. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32096. /** Use a conservative occlusion algorithm */
  32097. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32098. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32099. * Test order :
  32100. * Is the bounding sphere outside the frustum ?
  32101. * If not, are the bounding box vertices outside the frustum ?
  32102. * It not, then the cullable object is in the frustum.
  32103. */
  32104. static readonly CULLINGSTRATEGY_STANDARD: number;
  32105. /** Culling strategy : Bounding Sphere Only.
  32106. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32107. * It's also less accurate than the standard because some not visible objects can still be selected.
  32108. * Test : is the bounding sphere outside the frustum ?
  32109. * If not, then the cullable object is in the frustum.
  32110. */
  32111. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32112. /** Culling strategy : Optimistic Inclusion.
  32113. * This in an inclusion test first, then the standard exclusion test.
  32114. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32115. * 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.
  32116. * Anyway, it's as accurate as the standard strategy.
  32117. * Test :
  32118. * Is the cullable object bounding sphere center in the frustum ?
  32119. * If not, apply the default culling strategy.
  32120. */
  32121. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32122. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32123. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32124. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32125. * 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.
  32126. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32127. * Test :
  32128. * Is the cullable object bounding sphere center in the frustum ?
  32129. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32130. */
  32131. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32132. /**
  32133. * No billboard
  32134. */
  32135. static get BILLBOARDMODE_NONE(): number;
  32136. /** Billboard on X axis */
  32137. static get BILLBOARDMODE_X(): number;
  32138. /** Billboard on Y axis */
  32139. static get BILLBOARDMODE_Y(): number;
  32140. /** Billboard on Z axis */
  32141. static get BILLBOARDMODE_Z(): number;
  32142. /** Billboard on all axes */
  32143. static get BILLBOARDMODE_ALL(): number;
  32144. /** Billboard on using position instead of orientation */
  32145. static get BILLBOARDMODE_USE_POSITION(): number;
  32146. /** @hidden */
  32147. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32148. /**
  32149. * The culling strategy to use to check whether the mesh must be rendered or not.
  32150. * This value can be changed at any time and will be used on the next render mesh selection.
  32151. * The possible values are :
  32152. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32153. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32154. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32155. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32156. * Please read each static variable documentation to get details about the culling process.
  32157. * */
  32158. cullingStrategy: number;
  32159. /**
  32160. * Gets the number of facets in the mesh
  32161. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32162. */
  32163. get facetNb(): number;
  32164. /**
  32165. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32166. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32167. */
  32168. get partitioningSubdivisions(): number;
  32169. set partitioningSubdivisions(nb: number);
  32170. /**
  32171. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32172. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32173. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32174. */
  32175. get partitioningBBoxRatio(): number;
  32176. set partitioningBBoxRatio(ratio: number);
  32177. /**
  32178. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32179. * Works only for updatable meshes.
  32180. * Doesn't work with multi-materials
  32181. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32182. */
  32183. get mustDepthSortFacets(): boolean;
  32184. set mustDepthSortFacets(sort: boolean);
  32185. /**
  32186. * The location (Vector3) where the facet depth sort must be computed from.
  32187. * By default, the active camera position.
  32188. * Used only when facet depth sort is enabled
  32189. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32190. */
  32191. get facetDepthSortFrom(): Vector3;
  32192. set facetDepthSortFrom(location: Vector3);
  32193. /**
  32194. * gets a boolean indicating if facetData is enabled
  32195. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32196. */
  32197. get isFacetDataEnabled(): boolean;
  32198. /** @hidden */
  32199. _updateNonUniformScalingState(value: boolean): boolean;
  32200. /**
  32201. * An event triggered when this mesh collides with another one
  32202. */
  32203. onCollideObservable: Observable<AbstractMesh>;
  32204. /** Set a function to call when this mesh collides with another one */
  32205. set onCollide(callback: () => void);
  32206. /**
  32207. * An event triggered when the collision's position changes
  32208. */
  32209. onCollisionPositionChangeObservable: Observable<Vector3>;
  32210. /** Set a function to call when the collision's position changes */
  32211. set onCollisionPositionChange(callback: () => void);
  32212. /**
  32213. * An event triggered when material is changed
  32214. */
  32215. onMaterialChangedObservable: Observable<AbstractMesh>;
  32216. /**
  32217. * Gets or sets the orientation for POV movement & rotation
  32218. */
  32219. definedFacingForward: boolean;
  32220. /** @hidden */
  32221. _occlusionQuery: Nullable<WebGLQuery>;
  32222. /** @hidden */
  32223. _renderingGroup: Nullable<RenderingGroup>;
  32224. /**
  32225. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32226. */
  32227. get visibility(): number;
  32228. /**
  32229. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32230. */
  32231. set visibility(value: number);
  32232. /** Gets or sets the alpha index used to sort transparent meshes
  32233. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32234. */
  32235. alphaIndex: number;
  32236. /**
  32237. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32238. */
  32239. isVisible: boolean;
  32240. /**
  32241. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32242. */
  32243. isPickable: boolean;
  32244. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32245. showSubMeshesBoundingBox: boolean;
  32246. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32247. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32248. */
  32249. isBlocker: boolean;
  32250. /**
  32251. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32252. */
  32253. enablePointerMoveEvents: boolean;
  32254. /**
  32255. * Specifies the rendering group id for this mesh (0 by default)
  32256. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32257. */
  32258. renderingGroupId: number;
  32259. private _material;
  32260. /** Gets or sets current material */
  32261. get material(): Nullable<Material>;
  32262. set material(value: Nullable<Material>);
  32263. /**
  32264. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32265. * @see https://doc.babylonjs.com/babylon101/shadows
  32266. */
  32267. get receiveShadows(): boolean;
  32268. set receiveShadows(value: boolean);
  32269. /** Defines color to use when rendering outline */
  32270. outlineColor: Color3;
  32271. /** Define width to use when rendering outline */
  32272. outlineWidth: number;
  32273. /** Defines color to use when rendering overlay */
  32274. overlayColor: Color3;
  32275. /** Defines alpha to use when rendering overlay */
  32276. overlayAlpha: number;
  32277. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32278. get hasVertexAlpha(): boolean;
  32279. set hasVertexAlpha(value: boolean);
  32280. /** 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) */
  32281. get useVertexColors(): boolean;
  32282. set useVertexColors(value: boolean);
  32283. /**
  32284. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32285. */
  32286. get computeBonesUsingShaders(): boolean;
  32287. set computeBonesUsingShaders(value: boolean);
  32288. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32289. get numBoneInfluencers(): number;
  32290. set numBoneInfluencers(value: number);
  32291. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32292. get applyFog(): boolean;
  32293. set applyFog(value: boolean);
  32294. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32295. useOctreeForRenderingSelection: boolean;
  32296. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32297. useOctreeForPicking: boolean;
  32298. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32299. useOctreeForCollisions: boolean;
  32300. /**
  32301. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32302. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32303. */
  32304. get layerMask(): number;
  32305. set layerMask(value: number);
  32306. /**
  32307. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32308. */
  32309. alwaysSelectAsActiveMesh: boolean;
  32310. /**
  32311. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32312. */
  32313. doNotSyncBoundingInfo: boolean;
  32314. /**
  32315. * Gets or sets the current action manager
  32316. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32317. */
  32318. actionManager: Nullable<AbstractActionManager>;
  32319. private _meshCollisionData;
  32320. /**
  32321. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32322. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32323. */
  32324. ellipsoid: Vector3;
  32325. /**
  32326. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32327. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32328. */
  32329. ellipsoidOffset: Vector3;
  32330. /**
  32331. * Gets or sets a collision mask used to mask collisions (default is -1).
  32332. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32333. */
  32334. get collisionMask(): number;
  32335. set collisionMask(mask: number);
  32336. /**
  32337. * Gets or sets the current collision group mask (-1 by default).
  32338. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32339. */
  32340. get collisionGroup(): number;
  32341. set collisionGroup(mask: number);
  32342. /**
  32343. * Gets or sets current surrounding meshes (null by default).
  32344. *
  32345. * By default collision detection is tested against every mesh in the scene.
  32346. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32347. * meshes will be tested for the collision.
  32348. *
  32349. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32350. */
  32351. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32352. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32353. /**
  32354. * Defines edge width used when edgesRenderer is enabled
  32355. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32356. */
  32357. edgesWidth: number;
  32358. /**
  32359. * Defines edge color used when edgesRenderer is enabled
  32360. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32361. */
  32362. edgesColor: Color4;
  32363. /** @hidden */
  32364. _edgesRenderer: Nullable<IEdgesRenderer>;
  32365. /** @hidden */
  32366. _masterMesh: Nullable<AbstractMesh>;
  32367. /** @hidden */
  32368. _boundingInfo: Nullable<BoundingInfo>;
  32369. /** @hidden */
  32370. _renderId: number;
  32371. /**
  32372. * Gets or sets the list of subMeshes
  32373. * @see https://doc.babylonjs.com/how_to/multi_materials
  32374. */
  32375. subMeshes: SubMesh[];
  32376. /** @hidden */
  32377. _intersectionsInProgress: AbstractMesh[];
  32378. /** @hidden */
  32379. _unIndexed: boolean;
  32380. /** @hidden */
  32381. _lightSources: Light[];
  32382. /** Gets the list of lights affecting that mesh */
  32383. get lightSources(): Light[];
  32384. /** @hidden */
  32385. get _positions(): Nullable<Vector3[]>;
  32386. /** @hidden */
  32387. _waitingData: {
  32388. lods: Nullable<any>;
  32389. actions: Nullable<any>;
  32390. freezeWorldMatrix: Nullable<boolean>;
  32391. };
  32392. /** @hidden */
  32393. _bonesTransformMatrices: Nullable<Float32Array>;
  32394. /** @hidden */
  32395. _transformMatrixTexture: Nullable<RawTexture>;
  32396. /**
  32397. * Gets or sets a skeleton to apply skining transformations
  32398. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32399. */
  32400. set skeleton(value: Nullable<Skeleton>);
  32401. get skeleton(): Nullable<Skeleton>;
  32402. /**
  32403. * An event triggered when the mesh is rebuilt.
  32404. */
  32405. onRebuildObservable: Observable<AbstractMesh>;
  32406. /**
  32407. * Creates a new AbstractMesh
  32408. * @param name defines the name of the mesh
  32409. * @param scene defines the hosting scene
  32410. */
  32411. constructor(name: string, scene?: Nullable<Scene>);
  32412. /**
  32413. * Returns the string "AbstractMesh"
  32414. * @returns "AbstractMesh"
  32415. */
  32416. getClassName(): string;
  32417. /**
  32418. * Gets a string representation of the current mesh
  32419. * @param fullDetails defines a boolean indicating if full details must be included
  32420. * @returns a string representation of the current mesh
  32421. */
  32422. toString(fullDetails?: boolean): string;
  32423. /**
  32424. * @hidden
  32425. */
  32426. protected _getEffectiveParent(): Nullable<Node>;
  32427. /** @hidden */
  32428. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32429. /** @hidden */
  32430. _rebuild(): void;
  32431. /** @hidden */
  32432. _resyncLightSources(): void;
  32433. /** @hidden */
  32434. _resyncLightSource(light: Light): void;
  32435. /** @hidden */
  32436. _unBindEffect(): void;
  32437. /** @hidden */
  32438. _removeLightSource(light: Light, dispose: boolean): void;
  32439. private _markSubMeshesAsDirty;
  32440. /** @hidden */
  32441. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32442. /** @hidden */
  32443. _markSubMeshesAsAttributesDirty(): void;
  32444. /** @hidden */
  32445. _markSubMeshesAsMiscDirty(): void;
  32446. /**
  32447. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32448. */
  32449. get scaling(): Vector3;
  32450. set scaling(newScaling: Vector3);
  32451. /**
  32452. * Returns true if the mesh is blocked. Implemented by child classes
  32453. */
  32454. get isBlocked(): boolean;
  32455. /**
  32456. * Returns the mesh itself by default. Implemented by child classes
  32457. * @param camera defines the camera to use to pick the right LOD level
  32458. * @returns the currentAbstractMesh
  32459. */
  32460. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32461. /**
  32462. * Returns 0 by default. Implemented by child classes
  32463. * @returns an integer
  32464. */
  32465. getTotalVertices(): number;
  32466. /**
  32467. * Returns a positive integer : the total number of indices in this mesh geometry.
  32468. * @returns the numner of indices or zero if the mesh has no geometry.
  32469. */
  32470. getTotalIndices(): number;
  32471. /**
  32472. * Returns null by default. Implemented by child classes
  32473. * @returns null
  32474. */
  32475. getIndices(): Nullable<IndicesArray>;
  32476. /**
  32477. * Returns the array of the requested vertex data kind. Implemented by child classes
  32478. * @param kind defines the vertex data kind to use
  32479. * @returns null
  32480. */
  32481. getVerticesData(kind: string): Nullable<FloatArray>;
  32482. /**
  32483. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32484. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32485. * Note that a new underlying VertexBuffer object is created each call.
  32486. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32487. * @param kind defines vertex data kind:
  32488. * * VertexBuffer.PositionKind
  32489. * * VertexBuffer.UVKind
  32490. * * VertexBuffer.UV2Kind
  32491. * * VertexBuffer.UV3Kind
  32492. * * VertexBuffer.UV4Kind
  32493. * * VertexBuffer.UV5Kind
  32494. * * VertexBuffer.UV6Kind
  32495. * * VertexBuffer.ColorKind
  32496. * * VertexBuffer.MatricesIndicesKind
  32497. * * VertexBuffer.MatricesIndicesExtraKind
  32498. * * VertexBuffer.MatricesWeightsKind
  32499. * * VertexBuffer.MatricesWeightsExtraKind
  32500. * @param data defines the data source
  32501. * @param updatable defines if the data must be flagged as updatable (or static)
  32502. * @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
  32503. * @returns the current mesh
  32504. */
  32505. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32506. /**
  32507. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32508. * If the mesh has no geometry, it is simply returned as it is.
  32509. * @param kind defines vertex data kind:
  32510. * * VertexBuffer.PositionKind
  32511. * * VertexBuffer.UVKind
  32512. * * VertexBuffer.UV2Kind
  32513. * * VertexBuffer.UV3Kind
  32514. * * VertexBuffer.UV4Kind
  32515. * * VertexBuffer.UV5Kind
  32516. * * VertexBuffer.UV6Kind
  32517. * * VertexBuffer.ColorKind
  32518. * * VertexBuffer.MatricesIndicesKind
  32519. * * VertexBuffer.MatricesIndicesExtraKind
  32520. * * VertexBuffer.MatricesWeightsKind
  32521. * * VertexBuffer.MatricesWeightsExtraKind
  32522. * @param data defines the data source
  32523. * @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
  32524. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32525. * @returns the current mesh
  32526. */
  32527. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32528. /**
  32529. * Sets the mesh indices,
  32530. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32531. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32532. * @param totalVertices Defines the total number of vertices
  32533. * @returns the current mesh
  32534. */
  32535. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32536. /**
  32537. * Gets a boolean indicating if specific vertex data is present
  32538. * @param kind defines the vertex data kind to use
  32539. * @returns true is data kind is present
  32540. */
  32541. isVerticesDataPresent(kind: string): boolean;
  32542. /**
  32543. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32544. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32545. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32546. * @returns a BoundingInfo
  32547. */
  32548. getBoundingInfo(): BoundingInfo;
  32549. /**
  32550. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32551. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32552. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32553. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32554. * @returns the current mesh
  32555. */
  32556. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32557. /**
  32558. * Overwrite the current bounding info
  32559. * @param boundingInfo defines the new bounding info
  32560. * @returns the current mesh
  32561. */
  32562. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32563. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32564. get useBones(): boolean;
  32565. /** @hidden */
  32566. _preActivate(): void;
  32567. /** @hidden */
  32568. _preActivateForIntermediateRendering(renderId: number): void;
  32569. /** @hidden */
  32570. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32571. /** @hidden */
  32572. _postActivate(): void;
  32573. /** @hidden */
  32574. _freeze(): void;
  32575. /** @hidden */
  32576. _unFreeze(): void;
  32577. /**
  32578. * Gets the current world matrix
  32579. * @returns a Matrix
  32580. */
  32581. getWorldMatrix(): Matrix;
  32582. /** @hidden */
  32583. _getWorldMatrixDeterminant(): number;
  32584. /**
  32585. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32586. */
  32587. get isAnInstance(): boolean;
  32588. /**
  32589. * Gets a boolean indicating if this mesh has instances
  32590. */
  32591. get hasInstances(): boolean;
  32592. /**
  32593. * Gets a boolean indicating if this mesh has thin instances
  32594. */
  32595. get hasThinInstances(): boolean;
  32596. /**
  32597. * Perform relative position change from the point of view of behind the front of the mesh.
  32598. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32599. * Supports definition of mesh facing forward or backward
  32600. * @param amountRight defines the distance on the right axis
  32601. * @param amountUp defines the distance on the up axis
  32602. * @param amountForward defines the distance on the forward axis
  32603. * @returns the current mesh
  32604. */
  32605. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32606. /**
  32607. * Calculate relative position change from the point of view of behind the front of the mesh.
  32608. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32609. * Supports definition of mesh facing forward or backward
  32610. * @param amountRight defines the distance on the right axis
  32611. * @param amountUp defines the distance on the up axis
  32612. * @param amountForward defines the distance on the forward axis
  32613. * @returns the new displacement vector
  32614. */
  32615. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32616. /**
  32617. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32618. * Supports definition of mesh facing forward or backward
  32619. * @param flipBack defines the flip
  32620. * @param twirlClockwise defines the twirl
  32621. * @param tiltRight defines the tilt
  32622. * @returns the current mesh
  32623. */
  32624. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32625. /**
  32626. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32627. * Supports definition of mesh facing forward or backward.
  32628. * @param flipBack defines the flip
  32629. * @param twirlClockwise defines the twirl
  32630. * @param tiltRight defines the tilt
  32631. * @returns the new rotation vector
  32632. */
  32633. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32634. /**
  32635. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32636. * This means the mesh underlying bounding box and sphere are recomputed.
  32637. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32638. * @returns the current mesh
  32639. */
  32640. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32641. /** @hidden */
  32642. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32643. /** @hidden */
  32644. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32645. /** @hidden */
  32646. _updateBoundingInfo(): AbstractMesh;
  32647. /** @hidden */
  32648. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32649. /** @hidden */
  32650. protected _afterComputeWorldMatrix(): void;
  32651. /** @hidden */
  32652. get _effectiveMesh(): AbstractMesh;
  32653. /**
  32654. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32655. * A mesh is in the frustum if its bounding box intersects the frustum
  32656. * @param frustumPlanes defines the frustum to test
  32657. * @returns true if the mesh is in the frustum planes
  32658. */
  32659. isInFrustum(frustumPlanes: Plane[]): boolean;
  32660. /**
  32661. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32662. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32663. * @param frustumPlanes defines the frustum to test
  32664. * @returns true if the mesh is completely in the frustum planes
  32665. */
  32666. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32667. /**
  32668. * True if the mesh intersects another mesh or a SolidParticle object
  32669. * @param mesh defines a target mesh or SolidParticle to test
  32670. * @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)
  32671. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32672. * @returns true if there is an intersection
  32673. */
  32674. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32675. /**
  32676. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32677. * @param point defines the point to test
  32678. * @returns true if there is an intersection
  32679. */
  32680. intersectsPoint(point: Vector3): boolean;
  32681. /**
  32682. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32683. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32684. */
  32685. get checkCollisions(): boolean;
  32686. set checkCollisions(collisionEnabled: boolean);
  32687. /**
  32688. * Gets Collider object used to compute collisions (not physics)
  32689. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32690. */
  32691. get collider(): Nullable<Collider>;
  32692. /**
  32693. * Move the mesh using collision engine
  32694. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32695. * @param displacement defines the requested displacement vector
  32696. * @returns the current mesh
  32697. */
  32698. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32699. private _onCollisionPositionChange;
  32700. /** @hidden */
  32701. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32702. /** @hidden */
  32703. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32704. /** @hidden */
  32705. _checkCollision(collider: Collider): AbstractMesh;
  32706. /** @hidden */
  32707. _generatePointsArray(): boolean;
  32708. /**
  32709. * Checks if the passed Ray intersects with the mesh
  32710. * @param ray defines the ray to use
  32711. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32712. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32713. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32714. * @returns the picking info
  32715. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32716. */
  32717. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32718. /**
  32719. * Clones the current mesh
  32720. * @param name defines the mesh name
  32721. * @param newParent defines the new mesh parent
  32722. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32723. * @returns the new mesh
  32724. */
  32725. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32726. /**
  32727. * Disposes all the submeshes of the current meshnp
  32728. * @returns the current mesh
  32729. */
  32730. releaseSubMeshes(): AbstractMesh;
  32731. /**
  32732. * Releases resources associated with this abstract mesh.
  32733. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32734. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32735. */
  32736. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32737. /**
  32738. * Adds the passed mesh as a child to the current mesh
  32739. * @param mesh defines the child mesh
  32740. * @returns the current mesh
  32741. */
  32742. addChild(mesh: AbstractMesh): AbstractMesh;
  32743. /**
  32744. * Removes the passed mesh from the current mesh children list
  32745. * @param mesh defines the child mesh
  32746. * @returns the current mesh
  32747. */
  32748. removeChild(mesh: AbstractMesh): AbstractMesh;
  32749. /** @hidden */
  32750. private _initFacetData;
  32751. /**
  32752. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32753. * This method can be called within the render loop.
  32754. * 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
  32755. * @returns the current mesh
  32756. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32757. */
  32758. updateFacetData(): AbstractMesh;
  32759. /**
  32760. * Returns the facetLocalNormals array.
  32761. * The normals are expressed in the mesh local spac
  32762. * @returns an array of Vector3
  32763. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32764. */
  32765. getFacetLocalNormals(): Vector3[];
  32766. /**
  32767. * Returns the facetLocalPositions array.
  32768. * The facet positions are expressed in the mesh local space
  32769. * @returns an array of Vector3
  32770. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32771. */
  32772. getFacetLocalPositions(): Vector3[];
  32773. /**
  32774. * Returns the facetLocalPartioning array
  32775. * @returns an array of array of numbers
  32776. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32777. */
  32778. getFacetLocalPartitioning(): number[][];
  32779. /**
  32780. * Returns the i-th facet position in the world system.
  32781. * This method allocates a new Vector3 per call
  32782. * @param i defines the facet index
  32783. * @returns a new Vector3
  32784. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32785. */
  32786. getFacetPosition(i: number): Vector3;
  32787. /**
  32788. * Sets the reference Vector3 with the i-th facet position in the world system
  32789. * @param i defines the facet index
  32790. * @param ref defines the target vector
  32791. * @returns the current mesh
  32792. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32793. */
  32794. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32795. /**
  32796. * Returns the i-th facet normal in the world system.
  32797. * This method allocates a new Vector3 per call
  32798. * @param i defines the facet index
  32799. * @returns a new Vector3
  32800. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32801. */
  32802. getFacetNormal(i: number): Vector3;
  32803. /**
  32804. * Sets the reference Vector3 with the i-th facet normal in the world system
  32805. * @param i defines the facet index
  32806. * @param ref defines the target vector
  32807. * @returns the current mesh
  32808. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32809. */
  32810. getFacetNormalToRef(i: number, ref: Vector3): this;
  32811. /**
  32812. * 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)
  32813. * @param x defines x coordinate
  32814. * @param y defines y coordinate
  32815. * @param z defines z coordinate
  32816. * @returns the array of facet indexes
  32817. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32818. */
  32819. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32820. /**
  32821. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32822. * @param projected sets as the (x,y,z) world projection on the facet
  32823. * @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
  32824. * @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
  32825. * @param x defines x coordinate
  32826. * @param y defines y coordinate
  32827. * @param z defines z coordinate
  32828. * @returns the face index if found (or null instead)
  32829. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32830. */
  32831. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32832. /**
  32833. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32834. * @param projected sets as the (x,y,z) local projection on the facet
  32835. * @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
  32836. * @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
  32837. * @param x defines x coordinate
  32838. * @param y defines y coordinate
  32839. * @param z defines z coordinate
  32840. * @returns the face index if found (or null instead)
  32841. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32842. */
  32843. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32844. /**
  32845. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32846. * @returns the parameters
  32847. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32848. */
  32849. getFacetDataParameters(): any;
  32850. /**
  32851. * Disables the feature FacetData and frees the related memory
  32852. * @returns the current mesh
  32853. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32854. */
  32855. disableFacetData(): AbstractMesh;
  32856. /**
  32857. * Updates the AbstractMesh indices array
  32858. * @param indices defines the data source
  32859. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32860. * @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)
  32861. * @returns the current mesh
  32862. */
  32863. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32864. /**
  32865. * Creates new normals data for the mesh
  32866. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32867. * @returns the current mesh
  32868. */
  32869. createNormals(updatable: boolean): AbstractMesh;
  32870. /**
  32871. * Align the mesh with a normal
  32872. * @param normal defines the normal to use
  32873. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32874. * @returns the current mesh
  32875. */
  32876. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32877. /** @hidden */
  32878. _checkOcclusionQuery(): boolean;
  32879. /**
  32880. * Disables the mesh edge rendering mode
  32881. * @returns the currentAbstractMesh
  32882. */
  32883. disableEdgesRendering(): AbstractMesh;
  32884. /**
  32885. * Enables the edge rendering mode on the mesh.
  32886. * This mode makes the mesh edges visible
  32887. * @param epsilon defines the maximal distance between two angles to detect a face
  32888. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32889. * @returns the currentAbstractMesh
  32890. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32891. */
  32892. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32893. /**
  32894. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32895. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32896. */
  32897. getConnectedParticleSystems(): IParticleSystem[];
  32898. }
  32899. }
  32900. declare module "babylonjs/Actions/actionEvent" {
  32901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32902. import { Nullable } from "babylonjs/types";
  32903. import { Sprite } from "babylonjs/Sprites/sprite";
  32904. import { Scene } from "babylonjs/scene";
  32905. import { Vector2 } from "babylonjs/Maths/math.vector";
  32906. /**
  32907. * Interface used to define ActionEvent
  32908. */
  32909. export interface IActionEvent {
  32910. /** The mesh or sprite that triggered the action */
  32911. source: any;
  32912. /** The X mouse cursor position at the time of the event */
  32913. pointerX: number;
  32914. /** The Y mouse cursor position at the time of the event */
  32915. pointerY: number;
  32916. /** The mesh that is currently pointed at (can be null) */
  32917. meshUnderPointer: Nullable<AbstractMesh>;
  32918. /** the original (browser) event that triggered the ActionEvent */
  32919. sourceEvent?: any;
  32920. /** additional data for the event */
  32921. additionalData?: any;
  32922. }
  32923. /**
  32924. * ActionEvent is the event being sent when an action is triggered.
  32925. */
  32926. export class ActionEvent implements IActionEvent {
  32927. /** The mesh or sprite that triggered the action */
  32928. source: any;
  32929. /** The X mouse cursor position at the time of the event */
  32930. pointerX: number;
  32931. /** The Y mouse cursor position at the time of the event */
  32932. pointerY: number;
  32933. /** The mesh that is currently pointed at (can be null) */
  32934. meshUnderPointer: Nullable<AbstractMesh>;
  32935. /** the original (browser) event that triggered the ActionEvent */
  32936. sourceEvent?: any;
  32937. /** additional data for the event */
  32938. additionalData?: any;
  32939. /**
  32940. * Creates a new ActionEvent
  32941. * @param source The mesh or sprite that triggered the action
  32942. * @param pointerX The X mouse cursor position at the time of the event
  32943. * @param pointerY The Y mouse cursor position at the time of the event
  32944. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32945. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32946. * @param additionalData additional data for the event
  32947. */
  32948. constructor(
  32949. /** The mesh or sprite that triggered the action */
  32950. source: any,
  32951. /** The X mouse cursor position at the time of the event */
  32952. pointerX: number,
  32953. /** The Y mouse cursor position at the time of the event */
  32954. pointerY: number,
  32955. /** The mesh that is currently pointed at (can be null) */
  32956. meshUnderPointer: Nullable<AbstractMesh>,
  32957. /** the original (browser) event that triggered the ActionEvent */
  32958. sourceEvent?: any,
  32959. /** additional data for the event */
  32960. additionalData?: any);
  32961. /**
  32962. * Helper function to auto-create an ActionEvent from a source mesh.
  32963. * @param source The source mesh that triggered the event
  32964. * @param evt The original (browser) event
  32965. * @param additionalData additional data for the event
  32966. * @returns the new ActionEvent
  32967. */
  32968. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32969. /**
  32970. * Helper function to auto-create an ActionEvent from a source sprite
  32971. * @param source The source sprite that triggered the event
  32972. * @param scene Scene associated with the sprite
  32973. * @param evt The original (browser) event
  32974. * @param additionalData additional data for the event
  32975. * @returns the new ActionEvent
  32976. */
  32977. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32978. /**
  32979. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32980. * @param scene the scene where the event occurred
  32981. * @param evt The original (browser) event
  32982. * @returns the new ActionEvent
  32983. */
  32984. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32985. /**
  32986. * Helper function to auto-create an ActionEvent from a primitive
  32987. * @param prim defines the target primitive
  32988. * @param pointerPos defines the pointer position
  32989. * @param evt The original (browser) event
  32990. * @param additionalData additional data for the event
  32991. * @returns the new ActionEvent
  32992. */
  32993. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32994. }
  32995. }
  32996. declare module "babylonjs/Actions/abstractActionManager" {
  32997. import { IDisposable } from "babylonjs/scene";
  32998. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  32999. import { IAction } from "babylonjs/Actions/action";
  33000. import { Nullable } from "babylonjs/types";
  33001. /**
  33002. * Abstract class used to decouple action Manager from scene and meshes.
  33003. * Do not instantiate.
  33004. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33005. */
  33006. export abstract class AbstractActionManager implements IDisposable {
  33007. /** Gets the list of active triggers */
  33008. static Triggers: {
  33009. [key: string]: number;
  33010. };
  33011. /** Gets the cursor to use when hovering items */
  33012. hoverCursor: string;
  33013. /** Gets the list of actions */
  33014. actions: IAction[];
  33015. /**
  33016. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33017. */
  33018. isRecursive: boolean;
  33019. /**
  33020. * Releases all associated resources
  33021. */
  33022. abstract dispose(): void;
  33023. /**
  33024. * Does this action manager has pointer triggers
  33025. */
  33026. abstract get hasPointerTriggers(): boolean;
  33027. /**
  33028. * Does this action manager has pick triggers
  33029. */
  33030. abstract get hasPickTriggers(): boolean;
  33031. /**
  33032. * Process a specific trigger
  33033. * @param trigger defines the trigger to process
  33034. * @param evt defines the event details to be processed
  33035. */
  33036. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33037. /**
  33038. * Does this action manager handles actions of any of the given triggers
  33039. * @param triggers defines the triggers to be tested
  33040. * @return a boolean indicating whether one (or more) of the triggers is handled
  33041. */
  33042. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33043. /**
  33044. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33045. * speed.
  33046. * @param triggerA defines the trigger to be tested
  33047. * @param triggerB defines the trigger to be tested
  33048. * @return a boolean indicating whether one (or more) of the triggers is handled
  33049. */
  33050. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33051. /**
  33052. * Does this action manager handles actions of a given trigger
  33053. * @param trigger defines the trigger to be tested
  33054. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33055. * @return whether the trigger is handled
  33056. */
  33057. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33058. /**
  33059. * Serialize this manager to a JSON object
  33060. * @param name defines the property name to store this manager
  33061. * @returns a JSON representation of this manager
  33062. */
  33063. abstract serialize(name: string): any;
  33064. /**
  33065. * Registers an action to this action manager
  33066. * @param action defines the action to be registered
  33067. * @return the action amended (prepared) after registration
  33068. */
  33069. abstract registerAction(action: IAction): Nullable<IAction>;
  33070. /**
  33071. * Unregisters an action to this action manager
  33072. * @param action defines the action to be unregistered
  33073. * @return a boolean indicating whether the action has been unregistered
  33074. */
  33075. abstract unregisterAction(action: IAction): Boolean;
  33076. /**
  33077. * Does exist one action manager with at least one trigger
  33078. **/
  33079. static get HasTriggers(): boolean;
  33080. /**
  33081. * Does exist one action manager with at least one pick trigger
  33082. **/
  33083. static get HasPickTriggers(): boolean;
  33084. /**
  33085. * Does exist one action manager that handles actions of a given trigger
  33086. * @param trigger defines the trigger to be tested
  33087. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33088. **/
  33089. static HasSpecificTrigger(trigger: number): boolean;
  33090. }
  33091. }
  33092. declare module "babylonjs/node" {
  33093. import { Scene } from "babylonjs/scene";
  33094. import { Nullable } from "babylonjs/types";
  33095. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33096. import { Engine } from "babylonjs/Engines/engine";
  33097. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33098. import { Observable } from "babylonjs/Misc/observable";
  33099. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33100. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33101. import { Animatable } from "babylonjs/Animations/animatable";
  33102. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33103. import { Animation } from "babylonjs/Animations/animation";
  33104. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33106. /**
  33107. * Defines how a node can be built from a string name.
  33108. */
  33109. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33110. /**
  33111. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33112. */
  33113. export class Node implements IBehaviorAware<Node> {
  33114. /** @hidden */
  33115. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33116. private static _NodeConstructors;
  33117. /**
  33118. * Add a new node constructor
  33119. * @param type defines the type name of the node to construct
  33120. * @param constructorFunc defines the constructor function
  33121. */
  33122. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33123. /**
  33124. * Returns a node constructor based on type name
  33125. * @param type defines the type name
  33126. * @param name defines the new node name
  33127. * @param scene defines the hosting scene
  33128. * @param options defines optional options to transmit to constructors
  33129. * @returns the new constructor or null
  33130. */
  33131. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33132. /**
  33133. * Gets or sets the name of the node
  33134. */
  33135. name: string;
  33136. /**
  33137. * Gets or sets the id of the node
  33138. */
  33139. id: string;
  33140. /**
  33141. * Gets or sets the unique id of the node
  33142. */
  33143. uniqueId: number;
  33144. /**
  33145. * Gets or sets a string used to store user defined state for the node
  33146. */
  33147. state: string;
  33148. /**
  33149. * Gets or sets an object used to store user defined information for the node
  33150. */
  33151. metadata: any;
  33152. /**
  33153. * For internal use only. Please do not use.
  33154. */
  33155. reservedDataStore: any;
  33156. /**
  33157. * List of inspectable custom properties (used by the Inspector)
  33158. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33159. */
  33160. inspectableCustomProperties: IInspectable[];
  33161. private _doNotSerialize;
  33162. /**
  33163. * Gets or sets a boolean used to define if the node must be serialized
  33164. */
  33165. get doNotSerialize(): boolean;
  33166. set doNotSerialize(value: boolean);
  33167. /** @hidden */
  33168. _isDisposed: boolean;
  33169. /**
  33170. * Gets a list of Animations associated with the node
  33171. */
  33172. animations: import("babylonjs/Animations/animation").Animation[];
  33173. protected _ranges: {
  33174. [name: string]: Nullable<AnimationRange>;
  33175. };
  33176. /**
  33177. * Callback raised when the node is ready to be used
  33178. */
  33179. onReady: Nullable<(node: Node) => void>;
  33180. private _isEnabled;
  33181. private _isParentEnabled;
  33182. private _isReady;
  33183. /** @hidden */
  33184. _currentRenderId: number;
  33185. private _parentUpdateId;
  33186. /** @hidden */
  33187. _childUpdateId: number;
  33188. /** @hidden */
  33189. _waitingParentId: Nullable<string>;
  33190. /** @hidden */
  33191. _scene: Scene;
  33192. /** @hidden */
  33193. _cache: any;
  33194. private _parentNode;
  33195. private _children;
  33196. /** @hidden */
  33197. _worldMatrix: Matrix;
  33198. /** @hidden */
  33199. _worldMatrixDeterminant: number;
  33200. /** @hidden */
  33201. _worldMatrixDeterminantIsDirty: boolean;
  33202. /** @hidden */
  33203. private _sceneRootNodesIndex;
  33204. /**
  33205. * Gets a boolean indicating if the node has been disposed
  33206. * @returns true if the node was disposed
  33207. */
  33208. isDisposed(): boolean;
  33209. /**
  33210. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33211. * @see https://doc.babylonjs.com/how_to/parenting
  33212. */
  33213. set parent(parent: Nullable<Node>);
  33214. get parent(): Nullable<Node>;
  33215. /** @hidden */
  33216. _addToSceneRootNodes(): void;
  33217. /** @hidden */
  33218. _removeFromSceneRootNodes(): void;
  33219. private _animationPropertiesOverride;
  33220. /**
  33221. * Gets or sets the animation properties override
  33222. */
  33223. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33224. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33225. /**
  33226. * Gets a string idenfifying the name of the class
  33227. * @returns "Node" string
  33228. */
  33229. getClassName(): string;
  33230. /** @hidden */
  33231. readonly _isNode: boolean;
  33232. /**
  33233. * An event triggered when the mesh is disposed
  33234. */
  33235. onDisposeObservable: Observable<Node>;
  33236. private _onDisposeObserver;
  33237. /**
  33238. * Sets a callback that will be raised when the node will be disposed
  33239. */
  33240. set onDispose(callback: () => void);
  33241. /**
  33242. * Creates a new Node
  33243. * @param name the name and id to be given to this node
  33244. * @param scene the scene this node will be added to
  33245. */
  33246. constructor(name: string, scene?: Nullable<Scene>);
  33247. /**
  33248. * Gets the scene of the node
  33249. * @returns a scene
  33250. */
  33251. getScene(): Scene;
  33252. /**
  33253. * Gets the engine of the node
  33254. * @returns a Engine
  33255. */
  33256. getEngine(): Engine;
  33257. private _behaviors;
  33258. /**
  33259. * Attach a behavior to the node
  33260. * @see https://doc.babylonjs.com/features/behaviour
  33261. * @param behavior defines the behavior to attach
  33262. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33263. * @returns the current Node
  33264. */
  33265. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33266. /**
  33267. * Remove an attached behavior
  33268. * @see https://doc.babylonjs.com/features/behaviour
  33269. * @param behavior defines the behavior to attach
  33270. * @returns the current Node
  33271. */
  33272. removeBehavior(behavior: Behavior<Node>): Node;
  33273. /**
  33274. * Gets the list of attached behaviors
  33275. * @see https://doc.babylonjs.com/features/behaviour
  33276. */
  33277. get behaviors(): Behavior<Node>[];
  33278. /**
  33279. * Gets an attached behavior by name
  33280. * @param name defines the name of the behavior to look for
  33281. * @see https://doc.babylonjs.com/features/behaviour
  33282. * @returns null if behavior was not found else the requested behavior
  33283. */
  33284. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33285. /**
  33286. * Returns the latest update of the World matrix
  33287. * @returns a Matrix
  33288. */
  33289. getWorldMatrix(): Matrix;
  33290. /** @hidden */
  33291. _getWorldMatrixDeterminant(): number;
  33292. /**
  33293. * Returns directly the latest state of the mesh World matrix.
  33294. * A Matrix is returned.
  33295. */
  33296. get worldMatrixFromCache(): Matrix;
  33297. /** @hidden */
  33298. _initCache(): void;
  33299. /** @hidden */
  33300. updateCache(force?: boolean): void;
  33301. /** @hidden */
  33302. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33303. /** @hidden */
  33304. _updateCache(ignoreParentClass?: boolean): void;
  33305. /** @hidden */
  33306. _isSynchronized(): boolean;
  33307. /** @hidden */
  33308. _markSyncedWithParent(): void;
  33309. /** @hidden */
  33310. isSynchronizedWithParent(): boolean;
  33311. /** @hidden */
  33312. isSynchronized(): boolean;
  33313. /**
  33314. * Is this node ready to be used/rendered
  33315. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33316. * @return true if the node is ready
  33317. */
  33318. isReady(completeCheck?: boolean): boolean;
  33319. /**
  33320. * Is this node enabled?
  33321. * 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
  33322. * @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
  33323. * @return whether this node (and its parent) is enabled
  33324. */
  33325. isEnabled(checkAncestors?: boolean): boolean;
  33326. /** @hidden */
  33327. protected _syncParentEnabledState(): void;
  33328. /**
  33329. * Set the enabled state of this node
  33330. * @param value defines the new enabled state
  33331. */
  33332. setEnabled(value: boolean): void;
  33333. /**
  33334. * Is this node a descendant of the given node?
  33335. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33336. * @param ancestor defines the parent node to inspect
  33337. * @returns a boolean indicating if this node is a descendant of the given node
  33338. */
  33339. isDescendantOf(ancestor: Node): boolean;
  33340. /** @hidden */
  33341. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33342. /**
  33343. * Will return all nodes that have this node as ascendant
  33344. * @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
  33345. * @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
  33346. * @return all children nodes of all types
  33347. */
  33348. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33349. /**
  33350. * Get all child-meshes of this node
  33351. * @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)
  33352. * @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
  33353. * @returns an array of AbstractMesh
  33354. */
  33355. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33356. /**
  33357. * Get all direct children of this node
  33358. * @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
  33359. * @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)
  33360. * @returns an array of Node
  33361. */
  33362. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33363. /** @hidden */
  33364. _setReady(state: boolean): void;
  33365. /**
  33366. * Get an animation by name
  33367. * @param name defines the name of the animation to look for
  33368. * @returns null if not found else the requested animation
  33369. */
  33370. getAnimationByName(name: string): Nullable<Animation>;
  33371. /**
  33372. * Creates an animation range for this node
  33373. * @param name defines the name of the range
  33374. * @param from defines the starting key
  33375. * @param to defines the end key
  33376. */
  33377. createAnimationRange(name: string, from: number, to: number): void;
  33378. /**
  33379. * Delete a specific animation range
  33380. * @param name defines the name of the range to delete
  33381. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33382. */
  33383. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33384. /**
  33385. * Get an animation range by name
  33386. * @param name defines the name of the animation range to look for
  33387. * @returns null if not found else the requested animation range
  33388. */
  33389. getAnimationRange(name: string): Nullable<AnimationRange>;
  33390. /**
  33391. * Gets the list of all animation ranges defined on this node
  33392. * @returns an array
  33393. */
  33394. getAnimationRanges(): Nullable<AnimationRange>[];
  33395. /**
  33396. * Will start the animation sequence
  33397. * @param name defines the range frames for animation sequence
  33398. * @param loop defines if the animation should loop (false by default)
  33399. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33400. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33401. * @returns the object created for this animation. If range does not exist, it will return null
  33402. */
  33403. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33404. /**
  33405. * Serialize animation ranges into a JSON compatible object
  33406. * @returns serialization object
  33407. */
  33408. serializeAnimationRanges(): any;
  33409. /**
  33410. * Computes the world matrix of the node
  33411. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33412. * @returns the world matrix
  33413. */
  33414. computeWorldMatrix(force?: boolean): Matrix;
  33415. /**
  33416. * Releases resources associated with this node.
  33417. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33418. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33419. */
  33420. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33421. /**
  33422. * Parse animation range data from a serialization object and store them into a given node
  33423. * @param node defines where to store the animation ranges
  33424. * @param parsedNode defines the serialization object to read data from
  33425. * @param scene defines the hosting scene
  33426. */
  33427. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33428. /**
  33429. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33430. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33431. * @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
  33432. * @returns the new bounding vectors
  33433. */
  33434. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33435. min: Vector3;
  33436. max: Vector3;
  33437. };
  33438. }
  33439. }
  33440. declare module "babylonjs/Animations/animation" {
  33441. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33442. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33443. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33444. import { Nullable } from "babylonjs/types";
  33445. import { Scene } from "babylonjs/scene";
  33446. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33447. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33448. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33449. import { Node } from "babylonjs/node";
  33450. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33451. import { Size } from "babylonjs/Maths/math.size";
  33452. import { Animatable } from "babylonjs/Animations/animatable";
  33453. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33454. /**
  33455. * @hidden
  33456. */
  33457. export class _IAnimationState {
  33458. key: number;
  33459. repeatCount: number;
  33460. workValue?: any;
  33461. loopMode?: number;
  33462. offsetValue?: any;
  33463. highLimitValue?: any;
  33464. }
  33465. /**
  33466. * Class used to store any kind of animation
  33467. */
  33468. export class Animation {
  33469. /**Name of the animation */
  33470. name: string;
  33471. /**Property to animate */
  33472. targetProperty: string;
  33473. /**The frames per second of the animation */
  33474. framePerSecond: number;
  33475. /**The data type of the animation */
  33476. dataType: number;
  33477. /**The loop mode of the animation */
  33478. loopMode?: number | undefined;
  33479. /**Specifies if blending should be enabled */
  33480. enableBlending?: boolean | undefined;
  33481. /**
  33482. * Use matrix interpolation instead of using direct key value when animating matrices
  33483. */
  33484. static AllowMatricesInterpolation: boolean;
  33485. /**
  33486. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33487. */
  33488. static AllowMatrixDecomposeForInterpolation: boolean;
  33489. /** Define the Url to load snippets */
  33490. static SnippetUrl: string;
  33491. /** Snippet ID if the animation was created from the snippet server */
  33492. snippetId: string;
  33493. /**
  33494. * Stores the key frames of the animation
  33495. */
  33496. private _keys;
  33497. /**
  33498. * Stores the easing function of the animation
  33499. */
  33500. private _easingFunction;
  33501. /**
  33502. * @hidden Internal use only
  33503. */
  33504. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33505. /**
  33506. * The set of event that will be linked to this animation
  33507. */
  33508. private _events;
  33509. /**
  33510. * Stores an array of target property paths
  33511. */
  33512. targetPropertyPath: string[];
  33513. /**
  33514. * Stores the blending speed of the animation
  33515. */
  33516. blendingSpeed: number;
  33517. /**
  33518. * Stores the animation ranges for the animation
  33519. */
  33520. private _ranges;
  33521. /**
  33522. * @hidden Internal use
  33523. */
  33524. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33525. /**
  33526. * Sets up an animation
  33527. * @param property The property to animate
  33528. * @param animationType The animation type to apply
  33529. * @param framePerSecond The frames per second of the animation
  33530. * @param easingFunction The easing function used in the animation
  33531. * @returns The created animation
  33532. */
  33533. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33534. /**
  33535. * Create and start an animation on a node
  33536. * @param name defines the name of the global animation that will be run on all nodes
  33537. * @param node defines the root node where the animation will take place
  33538. * @param targetProperty defines property to animate
  33539. * @param framePerSecond defines the number of frame per second yo use
  33540. * @param totalFrame defines the number of frames in total
  33541. * @param from defines the initial value
  33542. * @param to defines the final value
  33543. * @param loopMode defines which loop mode you want to use (off by default)
  33544. * @param easingFunction defines the easing function to use (linear by default)
  33545. * @param onAnimationEnd defines the callback to call when animation end
  33546. * @returns the animatable created for this animation
  33547. */
  33548. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33549. /**
  33550. * Create and start an animation on a node and its descendants
  33551. * @param name defines the name of the global animation that will be run on all nodes
  33552. * @param node defines the root node where the animation will take place
  33553. * @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
  33554. * @param targetProperty defines property to animate
  33555. * @param framePerSecond defines the number of frame per second to use
  33556. * @param totalFrame defines the number of frames in total
  33557. * @param from defines the initial value
  33558. * @param to defines the final value
  33559. * @param loopMode defines which loop mode you want to use (off by default)
  33560. * @param easingFunction defines the easing function to use (linear by default)
  33561. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33562. * @returns the list of animatables created for all nodes
  33563. * @example https://www.babylonjs-playground.com/#MH0VLI
  33564. */
  33565. 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[]>;
  33566. /**
  33567. * Creates a new animation, merges it with the existing animations and starts it
  33568. * @param name Name of the animation
  33569. * @param node Node which contains the scene that begins the animations
  33570. * @param targetProperty Specifies which property to animate
  33571. * @param framePerSecond The frames per second of the animation
  33572. * @param totalFrame The total number of frames
  33573. * @param from The frame at the beginning of the animation
  33574. * @param to The frame at the end of the animation
  33575. * @param loopMode Specifies the loop mode of the animation
  33576. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33577. * @param onAnimationEnd Callback to run once the animation is complete
  33578. * @returns Nullable animation
  33579. */
  33580. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33581. /**
  33582. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33583. * @param sourceAnimation defines the Animation containing keyframes to convert
  33584. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33585. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33586. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33587. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33588. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33589. */
  33590. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33591. /**
  33592. * Transition property of an host to the target Value
  33593. * @param property The property to transition
  33594. * @param targetValue The target Value of the property
  33595. * @param host The object where the property to animate belongs
  33596. * @param scene Scene used to run the animation
  33597. * @param frameRate Framerate (in frame/s) to use
  33598. * @param transition The transition type we want to use
  33599. * @param duration The duration of the animation, in milliseconds
  33600. * @param onAnimationEnd Callback trigger at the end of the animation
  33601. * @returns Nullable animation
  33602. */
  33603. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33604. /**
  33605. * Return the array of runtime animations currently using this animation
  33606. */
  33607. get runtimeAnimations(): RuntimeAnimation[];
  33608. /**
  33609. * Specifies if any of the runtime animations are currently running
  33610. */
  33611. get hasRunningRuntimeAnimations(): boolean;
  33612. /**
  33613. * Initializes the animation
  33614. * @param name Name of the animation
  33615. * @param targetProperty Property to animate
  33616. * @param framePerSecond The frames per second of the animation
  33617. * @param dataType The data type of the animation
  33618. * @param loopMode The loop mode of the animation
  33619. * @param enableBlending Specifies if blending should be enabled
  33620. */
  33621. constructor(
  33622. /**Name of the animation */
  33623. name: string,
  33624. /**Property to animate */
  33625. targetProperty: string,
  33626. /**The frames per second of the animation */
  33627. framePerSecond: number,
  33628. /**The data type of the animation */
  33629. dataType: number,
  33630. /**The loop mode of the animation */
  33631. loopMode?: number | undefined,
  33632. /**Specifies if blending should be enabled */
  33633. enableBlending?: boolean | undefined);
  33634. /**
  33635. * Converts the animation to a string
  33636. * @param fullDetails support for multiple levels of logging within scene loading
  33637. * @returns String form of the animation
  33638. */
  33639. toString(fullDetails?: boolean): string;
  33640. /**
  33641. * Add an event to this animation
  33642. * @param event Event to add
  33643. */
  33644. addEvent(event: AnimationEvent): void;
  33645. /**
  33646. * Remove all events found at the given frame
  33647. * @param frame The frame to remove events from
  33648. */
  33649. removeEvents(frame: number): void;
  33650. /**
  33651. * Retrieves all the events from the animation
  33652. * @returns Events from the animation
  33653. */
  33654. getEvents(): AnimationEvent[];
  33655. /**
  33656. * Creates an animation range
  33657. * @param name Name of the animation range
  33658. * @param from Starting frame of the animation range
  33659. * @param to Ending frame of the animation
  33660. */
  33661. createRange(name: string, from: number, to: number): void;
  33662. /**
  33663. * Deletes an animation range by name
  33664. * @param name Name of the animation range to delete
  33665. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33666. */
  33667. deleteRange(name: string, deleteFrames?: boolean): void;
  33668. /**
  33669. * Gets the animation range by name, or null if not defined
  33670. * @param name Name of the animation range
  33671. * @returns Nullable animation range
  33672. */
  33673. getRange(name: string): Nullable<AnimationRange>;
  33674. /**
  33675. * Gets the key frames from the animation
  33676. * @returns The key frames of the animation
  33677. */
  33678. getKeys(): Array<IAnimationKey>;
  33679. /**
  33680. * Gets the highest frame rate of the animation
  33681. * @returns Highest frame rate of the animation
  33682. */
  33683. getHighestFrame(): number;
  33684. /**
  33685. * Gets the easing function of the animation
  33686. * @returns Easing function of the animation
  33687. */
  33688. getEasingFunction(): IEasingFunction;
  33689. /**
  33690. * Sets the easing function of the animation
  33691. * @param easingFunction A custom mathematical formula for animation
  33692. */
  33693. setEasingFunction(easingFunction: EasingFunction): void;
  33694. /**
  33695. * Interpolates a scalar linearly
  33696. * @param startValue Start value of the animation curve
  33697. * @param endValue End value of the animation curve
  33698. * @param gradient Scalar amount to interpolate
  33699. * @returns Interpolated scalar value
  33700. */
  33701. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33702. /**
  33703. * Interpolates a scalar cubically
  33704. * @param startValue Start value of the animation curve
  33705. * @param outTangent End tangent of the animation
  33706. * @param endValue End value of the animation curve
  33707. * @param inTangent Start tangent of the animation curve
  33708. * @param gradient Scalar amount to interpolate
  33709. * @returns Interpolated scalar value
  33710. */
  33711. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33712. /**
  33713. * Interpolates a quaternion using a spherical linear interpolation
  33714. * @param startValue Start value of the animation curve
  33715. * @param endValue End value of the animation curve
  33716. * @param gradient Scalar amount to interpolate
  33717. * @returns Interpolated quaternion value
  33718. */
  33719. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33720. /**
  33721. * Interpolates a quaternion cubically
  33722. * @param startValue Start value of the animation curve
  33723. * @param outTangent End tangent of the animation curve
  33724. * @param endValue End value of the animation curve
  33725. * @param inTangent Start tangent of the animation curve
  33726. * @param gradient Scalar amount to interpolate
  33727. * @returns Interpolated quaternion value
  33728. */
  33729. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33730. /**
  33731. * Interpolates a Vector3 linearl
  33732. * @param startValue Start value of the animation curve
  33733. * @param endValue End value of the animation curve
  33734. * @param gradient Scalar amount to interpolate
  33735. * @returns Interpolated scalar value
  33736. */
  33737. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33738. /**
  33739. * Interpolates a Vector3 cubically
  33740. * @param startValue Start value of the animation curve
  33741. * @param outTangent End tangent of the animation
  33742. * @param endValue End value of the animation curve
  33743. * @param inTangent Start tangent of the animation curve
  33744. * @param gradient Scalar amount to interpolate
  33745. * @returns InterpolatedVector3 value
  33746. */
  33747. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33748. /**
  33749. * Interpolates a Vector2 linearly
  33750. * @param startValue Start value of the animation curve
  33751. * @param endValue End value of the animation curve
  33752. * @param gradient Scalar amount to interpolate
  33753. * @returns Interpolated Vector2 value
  33754. */
  33755. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33756. /**
  33757. * Interpolates a Vector2 cubically
  33758. * @param startValue Start value of the animation curve
  33759. * @param outTangent End tangent of the animation
  33760. * @param endValue End value of the animation curve
  33761. * @param inTangent Start tangent of the animation curve
  33762. * @param gradient Scalar amount to interpolate
  33763. * @returns Interpolated Vector2 value
  33764. */
  33765. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33766. /**
  33767. * Interpolates a size linearly
  33768. * @param startValue Start value of the animation curve
  33769. * @param endValue End value of the animation curve
  33770. * @param gradient Scalar amount to interpolate
  33771. * @returns Interpolated Size value
  33772. */
  33773. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33774. /**
  33775. * Interpolates a Color3 linearly
  33776. * @param startValue Start value of the animation curve
  33777. * @param endValue End value of the animation curve
  33778. * @param gradient Scalar amount to interpolate
  33779. * @returns Interpolated Color3 value
  33780. */
  33781. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33782. /**
  33783. * Interpolates a Color4 linearly
  33784. * @param startValue Start value of the animation curve
  33785. * @param endValue End value of the animation curve
  33786. * @param gradient Scalar amount to interpolate
  33787. * @returns Interpolated Color3 value
  33788. */
  33789. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33790. /**
  33791. * @hidden Internal use only
  33792. */
  33793. _getKeyValue(value: any): any;
  33794. /**
  33795. * @hidden Internal use only
  33796. */
  33797. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33798. /**
  33799. * Defines the function to use to interpolate matrices
  33800. * @param startValue defines the start matrix
  33801. * @param endValue defines the end matrix
  33802. * @param gradient defines the gradient between both matrices
  33803. * @param result defines an optional target matrix where to store the interpolation
  33804. * @returns the interpolated matrix
  33805. */
  33806. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33807. /**
  33808. * Makes a copy of the animation
  33809. * @returns Cloned animation
  33810. */
  33811. clone(): Animation;
  33812. /**
  33813. * Sets the key frames of the animation
  33814. * @param values The animation key frames to set
  33815. */
  33816. setKeys(values: Array<IAnimationKey>): void;
  33817. /**
  33818. * Serializes the animation to an object
  33819. * @returns Serialized object
  33820. */
  33821. serialize(): any;
  33822. /**
  33823. * Float animation type
  33824. */
  33825. static readonly ANIMATIONTYPE_FLOAT: number;
  33826. /**
  33827. * Vector3 animation type
  33828. */
  33829. static readonly ANIMATIONTYPE_VECTOR3: number;
  33830. /**
  33831. * Quaternion animation type
  33832. */
  33833. static readonly ANIMATIONTYPE_QUATERNION: number;
  33834. /**
  33835. * Matrix animation type
  33836. */
  33837. static readonly ANIMATIONTYPE_MATRIX: number;
  33838. /**
  33839. * Color3 animation type
  33840. */
  33841. static readonly ANIMATIONTYPE_COLOR3: number;
  33842. /**
  33843. * Color3 animation type
  33844. */
  33845. static readonly ANIMATIONTYPE_COLOR4: number;
  33846. /**
  33847. * Vector2 animation type
  33848. */
  33849. static readonly ANIMATIONTYPE_VECTOR2: number;
  33850. /**
  33851. * Size animation type
  33852. */
  33853. static readonly ANIMATIONTYPE_SIZE: number;
  33854. /**
  33855. * Relative Loop Mode
  33856. */
  33857. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33858. /**
  33859. * Cycle Loop Mode
  33860. */
  33861. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33862. /**
  33863. * Constant Loop Mode
  33864. */
  33865. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33866. /** @hidden */
  33867. static _UniversalLerp(left: any, right: any, amount: number): any;
  33868. /**
  33869. * Parses an animation object and creates an animation
  33870. * @param parsedAnimation Parsed animation object
  33871. * @returns Animation object
  33872. */
  33873. static Parse(parsedAnimation: any): Animation;
  33874. /**
  33875. * Appends the serialized animations from the source animations
  33876. * @param source Source containing the animations
  33877. * @param destination Target to store the animations
  33878. */
  33879. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33880. /**
  33881. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33882. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33883. * @param url defines the url to load from
  33884. * @returns a promise that will resolve to the new animation or an array of animations
  33885. */
  33886. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33887. /**
  33888. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33889. * @param snippetId defines the snippet to load
  33890. * @returns a promise that will resolve to the new animation or a new array of animations
  33891. */
  33892. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33893. }
  33894. }
  33895. declare module "babylonjs/Animations/animatable.interface" {
  33896. import { Nullable } from "babylonjs/types";
  33897. import { Animation } from "babylonjs/Animations/animation";
  33898. /**
  33899. * Interface containing an array of animations
  33900. */
  33901. export interface IAnimatable {
  33902. /**
  33903. * Array of animations
  33904. */
  33905. animations: Nullable<Array<Animation>>;
  33906. }
  33907. }
  33908. declare module "babylonjs/Misc/decorators" {
  33909. import { Nullable } from "babylonjs/types";
  33910. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33911. import { Scene } from "babylonjs/scene";
  33912. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33913. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  33914. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  33915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33916. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33917. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33918. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33919. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33920. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33921. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33922. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33923. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33924. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33925. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33926. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33927. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33928. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33929. /**
  33930. * Decorator used to define property that can be serialized as reference to a camera
  33931. * @param sourceName defines the name of the property to decorate
  33932. */
  33933. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33934. /**
  33935. * Class used to help serialization objects
  33936. */
  33937. export class SerializationHelper {
  33938. /** @hidden */
  33939. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33940. /** @hidden */
  33941. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33942. /** @hidden */
  33943. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33944. /** @hidden */
  33945. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33946. /**
  33947. * Appends the serialized animations from the source animations
  33948. * @param source Source containing the animations
  33949. * @param destination Target to store the animations
  33950. */
  33951. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33952. /**
  33953. * Static function used to serialized a specific entity
  33954. * @param entity defines the entity to serialize
  33955. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33956. * @returns a JSON compatible object representing the serialization of the entity
  33957. */
  33958. static Serialize<T>(entity: T, serializationObject?: any): any;
  33959. /**
  33960. * Creates a new entity from a serialization data object
  33961. * @param creationFunction defines a function used to instanciated the new entity
  33962. * @param source defines the source serialization data
  33963. * @param scene defines the hosting scene
  33964. * @param rootUrl defines the root url for resources
  33965. * @returns a new entity
  33966. */
  33967. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33968. /**
  33969. * Clones an object
  33970. * @param creationFunction defines the function used to instanciate the new object
  33971. * @param source defines the source object
  33972. * @returns the cloned object
  33973. */
  33974. static Clone<T>(creationFunction: () => T, source: T): T;
  33975. /**
  33976. * Instanciates a new object based on a source one (some data will be shared between both object)
  33977. * @param creationFunction defines the function used to instanciate the new object
  33978. * @param source defines the source object
  33979. * @returns the new object
  33980. */
  33981. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33982. }
  33983. }
  33984. declare module "babylonjs/Materials/Textures/baseTexture" {
  33985. import { Observable } from "babylonjs/Misc/observable";
  33986. import { Nullable } from "babylonjs/types";
  33987. import { Scene } from "babylonjs/scene";
  33988. import { Matrix } from "babylonjs/Maths/math.vector";
  33989. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33990. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33991. import { ISize } from "babylonjs/Maths/math.size";
  33992. import "babylonjs/Misc/fileTools";
  33993. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33994. /**
  33995. * Base class of all the textures in babylon.
  33996. * It groups all the common properties the materials, post process, lights... might need
  33997. * in order to make a correct use of the texture.
  33998. */
  33999. export class BaseTexture implements IAnimatable {
  34000. /**
  34001. * Default anisotropic filtering level for the application.
  34002. * It is set to 4 as a good tradeoff between perf and quality.
  34003. */
  34004. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34005. /**
  34006. * Gets or sets the unique id of the texture
  34007. */
  34008. uniqueId: number;
  34009. /**
  34010. * Define the name of the texture.
  34011. */
  34012. name: string;
  34013. /**
  34014. * Gets or sets an object used to store user defined information.
  34015. */
  34016. metadata: any;
  34017. /**
  34018. * For internal use only. Please do not use.
  34019. */
  34020. reservedDataStore: any;
  34021. private _hasAlpha;
  34022. /**
  34023. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34024. */
  34025. set hasAlpha(value: boolean);
  34026. get hasAlpha(): boolean;
  34027. /**
  34028. * Defines if the alpha value should be determined via the rgb values.
  34029. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34030. */
  34031. getAlphaFromRGB: boolean;
  34032. /**
  34033. * Intensity or strength of the texture.
  34034. * It is commonly used by materials to fine tune the intensity of the texture
  34035. */
  34036. level: number;
  34037. /**
  34038. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34039. * This is part of the texture as textures usually maps to one uv set.
  34040. */
  34041. coordinatesIndex: number;
  34042. private _coordinatesMode;
  34043. /**
  34044. * How a texture is mapped.
  34045. *
  34046. * | Value | Type | Description |
  34047. * | ----- | ----------------------------------- | ----------- |
  34048. * | 0 | EXPLICIT_MODE | |
  34049. * | 1 | SPHERICAL_MODE | |
  34050. * | 2 | PLANAR_MODE | |
  34051. * | 3 | CUBIC_MODE | |
  34052. * | 4 | PROJECTION_MODE | |
  34053. * | 5 | SKYBOX_MODE | |
  34054. * | 6 | INVCUBIC_MODE | |
  34055. * | 7 | EQUIRECTANGULAR_MODE | |
  34056. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34057. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34058. */
  34059. set coordinatesMode(value: number);
  34060. get coordinatesMode(): number;
  34061. /**
  34062. * | Value | Type | Description |
  34063. * | ----- | ------------------ | ----------- |
  34064. * | 0 | CLAMP_ADDRESSMODE | |
  34065. * | 1 | WRAP_ADDRESSMODE | |
  34066. * | 2 | MIRROR_ADDRESSMODE | |
  34067. */
  34068. wrapU: number;
  34069. /**
  34070. * | Value | Type | Description |
  34071. * | ----- | ------------------ | ----------- |
  34072. * | 0 | CLAMP_ADDRESSMODE | |
  34073. * | 1 | WRAP_ADDRESSMODE | |
  34074. * | 2 | MIRROR_ADDRESSMODE | |
  34075. */
  34076. wrapV: number;
  34077. /**
  34078. * | Value | Type | Description |
  34079. * | ----- | ------------------ | ----------- |
  34080. * | 0 | CLAMP_ADDRESSMODE | |
  34081. * | 1 | WRAP_ADDRESSMODE | |
  34082. * | 2 | MIRROR_ADDRESSMODE | |
  34083. */
  34084. wrapR: number;
  34085. /**
  34086. * With compliant hardware and browser (supporting anisotropic filtering)
  34087. * this defines the level of anisotropic filtering in the texture.
  34088. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34089. */
  34090. anisotropicFilteringLevel: number;
  34091. /**
  34092. * Define if the texture is a cube texture or if false a 2d texture.
  34093. */
  34094. get isCube(): boolean;
  34095. set isCube(value: boolean);
  34096. /**
  34097. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34098. */
  34099. get is3D(): boolean;
  34100. set is3D(value: boolean);
  34101. /**
  34102. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34103. */
  34104. get is2DArray(): boolean;
  34105. set is2DArray(value: boolean);
  34106. /**
  34107. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34108. * HDR texture are usually stored in linear space.
  34109. * This only impacts the PBR and Background materials
  34110. */
  34111. gammaSpace: boolean;
  34112. /**
  34113. * Gets or sets whether or not the texture contains RGBD data.
  34114. */
  34115. get isRGBD(): boolean;
  34116. set isRGBD(value: boolean);
  34117. /**
  34118. * Is Z inverted in the texture (useful in a cube texture).
  34119. */
  34120. invertZ: boolean;
  34121. /**
  34122. * Are mip maps generated for this texture or not.
  34123. */
  34124. get noMipmap(): boolean;
  34125. /**
  34126. * @hidden
  34127. */
  34128. lodLevelInAlpha: boolean;
  34129. /**
  34130. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34131. */
  34132. get lodGenerationOffset(): number;
  34133. set lodGenerationOffset(value: number);
  34134. /**
  34135. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34136. */
  34137. get lodGenerationScale(): number;
  34138. set lodGenerationScale(value: number);
  34139. /**
  34140. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34141. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34142. * average roughness values.
  34143. */
  34144. get linearSpecularLOD(): boolean;
  34145. set linearSpecularLOD(value: boolean);
  34146. /**
  34147. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34148. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34149. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34150. */
  34151. get irradianceTexture(): Nullable<BaseTexture>;
  34152. set irradianceTexture(value: Nullable<BaseTexture>);
  34153. /**
  34154. * Define if the texture is a render target.
  34155. */
  34156. isRenderTarget: boolean;
  34157. /**
  34158. * Define the unique id of the texture in the scene.
  34159. */
  34160. get uid(): string;
  34161. /** @hidden */
  34162. _prefiltered: boolean;
  34163. /**
  34164. * Return a string representation of the texture.
  34165. * @returns the texture as a string
  34166. */
  34167. toString(): string;
  34168. /**
  34169. * Get the class name of the texture.
  34170. * @returns "BaseTexture"
  34171. */
  34172. getClassName(): string;
  34173. /**
  34174. * Define the list of animation attached to the texture.
  34175. */
  34176. animations: import("babylonjs/Animations/animation").Animation[];
  34177. /**
  34178. * An event triggered when the texture is disposed.
  34179. */
  34180. onDisposeObservable: Observable<BaseTexture>;
  34181. private _onDisposeObserver;
  34182. /**
  34183. * Callback triggered when the texture has been disposed.
  34184. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34185. */
  34186. set onDispose(callback: () => void);
  34187. /**
  34188. * Define the current state of the loading sequence when in delayed load mode.
  34189. */
  34190. delayLoadState: number;
  34191. private _scene;
  34192. private _engine;
  34193. /** @hidden */
  34194. _texture: Nullable<InternalTexture>;
  34195. private _uid;
  34196. /**
  34197. * Define if the texture is preventinga material to render or not.
  34198. * If not and the texture is not ready, the engine will use a default black texture instead.
  34199. */
  34200. get isBlocking(): boolean;
  34201. /**
  34202. * Instantiates a new BaseTexture.
  34203. * Base class of all the textures in babylon.
  34204. * It groups all the common properties the materials, post process, lights... might need
  34205. * in order to make a correct use of the texture.
  34206. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34207. */
  34208. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34209. /**
  34210. * Get the scene the texture belongs to.
  34211. * @returns the scene or null if undefined
  34212. */
  34213. getScene(): Nullable<Scene>;
  34214. /** @hidden */
  34215. protected _getEngine(): Nullable<ThinEngine>;
  34216. /**
  34217. * Get the texture transform matrix used to offset tile the texture for istance.
  34218. * @returns the transformation matrix
  34219. */
  34220. getTextureMatrix(): Matrix;
  34221. /**
  34222. * Get the texture reflection matrix used to rotate/transform the reflection.
  34223. * @returns the reflection matrix
  34224. */
  34225. getReflectionTextureMatrix(): Matrix;
  34226. /**
  34227. * Get the underlying lower level texture from Babylon.
  34228. * @returns the insternal texture
  34229. */
  34230. getInternalTexture(): Nullable<InternalTexture>;
  34231. /**
  34232. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34233. * @returns true if ready or not blocking
  34234. */
  34235. isReadyOrNotBlocking(): boolean;
  34236. /**
  34237. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34238. * @returns true if fully ready
  34239. */
  34240. isReady(): boolean;
  34241. private _cachedSize;
  34242. /**
  34243. * Get the size of the texture.
  34244. * @returns the texture size.
  34245. */
  34246. getSize(): ISize;
  34247. /**
  34248. * Get the base size of the texture.
  34249. * It can be different from the size if the texture has been resized for POT for instance
  34250. * @returns the base size
  34251. */
  34252. getBaseSize(): ISize;
  34253. /**
  34254. * Update the sampling mode of the texture.
  34255. * Default is Trilinear mode.
  34256. *
  34257. * | Value | Type | Description |
  34258. * | ----- | ------------------ | ----------- |
  34259. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34260. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34261. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34262. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34263. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34264. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34265. * | 7 | NEAREST_LINEAR | |
  34266. * | 8 | NEAREST_NEAREST | |
  34267. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34268. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34269. * | 11 | LINEAR_LINEAR | |
  34270. * | 12 | LINEAR_NEAREST | |
  34271. *
  34272. * > _mag_: magnification filter (close to the viewer)
  34273. * > _min_: minification filter (far from the viewer)
  34274. * > _mip_: filter used between mip map levels
  34275. *@param samplingMode Define the new sampling mode of the texture
  34276. */
  34277. updateSamplingMode(samplingMode: number): void;
  34278. /**
  34279. * Scales the texture if is `canRescale()`
  34280. * @param ratio the resize factor we want to use to rescale
  34281. */
  34282. scale(ratio: number): void;
  34283. /**
  34284. * Get if the texture can rescale.
  34285. */
  34286. get canRescale(): boolean;
  34287. /** @hidden */
  34288. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34289. /** @hidden */
  34290. _rebuild(): void;
  34291. /**
  34292. * Triggers the load sequence in delayed load mode.
  34293. */
  34294. delayLoad(): void;
  34295. /**
  34296. * Clones the texture.
  34297. * @returns the cloned texture
  34298. */
  34299. clone(): Nullable<BaseTexture>;
  34300. /**
  34301. * Get the texture underlying type (INT, FLOAT...)
  34302. */
  34303. get textureType(): number;
  34304. /**
  34305. * Get the texture underlying format (RGB, RGBA...)
  34306. */
  34307. get textureFormat(): number;
  34308. /**
  34309. * Indicates that textures need to be re-calculated for all materials
  34310. */
  34311. protected _markAllSubMeshesAsTexturesDirty(): void;
  34312. /**
  34313. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34314. * This will returns an RGBA array buffer containing either in values (0-255) or
  34315. * float values (0-1) depending of the underlying buffer type.
  34316. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34317. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34318. * @param buffer defines a user defined buffer to fill with data (can be null)
  34319. * @returns The Array buffer containing the pixels data.
  34320. */
  34321. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34322. /**
  34323. * Release and destroy the underlying lower level texture aka internalTexture.
  34324. */
  34325. releaseInternalTexture(): void;
  34326. /** @hidden */
  34327. get _lodTextureHigh(): Nullable<BaseTexture>;
  34328. /** @hidden */
  34329. get _lodTextureMid(): Nullable<BaseTexture>;
  34330. /** @hidden */
  34331. get _lodTextureLow(): Nullable<BaseTexture>;
  34332. /**
  34333. * Dispose the texture and release its associated resources.
  34334. */
  34335. dispose(): void;
  34336. /**
  34337. * Serialize the texture into a JSON representation that can be parsed later on.
  34338. * @returns the JSON representation of the texture
  34339. */
  34340. serialize(): any;
  34341. /**
  34342. * Helper function to be called back once a list of texture contains only ready textures.
  34343. * @param textures Define the list of textures to wait for
  34344. * @param callback Define the callback triggered once the entire list will be ready
  34345. */
  34346. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34347. private static _isScene;
  34348. }
  34349. }
  34350. declare module "babylonjs/Materials/effect" {
  34351. import { Observable } from "babylonjs/Misc/observable";
  34352. import { Nullable } from "babylonjs/types";
  34353. import { IDisposable } from "babylonjs/scene";
  34354. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34355. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34356. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34357. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34358. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34359. import { Engine } from "babylonjs/Engines/engine";
  34360. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34361. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34362. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34363. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34364. /**
  34365. * Options to be used when creating an effect.
  34366. */
  34367. export interface IEffectCreationOptions {
  34368. /**
  34369. * Atrributes that will be used in the shader.
  34370. */
  34371. attributes: string[];
  34372. /**
  34373. * Uniform varible names that will be set in the shader.
  34374. */
  34375. uniformsNames: string[];
  34376. /**
  34377. * Uniform buffer variable names that will be set in the shader.
  34378. */
  34379. uniformBuffersNames: string[];
  34380. /**
  34381. * Sampler texture variable names that will be set in the shader.
  34382. */
  34383. samplers: string[];
  34384. /**
  34385. * Define statements that will be set in the shader.
  34386. */
  34387. defines: any;
  34388. /**
  34389. * Possible fallbacks for this effect to improve performance when needed.
  34390. */
  34391. fallbacks: Nullable<IEffectFallbacks>;
  34392. /**
  34393. * Callback that will be called when the shader is compiled.
  34394. */
  34395. onCompiled: Nullable<(effect: Effect) => void>;
  34396. /**
  34397. * Callback that will be called if an error occurs during shader compilation.
  34398. */
  34399. onError: Nullable<(effect: Effect, errors: string) => void>;
  34400. /**
  34401. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34402. */
  34403. indexParameters?: any;
  34404. /**
  34405. * Max number of lights that can be used in the shader.
  34406. */
  34407. maxSimultaneousLights?: number;
  34408. /**
  34409. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34410. */
  34411. transformFeedbackVaryings?: Nullable<string[]>;
  34412. /**
  34413. * 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
  34414. */
  34415. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34416. /**
  34417. * Is this effect rendering to several color attachments ?
  34418. */
  34419. multiTarget?: boolean;
  34420. }
  34421. /**
  34422. * Effect containing vertex and fragment shader that can be executed on an object.
  34423. */
  34424. export class Effect implements IDisposable {
  34425. /**
  34426. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34427. */
  34428. static ShadersRepository: string;
  34429. /**
  34430. * Enable logging of the shader code when a compilation error occurs
  34431. */
  34432. static LogShaderCodeOnCompilationError: boolean;
  34433. /**
  34434. * Name of the effect.
  34435. */
  34436. name: any;
  34437. /**
  34438. * String container all the define statements that should be set on the shader.
  34439. */
  34440. defines: string;
  34441. /**
  34442. * Callback that will be called when the shader is compiled.
  34443. */
  34444. onCompiled: Nullable<(effect: Effect) => void>;
  34445. /**
  34446. * Callback that will be called if an error occurs during shader compilation.
  34447. */
  34448. onError: Nullable<(effect: Effect, errors: string) => void>;
  34449. /**
  34450. * Callback that will be called when effect is bound.
  34451. */
  34452. onBind: Nullable<(effect: Effect) => void>;
  34453. /**
  34454. * Unique ID of the effect.
  34455. */
  34456. uniqueId: number;
  34457. /**
  34458. * Observable that will be called when the shader is compiled.
  34459. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34460. */
  34461. onCompileObservable: Observable<Effect>;
  34462. /**
  34463. * Observable that will be called if an error occurs during shader compilation.
  34464. */
  34465. onErrorObservable: Observable<Effect>;
  34466. /** @hidden */
  34467. _onBindObservable: Nullable<Observable<Effect>>;
  34468. /**
  34469. * @hidden
  34470. * Specifies if the effect was previously ready
  34471. */
  34472. _wasPreviouslyReady: boolean;
  34473. /**
  34474. * Observable that will be called when effect is bound.
  34475. */
  34476. get onBindObservable(): Observable<Effect>;
  34477. /** @hidden */
  34478. _bonesComputationForcedToCPU: boolean;
  34479. /** @hidden */
  34480. _multiTarget: boolean;
  34481. private static _uniqueIdSeed;
  34482. private _engine;
  34483. private _uniformBuffersNames;
  34484. private _uniformBuffersNamesList;
  34485. private _uniformsNames;
  34486. private _samplerList;
  34487. private _samplers;
  34488. private _isReady;
  34489. private _compilationError;
  34490. private _allFallbacksProcessed;
  34491. private _attributesNames;
  34492. private _attributes;
  34493. private _attributeLocationByName;
  34494. private _uniforms;
  34495. /**
  34496. * Key for the effect.
  34497. * @hidden
  34498. */
  34499. _key: string;
  34500. private _indexParameters;
  34501. private _fallbacks;
  34502. private _vertexSourceCode;
  34503. private _fragmentSourceCode;
  34504. private _vertexSourceCodeOverride;
  34505. private _fragmentSourceCodeOverride;
  34506. private _transformFeedbackVaryings;
  34507. /**
  34508. * Compiled shader to webGL program.
  34509. * @hidden
  34510. */
  34511. _pipelineContext: Nullable<IPipelineContext>;
  34512. private _valueCache;
  34513. private static _baseCache;
  34514. /**
  34515. * Instantiates an effect.
  34516. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34517. * @param baseName Name of the effect.
  34518. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34519. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34520. * @param samplers List of sampler variables that will be passed to the shader.
  34521. * @param engine Engine to be used to render the effect
  34522. * @param defines Define statements to be added to the shader.
  34523. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34524. * @param onCompiled Callback that will be called when the shader is compiled.
  34525. * @param onError Callback that will be called if an error occurs during shader compilation.
  34526. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34527. */
  34528. 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);
  34529. private _useFinalCode;
  34530. /**
  34531. * Unique key for this effect
  34532. */
  34533. get key(): string;
  34534. /**
  34535. * If the effect has been compiled and prepared.
  34536. * @returns if the effect is compiled and prepared.
  34537. */
  34538. isReady(): boolean;
  34539. private _isReadyInternal;
  34540. /**
  34541. * The engine the effect was initialized with.
  34542. * @returns the engine.
  34543. */
  34544. getEngine(): Engine;
  34545. /**
  34546. * The pipeline context for this effect
  34547. * @returns the associated pipeline context
  34548. */
  34549. getPipelineContext(): Nullable<IPipelineContext>;
  34550. /**
  34551. * The set of names of attribute variables for the shader.
  34552. * @returns An array of attribute names.
  34553. */
  34554. getAttributesNames(): string[];
  34555. /**
  34556. * Returns the attribute at the given index.
  34557. * @param index The index of the attribute.
  34558. * @returns The location of the attribute.
  34559. */
  34560. getAttributeLocation(index: number): number;
  34561. /**
  34562. * Returns the attribute based on the name of the variable.
  34563. * @param name of the attribute to look up.
  34564. * @returns the attribute location.
  34565. */
  34566. getAttributeLocationByName(name: string): number;
  34567. /**
  34568. * The number of attributes.
  34569. * @returns the numnber of attributes.
  34570. */
  34571. getAttributesCount(): number;
  34572. /**
  34573. * Gets the index of a uniform variable.
  34574. * @param uniformName of the uniform to look up.
  34575. * @returns the index.
  34576. */
  34577. getUniformIndex(uniformName: string): number;
  34578. /**
  34579. * Returns the attribute based on the name of the variable.
  34580. * @param uniformName of the uniform to look up.
  34581. * @returns the location of the uniform.
  34582. */
  34583. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34584. /**
  34585. * Returns an array of sampler variable names
  34586. * @returns The array of sampler variable names.
  34587. */
  34588. getSamplers(): string[];
  34589. /**
  34590. * Returns an array of uniform variable names
  34591. * @returns The array of uniform variable names.
  34592. */
  34593. getUniformNames(): string[];
  34594. /**
  34595. * Returns an array of uniform buffer variable names
  34596. * @returns The array of uniform buffer variable names.
  34597. */
  34598. getUniformBuffersNames(): string[];
  34599. /**
  34600. * Returns the index parameters used to create the effect
  34601. * @returns The index parameters object
  34602. */
  34603. getIndexParameters(): any;
  34604. /**
  34605. * The error from the last compilation.
  34606. * @returns the error string.
  34607. */
  34608. getCompilationError(): string;
  34609. /**
  34610. * Gets a boolean indicating that all fallbacks were used during compilation
  34611. * @returns true if all fallbacks were used
  34612. */
  34613. allFallbacksProcessed(): boolean;
  34614. /**
  34615. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34616. * @param func The callback to be used.
  34617. */
  34618. executeWhenCompiled(func: (effect: Effect) => void): void;
  34619. private _checkIsReady;
  34620. private _loadShader;
  34621. /**
  34622. * Gets the vertex shader source code of this effect
  34623. */
  34624. get vertexSourceCode(): string;
  34625. /**
  34626. * Gets the fragment shader source code of this effect
  34627. */
  34628. get fragmentSourceCode(): string;
  34629. /**
  34630. * Recompiles the webGL program
  34631. * @param vertexSourceCode The source code for the vertex shader.
  34632. * @param fragmentSourceCode The source code for the fragment shader.
  34633. * @param onCompiled Callback called when completed.
  34634. * @param onError Callback called on error.
  34635. * @hidden
  34636. */
  34637. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34638. /**
  34639. * Prepares the effect
  34640. * @hidden
  34641. */
  34642. _prepareEffect(): void;
  34643. private _getShaderCodeAndErrorLine;
  34644. private _processCompilationErrors;
  34645. /**
  34646. * Checks if the effect is supported. (Must be called after compilation)
  34647. */
  34648. get isSupported(): boolean;
  34649. /**
  34650. * Binds a texture to the engine to be used as output of the shader.
  34651. * @param channel Name of the output variable.
  34652. * @param texture Texture to bind.
  34653. * @hidden
  34654. */
  34655. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34656. /**
  34657. * Sets a texture on the engine to be used in the shader.
  34658. * @param channel Name of the sampler variable.
  34659. * @param texture Texture to set.
  34660. */
  34661. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34662. /**
  34663. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34664. * @param channel Name of the sampler variable.
  34665. * @param texture Texture to set.
  34666. */
  34667. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34668. /**
  34669. * Sets an array of textures on the engine to be used in the shader.
  34670. * @param channel Name of the variable.
  34671. * @param textures Textures to set.
  34672. */
  34673. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34674. /**
  34675. * 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)
  34676. * @param channel Name of the sampler variable.
  34677. * @param postProcess Post process to get the input texture from.
  34678. */
  34679. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34680. /**
  34681. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34682. * 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)
  34683. * @param channel Name of the sampler variable.
  34684. * @param postProcess Post process to get the output texture from.
  34685. */
  34686. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34687. /** @hidden */
  34688. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34689. /** @hidden */
  34690. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34691. /** @hidden */
  34692. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34693. /** @hidden */
  34694. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34695. /**
  34696. * Binds a buffer to a uniform.
  34697. * @param buffer Buffer to bind.
  34698. * @param name Name of the uniform variable to bind to.
  34699. */
  34700. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34701. /**
  34702. * Binds block to a uniform.
  34703. * @param blockName Name of the block to bind.
  34704. * @param index Index to bind.
  34705. */
  34706. bindUniformBlock(blockName: string, index: number): void;
  34707. /**
  34708. * Sets an interger value on a uniform variable.
  34709. * @param uniformName Name of the variable.
  34710. * @param value Value to be set.
  34711. * @returns this effect.
  34712. */
  34713. setInt(uniformName: string, value: number): Effect;
  34714. /**
  34715. * Sets an int array on a uniform variable.
  34716. * @param uniformName Name of the variable.
  34717. * @param array array to be set.
  34718. * @returns this effect.
  34719. */
  34720. setIntArray(uniformName: string, array: Int32Array): Effect;
  34721. /**
  34722. * 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)
  34723. * @param uniformName Name of the variable.
  34724. * @param array array to be set.
  34725. * @returns this effect.
  34726. */
  34727. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34728. /**
  34729. * 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)
  34730. * @param uniformName Name of the variable.
  34731. * @param array array to be set.
  34732. * @returns this effect.
  34733. */
  34734. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34735. /**
  34736. * 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)
  34737. * @param uniformName Name of the variable.
  34738. * @param array array to be set.
  34739. * @returns this effect.
  34740. */
  34741. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34742. /**
  34743. * Sets an float array on a uniform variable.
  34744. * @param uniformName Name of the variable.
  34745. * @param array array to be set.
  34746. * @returns this effect.
  34747. */
  34748. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34749. /**
  34750. * 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)
  34751. * @param uniformName Name of the variable.
  34752. * @param array array to be set.
  34753. * @returns this effect.
  34754. */
  34755. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34756. /**
  34757. * 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)
  34758. * @param uniformName Name of the variable.
  34759. * @param array array to be set.
  34760. * @returns this effect.
  34761. */
  34762. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34763. /**
  34764. * 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)
  34765. * @param uniformName Name of the variable.
  34766. * @param array array to be set.
  34767. * @returns this effect.
  34768. */
  34769. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34770. /**
  34771. * Sets an array on a uniform variable.
  34772. * @param uniformName Name of the variable.
  34773. * @param array array to be set.
  34774. * @returns this effect.
  34775. */
  34776. setArray(uniformName: string, array: number[]): Effect;
  34777. /**
  34778. * 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)
  34779. * @param uniformName Name of the variable.
  34780. * @param array array to be set.
  34781. * @returns this effect.
  34782. */
  34783. setArray2(uniformName: string, array: number[]): Effect;
  34784. /**
  34785. * 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)
  34786. * @param uniformName Name of the variable.
  34787. * @param array array to be set.
  34788. * @returns this effect.
  34789. */
  34790. setArray3(uniformName: string, array: number[]): Effect;
  34791. /**
  34792. * 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)
  34793. * @param uniformName Name of the variable.
  34794. * @param array array to be set.
  34795. * @returns this effect.
  34796. */
  34797. setArray4(uniformName: string, array: number[]): Effect;
  34798. /**
  34799. * Sets matrices on a uniform variable.
  34800. * @param uniformName Name of the variable.
  34801. * @param matrices matrices to be set.
  34802. * @returns this effect.
  34803. */
  34804. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34805. /**
  34806. * Sets matrix on a uniform variable.
  34807. * @param uniformName Name of the variable.
  34808. * @param matrix matrix to be set.
  34809. * @returns this effect.
  34810. */
  34811. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34812. /**
  34813. * 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)
  34814. * @param uniformName Name of the variable.
  34815. * @param matrix matrix to be set.
  34816. * @returns this effect.
  34817. */
  34818. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34819. /**
  34820. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34821. * @param uniformName Name of the variable.
  34822. * @param matrix matrix to be set.
  34823. * @returns this effect.
  34824. */
  34825. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34826. /**
  34827. * Sets a float on a uniform variable.
  34828. * @param uniformName Name of the variable.
  34829. * @param value value to be set.
  34830. * @returns this effect.
  34831. */
  34832. setFloat(uniformName: string, value: number): Effect;
  34833. /**
  34834. * Sets a boolean on a uniform variable.
  34835. * @param uniformName Name of the variable.
  34836. * @param bool value to be set.
  34837. * @returns this effect.
  34838. */
  34839. setBool(uniformName: string, bool: boolean): Effect;
  34840. /**
  34841. * Sets a Vector2 on a uniform variable.
  34842. * @param uniformName Name of the variable.
  34843. * @param vector2 vector2 to be set.
  34844. * @returns this effect.
  34845. */
  34846. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34847. /**
  34848. * Sets a float2 on a uniform variable.
  34849. * @param uniformName Name of the variable.
  34850. * @param x First float in float2.
  34851. * @param y Second float in float2.
  34852. * @returns this effect.
  34853. */
  34854. setFloat2(uniformName: string, x: number, y: number): Effect;
  34855. /**
  34856. * Sets a Vector3 on a uniform variable.
  34857. * @param uniformName Name of the variable.
  34858. * @param vector3 Value to be set.
  34859. * @returns this effect.
  34860. */
  34861. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34862. /**
  34863. * Sets a float3 on a uniform variable.
  34864. * @param uniformName Name of the variable.
  34865. * @param x First float in float3.
  34866. * @param y Second float in float3.
  34867. * @param z Third float in float3.
  34868. * @returns this effect.
  34869. */
  34870. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34871. /**
  34872. * Sets a Vector4 on a uniform variable.
  34873. * @param uniformName Name of the variable.
  34874. * @param vector4 Value to be set.
  34875. * @returns this effect.
  34876. */
  34877. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34878. /**
  34879. * Sets a float4 on a uniform variable.
  34880. * @param uniformName Name of the variable.
  34881. * @param x First float in float4.
  34882. * @param y Second float in float4.
  34883. * @param z Third float in float4.
  34884. * @param w Fourth float in float4.
  34885. * @returns this effect.
  34886. */
  34887. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34888. /**
  34889. * Sets a Color3 on a uniform variable.
  34890. * @param uniformName Name of the variable.
  34891. * @param color3 Value to be set.
  34892. * @returns this effect.
  34893. */
  34894. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34895. /**
  34896. * Sets a Color4 on a uniform variable.
  34897. * @param uniformName Name of the variable.
  34898. * @param color3 Value to be set.
  34899. * @param alpha Alpha value to be set.
  34900. * @returns this effect.
  34901. */
  34902. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34903. /**
  34904. * Sets a Color4 on a uniform variable
  34905. * @param uniformName defines the name of the variable
  34906. * @param color4 defines the value to be set
  34907. * @returns this effect.
  34908. */
  34909. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34910. /** Release all associated resources */
  34911. dispose(): void;
  34912. /**
  34913. * This function will add a new shader to the shader store
  34914. * @param name the name of the shader
  34915. * @param pixelShader optional pixel shader content
  34916. * @param vertexShader optional vertex shader content
  34917. */
  34918. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34919. /**
  34920. * Store of each shader (The can be looked up using effect.key)
  34921. */
  34922. static ShadersStore: {
  34923. [key: string]: string;
  34924. };
  34925. /**
  34926. * Store of each included file for a shader (The can be looked up using effect.key)
  34927. */
  34928. static IncludesShadersStore: {
  34929. [key: string]: string;
  34930. };
  34931. /**
  34932. * Resets the cache of effects.
  34933. */
  34934. static ResetCache(): void;
  34935. }
  34936. }
  34937. declare module "babylonjs/Engines/engineCapabilities" {
  34938. /**
  34939. * Interface used to describe the capabilities of the engine relatively to the current browser
  34940. */
  34941. export interface EngineCapabilities {
  34942. /** Maximum textures units per fragment shader */
  34943. maxTexturesImageUnits: number;
  34944. /** Maximum texture units per vertex shader */
  34945. maxVertexTextureImageUnits: number;
  34946. /** Maximum textures units in the entire pipeline */
  34947. maxCombinedTexturesImageUnits: number;
  34948. /** Maximum texture size */
  34949. maxTextureSize: number;
  34950. /** Maximum texture samples */
  34951. maxSamples?: number;
  34952. /** Maximum cube texture size */
  34953. maxCubemapTextureSize: number;
  34954. /** Maximum render texture size */
  34955. maxRenderTextureSize: number;
  34956. /** Maximum number of vertex attributes */
  34957. maxVertexAttribs: number;
  34958. /** Maximum number of varyings */
  34959. maxVaryingVectors: number;
  34960. /** Maximum number of uniforms per vertex shader */
  34961. maxVertexUniformVectors: number;
  34962. /** Maximum number of uniforms per fragment shader */
  34963. maxFragmentUniformVectors: number;
  34964. /** Defines if standard derivates (dx/dy) are supported */
  34965. standardDerivatives: boolean;
  34966. /** Defines if s3tc texture compression is supported */
  34967. s3tc?: WEBGL_compressed_texture_s3tc;
  34968. /** Defines if pvrtc texture compression is supported */
  34969. pvrtc: any;
  34970. /** Defines if etc1 texture compression is supported */
  34971. etc1: any;
  34972. /** Defines if etc2 texture compression is supported */
  34973. etc2: any;
  34974. /** Defines if astc texture compression is supported */
  34975. astc: any;
  34976. /** Defines if float textures are supported */
  34977. textureFloat: boolean;
  34978. /** Defines if vertex array objects are supported */
  34979. vertexArrayObject: boolean;
  34980. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34981. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34982. /** Gets the maximum level of anisotropy supported */
  34983. maxAnisotropy: number;
  34984. /** Defines if instancing is supported */
  34985. instancedArrays: boolean;
  34986. /** Defines if 32 bits indices are supported */
  34987. uintIndices: boolean;
  34988. /** Defines if high precision shaders are supported */
  34989. highPrecisionShaderSupported: boolean;
  34990. /** Defines if depth reading in the fragment shader is supported */
  34991. fragmentDepthSupported: boolean;
  34992. /** Defines if float texture linear filtering is supported*/
  34993. textureFloatLinearFiltering: boolean;
  34994. /** Defines if rendering to float textures is supported */
  34995. textureFloatRender: boolean;
  34996. /** Defines if half float textures are supported*/
  34997. textureHalfFloat: boolean;
  34998. /** Defines if half float texture linear filtering is supported*/
  34999. textureHalfFloatLinearFiltering: boolean;
  35000. /** Defines if rendering to half float textures is supported */
  35001. textureHalfFloatRender: boolean;
  35002. /** Defines if textureLOD shader command is supported */
  35003. textureLOD: boolean;
  35004. /** Defines if draw buffers extension is supported */
  35005. drawBuffersExtension: boolean;
  35006. /** Defines if depth textures are supported */
  35007. depthTextureExtension: boolean;
  35008. /** Defines if float color buffer are supported */
  35009. colorBufferFloat: boolean;
  35010. /** Gets disjoint timer query extension (null if not supported) */
  35011. timerQuery?: EXT_disjoint_timer_query;
  35012. /** Defines if timestamp can be used with timer query */
  35013. canUseTimestampForTimerQuery: boolean;
  35014. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35015. multiview?: any;
  35016. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35017. oculusMultiview?: any;
  35018. /** Function used to let the system compiles shaders in background */
  35019. parallelShaderCompile?: {
  35020. COMPLETION_STATUS_KHR: number;
  35021. };
  35022. /** Max number of texture samples for MSAA */
  35023. maxMSAASamples: number;
  35024. /** Defines if the blend min max extension is supported */
  35025. blendMinMax: boolean;
  35026. }
  35027. }
  35028. declare module "babylonjs/States/depthCullingState" {
  35029. import { Nullable } from "babylonjs/types";
  35030. /**
  35031. * @hidden
  35032. **/
  35033. export class DepthCullingState {
  35034. private _isDepthTestDirty;
  35035. private _isDepthMaskDirty;
  35036. private _isDepthFuncDirty;
  35037. private _isCullFaceDirty;
  35038. private _isCullDirty;
  35039. private _isZOffsetDirty;
  35040. private _isFrontFaceDirty;
  35041. private _depthTest;
  35042. private _depthMask;
  35043. private _depthFunc;
  35044. private _cull;
  35045. private _cullFace;
  35046. private _zOffset;
  35047. private _frontFace;
  35048. /**
  35049. * Initializes the state.
  35050. */
  35051. constructor();
  35052. get isDirty(): boolean;
  35053. get zOffset(): number;
  35054. set zOffset(value: number);
  35055. get cullFace(): Nullable<number>;
  35056. set cullFace(value: Nullable<number>);
  35057. get cull(): Nullable<boolean>;
  35058. set cull(value: Nullable<boolean>);
  35059. get depthFunc(): Nullable<number>;
  35060. set depthFunc(value: Nullable<number>);
  35061. get depthMask(): boolean;
  35062. set depthMask(value: boolean);
  35063. get depthTest(): boolean;
  35064. set depthTest(value: boolean);
  35065. get frontFace(): Nullable<number>;
  35066. set frontFace(value: Nullable<number>);
  35067. reset(): void;
  35068. apply(gl: WebGLRenderingContext): void;
  35069. }
  35070. }
  35071. declare module "babylonjs/States/stencilState" {
  35072. /**
  35073. * @hidden
  35074. **/
  35075. export class StencilState {
  35076. /** 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 */
  35077. static readonly ALWAYS: number;
  35078. /** Passed to stencilOperation to specify that stencil value must be kept */
  35079. static readonly KEEP: number;
  35080. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35081. static readonly REPLACE: number;
  35082. private _isStencilTestDirty;
  35083. private _isStencilMaskDirty;
  35084. private _isStencilFuncDirty;
  35085. private _isStencilOpDirty;
  35086. private _stencilTest;
  35087. private _stencilMask;
  35088. private _stencilFunc;
  35089. private _stencilFuncRef;
  35090. private _stencilFuncMask;
  35091. private _stencilOpStencilFail;
  35092. private _stencilOpDepthFail;
  35093. private _stencilOpStencilDepthPass;
  35094. get isDirty(): boolean;
  35095. get stencilFunc(): number;
  35096. set stencilFunc(value: number);
  35097. get stencilFuncRef(): number;
  35098. set stencilFuncRef(value: number);
  35099. get stencilFuncMask(): number;
  35100. set stencilFuncMask(value: number);
  35101. get stencilOpStencilFail(): number;
  35102. set stencilOpStencilFail(value: number);
  35103. get stencilOpDepthFail(): number;
  35104. set stencilOpDepthFail(value: number);
  35105. get stencilOpStencilDepthPass(): number;
  35106. set stencilOpStencilDepthPass(value: number);
  35107. get stencilMask(): number;
  35108. set stencilMask(value: number);
  35109. get stencilTest(): boolean;
  35110. set stencilTest(value: boolean);
  35111. constructor();
  35112. reset(): void;
  35113. apply(gl: WebGLRenderingContext): void;
  35114. }
  35115. }
  35116. declare module "babylonjs/States/alphaCullingState" {
  35117. /**
  35118. * @hidden
  35119. **/
  35120. export class AlphaState {
  35121. private _isAlphaBlendDirty;
  35122. private _isBlendFunctionParametersDirty;
  35123. private _isBlendEquationParametersDirty;
  35124. private _isBlendConstantsDirty;
  35125. private _alphaBlend;
  35126. private _blendFunctionParameters;
  35127. private _blendEquationParameters;
  35128. private _blendConstants;
  35129. /**
  35130. * Initializes the state.
  35131. */
  35132. constructor();
  35133. get isDirty(): boolean;
  35134. get alphaBlend(): boolean;
  35135. set alphaBlend(value: boolean);
  35136. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35137. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35138. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35139. reset(): void;
  35140. apply(gl: WebGLRenderingContext): void;
  35141. }
  35142. }
  35143. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35144. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35145. /** @hidden */
  35146. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35147. attributeProcessor(attribute: string): string;
  35148. varyingProcessor(varying: string, isFragment: boolean): string;
  35149. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35150. }
  35151. }
  35152. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35153. /**
  35154. * Interface for attribute information associated with buffer instanciation
  35155. */
  35156. export interface InstancingAttributeInfo {
  35157. /**
  35158. * Name of the GLSL attribute
  35159. * if attribute index is not specified, this is used to retrieve the index from the effect
  35160. */
  35161. attributeName: string;
  35162. /**
  35163. * Index/offset of the attribute in the vertex shader
  35164. * if not specified, this will be computes from the name.
  35165. */
  35166. index?: number;
  35167. /**
  35168. * size of the attribute, 1, 2, 3 or 4
  35169. */
  35170. attributeSize: number;
  35171. /**
  35172. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35173. */
  35174. offset: number;
  35175. /**
  35176. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35177. * default to 1
  35178. */
  35179. divisor?: number;
  35180. /**
  35181. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35182. * default is FLOAT
  35183. */
  35184. attributeType?: number;
  35185. /**
  35186. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35187. */
  35188. normalized?: boolean;
  35189. }
  35190. }
  35191. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35192. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35193. import { Nullable } from "babylonjs/types";
  35194. module "babylonjs/Engines/thinEngine" {
  35195. interface ThinEngine {
  35196. /**
  35197. * Update a video texture
  35198. * @param texture defines the texture to update
  35199. * @param video defines the video element to use
  35200. * @param invertY defines if data must be stored with Y axis inverted
  35201. */
  35202. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35203. }
  35204. }
  35205. }
  35206. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  35207. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35208. import { Nullable } from "babylonjs/types";
  35209. module "babylonjs/Engines/thinEngine" {
  35210. interface ThinEngine {
  35211. /**
  35212. * Creates a dynamic texture
  35213. * @param width defines the width of the texture
  35214. * @param height defines the height of the texture
  35215. * @param generateMipMaps defines if the engine should generate the mip levels
  35216. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35217. * @returns the dynamic texture inside an InternalTexture
  35218. */
  35219. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35220. /**
  35221. * Update the content of a dynamic texture
  35222. * @param texture defines the texture to update
  35223. * @param canvas defines the canvas containing the source
  35224. * @param invertY defines if data must be stored with Y axis inverted
  35225. * @param premulAlpha defines if alpha is stored as premultiplied
  35226. * @param format defines the format of the data
  35227. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35228. */
  35229. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35230. }
  35231. }
  35232. }
  35233. declare module "babylonjs/Materials/Textures/videoTexture" {
  35234. import { Observable } from "babylonjs/Misc/observable";
  35235. import { Nullable } from "babylonjs/types";
  35236. import { Scene } from "babylonjs/scene";
  35237. import { Texture } from "babylonjs/Materials/Textures/texture";
  35238. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35239. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35240. /**
  35241. * Settings for finer control over video usage
  35242. */
  35243. export interface VideoTextureSettings {
  35244. /**
  35245. * Applies `autoplay` to video, if specified
  35246. */
  35247. autoPlay?: boolean;
  35248. /**
  35249. * Applies `loop` to video, if specified
  35250. */
  35251. loop?: boolean;
  35252. /**
  35253. * Automatically updates internal texture from video at every frame in the render loop
  35254. */
  35255. autoUpdateTexture: boolean;
  35256. /**
  35257. * Image src displayed during the video loading or until the user interacts with the video.
  35258. */
  35259. poster?: string;
  35260. }
  35261. /**
  35262. * If you want to display a video in your scene, this is the special texture for that.
  35263. * This special texture works similar to other textures, with the exception of a few parameters.
  35264. * @see https://doc.babylonjs.com/how_to/video_texture
  35265. */
  35266. export class VideoTexture extends Texture {
  35267. /**
  35268. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35269. */
  35270. readonly autoUpdateTexture: boolean;
  35271. /**
  35272. * The video instance used by the texture internally
  35273. */
  35274. readonly video: HTMLVideoElement;
  35275. private _onUserActionRequestedObservable;
  35276. /**
  35277. * Event triggerd when a dom action is required by the user to play the video.
  35278. * This happens due to recent changes in browser policies preventing video to auto start.
  35279. */
  35280. get onUserActionRequestedObservable(): Observable<Texture>;
  35281. private _generateMipMaps;
  35282. private _stillImageCaptured;
  35283. private _displayingPosterTexture;
  35284. private _settings;
  35285. private _createInternalTextureOnEvent;
  35286. private _frameId;
  35287. private _currentSrc;
  35288. /**
  35289. * Creates a video texture.
  35290. * If you want to display a video in your scene, this is the special texture for that.
  35291. * This special texture works similar to other textures, with the exception of a few parameters.
  35292. * @see https://doc.babylonjs.com/how_to/video_texture
  35293. * @param name optional name, will detect from video source, if not defined
  35294. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35295. * @param scene is obviously the current scene.
  35296. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35297. * @param invertY is false by default but can be used to invert video on Y axis
  35298. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35299. * @param settings allows finer control over video usage
  35300. */
  35301. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35302. private _getName;
  35303. private _getVideo;
  35304. private _createInternalTexture;
  35305. private reset;
  35306. /**
  35307. * @hidden Internal method to initiate `update`.
  35308. */
  35309. _rebuild(): void;
  35310. /**
  35311. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35312. */
  35313. update(): void;
  35314. /**
  35315. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35316. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35317. */
  35318. updateTexture(isVisible: boolean): void;
  35319. protected _updateInternalTexture: () => void;
  35320. /**
  35321. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35322. * @param url New url.
  35323. */
  35324. updateURL(url: string): void;
  35325. /**
  35326. * Clones the texture.
  35327. * @returns the cloned texture
  35328. */
  35329. clone(): VideoTexture;
  35330. /**
  35331. * Dispose the texture and release its associated resources.
  35332. */
  35333. dispose(): void;
  35334. /**
  35335. * Creates a video texture straight from a stream.
  35336. * @param scene Define the scene the texture should be created in
  35337. * @param stream Define the stream the texture should be created from
  35338. * @returns The created video texture as a promise
  35339. */
  35340. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35341. /**
  35342. * Creates a video texture straight from your WebCam video feed.
  35343. * @param scene Define the scene the texture should be created in
  35344. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35345. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35346. * @returns The created video texture as a promise
  35347. */
  35348. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35349. minWidth: number;
  35350. maxWidth: number;
  35351. minHeight: number;
  35352. maxHeight: number;
  35353. deviceId: string;
  35354. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35355. /**
  35356. * Creates a video texture straight from your WebCam video feed.
  35357. * @param scene Define the scene the texture should be created in
  35358. * @param onReady Define a callback to triggered once the texture will be ready
  35359. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35360. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35361. */
  35362. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35363. minWidth: number;
  35364. maxWidth: number;
  35365. minHeight: number;
  35366. maxHeight: number;
  35367. deviceId: string;
  35368. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35369. }
  35370. }
  35371. declare module "babylonjs/Engines/thinEngine" {
  35372. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35373. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35374. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35375. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35376. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35377. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35378. import { Observable } from "babylonjs/Misc/observable";
  35379. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35380. import { StencilState } from "babylonjs/States/stencilState";
  35381. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35383. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35384. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35385. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35386. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35387. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35388. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35389. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35390. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35391. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35392. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35393. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35394. import { WebRequest } from "babylonjs/Misc/webRequest";
  35395. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35396. /**
  35397. * Defines the interface used by objects working like Scene
  35398. * @hidden
  35399. */
  35400. export interface ISceneLike {
  35401. _addPendingData(data: any): void;
  35402. _removePendingData(data: any): void;
  35403. offlineProvider: IOfflineProvider;
  35404. }
  35405. /** Interface defining initialization parameters for Engine class */
  35406. export interface EngineOptions extends WebGLContextAttributes {
  35407. /**
  35408. * Defines if the engine should no exceed a specified device ratio
  35409. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35410. */
  35411. limitDeviceRatio?: number;
  35412. /**
  35413. * Defines if webvr should be enabled automatically
  35414. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35415. */
  35416. autoEnableWebVR?: boolean;
  35417. /**
  35418. * Defines if webgl2 should be turned off even if supported
  35419. * @see https://doc.babylonjs.com/features/webgl2
  35420. */
  35421. disableWebGL2Support?: boolean;
  35422. /**
  35423. * Defines if webaudio should be initialized as well
  35424. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35425. */
  35426. audioEngine?: boolean;
  35427. /**
  35428. * Defines if animations should run using a deterministic lock step
  35429. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35430. */
  35431. deterministicLockstep?: boolean;
  35432. /** Defines the maximum steps to use with deterministic lock step mode */
  35433. lockstepMaxSteps?: number;
  35434. /** Defines the seconds between each deterministic lock step */
  35435. timeStep?: number;
  35436. /**
  35437. * Defines that engine should ignore context lost events
  35438. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35439. */
  35440. doNotHandleContextLost?: boolean;
  35441. /**
  35442. * Defines that engine should ignore modifying touch action attribute and style
  35443. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35444. */
  35445. doNotHandleTouchAction?: boolean;
  35446. /**
  35447. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35448. */
  35449. useHighPrecisionFloats?: boolean;
  35450. /**
  35451. * Make the canvas XR Compatible for XR sessions
  35452. */
  35453. xrCompatible?: boolean;
  35454. }
  35455. /**
  35456. * The base engine class (root of all engines)
  35457. */
  35458. export class ThinEngine {
  35459. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35460. static ExceptionList: ({
  35461. key: string;
  35462. capture: string;
  35463. captureConstraint: number;
  35464. targets: string[];
  35465. } | {
  35466. key: string;
  35467. capture: null;
  35468. captureConstraint: null;
  35469. targets: string[];
  35470. })[];
  35471. /** @hidden */
  35472. static _TextureLoaders: IInternalTextureLoader[];
  35473. /**
  35474. * Returns the current npm package of the sdk
  35475. */
  35476. static get NpmPackage(): string;
  35477. /**
  35478. * Returns the current version of the framework
  35479. */
  35480. static get Version(): string;
  35481. /**
  35482. * Returns a string describing the current engine
  35483. */
  35484. get description(): string;
  35485. /**
  35486. * Gets or sets the epsilon value used by collision engine
  35487. */
  35488. static CollisionsEpsilon: number;
  35489. /**
  35490. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35491. */
  35492. static get ShadersRepository(): string;
  35493. static set ShadersRepository(value: string);
  35494. /** @hidden */
  35495. _shaderProcessor: IShaderProcessor;
  35496. /**
  35497. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35498. */
  35499. forcePOTTextures: boolean;
  35500. /**
  35501. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35502. */
  35503. isFullscreen: boolean;
  35504. /**
  35505. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35506. */
  35507. cullBackFaces: boolean;
  35508. /**
  35509. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35510. */
  35511. renderEvenInBackground: boolean;
  35512. /**
  35513. * Gets or sets a boolean indicating that cache can be kept between frames
  35514. */
  35515. preventCacheWipeBetweenFrames: boolean;
  35516. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35517. validateShaderPrograms: boolean;
  35518. /**
  35519. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35520. * This can provide greater z depth for distant objects.
  35521. */
  35522. useReverseDepthBuffer: boolean;
  35523. /**
  35524. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35525. */
  35526. disableUniformBuffers: boolean;
  35527. /** @hidden */
  35528. _uniformBuffers: UniformBuffer[];
  35529. /**
  35530. * Gets a boolean indicating that the engine supports uniform buffers
  35531. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35532. */
  35533. get supportsUniformBuffers(): boolean;
  35534. /** @hidden */
  35535. _gl: WebGLRenderingContext;
  35536. /** @hidden */
  35537. _webGLVersion: number;
  35538. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35539. protected _windowIsBackground: boolean;
  35540. protected _creationOptions: EngineOptions;
  35541. protected _highPrecisionShadersAllowed: boolean;
  35542. /** @hidden */
  35543. get _shouldUseHighPrecisionShader(): boolean;
  35544. /**
  35545. * Gets a boolean indicating that only power of 2 textures are supported
  35546. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35547. */
  35548. get needPOTTextures(): boolean;
  35549. /** @hidden */
  35550. _badOS: boolean;
  35551. /** @hidden */
  35552. _badDesktopOS: boolean;
  35553. private _hardwareScalingLevel;
  35554. /** @hidden */
  35555. _caps: EngineCapabilities;
  35556. private _isStencilEnable;
  35557. private _glVersion;
  35558. private _glRenderer;
  35559. private _glVendor;
  35560. /** @hidden */
  35561. _videoTextureSupported: boolean;
  35562. protected _renderingQueueLaunched: boolean;
  35563. protected _activeRenderLoops: (() => void)[];
  35564. /**
  35565. * Observable signaled when a context lost event is raised
  35566. */
  35567. onContextLostObservable: Observable<ThinEngine>;
  35568. /**
  35569. * Observable signaled when a context restored event is raised
  35570. */
  35571. onContextRestoredObservable: Observable<ThinEngine>;
  35572. private _onContextLost;
  35573. private _onContextRestored;
  35574. protected _contextWasLost: boolean;
  35575. /** @hidden */
  35576. _doNotHandleContextLost: boolean;
  35577. /**
  35578. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35579. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35580. */
  35581. get doNotHandleContextLost(): boolean;
  35582. set doNotHandleContextLost(value: boolean);
  35583. /**
  35584. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35585. */
  35586. disableVertexArrayObjects: boolean;
  35587. /** @hidden */
  35588. protected _colorWrite: boolean;
  35589. /** @hidden */
  35590. protected _colorWriteChanged: boolean;
  35591. /** @hidden */
  35592. protected _depthCullingState: DepthCullingState;
  35593. /** @hidden */
  35594. protected _stencilState: StencilState;
  35595. /** @hidden */
  35596. _alphaState: AlphaState;
  35597. /** @hidden */
  35598. _alphaMode: number;
  35599. /** @hidden */
  35600. _alphaEquation: number;
  35601. /** @hidden */
  35602. _internalTexturesCache: InternalTexture[];
  35603. /** @hidden */
  35604. protected _activeChannel: number;
  35605. private _currentTextureChannel;
  35606. /** @hidden */
  35607. protected _boundTexturesCache: {
  35608. [key: string]: Nullable<InternalTexture>;
  35609. };
  35610. /** @hidden */
  35611. protected _currentEffect: Nullable<Effect>;
  35612. /** @hidden */
  35613. protected _currentProgram: Nullable<WebGLProgram>;
  35614. private _compiledEffects;
  35615. private _vertexAttribArraysEnabled;
  35616. /** @hidden */
  35617. protected _cachedViewport: Nullable<IViewportLike>;
  35618. private _cachedVertexArrayObject;
  35619. /** @hidden */
  35620. protected _cachedVertexBuffers: any;
  35621. /** @hidden */
  35622. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35623. /** @hidden */
  35624. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35625. /** @hidden */
  35626. _currentRenderTarget: Nullable<InternalTexture>;
  35627. private _uintIndicesCurrentlySet;
  35628. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35629. /** @hidden */
  35630. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35631. /** @hidden */
  35632. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35633. private _currentBufferPointers;
  35634. private _currentInstanceLocations;
  35635. private _currentInstanceBuffers;
  35636. private _textureUnits;
  35637. /** @hidden */
  35638. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35639. /** @hidden */
  35640. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35641. /** @hidden */
  35642. _boundRenderFunction: any;
  35643. private _vaoRecordInProgress;
  35644. private _mustWipeVertexAttributes;
  35645. private _emptyTexture;
  35646. private _emptyCubeTexture;
  35647. private _emptyTexture3D;
  35648. private _emptyTexture2DArray;
  35649. /** @hidden */
  35650. _frameHandler: number;
  35651. private _nextFreeTextureSlots;
  35652. private _maxSimultaneousTextures;
  35653. private _activeRequests;
  35654. /** @hidden */
  35655. _transformTextureUrl: Nullable<(url: string) => string>;
  35656. protected get _supportsHardwareTextureRescaling(): boolean;
  35657. private _framebufferDimensionsObject;
  35658. /**
  35659. * sets the object from which width and height will be taken from when getting render width and height
  35660. * Will fallback to the gl object
  35661. * @param dimensions the framebuffer width and height that will be used.
  35662. */
  35663. set framebufferDimensionsObject(dimensions: Nullable<{
  35664. framebufferWidth: number;
  35665. framebufferHeight: number;
  35666. }>);
  35667. /**
  35668. * Gets the current viewport
  35669. */
  35670. get currentViewport(): Nullable<IViewportLike>;
  35671. /**
  35672. * Gets the default empty texture
  35673. */
  35674. get emptyTexture(): InternalTexture;
  35675. /**
  35676. * Gets the default empty 3D texture
  35677. */
  35678. get emptyTexture3D(): InternalTexture;
  35679. /**
  35680. * Gets the default empty 2D array texture
  35681. */
  35682. get emptyTexture2DArray(): InternalTexture;
  35683. /**
  35684. * Gets the default empty cube texture
  35685. */
  35686. get emptyCubeTexture(): InternalTexture;
  35687. /**
  35688. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35689. */
  35690. readonly premultipliedAlpha: boolean;
  35691. /**
  35692. * Observable event triggered before each texture is initialized
  35693. */
  35694. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35695. /**
  35696. * Creates a new engine
  35697. * @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
  35698. * @param antialias defines enable antialiasing (default: false)
  35699. * @param options defines further options to be sent to the getContext() function
  35700. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35701. */
  35702. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35703. private _rebuildInternalTextures;
  35704. private _rebuildEffects;
  35705. /**
  35706. * Gets a boolean indicating if all created effects are ready
  35707. * @returns true if all effects are ready
  35708. */
  35709. areAllEffectsReady(): boolean;
  35710. protected _rebuildBuffers(): void;
  35711. protected _initGLContext(): void;
  35712. /**
  35713. * Gets version of the current webGL context
  35714. */
  35715. get webGLVersion(): number;
  35716. /**
  35717. * Gets a string idenfifying the name of the class
  35718. * @returns "Engine" string
  35719. */
  35720. getClassName(): string;
  35721. /**
  35722. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35723. */
  35724. get isStencilEnable(): boolean;
  35725. /** @hidden */
  35726. _prepareWorkingCanvas(): void;
  35727. /**
  35728. * Reset the texture cache to empty state
  35729. */
  35730. resetTextureCache(): void;
  35731. /**
  35732. * Gets an object containing information about the current webGL context
  35733. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35734. */
  35735. getGlInfo(): {
  35736. vendor: string;
  35737. renderer: string;
  35738. version: string;
  35739. };
  35740. /**
  35741. * Defines the hardware scaling level.
  35742. * By default the hardware scaling level is computed from the window device ratio.
  35743. * 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.
  35744. * @param level defines the level to use
  35745. */
  35746. setHardwareScalingLevel(level: number): void;
  35747. /**
  35748. * Gets the current hardware scaling level.
  35749. * By default the hardware scaling level is computed from the window device ratio.
  35750. * 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.
  35751. * @returns a number indicating the current hardware scaling level
  35752. */
  35753. getHardwareScalingLevel(): number;
  35754. /**
  35755. * Gets the list of loaded textures
  35756. * @returns an array containing all loaded textures
  35757. */
  35758. getLoadedTexturesCache(): InternalTexture[];
  35759. /**
  35760. * Gets the object containing all engine capabilities
  35761. * @returns the EngineCapabilities object
  35762. */
  35763. getCaps(): EngineCapabilities;
  35764. /**
  35765. * stop executing a render loop function and remove it from the execution array
  35766. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35767. */
  35768. stopRenderLoop(renderFunction?: () => void): void;
  35769. /** @hidden */
  35770. _renderLoop(): void;
  35771. /**
  35772. * Gets the HTML canvas attached with the current webGL context
  35773. * @returns a HTML canvas
  35774. */
  35775. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35776. /**
  35777. * Gets host window
  35778. * @returns the host window object
  35779. */
  35780. getHostWindow(): Nullable<Window>;
  35781. /**
  35782. * Gets the current render width
  35783. * @param useScreen defines if screen size must be used (or the current render target if any)
  35784. * @returns a number defining the current render width
  35785. */
  35786. getRenderWidth(useScreen?: boolean): number;
  35787. /**
  35788. * Gets the current render height
  35789. * @param useScreen defines if screen size must be used (or the current render target if any)
  35790. * @returns a number defining the current render height
  35791. */
  35792. getRenderHeight(useScreen?: boolean): number;
  35793. /**
  35794. * Can be used to override the current requestAnimationFrame requester.
  35795. * @hidden
  35796. */
  35797. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35798. /**
  35799. * Register and execute a render loop. The engine can have more than one render function
  35800. * @param renderFunction defines the function to continuously execute
  35801. */
  35802. runRenderLoop(renderFunction: () => void): void;
  35803. /**
  35804. * Clear the current render buffer or the current render target (if any is set up)
  35805. * @param color defines the color to use
  35806. * @param backBuffer defines if the back buffer must be cleared
  35807. * @param depth defines if the depth buffer must be cleared
  35808. * @param stencil defines if the stencil buffer must be cleared
  35809. */
  35810. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35811. private _viewportCached;
  35812. /** @hidden */
  35813. _viewport(x: number, y: number, width: number, height: number): void;
  35814. /**
  35815. * Set the WebGL's viewport
  35816. * @param viewport defines the viewport element to be used
  35817. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35818. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35819. */
  35820. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35821. /**
  35822. * Begin a new frame
  35823. */
  35824. beginFrame(): void;
  35825. /**
  35826. * Enf the current frame
  35827. */
  35828. endFrame(): void;
  35829. /**
  35830. * Resize the view according to the canvas' size
  35831. */
  35832. resize(): void;
  35833. /**
  35834. * Force a specific size of the canvas
  35835. * @param width defines the new canvas' width
  35836. * @param height defines the new canvas' height
  35837. * @returns true if the size was changed
  35838. */
  35839. setSize(width: number, height: number): boolean;
  35840. /**
  35841. * Binds the frame buffer to the specified texture.
  35842. * @param texture The texture to render to or null for the default canvas
  35843. * @param faceIndex The face of the texture to render to in case of cube texture
  35844. * @param requiredWidth The width of the target to render to
  35845. * @param requiredHeight The height of the target to render to
  35846. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35847. * @param lodLevel defines the lod level to bind to the frame buffer
  35848. * @param layer defines the 2d array index to bind to frame buffer to
  35849. */
  35850. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35851. /** @hidden */
  35852. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35853. /**
  35854. * Unbind the current render target texture from the webGL context
  35855. * @param texture defines the render target texture to unbind
  35856. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35857. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35858. */
  35859. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35860. /**
  35861. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35862. */
  35863. flushFramebuffer(): void;
  35864. /**
  35865. * Unbind the current render target and bind the default framebuffer
  35866. */
  35867. restoreDefaultFramebuffer(): void;
  35868. /** @hidden */
  35869. protected _resetVertexBufferBinding(): void;
  35870. /**
  35871. * Creates a vertex buffer
  35872. * @param data the data for the vertex buffer
  35873. * @returns the new WebGL static buffer
  35874. */
  35875. createVertexBuffer(data: DataArray): DataBuffer;
  35876. private _createVertexBuffer;
  35877. /**
  35878. * Creates a dynamic vertex buffer
  35879. * @param data the data for the dynamic vertex buffer
  35880. * @returns the new WebGL dynamic buffer
  35881. */
  35882. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35883. protected _resetIndexBufferBinding(): void;
  35884. /**
  35885. * Creates a new index buffer
  35886. * @param indices defines the content of the index buffer
  35887. * @param updatable defines if the index buffer must be updatable
  35888. * @returns a new webGL buffer
  35889. */
  35890. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35891. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35892. /**
  35893. * Bind a webGL buffer to the webGL context
  35894. * @param buffer defines the buffer to bind
  35895. */
  35896. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35897. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35898. private bindBuffer;
  35899. /**
  35900. * update the bound buffer with the given data
  35901. * @param data defines the data to update
  35902. */
  35903. updateArrayBuffer(data: Float32Array): void;
  35904. private _vertexAttribPointer;
  35905. /** @hidden */
  35906. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35907. private _bindVertexBuffersAttributes;
  35908. /**
  35909. * Records a vertex array object
  35910. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35911. * @param vertexBuffers defines the list of vertex buffers to store
  35912. * @param indexBuffer defines the index buffer to store
  35913. * @param effect defines the effect to store
  35914. * @returns the new vertex array object
  35915. */
  35916. recordVertexArrayObject(vertexBuffers: {
  35917. [key: string]: VertexBuffer;
  35918. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35919. /**
  35920. * Bind a specific vertex array object
  35921. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35922. * @param vertexArrayObject defines the vertex array object to bind
  35923. * @param indexBuffer defines the index buffer to bind
  35924. */
  35925. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35926. /**
  35927. * Bind webGl buffers directly to the webGL context
  35928. * @param vertexBuffer defines the vertex buffer to bind
  35929. * @param indexBuffer defines the index buffer to bind
  35930. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35931. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35932. * @param effect defines the effect associated with the vertex buffer
  35933. */
  35934. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35935. private _unbindVertexArrayObject;
  35936. /**
  35937. * Bind a list of vertex buffers to the webGL context
  35938. * @param vertexBuffers defines the list of vertex buffers to bind
  35939. * @param indexBuffer defines the index buffer to bind
  35940. * @param effect defines the effect associated with the vertex buffers
  35941. */
  35942. bindBuffers(vertexBuffers: {
  35943. [key: string]: Nullable<VertexBuffer>;
  35944. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35945. /**
  35946. * Unbind all instance attributes
  35947. */
  35948. unbindInstanceAttributes(): void;
  35949. /**
  35950. * Release and free the memory of a vertex array object
  35951. * @param vao defines the vertex array object to delete
  35952. */
  35953. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35954. /** @hidden */
  35955. _releaseBuffer(buffer: DataBuffer): boolean;
  35956. protected _deleteBuffer(buffer: DataBuffer): void;
  35957. /**
  35958. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35959. * @param instancesBuffer defines the webGL buffer to update and bind
  35960. * @param data defines the data to store in the buffer
  35961. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35962. */
  35963. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35964. /**
  35965. * Bind the content of a webGL buffer used with instantiation
  35966. * @param instancesBuffer defines the webGL buffer to bind
  35967. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35968. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35969. */
  35970. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35971. /**
  35972. * Disable the instance attribute corresponding to the name in parameter
  35973. * @param name defines the name of the attribute to disable
  35974. */
  35975. disableInstanceAttributeByName(name: string): void;
  35976. /**
  35977. * Disable the instance attribute corresponding to the location in parameter
  35978. * @param attributeLocation defines the attribute location of the attribute to disable
  35979. */
  35980. disableInstanceAttribute(attributeLocation: number): void;
  35981. /**
  35982. * Disable the attribute corresponding to the location in parameter
  35983. * @param attributeLocation defines the attribute location of the attribute to disable
  35984. */
  35985. disableAttributeByIndex(attributeLocation: number): void;
  35986. /**
  35987. * Send a draw order
  35988. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35989. * @param indexStart defines the starting index
  35990. * @param indexCount defines the number of index to draw
  35991. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35992. */
  35993. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35994. /**
  35995. * Draw a list of points
  35996. * @param verticesStart defines the index of first vertex to draw
  35997. * @param verticesCount defines the count of vertices to draw
  35998. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35999. */
  36000. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36001. /**
  36002. * Draw a list of unindexed primitives
  36003. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36004. * @param verticesStart defines the index of first vertex to draw
  36005. * @param verticesCount defines the count of vertices to draw
  36006. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36007. */
  36008. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36009. /**
  36010. * Draw a list of indexed primitives
  36011. * @param fillMode defines the primitive to use
  36012. * @param indexStart defines the starting index
  36013. * @param indexCount defines the number of index to draw
  36014. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36015. */
  36016. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36017. /**
  36018. * Draw a list of unindexed primitives
  36019. * @param fillMode defines the primitive to use
  36020. * @param verticesStart defines the index of first vertex to draw
  36021. * @param verticesCount defines the count of vertices to draw
  36022. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36023. */
  36024. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36025. private _drawMode;
  36026. /** @hidden */
  36027. protected _reportDrawCall(): void;
  36028. /** @hidden */
  36029. _releaseEffect(effect: Effect): void;
  36030. /** @hidden */
  36031. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36032. /**
  36033. * Create a new effect (used to store vertex/fragment shaders)
  36034. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36035. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36036. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36037. * @param samplers defines an array of string used to represent textures
  36038. * @param defines defines the string containing the defines to use to compile the shaders
  36039. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36040. * @param onCompiled defines a function to call when the effect creation is successful
  36041. * @param onError defines a function to call when the effect creation has failed
  36042. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36043. * @returns the new Effect
  36044. */
  36045. 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;
  36046. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36047. private _compileShader;
  36048. private _compileRawShader;
  36049. /** @hidden */
  36050. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36051. /**
  36052. * Directly creates a webGL program
  36053. * @param pipelineContext defines the pipeline context to attach to
  36054. * @param vertexCode defines the vertex shader code to use
  36055. * @param fragmentCode defines the fragment shader code to use
  36056. * @param context defines the webGL context to use (if not set, the current one will be used)
  36057. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36058. * @returns the new webGL program
  36059. */
  36060. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36061. /**
  36062. * Creates a webGL program
  36063. * @param pipelineContext defines the pipeline context to attach to
  36064. * @param vertexCode defines the vertex shader code to use
  36065. * @param fragmentCode defines the fragment shader code to use
  36066. * @param defines defines the string containing the defines to use to compile the shaders
  36067. * @param context defines the webGL context to use (if not set, the current one will be used)
  36068. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36069. * @returns the new webGL program
  36070. */
  36071. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36072. /**
  36073. * Creates a new pipeline context
  36074. * @returns the new pipeline
  36075. */
  36076. createPipelineContext(): IPipelineContext;
  36077. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36078. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36079. /** @hidden */
  36080. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36081. /** @hidden */
  36082. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36083. /** @hidden */
  36084. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36085. /**
  36086. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36087. * @param pipelineContext defines the pipeline context to use
  36088. * @param uniformsNames defines the list of uniform names
  36089. * @returns an array of webGL uniform locations
  36090. */
  36091. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36092. /**
  36093. * Gets the lsit of active attributes for a given webGL program
  36094. * @param pipelineContext defines the pipeline context to use
  36095. * @param attributesNames defines the list of attribute names to get
  36096. * @returns an array of indices indicating the offset of each attribute
  36097. */
  36098. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36099. /**
  36100. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36101. * @param effect defines the effect to activate
  36102. */
  36103. enableEffect(effect: Nullable<Effect>): void;
  36104. /**
  36105. * Set the value of an uniform to a number (int)
  36106. * @param uniform defines the webGL uniform location where to store the value
  36107. * @param value defines the int number to store
  36108. */
  36109. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36110. /**
  36111. * Set the value of an uniform to an array of int32
  36112. * @param uniform defines the webGL uniform location where to store the value
  36113. * @param array defines the array of int32 to store
  36114. */
  36115. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36116. /**
  36117. * Set the value of an uniform to an array of int32 (stored as vec2)
  36118. * @param uniform defines the webGL uniform location where to store the value
  36119. * @param array defines the array of int32 to store
  36120. */
  36121. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36122. /**
  36123. * Set the value of an uniform to an array of int32 (stored as vec3)
  36124. * @param uniform defines the webGL uniform location where to store the value
  36125. * @param array defines the array of int32 to store
  36126. */
  36127. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36128. /**
  36129. * Set the value of an uniform to an array of int32 (stored as vec4)
  36130. * @param uniform defines the webGL uniform location where to store the value
  36131. * @param array defines the array of int32 to store
  36132. */
  36133. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36134. /**
  36135. * Set the value of an uniform to an array of number
  36136. * @param uniform defines the webGL uniform location where to store the value
  36137. * @param array defines the array of number to store
  36138. */
  36139. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36140. /**
  36141. * Set the value of an uniform to an array of number (stored as vec2)
  36142. * @param uniform defines the webGL uniform location where to store the value
  36143. * @param array defines the array of number to store
  36144. */
  36145. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36146. /**
  36147. * Set the value of an uniform to an array of number (stored as vec3)
  36148. * @param uniform defines the webGL uniform location where to store the value
  36149. * @param array defines the array of number to store
  36150. */
  36151. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36152. /**
  36153. * Set the value of an uniform to an array of number (stored as vec4)
  36154. * @param uniform defines the webGL uniform location where to store the value
  36155. * @param array defines the array of number to store
  36156. */
  36157. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36158. /**
  36159. * Set the value of an uniform to an array of float32 (stored as matrices)
  36160. * @param uniform defines the webGL uniform location where to store the value
  36161. * @param matrices defines the array of float32 to store
  36162. */
  36163. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36164. /**
  36165. * Set the value of an uniform to a matrix (3x3)
  36166. * @param uniform defines the webGL uniform location where to store the value
  36167. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36168. */
  36169. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36170. /**
  36171. * Set the value of an uniform to a matrix (2x2)
  36172. * @param uniform defines the webGL uniform location where to store the value
  36173. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36174. */
  36175. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36176. /**
  36177. * Set the value of an uniform to a number (float)
  36178. * @param uniform defines the webGL uniform location where to store the value
  36179. * @param value defines the float number to store
  36180. */
  36181. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36182. /**
  36183. * Set the value of an uniform to a vec2
  36184. * @param uniform defines the webGL uniform location where to store the value
  36185. * @param x defines the 1st component of the value
  36186. * @param y defines the 2nd component of the value
  36187. */
  36188. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36189. /**
  36190. * Set the value of an uniform to a vec3
  36191. * @param uniform defines the webGL uniform location where to store the value
  36192. * @param x defines the 1st component of the value
  36193. * @param y defines the 2nd component of the value
  36194. * @param z defines the 3rd component of the value
  36195. */
  36196. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36197. /**
  36198. * Set the value of an uniform to a vec4
  36199. * @param uniform defines the webGL uniform location where to store the value
  36200. * @param x defines the 1st component of the value
  36201. * @param y defines the 2nd component of the value
  36202. * @param z defines the 3rd component of the value
  36203. * @param w defines the 4th component of the value
  36204. */
  36205. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36206. /**
  36207. * Apply all cached states (depth, culling, stencil and alpha)
  36208. */
  36209. applyStates(): void;
  36210. /**
  36211. * Enable or disable color writing
  36212. * @param enable defines the state to set
  36213. */
  36214. setColorWrite(enable: boolean): void;
  36215. /**
  36216. * Gets a boolean indicating if color writing is enabled
  36217. * @returns the current color writing state
  36218. */
  36219. getColorWrite(): boolean;
  36220. /**
  36221. * Gets the depth culling state manager
  36222. */
  36223. get depthCullingState(): DepthCullingState;
  36224. /**
  36225. * Gets the alpha state manager
  36226. */
  36227. get alphaState(): AlphaState;
  36228. /**
  36229. * Gets the stencil state manager
  36230. */
  36231. get stencilState(): StencilState;
  36232. /**
  36233. * Clears the list of texture accessible through engine.
  36234. * This can help preventing texture load conflict due to name collision.
  36235. */
  36236. clearInternalTexturesCache(): void;
  36237. /**
  36238. * Force the entire cache to be cleared
  36239. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36240. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36241. */
  36242. wipeCaches(bruteForce?: boolean): void;
  36243. /** @hidden */
  36244. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36245. min: number;
  36246. mag: number;
  36247. };
  36248. /** @hidden */
  36249. _createTexture(): WebGLTexture;
  36250. /**
  36251. * Usually called from Texture.ts.
  36252. * Passed information to create a WebGLTexture
  36253. * @param url defines a value which contains one of the following:
  36254. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36255. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36256. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36257. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36258. * @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)
  36259. * @param scene needed for loading to the correct scene
  36260. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36261. * @param onLoad optional callback to be called upon successful completion
  36262. * @param onError optional callback to be called upon failure
  36263. * @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
  36264. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36265. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36266. * @param forcedExtension defines the extension to use to pick the right loader
  36267. * @param mimeType defines an optional mime type
  36268. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36269. */
  36270. 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;
  36271. /**
  36272. * Loads an image as an HTMLImageElement.
  36273. * @param input url string, ArrayBuffer, or Blob to load
  36274. * @param onLoad callback called when the image successfully loads
  36275. * @param onError callback called when the image fails to load
  36276. * @param offlineProvider offline provider for caching
  36277. * @param mimeType optional mime type
  36278. * @returns the HTMLImageElement of the loaded image
  36279. * @hidden
  36280. */
  36281. 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>;
  36282. /**
  36283. * @hidden
  36284. */
  36285. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36286. private _unpackFlipYCached;
  36287. /**
  36288. * In case you are sharing the context with other applications, it might
  36289. * be interested to not cache the unpack flip y state to ensure a consistent
  36290. * value would be set.
  36291. */
  36292. enableUnpackFlipYCached: boolean;
  36293. /** @hidden */
  36294. _unpackFlipY(value: boolean): void;
  36295. /** @hidden */
  36296. _getUnpackAlignement(): number;
  36297. private _getTextureTarget;
  36298. /**
  36299. * Update the sampling mode of a given texture
  36300. * @param samplingMode defines the required sampling mode
  36301. * @param texture defines the texture to update
  36302. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36303. */
  36304. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36305. /**
  36306. * Update the sampling mode of a given texture
  36307. * @param texture defines the texture to update
  36308. * @param wrapU defines the texture wrap mode of the u coordinates
  36309. * @param wrapV defines the texture wrap mode of the v coordinates
  36310. * @param wrapR defines the texture wrap mode of the r coordinates
  36311. */
  36312. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36313. /** @hidden */
  36314. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36315. width: number;
  36316. height: number;
  36317. layers?: number;
  36318. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36319. /** @hidden */
  36320. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36321. /** @hidden */
  36322. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36323. /**
  36324. * Update a portion of an internal texture
  36325. * @param texture defines the texture to update
  36326. * @param imageData defines the data to store into the texture
  36327. * @param xOffset defines the x coordinates of the update rectangle
  36328. * @param yOffset defines the y coordinates of the update rectangle
  36329. * @param width defines the width of the update rectangle
  36330. * @param height defines the height of the update rectangle
  36331. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36332. * @param lod defines the lod level to update (0 by default)
  36333. */
  36334. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36335. /** @hidden */
  36336. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36337. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36338. private _prepareWebGLTexture;
  36339. /** @hidden */
  36340. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36341. private _getDepthStencilBuffer;
  36342. /** @hidden */
  36343. _releaseFramebufferObjects(texture: InternalTexture): void;
  36344. /** @hidden */
  36345. _releaseTexture(texture: InternalTexture): void;
  36346. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36347. protected _setProgram(program: WebGLProgram): void;
  36348. protected _boundUniforms: {
  36349. [key: number]: WebGLUniformLocation;
  36350. };
  36351. /**
  36352. * Binds an effect to the webGL context
  36353. * @param effect defines the effect to bind
  36354. */
  36355. bindSamplers(effect: Effect): void;
  36356. private _activateCurrentTexture;
  36357. /** @hidden */
  36358. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36359. /** @hidden */
  36360. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36361. /**
  36362. * Unbind all textures from the webGL context
  36363. */
  36364. unbindAllTextures(): void;
  36365. /**
  36366. * Sets a texture to the according uniform.
  36367. * @param channel The texture channel
  36368. * @param uniform The uniform to set
  36369. * @param texture The texture to apply
  36370. */
  36371. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36372. private _bindSamplerUniformToChannel;
  36373. private _getTextureWrapMode;
  36374. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36375. /**
  36376. * Sets an array of texture to the webGL context
  36377. * @param channel defines the channel where the texture array must be set
  36378. * @param uniform defines the associated uniform location
  36379. * @param textures defines the array of textures to bind
  36380. */
  36381. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36382. /** @hidden */
  36383. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36384. private _setTextureParameterFloat;
  36385. private _setTextureParameterInteger;
  36386. /**
  36387. * Unbind all vertex attributes from the webGL context
  36388. */
  36389. unbindAllAttributes(): void;
  36390. /**
  36391. * 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
  36392. */
  36393. releaseEffects(): void;
  36394. /**
  36395. * Dispose and release all associated resources
  36396. */
  36397. dispose(): void;
  36398. /**
  36399. * Attach a new callback raised when context lost event is fired
  36400. * @param callback defines the callback to call
  36401. */
  36402. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36403. /**
  36404. * Attach a new callback raised when context restored event is fired
  36405. * @param callback defines the callback to call
  36406. */
  36407. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36408. /**
  36409. * Get the current error code of the webGL context
  36410. * @returns the error code
  36411. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36412. */
  36413. getError(): number;
  36414. private _canRenderToFloatFramebuffer;
  36415. private _canRenderToHalfFloatFramebuffer;
  36416. private _canRenderToFramebuffer;
  36417. /** @hidden */
  36418. _getWebGLTextureType(type: number): number;
  36419. /** @hidden */
  36420. _getInternalFormat(format: number): number;
  36421. /** @hidden */
  36422. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36423. /** @hidden */
  36424. _getRGBAMultiSampleBufferFormat(type: number): number;
  36425. /** @hidden */
  36426. _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;
  36427. /**
  36428. * Loads a file from a url
  36429. * @param url url to load
  36430. * @param onSuccess callback called when the file successfully loads
  36431. * @param onProgress callback called while file is loading (if the server supports this mode)
  36432. * @param offlineProvider defines the offline provider for caching
  36433. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36434. * @param onError callback called when the file fails to load
  36435. * @returns a file request object
  36436. * @hidden
  36437. */
  36438. 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;
  36439. /**
  36440. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36441. * @param x defines the x coordinate of the rectangle where pixels must be read
  36442. * @param y defines the y coordinate of the rectangle where pixels must be read
  36443. * @param width defines the width of the rectangle where pixels must be read
  36444. * @param height defines the height of the rectangle where pixels must be read
  36445. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36446. * @returns a Uint8Array containing RGBA colors
  36447. */
  36448. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36449. private static _isSupported;
  36450. /**
  36451. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36452. * @returns true if the engine can be created
  36453. * @ignorenaming
  36454. */
  36455. static isSupported(): boolean;
  36456. /**
  36457. * Find the next highest power of two.
  36458. * @param x Number to start search from.
  36459. * @return Next highest power of two.
  36460. */
  36461. static CeilingPOT(x: number): number;
  36462. /**
  36463. * Find the next lowest power of two.
  36464. * @param x Number to start search from.
  36465. * @return Next lowest power of two.
  36466. */
  36467. static FloorPOT(x: number): number;
  36468. /**
  36469. * Find the nearest power of two.
  36470. * @param x Number to start search from.
  36471. * @return Next nearest power of two.
  36472. */
  36473. static NearestPOT(x: number): number;
  36474. /**
  36475. * Get the closest exponent of two
  36476. * @param value defines the value to approximate
  36477. * @param max defines the maximum value to return
  36478. * @param mode defines how to define the closest value
  36479. * @returns closest exponent of two of the given value
  36480. */
  36481. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36482. /**
  36483. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36484. * @param func - the function to be called
  36485. * @param requester - the object that will request the next frame. Falls back to window.
  36486. * @returns frame number
  36487. */
  36488. static QueueNewFrame(func: () => void, requester?: any): number;
  36489. /**
  36490. * Gets host document
  36491. * @returns the host document object
  36492. */
  36493. getHostDocument(): Nullable<Document>;
  36494. }
  36495. }
  36496. declare module "babylonjs/Maths/sphericalPolynomial" {
  36497. import { Vector3 } from "babylonjs/Maths/math.vector";
  36498. import { Color3 } from "babylonjs/Maths/math.color";
  36499. /**
  36500. * Class representing spherical harmonics coefficients to the 3rd degree
  36501. */
  36502. export class SphericalHarmonics {
  36503. /**
  36504. * Defines whether or not the harmonics have been prescaled for rendering.
  36505. */
  36506. preScaled: boolean;
  36507. /**
  36508. * The l0,0 coefficients of the spherical harmonics
  36509. */
  36510. l00: Vector3;
  36511. /**
  36512. * The l1,-1 coefficients of the spherical harmonics
  36513. */
  36514. l1_1: Vector3;
  36515. /**
  36516. * The l1,0 coefficients of the spherical harmonics
  36517. */
  36518. l10: Vector3;
  36519. /**
  36520. * The l1,1 coefficients of the spherical harmonics
  36521. */
  36522. l11: Vector3;
  36523. /**
  36524. * The l2,-2 coefficients of the spherical harmonics
  36525. */
  36526. l2_2: Vector3;
  36527. /**
  36528. * The l2,-1 coefficients of the spherical harmonics
  36529. */
  36530. l2_1: Vector3;
  36531. /**
  36532. * The l2,0 coefficients of the spherical harmonics
  36533. */
  36534. l20: Vector3;
  36535. /**
  36536. * The l2,1 coefficients of the spherical harmonics
  36537. */
  36538. l21: Vector3;
  36539. /**
  36540. * The l2,2 coefficients of the spherical harmonics
  36541. */
  36542. l22: Vector3;
  36543. /**
  36544. * Adds a light to the spherical harmonics
  36545. * @param direction the direction of the light
  36546. * @param color the color of the light
  36547. * @param deltaSolidAngle the delta solid angle of the light
  36548. */
  36549. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36550. /**
  36551. * Scales the spherical harmonics by the given amount
  36552. * @param scale the amount to scale
  36553. */
  36554. scaleInPlace(scale: number): void;
  36555. /**
  36556. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36557. *
  36558. * ```
  36559. * E_lm = A_l * L_lm
  36560. * ```
  36561. *
  36562. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36563. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36564. * the scaling factors are given in equation 9.
  36565. */
  36566. convertIncidentRadianceToIrradiance(): void;
  36567. /**
  36568. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36569. *
  36570. * ```
  36571. * L = (1/pi) * E * rho
  36572. * ```
  36573. *
  36574. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36575. */
  36576. convertIrradianceToLambertianRadiance(): void;
  36577. /**
  36578. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36579. * required operations at run time.
  36580. *
  36581. * This is simply done by scaling back the SH with Ylm constants parameter.
  36582. * The trigonometric part being applied by the shader at run time.
  36583. */
  36584. preScaleForRendering(): void;
  36585. /**
  36586. * Constructs a spherical harmonics from an array.
  36587. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36588. * @returns the spherical harmonics
  36589. */
  36590. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36591. /**
  36592. * Gets the spherical harmonics from polynomial
  36593. * @param polynomial the spherical polynomial
  36594. * @returns the spherical harmonics
  36595. */
  36596. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36597. }
  36598. /**
  36599. * Class representing spherical polynomial coefficients to the 3rd degree
  36600. */
  36601. export class SphericalPolynomial {
  36602. private _harmonics;
  36603. /**
  36604. * The spherical harmonics used to create the polynomials.
  36605. */
  36606. get preScaledHarmonics(): SphericalHarmonics;
  36607. /**
  36608. * The x coefficients of the spherical polynomial
  36609. */
  36610. x: Vector3;
  36611. /**
  36612. * The y coefficients of the spherical polynomial
  36613. */
  36614. y: Vector3;
  36615. /**
  36616. * The z coefficients of the spherical polynomial
  36617. */
  36618. z: Vector3;
  36619. /**
  36620. * The xx coefficients of the spherical polynomial
  36621. */
  36622. xx: Vector3;
  36623. /**
  36624. * The yy coefficients of the spherical polynomial
  36625. */
  36626. yy: Vector3;
  36627. /**
  36628. * The zz coefficients of the spherical polynomial
  36629. */
  36630. zz: Vector3;
  36631. /**
  36632. * The xy coefficients of the spherical polynomial
  36633. */
  36634. xy: Vector3;
  36635. /**
  36636. * The yz coefficients of the spherical polynomial
  36637. */
  36638. yz: Vector3;
  36639. /**
  36640. * The zx coefficients of the spherical polynomial
  36641. */
  36642. zx: Vector3;
  36643. /**
  36644. * Adds an ambient color to the spherical polynomial
  36645. * @param color the color to add
  36646. */
  36647. addAmbient(color: Color3): void;
  36648. /**
  36649. * Scales the spherical polynomial by the given amount
  36650. * @param scale the amount to scale
  36651. */
  36652. scaleInPlace(scale: number): void;
  36653. /**
  36654. * Gets the spherical polynomial from harmonics
  36655. * @param harmonics the spherical harmonics
  36656. * @returns the spherical polynomial
  36657. */
  36658. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36659. /**
  36660. * Constructs a spherical polynomial from an array.
  36661. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36662. * @returns the spherical polynomial
  36663. */
  36664. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36665. }
  36666. }
  36667. declare module "babylonjs/Materials/Textures/internalTexture" {
  36668. import { Observable } from "babylonjs/Misc/observable";
  36669. import { Nullable, int } from "babylonjs/types";
  36670. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36671. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36672. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36673. /**
  36674. * Defines the source of the internal texture
  36675. */
  36676. export enum InternalTextureSource {
  36677. /**
  36678. * The source of the texture data is unknown
  36679. */
  36680. Unknown = 0,
  36681. /**
  36682. * Texture data comes from an URL
  36683. */
  36684. Url = 1,
  36685. /**
  36686. * Texture data is only used for temporary storage
  36687. */
  36688. Temp = 2,
  36689. /**
  36690. * Texture data comes from raw data (ArrayBuffer)
  36691. */
  36692. Raw = 3,
  36693. /**
  36694. * Texture content is dynamic (video or dynamic texture)
  36695. */
  36696. Dynamic = 4,
  36697. /**
  36698. * Texture content is generated by rendering to it
  36699. */
  36700. RenderTarget = 5,
  36701. /**
  36702. * Texture content is part of a multi render target process
  36703. */
  36704. MultiRenderTarget = 6,
  36705. /**
  36706. * Texture data comes from a cube data file
  36707. */
  36708. Cube = 7,
  36709. /**
  36710. * Texture data comes from a raw cube data
  36711. */
  36712. CubeRaw = 8,
  36713. /**
  36714. * Texture data come from a prefiltered cube data file
  36715. */
  36716. CubePrefiltered = 9,
  36717. /**
  36718. * Texture content is raw 3D data
  36719. */
  36720. Raw3D = 10,
  36721. /**
  36722. * Texture content is raw 2D array data
  36723. */
  36724. Raw2DArray = 11,
  36725. /**
  36726. * Texture content is a depth texture
  36727. */
  36728. Depth = 12,
  36729. /**
  36730. * Texture data comes from a raw cube data encoded with RGBD
  36731. */
  36732. CubeRawRGBD = 13
  36733. }
  36734. /**
  36735. * Class used to store data associated with WebGL texture data for the engine
  36736. * This class should not be used directly
  36737. */
  36738. export class InternalTexture {
  36739. /** @hidden */
  36740. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36741. /**
  36742. * Defines if the texture is ready
  36743. */
  36744. isReady: boolean;
  36745. /**
  36746. * Defines if the texture is a cube texture
  36747. */
  36748. isCube: boolean;
  36749. /**
  36750. * Defines if the texture contains 3D data
  36751. */
  36752. is3D: boolean;
  36753. /**
  36754. * Defines if the texture contains 2D array data
  36755. */
  36756. is2DArray: boolean;
  36757. /**
  36758. * Defines if the texture contains multiview data
  36759. */
  36760. isMultiview: boolean;
  36761. /**
  36762. * Gets the URL used to load this texture
  36763. */
  36764. url: string;
  36765. /**
  36766. * Gets the sampling mode of the texture
  36767. */
  36768. samplingMode: number;
  36769. /**
  36770. * Gets a boolean indicating if the texture needs mipmaps generation
  36771. */
  36772. generateMipMaps: boolean;
  36773. /**
  36774. * Gets the number of samples used by the texture (WebGL2+ only)
  36775. */
  36776. samples: number;
  36777. /**
  36778. * Gets the type of the texture (int, float...)
  36779. */
  36780. type: number;
  36781. /**
  36782. * Gets the format of the texture (RGB, RGBA...)
  36783. */
  36784. format: number;
  36785. /**
  36786. * Observable called when the texture is loaded
  36787. */
  36788. onLoadedObservable: Observable<InternalTexture>;
  36789. /**
  36790. * Gets the width of the texture
  36791. */
  36792. width: number;
  36793. /**
  36794. * Gets the height of the texture
  36795. */
  36796. height: number;
  36797. /**
  36798. * Gets the depth of the texture
  36799. */
  36800. depth: number;
  36801. /**
  36802. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36803. */
  36804. baseWidth: number;
  36805. /**
  36806. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36807. */
  36808. baseHeight: number;
  36809. /**
  36810. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36811. */
  36812. baseDepth: number;
  36813. /**
  36814. * Gets a boolean indicating if the texture is inverted on Y axis
  36815. */
  36816. invertY: boolean;
  36817. /** @hidden */
  36818. _invertVScale: boolean;
  36819. /** @hidden */
  36820. _associatedChannel: number;
  36821. /** @hidden */
  36822. _source: InternalTextureSource;
  36823. /** @hidden */
  36824. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36825. /** @hidden */
  36826. _bufferView: Nullable<ArrayBufferView>;
  36827. /** @hidden */
  36828. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36829. /** @hidden */
  36830. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36831. /** @hidden */
  36832. _size: number;
  36833. /** @hidden */
  36834. _extension: string;
  36835. /** @hidden */
  36836. _files: Nullable<string[]>;
  36837. /** @hidden */
  36838. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36839. /** @hidden */
  36840. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36841. /** @hidden */
  36842. _framebuffer: Nullable<WebGLFramebuffer>;
  36843. /** @hidden */
  36844. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36845. /** @hidden */
  36846. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36847. /** @hidden */
  36848. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36849. /** @hidden */
  36850. _attachments: Nullable<number[]>;
  36851. /** @hidden */
  36852. _textureArray: Nullable<InternalTexture[]>;
  36853. /** @hidden */
  36854. _cachedCoordinatesMode: Nullable<number>;
  36855. /** @hidden */
  36856. _cachedWrapU: Nullable<number>;
  36857. /** @hidden */
  36858. _cachedWrapV: Nullable<number>;
  36859. /** @hidden */
  36860. _cachedWrapR: Nullable<number>;
  36861. /** @hidden */
  36862. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36863. /** @hidden */
  36864. _isDisabled: boolean;
  36865. /** @hidden */
  36866. _compression: Nullable<string>;
  36867. /** @hidden */
  36868. _generateStencilBuffer: boolean;
  36869. /** @hidden */
  36870. _generateDepthBuffer: boolean;
  36871. /** @hidden */
  36872. _comparisonFunction: number;
  36873. /** @hidden */
  36874. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36875. /** @hidden */
  36876. _lodGenerationScale: number;
  36877. /** @hidden */
  36878. _lodGenerationOffset: number;
  36879. /** @hidden */
  36880. _depthStencilTexture: Nullable<InternalTexture>;
  36881. /** @hidden */
  36882. _colorTextureArray: Nullable<WebGLTexture>;
  36883. /** @hidden */
  36884. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36885. /** @hidden */
  36886. _lodTextureHigh: Nullable<BaseTexture>;
  36887. /** @hidden */
  36888. _lodTextureMid: Nullable<BaseTexture>;
  36889. /** @hidden */
  36890. _lodTextureLow: Nullable<BaseTexture>;
  36891. /** @hidden */
  36892. _isRGBD: boolean;
  36893. /** @hidden */
  36894. _linearSpecularLOD: boolean;
  36895. /** @hidden */
  36896. _irradianceTexture: Nullable<BaseTexture>;
  36897. /** @hidden */
  36898. _webGLTexture: Nullable<WebGLTexture>;
  36899. /** @hidden */
  36900. _references: number;
  36901. private _engine;
  36902. /**
  36903. * Gets the Engine the texture belongs to.
  36904. * @returns The babylon engine
  36905. */
  36906. getEngine(): ThinEngine;
  36907. /**
  36908. * Gets the data source type of the texture
  36909. */
  36910. get source(): InternalTextureSource;
  36911. /**
  36912. * Creates a new InternalTexture
  36913. * @param engine defines the engine to use
  36914. * @param source defines the type of data that will be used
  36915. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36916. */
  36917. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36918. /**
  36919. * Increments the number of references (ie. the number of Texture that point to it)
  36920. */
  36921. incrementReferences(): void;
  36922. /**
  36923. * Change the size of the texture (not the size of the content)
  36924. * @param width defines the new width
  36925. * @param height defines the new height
  36926. * @param depth defines the new depth (1 by default)
  36927. */
  36928. updateSize(width: int, height: int, depth?: int): void;
  36929. /** @hidden */
  36930. _rebuild(): void;
  36931. /** @hidden */
  36932. _swapAndDie(target: InternalTexture): void;
  36933. /**
  36934. * Dispose the current allocated resources
  36935. */
  36936. dispose(): void;
  36937. }
  36938. }
  36939. declare module "babylonjs/Audio/analyser" {
  36940. import { Scene } from "babylonjs/scene";
  36941. /**
  36942. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36943. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36944. */
  36945. export class Analyser {
  36946. /**
  36947. * Gets or sets the smoothing
  36948. * @ignorenaming
  36949. */
  36950. SMOOTHING: number;
  36951. /**
  36952. * Gets or sets the FFT table size
  36953. * @ignorenaming
  36954. */
  36955. FFT_SIZE: number;
  36956. /**
  36957. * Gets or sets the bar graph amplitude
  36958. * @ignorenaming
  36959. */
  36960. BARGRAPHAMPLITUDE: number;
  36961. /**
  36962. * Gets or sets the position of the debug canvas
  36963. * @ignorenaming
  36964. */
  36965. DEBUGCANVASPOS: {
  36966. x: number;
  36967. y: number;
  36968. };
  36969. /**
  36970. * Gets or sets the debug canvas size
  36971. * @ignorenaming
  36972. */
  36973. DEBUGCANVASSIZE: {
  36974. width: number;
  36975. height: number;
  36976. };
  36977. private _byteFreqs;
  36978. private _byteTime;
  36979. private _floatFreqs;
  36980. private _webAudioAnalyser;
  36981. private _debugCanvas;
  36982. private _debugCanvasContext;
  36983. private _scene;
  36984. private _registerFunc;
  36985. private _audioEngine;
  36986. /**
  36987. * Creates a new analyser
  36988. * @param scene defines hosting scene
  36989. */
  36990. constructor(scene: Scene);
  36991. /**
  36992. * Get the number of data values you will have to play with for the visualization
  36993. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36994. * @returns a number
  36995. */
  36996. getFrequencyBinCount(): number;
  36997. /**
  36998. * Gets the current frequency data as a byte array
  36999. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37000. * @returns a Uint8Array
  37001. */
  37002. getByteFrequencyData(): Uint8Array;
  37003. /**
  37004. * Gets the current waveform as a byte array
  37005. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37006. * @returns a Uint8Array
  37007. */
  37008. getByteTimeDomainData(): Uint8Array;
  37009. /**
  37010. * Gets the current frequency data as a float array
  37011. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37012. * @returns a Float32Array
  37013. */
  37014. getFloatFrequencyData(): Float32Array;
  37015. /**
  37016. * Renders the debug canvas
  37017. */
  37018. drawDebugCanvas(): void;
  37019. /**
  37020. * Stops rendering the debug canvas and removes it
  37021. */
  37022. stopDebugCanvas(): void;
  37023. /**
  37024. * Connects two audio nodes
  37025. * @param inputAudioNode defines first node to connect
  37026. * @param outputAudioNode defines second node to connect
  37027. */
  37028. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37029. /**
  37030. * Releases all associated resources
  37031. */
  37032. dispose(): void;
  37033. }
  37034. }
  37035. declare module "babylonjs/Audio/audioEngine" {
  37036. import { IDisposable } from "babylonjs/scene";
  37037. import { Analyser } from "babylonjs/Audio/analyser";
  37038. import { Nullable } from "babylonjs/types";
  37039. import { Observable } from "babylonjs/Misc/observable";
  37040. /**
  37041. * This represents an audio engine and it is responsible
  37042. * to play, synchronize and analyse sounds throughout the application.
  37043. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37044. */
  37045. export interface IAudioEngine extends IDisposable {
  37046. /**
  37047. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37048. */
  37049. readonly canUseWebAudio: boolean;
  37050. /**
  37051. * Gets the current AudioContext if available.
  37052. */
  37053. readonly audioContext: Nullable<AudioContext>;
  37054. /**
  37055. * The master gain node defines the global audio volume of your audio engine.
  37056. */
  37057. readonly masterGain: GainNode;
  37058. /**
  37059. * Gets whether or not mp3 are supported by your browser.
  37060. */
  37061. readonly isMP3supported: boolean;
  37062. /**
  37063. * Gets whether or not ogg are supported by your browser.
  37064. */
  37065. readonly isOGGsupported: boolean;
  37066. /**
  37067. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37068. * @ignoreNaming
  37069. */
  37070. WarnedWebAudioUnsupported: boolean;
  37071. /**
  37072. * Defines if the audio engine relies on a custom unlocked button.
  37073. * In this case, the embedded button will not be displayed.
  37074. */
  37075. useCustomUnlockedButton: boolean;
  37076. /**
  37077. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37078. */
  37079. readonly unlocked: boolean;
  37080. /**
  37081. * Event raised when audio has been unlocked on the browser.
  37082. */
  37083. onAudioUnlockedObservable: Observable<AudioEngine>;
  37084. /**
  37085. * Event raised when audio has been locked on the browser.
  37086. */
  37087. onAudioLockedObservable: Observable<AudioEngine>;
  37088. /**
  37089. * Flags the audio engine in Locked state.
  37090. * This happens due to new browser policies preventing audio to autoplay.
  37091. */
  37092. lock(): void;
  37093. /**
  37094. * Unlocks the audio engine once a user action has been done on the dom.
  37095. * This is helpful to resume play once browser policies have been satisfied.
  37096. */
  37097. unlock(): void;
  37098. /**
  37099. * Gets the global volume sets on the master gain.
  37100. * @returns the global volume if set or -1 otherwise
  37101. */
  37102. getGlobalVolume(): number;
  37103. /**
  37104. * Sets the global volume of your experience (sets on the master gain).
  37105. * @param newVolume Defines the new global volume of the application
  37106. */
  37107. setGlobalVolume(newVolume: number): void;
  37108. /**
  37109. * Connect the audio engine to an audio analyser allowing some amazing
  37110. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37111. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37112. * @param analyser The analyser to connect to the engine
  37113. */
  37114. connectToAnalyser(analyser: Analyser): void;
  37115. }
  37116. /**
  37117. * This represents the default audio engine used in babylon.
  37118. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37119. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37120. */
  37121. export class AudioEngine implements IAudioEngine {
  37122. private _audioContext;
  37123. private _audioContextInitialized;
  37124. private _muteButton;
  37125. private _hostElement;
  37126. /**
  37127. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37128. */
  37129. canUseWebAudio: boolean;
  37130. /**
  37131. * The master gain node defines the global audio volume of your audio engine.
  37132. */
  37133. masterGain: GainNode;
  37134. /**
  37135. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37136. * @ignoreNaming
  37137. */
  37138. WarnedWebAudioUnsupported: boolean;
  37139. /**
  37140. * Gets whether or not mp3 are supported by your browser.
  37141. */
  37142. isMP3supported: boolean;
  37143. /**
  37144. * Gets whether or not ogg are supported by your browser.
  37145. */
  37146. isOGGsupported: boolean;
  37147. /**
  37148. * Gets whether audio has been unlocked on the device.
  37149. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37150. * a user interaction has happened.
  37151. */
  37152. unlocked: boolean;
  37153. /**
  37154. * Defines if the audio engine relies on a custom unlocked button.
  37155. * In this case, the embedded button will not be displayed.
  37156. */
  37157. useCustomUnlockedButton: boolean;
  37158. /**
  37159. * Event raised when audio has been unlocked on the browser.
  37160. */
  37161. onAudioUnlockedObservable: Observable<AudioEngine>;
  37162. /**
  37163. * Event raised when audio has been locked on the browser.
  37164. */
  37165. onAudioLockedObservable: Observable<AudioEngine>;
  37166. /**
  37167. * Gets the current AudioContext if available.
  37168. */
  37169. get audioContext(): Nullable<AudioContext>;
  37170. private _connectedAnalyser;
  37171. /**
  37172. * Instantiates a new audio engine.
  37173. *
  37174. * There should be only one per page as some browsers restrict the number
  37175. * of audio contexts you can create.
  37176. * @param hostElement defines the host element where to display the mute icon if necessary
  37177. */
  37178. constructor(hostElement?: Nullable<HTMLElement>);
  37179. /**
  37180. * Flags the audio engine in Locked state.
  37181. * This happens due to new browser policies preventing audio to autoplay.
  37182. */
  37183. lock(): void;
  37184. /**
  37185. * Unlocks the audio engine once a user action has been done on the dom.
  37186. * This is helpful to resume play once browser policies have been satisfied.
  37187. */
  37188. unlock(): void;
  37189. private _resumeAudioContext;
  37190. private _initializeAudioContext;
  37191. private _tryToRun;
  37192. private _triggerRunningState;
  37193. private _triggerSuspendedState;
  37194. private _displayMuteButton;
  37195. private _moveButtonToTopLeft;
  37196. private _onResize;
  37197. private _hideMuteButton;
  37198. /**
  37199. * Destroy and release the resources associated with the audio ccontext.
  37200. */
  37201. dispose(): void;
  37202. /**
  37203. * Gets the global volume sets on the master gain.
  37204. * @returns the global volume if set or -1 otherwise
  37205. */
  37206. getGlobalVolume(): number;
  37207. /**
  37208. * Sets the global volume of your experience (sets on the master gain).
  37209. * @param newVolume Defines the new global volume of the application
  37210. */
  37211. setGlobalVolume(newVolume: number): void;
  37212. /**
  37213. * Connect the audio engine to an audio analyser allowing some amazing
  37214. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37215. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37216. * @param analyser The analyser to connect to the engine
  37217. */
  37218. connectToAnalyser(analyser: Analyser): void;
  37219. }
  37220. }
  37221. declare module "babylonjs/Loading/loadingScreen" {
  37222. /**
  37223. * Interface used to present a loading screen while loading a scene
  37224. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37225. */
  37226. export interface ILoadingScreen {
  37227. /**
  37228. * Function called to display the loading screen
  37229. */
  37230. displayLoadingUI: () => void;
  37231. /**
  37232. * Function called to hide the loading screen
  37233. */
  37234. hideLoadingUI: () => void;
  37235. /**
  37236. * Gets or sets the color to use for the background
  37237. */
  37238. loadingUIBackgroundColor: string;
  37239. /**
  37240. * Gets or sets the text to display while loading
  37241. */
  37242. loadingUIText: string;
  37243. }
  37244. /**
  37245. * Class used for the default loading screen
  37246. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37247. */
  37248. export class DefaultLoadingScreen implements ILoadingScreen {
  37249. private _renderingCanvas;
  37250. private _loadingText;
  37251. private _loadingDivBackgroundColor;
  37252. private _loadingDiv;
  37253. private _loadingTextDiv;
  37254. /** Gets or sets the logo url to use for the default loading screen */
  37255. static DefaultLogoUrl: string;
  37256. /** Gets or sets the spinner url to use for the default loading screen */
  37257. static DefaultSpinnerUrl: string;
  37258. /**
  37259. * Creates a new default loading screen
  37260. * @param _renderingCanvas defines the canvas used to render the scene
  37261. * @param _loadingText defines the default text to display
  37262. * @param _loadingDivBackgroundColor defines the default background color
  37263. */
  37264. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37265. /**
  37266. * Function called to display the loading screen
  37267. */
  37268. displayLoadingUI(): void;
  37269. /**
  37270. * Function called to hide the loading screen
  37271. */
  37272. hideLoadingUI(): void;
  37273. /**
  37274. * Gets or sets the text to display while loading
  37275. */
  37276. set loadingUIText(text: string);
  37277. get loadingUIText(): string;
  37278. /**
  37279. * Gets or sets the color to use for the background
  37280. */
  37281. get loadingUIBackgroundColor(): string;
  37282. set loadingUIBackgroundColor(color: string);
  37283. private _resizeLoadingUI;
  37284. }
  37285. }
  37286. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37287. /**
  37288. * Interface for any object that can request an animation frame
  37289. */
  37290. export interface ICustomAnimationFrameRequester {
  37291. /**
  37292. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37293. */
  37294. renderFunction?: Function;
  37295. /**
  37296. * Called to request the next frame to render to
  37297. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37298. */
  37299. requestAnimationFrame: Function;
  37300. /**
  37301. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37302. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37303. */
  37304. requestID?: number;
  37305. }
  37306. }
  37307. declare module "babylonjs/Misc/performanceMonitor" {
  37308. /**
  37309. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37310. */
  37311. export class PerformanceMonitor {
  37312. private _enabled;
  37313. private _rollingFrameTime;
  37314. private _lastFrameTimeMs;
  37315. /**
  37316. * constructor
  37317. * @param frameSampleSize The number of samples required to saturate the sliding window
  37318. */
  37319. constructor(frameSampleSize?: number);
  37320. /**
  37321. * Samples current frame
  37322. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37323. */
  37324. sampleFrame(timeMs?: number): void;
  37325. /**
  37326. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37327. */
  37328. get averageFrameTime(): number;
  37329. /**
  37330. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37331. */
  37332. get averageFrameTimeVariance(): number;
  37333. /**
  37334. * Returns the frame time of the most recent frame
  37335. */
  37336. get instantaneousFrameTime(): number;
  37337. /**
  37338. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37339. */
  37340. get averageFPS(): number;
  37341. /**
  37342. * Returns the average framerate in frames per second using the most recent frame time
  37343. */
  37344. get instantaneousFPS(): number;
  37345. /**
  37346. * Returns true if enough samples have been taken to completely fill the sliding window
  37347. */
  37348. get isSaturated(): boolean;
  37349. /**
  37350. * Enables contributions to the sliding window sample set
  37351. */
  37352. enable(): void;
  37353. /**
  37354. * Disables contributions to the sliding window sample set
  37355. * Samples will not be interpolated over the disabled period
  37356. */
  37357. disable(): void;
  37358. /**
  37359. * Returns true if sampling is enabled
  37360. */
  37361. get isEnabled(): boolean;
  37362. /**
  37363. * Resets performance monitor
  37364. */
  37365. reset(): void;
  37366. }
  37367. /**
  37368. * RollingAverage
  37369. *
  37370. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37371. */
  37372. export class RollingAverage {
  37373. /**
  37374. * Current average
  37375. */
  37376. average: number;
  37377. /**
  37378. * Current variance
  37379. */
  37380. variance: number;
  37381. protected _samples: Array<number>;
  37382. protected _sampleCount: number;
  37383. protected _pos: number;
  37384. protected _m2: number;
  37385. /**
  37386. * constructor
  37387. * @param length The number of samples required to saturate the sliding window
  37388. */
  37389. constructor(length: number);
  37390. /**
  37391. * Adds a sample to the sample set
  37392. * @param v The sample value
  37393. */
  37394. add(v: number): void;
  37395. /**
  37396. * Returns previously added values or null if outside of history or outside the sliding window domain
  37397. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37398. * @return Value previously recorded with add() or null if outside of range
  37399. */
  37400. history(i: number): number;
  37401. /**
  37402. * Returns true if enough samples have been taken to completely fill the sliding window
  37403. * @return true if sample-set saturated
  37404. */
  37405. isSaturated(): boolean;
  37406. /**
  37407. * Resets the rolling average (equivalent to 0 samples taken so far)
  37408. */
  37409. reset(): void;
  37410. /**
  37411. * Wraps a value around the sample range boundaries
  37412. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37413. * @return Wrapped position in sample range
  37414. */
  37415. protected _wrapPosition(i: number): number;
  37416. }
  37417. }
  37418. declare module "babylonjs/Misc/perfCounter" {
  37419. /**
  37420. * This class is used to track a performance counter which is number based.
  37421. * The user has access to many properties which give statistics of different nature.
  37422. *
  37423. * The implementer can track two kinds of Performance Counter: time and count.
  37424. * 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.
  37425. * 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.
  37426. */
  37427. export class PerfCounter {
  37428. /**
  37429. * Gets or sets a global boolean to turn on and off all the counters
  37430. */
  37431. static Enabled: boolean;
  37432. /**
  37433. * Returns the smallest value ever
  37434. */
  37435. get min(): number;
  37436. /**
  37437. * Returns the biggest value ever
  37438. */
  37439. get max(): number;
  37440. /**
  37441. * Returns the average value since the performance counter is running
  37442. */
  37443. get average(): number;
  37444. /**
  37445. * Returns the average value of the last second the counter was monitored
  37446. */
  37447. get lastSecAverage(): number;
  37448. /**
  37449. * Returns the current value
  37450. */
  37451. get current(): number;
  37452. /**
  37453. * Gets the accumulated total
  37454. */
  37455. get total(): number;
  37456. /**
  37457. * Gets the total value count
  37458. */
  37459. get count(): number;
  37460. /**
  37461. * Creates a new counter
  37462. */
  37463. constructor();
  37464. /**
  37465. * Call this method to start monitoring a new frame.
  37466. * 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.
  37467. */
  37468. fetchNewFrame(): void;
  37469. /**
  37470. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37471. * @param newCount the count value to add to the monitored count
  37472. * @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.
  37473. */
  37474. addCount(newCount: number, fetchResult: boolean): void;
  37475. /**
  37476. * Start monitoring this performance counter
  37477. */
  37478. beginMonitoring(): void;
  37479. /**
  37480. * Compute the time lapsed since the previous beginMonitoring() call.
  37481. * @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
  37482. */
  37483. endMonitoring(newFrame?: boolean): void;
  37484. private _fetchResult;
  37485. private _startMonitoringTime;
  37486. private _min;
  37487. private _max;
  37488. private _average;
  37489. private _current;
  37490. private _totalValueCount;
  37491. private _totalAccumulated;
  37492. private _lastSecAverage;
  37493. private _lastSecAccumulated;
  37494. private _lastSecTime;
  37495. private _lastSecValueCount;
  37496. }
  37497. }
  37498. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37499. module "babylonjs/Engines/thinEngine" {
  37500. interface ThinEngine {
  37501. /**
  37502. * Sets alpha constants used by some alpha blending modes
  37503. * @param r defines the red component
  37504. * @param g defines the green component
  37505. * @param b defines the blue component
  37506. * @param a defines the alpha component
  37507. */
  37508. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37509. /**
  37510. * Sets the current alpha mode
  37511. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37512. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37513. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37514. */
  37515. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37516. /**
  37517. * Gets the current alpha mode
  37518. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37519. * @returns the current alpha mode
  37520. */
  37521. getAlphaMode(): number;
  37522. /**
  37523. * Sets the current alpha equation
  37524. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37525. */
  37526. setAlphaEquation(equation: number): void;
  37527. /**
  37528. * Gets the current alpha equation.
  37529. * @returns the current alpha equation
  37530. */
  37531. getAlphaEquation(): number;
  37532. }
  37533. }
  37534. }
  37535. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37536. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37537. import { Nullable } from "babylonjs/types";
  37538. module "babylonjs/Engines/thinEngine" {
  37539. interface ThinEngine {
  37540. /** @hidden */
  37541. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37542. }
  37543. }
  37544. }
  37545. declare module "babylonjs/Engines/engine" {
  37546. import { Observable } from "babylonjs/Misc/observable";
  37547. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37548. import { Scene } from "babylonjs/scene";
  37549. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37550. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37551. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37552. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37553. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37554. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37555. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37556. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37557. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37558. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37559. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37560. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37561. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37562. import "babylonjs/Engines/Extensions/engine.alpha";
  37563. import "babylonjs/Engines/Extensions/engine.readTexture";
  37564. import { Material } from "babylonjs/Materials/material";
  37565. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37566. /**
  37567. * Defines the interface used by display changed events
  37568. */
  37569. export interface IDisplayChangedEventArgs {
  37570. /** Gets the vrDisplay object (if any) */
  37571. vrDisplay: Nullable<any>;
  37572. /** Gets a boolean indicating if webVR is supported */
  37573. vrSupported: boolean;
  37574. }
  37575. /**
  37576. * Defines the interface used by objects containing a viewport (like a camera)
  37577. */
  37578. interface IViewportOwnerLike {
  37579. /**
  37580. * Gets or sets the viewport
  37581. */
  37582. viewport: IViewportLike;
  37583. }
  37584. /**
  37585. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37586. */
  37587. export class Engine extends ThinEngine {
  37588. /** Defines that alpha blending is disabled */
  37589. static readonly ALPHA_DISABLE: number;
  37590. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37591. static readonly ALPHA_ADD: number;
  37592. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37593. static readonly ALPHA_COMBINE: number;
  37594. /** Defines that alpha blending to DEST - SRC * DEST */
  37595. static readonly ALPHA_SUBTRACT: number;
  37596. /** Defines that alpha blending to SRC * DEST */
  37597. static readonly ALPHA_MULTIPLY: number;
  37598. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37599. static readonly ALPHA_MAXIMIZED: number;
  37600. /** Defines that alpha blending to SRC + DEST */
  37601. static readonly ALPHA_ONEONE: number;
  37602. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37603. static readonly ALPHA_PREMULTIPLIED: number;
  37604. /**
  37605. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37607. */
  37608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37609. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37610. static readonly ALPHA_INTERPOLATE: number;
  37611. /**
  37612. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37614. */
  37615. static readonly ALPHA_SCREENMODE: number;
  37616. /** Defines that the ressource is not delayed*/
  37617. static readonly DELAYLOADSTATE_NONE: number;
  37618. /** Defines that the ressource was successfully delay loaded */
  37619. static readonly DELAYLOADSTATE_LOADED: number;
  37620. /** Defines that the ressource is currently delay loading */
  37621. static readonly DELAYLOADSTATE_LOADING: number;
  37622. /** Defines that the ressource is delayed and has not started loading */
  37623. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37625. static readonly NEVER: number;
  37626. /** 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 */
  37627. static readonly ALWAYS: number;
  37628. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37629. static readonly LESS: number;
  37630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37631. static readonly EQUAL: number;
  37632. /** 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 */
  37633. static readonly LEQUAL: number;
  37634. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37635. static readonly GREATER: number;
  37636. /** 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 */
  37637. static readonly GEQUAL: number;
  37638. /** 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 */
  37639. static readonly NOTEQUAL: number;
  37640. /** Passed to stencilOperation to specify that stencil value must be kept */
  37641. static readonly KEEP: number;
  37642. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37643. static readonly REPLACE: number;
  37644. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37645. static readonly INCR: number;
  37646. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37647. static readonly DECR: number;
  37648. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37649. static readonly INVERT: number;
  37650. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37651. static readonly INCR_WRAP: number;
  37652. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37653. static readonly DECR_WRAP: number;
  37654. /** Texture is not repeating outside of 0..1 UVs */
  37655. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37656. /** Texture is repeating outside of 0..1 UVs */
  37657. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37658. /** Texture is repeating and mirrored */
  37659. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37660. /** ALPHA */
  37661. static readonly TEXTUREFORMAT_ALPHA: number;
  37662. /** LUMINANCE */
  37663. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37664. /** LUMINANCE_ALPHA */
  37665. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37666. /** RGB */
  37667. static readonly TEXTUREFORMAT_RGB: number;
  37668. /** RGBA */
  37669. static readonly TEXTUREFORMAT_RGBA: number;
  37670. /** RED */
  37671. static readonly TEXTUREFORMAT_RED: number;
  37672. /** RED (2nd reference) */
  37673. static readonly TEXTUREFORMAT_R: number;
  37674. /** RG */
  37675. static readonly TEXTUREFORMAT_RG: number;
  37676. /** RED_INTEGER */
  37677. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37678. /** RED_INTEGER (2nd reference) */
  37679. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37680. /** RG_INTEGER */
  37681. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37682. /** RGB_INTEGER */
  37683. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37684. /** RGBA_INTEGER */
  37685. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37686. /** UNSIGNED_BYTE */
  37687. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37688. /** UNSIGNED_BYTE (2nd reference) */
  37689. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37690. /** FLOAT */
  37691. static readonly TEXTURETYPE_FLOAT: number;
  37692. /** HALF_FLOAT */
  37693. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37694. /** BYTE */
  37695. static readonly TEXTURETYPE_BYTE: number;
  37696. /** SHORT */
  37697. static readonly TEXTURETYPE_SHORT: number;
  37698. /** UNSIGNED_SHORT */
  37699. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37700. /** INT */
  37701. static readonly TEXTURETYPE_INT: number;
  37702. /** UNSIGNED_INT */
  37703. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37704. /** UNSIGNED_SHORT_4_4_4_4 */
  37705. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37706. /** UNSIGNED_SHORT_5_5_5_1 */
  37707. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37708. /** UNSIGNED_SHORT_5_6_5 */
  37709. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37710. /** UNSIGNED_INT_2_10_10_10_REV */
  37711. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37712. /** UNSIGNED_INT_24_8 */
  37713. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37714. /** UNSIGNED_INT_10F_11F_11F_REV */
  37715. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37716. /** UNSIGNED_INT_5_9_9_9_REV */
  37717. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37718. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37719. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37720. /** nearest is mag = nearest and min = nearest and mip = linear */
  37721. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37722. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37723. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37724. /** Trilinear is mag = linear and min = linear and mip = linear */
  37725. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37726. /** nearest is mag = nearest and min = nearest and mip = linear */
  37727. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37728. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37729. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37730. /** Trilinear is mag = linear and min = linear and mip = linear */
  37731. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37732. /** mag = nearest and min = nearest and mip = nearest */
  37733. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37734. /** mag = nearest and min = linear and mip = nearest */
  37735. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37736. /** mag = nearest and min = linear and mip = linear */
  37737. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37738. /** mag = nearest and min = linear and mip = none */
  37739. static readonly TEXTURE_NEAREST_LINEAR: number;
  37740. /** mag = nearest and min = nearest and mip = none */
  37741. static readonly TEXTURE_NEAREST_NEAREST: number;
  37742. /** mag = linear and min = nearest and mip = nearest */
  37743. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37744. /** mag = linear and min = nearest and mip = linear */
  37745. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37746. /** mag = linear and min = linear and mip = none */
  37747. static readonly TEXTURE_LINEAR_LINEAR: number;
  37748. /** mag = linear and min = nearest and mip = none */
  37749. static readonly TEXTURE_LINEAR_NEAREST: number;
  37750. /** Explicit coordinates mode */
  37751. static readonly TEXTURE_EXPLICIT_MODE: number;
  37752. /** Spherical coordinates mode */
  37753. static readonly TEXTURE_SPHERICAL_MODE: number;
  37754. /** Planar coordinates mode */
  37755. static readonly TEXTURE_PLANAR_MODE: number;
  37756. /** Cubic coordinates mode */
  37757. static readonly TEXTURE_CUBIC_MODE: number;
  37758. /** Projection coordinates mode */
  37759. static readonly TEXTURE_PROJECTION_MODE: number;
  37760. /** Skybox coordinates mode */
  37761. static readonly TEXTURE_SKYBOX_MODE: number;
  37762. /** Inverse Cubic coordinates mode */
  37763. static readonly TEXTURE_INVCUBIC_MODE: number;
  37764. /** Equirectangular coordinates mode */
  37765. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37766. /** Equirectangular Fixed coordinates mode */
  37767. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37768. /** Equirectangular Fixed Mirrored coordinates mode */
  37769. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37770. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37771. static readonly SCALEMODE_FLOOR: number;
  37772. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37773. static readonly SCALEMODE_NEAREST: number;
  37774. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37775. static readonly SCALEMODE_CEILING: number;
  37776. /**
  37777. * Returns the current npm package of the sdk
  37778. */
  37779. static get NpmPackage(): string;
  37780. /**
  37781. * Returns the current version of the framework
  37782. */
  37783. static get Version(): string;
  37784. /** Gets the list of created engines */
  37785. static get Instances(): Engine[];
  37786. /**
  37787. * Gets the latest created engine
  37788. */
  37789. static get LastCreatedEngine(): Nullable<Engine>;
  37790. /**
  37791. * Gets the latest created scene
  37792. */
  37793. static get LastCreatedScene(): Nullable<Scene>;
  37794. /**
  37795. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37796. * @param flag defines which part of the materials must be marked as dirty
  37797. * @param predicate defines a predicate used to filter which materials should be affected
  37798. */
  37799. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37800. /**
  37801. * Method called to create the default loading screen.
  37802. * This can be overriden in your own app.
  37803. * @param canvas The rendering canvas element
  37804. * @returns The loading screen
  37805. */
  37806. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37807. /**
  37808. * Method called to create the default rescale post process on each engine.
  37809. */
  37810. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37811. /**
  37812. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37813. **/
  37814. enableOfflineSupport: boolean;
  37815. /**
  37816. * 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)
  37817. **/
  37818. disableManifestCheck: boolean;
  37819. /**
  37820. * Gets the list of created scenes
  37821. */
  37822. scenes: Scene[];
  37823. /**
  37824. * Event raised when a new scene is created
  37825. */
  37826. onNewSceneAddedObservable: Observable<Scene>;
  37827. /**
  37828. * Gets the list of created postprocesses
  37829. */
  37830. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37831. /**
  37832. * Gets a boolean indicating if the pointer is currently locked
  37833. */
  37834. isPointerLock: boolean;
  37835. /**
  37836. * Observable event triggered each time the rendering canvas is resized
  37837. */
  37838. onResizeObservable: Observable<Engine>;
  37839. /**
  37840. * Observable event triggered each time the canvas loses focus
  37841. */
  37842. onCanvasBlurObservable: Observable<Engine>;
  37843. /**
  37844. * Observable event triggered each time the canvas gains focus
  37845. */
  37846. onCanvasFocusObservable: Observable<Engine>;
  37847. /**
  37848. * Observable event triggered each time the canvas receives pointerout event
  37849. */
  37850. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37851. /**
  37852. * Observable raised when the engine begins a new frame
  37853. */
  37854. onBeginFrameObservable: Observable<Engine>;
  37855. /**
  37856. * If set, will be used to request the next animation frame for the render loop
  37857. */
  37858. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37859. /**
  37860. * Observable raised when the engine ends the current frame
  37861. */
  37862. onEndFrameObservable: Observable<Engine>;
  37863. /**
  37864. * Observable raised when the engine is about to compile a shader
  37865. */
  37866. onBeforeShaderCompilationObservable: Observable<Engine>;
  37867. /**
  37868. * Observable raised when the engine has jsut compiled a shader
  37869. */
  37870. onAfterShaderCompilationObservable: Observable<Engine>;
  37871. /**
  37872. * Gets the audio engine
  37873. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37874. * @ignorenaming
  37875. */
  37876. static audioEngine: IAudioEngine;
  37877. /**
  37878. * Default AudioEngine factory responsible of creating the Audio Engine.
  37879. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37880. */
  37881. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37882. /**
  37883. * Default offline support factory responsible of creating a tool used to store data locally.
  37884. * By default, this will create a Database object if the workload has been embedded.
  37885. */
  37886. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37887. private _loadingScreen;
  37888. private _pointerLockRequested;
  37889. private _rescalePostProcess;
  37890. private _deterministicLockstep;
  37891. private _lockstepMaxSteps;
  37892. private _timeStep;
  37893. protected get _supportsHardwareTextureRescaling(): boolean;
  37894. private _fps;
  37895. private _deltaTime;
  37896. /** @hidden */
  37897. _drawCalls: PerfCounter;
  37898. /** 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 */
  37899. canvasTabIndex: number;
  37900. /**
  37901. * Turn this value on if you want to pause FPS computation when in background
  37902. */
  37903. disablePerformanceMonitorInBackground: boolean;
  37904. private _performanceMonitor;
  37905. /**
  37906. * Gets the performance monitor attached to this engine
  37907. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37908. */
  37909. get performanceMonitor(): PerformanceMonitor;
  37910. private _onFocus;
  37911. private _onBlur;
  37912. private _onCanvasPointerOut;
  37913. private _onCanvasBlur;
  37914. private _onCanvasFocus;
  37915. private _onFullscreenChange;
  37916. private _onPointerLockChange;
  37917. /**
  37918. * Gets the HTML element used to attach event listeners
  37919. * @returns a HTML element
  37920. */
  37921. getInputElement(): Nullable<HTMLElement>;
  37922. /**
  37923. * Creates a new engine
  37924. * @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
  37925. * @param antialias defines enable antialiasing (default: false)
  37926. * @param options defines further options to be sent to the getContext() function
  37927. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37928. */
  37929. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37930. /**
  37931. * Gets current aspect ratio
  37932. * @param viewportOwner defines the camera to use to get the aspect ratio
  37933. * @param useScreen defines if screen size must be used (or the current render target if any)
  37934. * @returns a number defining the aspect ratio
  37935. */
  37936. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37937. /**
  37938. * Gets current screen aspect ratio
  37939. * @returns a number defining the aspect ratio
  37940. */
  37941. getScreenAspectRatio(): number;
  37942. /**
  37943. * Gets the client rect of the HTML canvas attached with the current webGL context
  37944. * @returns a client rectanglee
  37945. */
  37946. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37947. /**
  37948. * Gets the client rect of the HTML element used for events
  37949. * @returns a client rectanglee
  37950. */
  37951. getInputElementClientRect(): Nullable<ClientRect>;
  37952. /**
  37953. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37954. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37955. * @returns true if engine is in deterministic lock step mode
  37956. */
  37957. isDeterministicLockStep(): boolean;
  37958. /**
  37959. * Gets the max steps when engine is running in deterministic lock step
  37960. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37961. * @returns the max steps
  37962. */
  37963. getLockstepMaxSteps(): number;
  37964. /**
  37965. * Returns the time in ms between steps when using deterministic lock step.
  37966. * @returns time step in (ms)
  37967. */
  37968. getTimeStep(): number;
  37969. /**
  37970. * Force the mipmap generation for the given render target texture
  37971. * @param texture defines the render target texture to use
  37972. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37973. */
  37974. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37975. /** States */
  37976. /**
  37977. * Set various states to the webGL context
  37978. * @param culling defines backface culling state
  37979. * @param zOffset defines the value to apply to zOffset (0 by default)
  37980. * @param force defines if states must be applied even if cache is up to date
  37981. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37982. */
  37983. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37984. /**
  37985. * Set the z offset to apply to current rendering
  37986. * @param value defines the offset to apply
  37987. */
  37988. setZOffset(value: number): void;
  37989. /**
  37990. * Gets the current value of the zOffset
  37991. * @returns the current zOffset state
  37992. */
  37993. getZOffset(): number;
  37994. /**
  37995. * Enable or disable depth buffering
  37996. * @param enable defines the state to set
  37997. */
  37998. setDepthBuffer(enable: boolean): void;
  37999. /**
  38000. * Gets a boolean indicating if depth writing is enabled
  38001. * @returns the current depth writing state
  38002. */
  38003. getDepthWrite(): boolean;
  38004. /**
  38005. * Enable or disable depth writing
  38006. * @param enable defines the state to set
  38007. */
  38008. setDepthWrite(enable: boolean): void;
  38009. /**
  38010. * Gets a boolean indicating if stencil buffer is enabled
  38011. * @returns the current stencil buffer state
  38012. */
  38013. getStencilBuffer(): boolean;
  38014. /**
  38015. * Enable or disable the stencil buffer
  38016. * @param enable defines if the stencil buffer must be enabled or disabled
  38017. */
  38018. setStencilBuffer(enable: boolean): void;
  38019. /**
  38020. * Gets the current stencil mask
  38021. * @returns a number defining the new stencil mask to use
  38022. */
  38023. getStencilMask(): number;
  38024. /**
  38025. * Sets the current stencil mask
  38026. * @param mask defines the new stencil mask to use
  38027. */
  38028. setStencilMask(mask: number): void;
  38029. /**
  38030. * Gets the current stencil function
  38031. * @returns a number defining the stencil function to use
  38032. */
  38033. getStencilFunction(): number;
  38034. /**
  38035. * Gets the current stencil reference value
  38036. * @returns a number defining the stencil reference value to use
  38037. */
  38038. getStencilFunctionReference(): number;
  38039. /**
  38040. * Gets the current stencil mask
  38041. * @returns a number defining the stencil mask to use
  38042. */
  38043. getStencilFunctionMask(): number;
  38044. /**
  38045. * Sets the current stencil function
  38046. * @param stencilFunc defines the new stencil function to use
  38047. */
  38048. setStencilFunction(stencilFunc: number): void;
  38049. /**
  38050. * Sets the current stencil reference
  38051. * @param reference defines the new stencil reference to use
  38052. */
  38053. setStencilFunctionReference(reference: number): void;
  38054. /**
  38055. * Sets the current stencil mask
  38056. * @param mask defines the new stencil mask to use
  38057. */
  38058. setStencilFunctionMask(mask: number): void;
  38059. /**
  38060. * Gets the current stencil operation when stencil fails
  38061. * @returns a number defining stencil operation to use when stencil fails
  38062. */
  38063. getStencilOperationFail(): number;
  38064. /**
  38065. * Gets the current stencil operation when depth fails
  38066. * @returns a number defining stencil operation to use when depth fails
  38067. */
  38068. getStencilOperationDepthFail(): number;
  38069. /**
  38070. * Gets the current stencil operation when stencil passes
  38071. * @returns a number defining stencil operation to use when stencil passes
  38072. */
  38073. getStencilOperationPass(): number;
  38074. /**
  38075. * Sets the stencil operation to use when stencil fails
  38076. * @param operation defines the stencil operation to use when stencil fails
  38077. */
  38078. setStencilOperationFail(operation: number): void;
  38079. /**
  38080. * Sets the stencil operation to use when depth fails
  38081. * @param operation defines the stencil operation to use when depth fails
  38082. */
  38083. setStencilOperationDepthFail(operation: number): void;
  38084. /**
  38085. * Sets the stencil operation to use when stencil passes
  38086. * @param operation defines the stencil operation to use when stencil passes
  38087. */
  38088. setStencilOperationPass(operation: number): void;
  38089. /**
  38090. * Sets a boolean indicating if the dithering state is enabled or disabled
  38091. * @param value defines the dithering state
  38092. */
  38093. setDitheringState(value: boolean): void;
  38094. /**
  38095. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38096. * @param value defines the rasterizer state
  38097. */
  38098. setRasterizerState(value: boolean): void;
  38099. /**
  38100. * Gets the current depth function
  38101. * @returns a number defining the depth function
  38102. */
  38103. getDepthFunction(): Nullable<number>;
  38104. /**
  38105. * Sets the current depth function
  38106. * @param depthFunc defines the function to use
  38107. */
  38108. setDepthFunction(depthFunc: number): void;
  38109. /**
  38110. * Sets the current depth function to GREATER
  38111. */
  38112. setDepthFunctionToGreater(): void;
  38113. /**
  38114. * Sets the current depth function to GEQUAL
  38115. */
  38116. setDepthFunctionToGreaterOrEqual(): void;
  38117. /**
  38118. * Sets the current depth function to LESS
  38119. */
  38120. setDepthFunctionToLess(): void;
  38121. /**
  38122. * Sets the current depth function to LEQUAL
  38123. */
  38124. setDepthFunctionToLessOrEqual(): void;
  38125. private _cachedStencilBuffer;
  38126. private _cachedStencilFunction;
  38127. private _cachedStencilMask;
  38128. private _cachedStencilOperationPass;
  38129. private _cachedStencilOperationFail;
  38130. private _cachedStencilOperationDepthFail;
  38131. private _cachedStencilReference;
  38132. /**
  38133. * Caches the the state of the stencil buffer
  38134. */
  38135. cacheStencilState(): void;
  38136. /**
  38137. * Restores the state of the stencil buffer
  38138. */
  38139. restoreStencilState(): void;
  38140. /**
  38141. * Directly set the WebGL Viewport
  38142. * @param x defines the x coordinate of the viewport (in screen space)
  38143. * @param y defines the y coordinate of the viewport (in screen space)
  38144. * @param width defines the width of the viewport (in screen space)
  38145. * @param height defines the height of the viewport (in screen space)
  38146. * @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
  38147. */
  38148. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38149. /**
  38150. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38151. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38152. * @param y defines the y-coordinate of the corner of the clear rectangle
  38153. * @param width defines the width of the clear rectangle
  38154. * @param height defines the height of the clear rectangle
  38155. * @param clearColor defines the clear color
  38156. */
  38157. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38158. /**
  38159. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38160. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38161. * @param y defines the y-coordinate of the corner of the clear rectangle
  38162. * @param width defines the width of the clear rectangle
  38163. * @param height defines the height of the clear rectangle
  38164. */
  38165. enableScissor(x: number, y: number, width: number, height: number): void;
  38166. /**
  38167. * Disable previously set scissor test rectangle
  38168. */
  38169. disableScissor(): void;
  38170. protected _reportDrawCall(): void;
  38171. /**
  38172. * Initializes a webVR display and starts listening to display change events
  38173. * The onVRDisplayChangedObservable will be notified upon these changes
  38174. * @returns The onVRDisplayChangedObservable
  38175. */
  38176. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38177. /** @hidden */
  38178. _prepareVRComponent(): void;
  38179. /** @hidden */
  38180. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38181. /** @hidden */
  38182. _submitVRFrame(): void;
  38183. /**
  38184. * Call this function to leave webVR mode
  38185. * Will do nothing if webVR is not supported or if there is no webVR device
  38186. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38187. */
  38188. disableVR(): void;
  38189. /**
  38190. * Gets a boolean indicating that the system is in VR mode and is presenting
  38191. * @returns true if VR mode is engaged
  38192. */
  38193. isVRPresenting(): boolean;
  38194. /** @hidden */
  38195. _requestVRFrame(): void;
  38196. /** @hidden */
  38197. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38198. /**
  38199. * Gets the source code of the vertex shader associated with a specific webGL program
  38200. * @param program defines the program to use
  38201. * @returns a string containing the source code of the vertex shader associated with the program
  38202. */
  38203. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38204. /**
  38205. * Gets the source code of the fragment shader associated with a specific webGL program
  38206. * @param program defines the program to use
  38207. * @returns a string containing the source code of the fragment shader associated with the program
  38208. */
  38209. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38210. /**
  38211. * Sets a depth stencil texture from a render target to the according uniform.
  38212. * @param channel The texture channel
  38213. * @param uniform The uniform to set
  38214. * @param texture The render target texture containing the depth stencil texture to apply
  38215. */
  38216. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38217. /**
  38218. * Sets a texture to the webGL context from a postprocess
  38219. * @param channel defines the channel to use
  38220. * @param postProcess defines the source postprocess
  38221. */
  38222. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38223. /**
  38224. * Binds the output of the passed in post process to the texture channel specified
  38225. * @param channel The channel the texture should be bound to
  38226. * @param postProcess The post process which's output should be bound
  38227. */
  38228. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38229. protected _rebuildBuffers(): void;
  38230. /** @hidden */
  38231. _renderFrame(): void;
  38232. _renderLoop(): void;
  38233. /** @hidden */
  38234. _renderViews(): boolean;
  38235. /**
  38236. * Toggle full screen mode
  38237. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38238. */
  38239. switchFullscreen(requestPointerLock: boolean): void;
  38240. /**
  38241. * Enters full screen mode
  38242. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38243. */
  38244. enterFullscreen(requestPointerLock: boolean): void;
  38245. /**
  38246. * Exits full screen mode
  38247. */
  38248. exitFullscreen(): void;
  38249. /**
  38250. * Enters Pointerlock mode
  38251. */
  38252. enterPointerlock(): void;
  38253. /**
  38254. * Exits Pointerlock mode
  38255. */
  38256. exitPointerlock(): void;
  38257. /**
  38258. * Begin a new frame
  38259. */
  38260. beginFrame(): void;
  38261. /**
  38262. * Enf the current frame
  38263. */
  38264. endFrame(): void;
  38265. resize(): void;
  38266. /**
  38267. * Force a specific size of the canvas
  38268. * @param width defines the new canvas' width
  38269. * @param height defines the new canvas' height
  38270. * @returns true if the size was changed
  38271. */
  38272. setSize(width: number, height: number): boolean;
  38273. /**
  38274. * Updates a dynamic vertex buffer.
  38275. * @param vertexBuffer the vertex buffer to update
  38276. * @param data the data used to update the vertex buffer
  38277. * @param byteOffset the byte offset of the data
  38278. * @param byteLength the byte length of the data
  38279. */
  38280. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38281. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38282. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38283. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38284. _releaseTexture(texture: InternalTexture): void;
  38285. /**
  38286. * @hidden
  38287. * Rescales a texture
  38288. * @param source input texutre
  38289. * @param destination destination texture
  38290. * @param scene scene to use to render the resize
  38291. * @param internalFormat format to use when resizing
  38292. * @param onComplete callback to be called when resize has completed
  38293. */
  38294. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38295. /**
  38296. * Gets the current framerate
  38297. * @returns a number representing the framerate
  38298. */
  38299. getFps(): number;
  38300. /**
  38301. * Gets the time spent between current and previous frame
  38302. * @returns a number representing the delta time in ms
  38303. */
  38304. getDeltaTime(): number;
  38305. private _measureFps;
  38306. /** @hidden */
  38307. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38308. /**
  38309. * Update a dynamic index buffer
  38310. * @param indexBuffer defines the target index buffer
  38311. * @param indices defines the data to update
  38312. * @param offset defines the offset in the target index buffer where update should start
  38313. */
  38314. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38315. /**
  38316. * Updates the sample count of a render target texture
  38317. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38318. * @param texture defines the texture to update
  38319. * @param samples defines the sample count to set
  38320. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38321. */
  38322. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38323. /**
  38324. * Updates a depth texture Comparison Mode and Function.
  38325. * If the comparison Function is equal to 0, the mode will be set to none.
  38326. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38327. * @param texture The texture to set the comparison function for
  38328. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38329. */
  38330. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38331. /**
  38332. * Creates a webGL buffer to use with instanciation
  38333. * @param capacity defines the size of the buffer
  38334. * @returns the webGL buffer
  38335. */
  38336. createInstancesBuffer(capacity: number): DataBuffer;
  38337. /**
  38338. * Delete a webGL buffer used with instanciation
  38339. * @param buffer defines the webGL buffer to delete
  38340. */
  38341. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38342. private _clientWaitAsync;
  38343. /** @hidden */
  38344. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38345. dispose(): void;
  38346. private _disableTouchAction;
  38347. /**
  38348. * Display the loading screen
  38349. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38350. */
  38351. displayLoadingUI(): void;
  38352. /**
  38353. * Hide the loading screen
  38354. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38355. */
  38356. hideLoadingUI(): void;
  38357. /**
  38358. * Gets the current loading screen object
  38359. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38360. */
  38361. get loadingScreen(): ILoadingScreen;
  38362. /**
  38363. * Sets the current loading screen object
  38364. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38365. */
  38366. set loadingScreen(loadingScreen: ILoadingScreen);
  38367. /**
  38368. * Sets the current loading screen text
  38369. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38370. */
  38371. set loadingUIText(text: string);
  38372. /**
  38373. * Sets the current loading screen background color
  38374. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38375. */
  38376. set loadingUIBackgroundColor(color: string);
  38377. /** Pointerlock and fullscreen */
  38378. /**
  38379. * Ask the browser to promote the current element to pointerlock mode
  38380. * @param element defines the DOM element to promote
  38381. */
  38382. static _RequestPointerlock(element: HTMLElement): void;
  38383. /**
  38384. * Asks the browser to exit pointerlock mode
  38385. */
  38386. static _ExitPointerlock(): void;
  38387. /**
  38388. * Ask the browser to promote the current element to fullscreen rendering mode
  38389. * @param element defines the DOM element to promote
  38390. */
  38391. static _RequestFullscreen(element: HTMLElement): void;
  38392. /**
  38393. * Asks the browser to exit fullscreen mode
  38394. */
  38395. static _ExitFullscreen(): void;
  38396. }
  38397. }
  38398. declare module "babylonjs/Engines/engineStore" {
  38399. import { Nullable } from "babylonjs/types";
  38400. import { Engine } from "babylonjs/Engines/engine";
  38401. import { Scene } from "babylonjs/scene";
  38402. /**
  38403. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38404. * during the life time of the application.
  38405. */
  38406. export class EngineStore {
  38407. /** Gets the list of created engines */
  38408. static Instances: import("babylonjs/Engines/engine").Engine[];
  38409. /** @hidden */
  38410. static _LastCreatedScene: Nullable<Scene>;
  38411. /**
  38412. * Gets the latest created engine
  38413. */
  38414. static get LastCreatedEngine(): Nullable<Engine>;
  38415. /**
  38416. * Gets the latest created scene
  38417. */
  38418. static get LastCreatedScene(): Nullable<Scene>;
  38419. /**
  38420. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38421. * @ignorenaming
  38422. */
  38423. static UseFallbackTexture: boolean;
  38424. /**
  38425. * Texture content used if a texture cannot loaded
  38426. * @ignorenaming
  38427. */
  38428. static FallbackTexture: string;
  38429. }
  38430. }
  38431. declare module "babylonjs/Misc/promise" {
  38432. /**
  38433. * Helper class that provides a small promise polyfill
  38434. */
  38435. export class PromisePolyfill {
  38436. /**
  38437. * Static function used to check if the polyfill is required
  38438. * If this is the case then the function will inject the polyfill to window.Promise
  38439. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38440. */
  38441. static Apply(force?: boolean): void;
  38442. }
  38443. }
  38444. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38445. /**
  38446. * Interface for screenshot methods with describe argument called `size` as object with options
  38447. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38448. */
  38449. export interface IScreenshotSize {
  38450. /**
  38451. * number in pixels for canvas height
  38452. */
  38453. height?: number;
  38454. /**
  38455. * multiplier allowing render at a higher or lower resolution
  38456. * If value is defined then height and width will be ignored and taken from camera
  38457. */
  38458. precision?: number;
  38459. /**
  38460. * number in pixels for canvas width
  38461. */
  38462. width?: number;
  38463. }
  38464. }
  38465. declare module "babylonjs/Misc/tools" {
  38466. import { Nullable, float } from "babylonjs/types";
  38467. import { DomManagement } from "babylonjs/Misc/domManagement";
  38468. import { WebRequest } from "babylonjs/Misc/webRequest";
  38469. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38470. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38471. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38472. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38473. import { Camera } from "babylonjs/Cameras/camera";
  38474. import { Engine } from "babylonjs/Engines/engine";
  38475. interface IColor4Like {
  38476. r: float;
  38477. g: float;
  38478. b: float;
  38479. a: float;
  38480. }
  38481. /**
  38482. * Class containing a set of static utilities functions
  38483. */
  38484. export class Tools {
  38485. /**
  38486. * Gets or sets the base URL to use to load assets
  38487. */
  38488. static get BaseUrl(): string;
  38489. static set BaseUrl(value: string);
  38490. /**
  38491. * Enable/Disable Custom HTTP Request Headers globally.
  38492. * default = false
  38493. * @see CustomRequestHeaders
  38494. */
  38495. static UseCustomRequestHeaders: boolean;
  38496. /**
  38497. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38498. * i.e. when loading files, where the server/service expects an Authorization header
  38499. */
  38500. static CustomRequestHeaders: {
  38501. [key: string]: string;
  38502. };
  38503. /**
  38504. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38505. */
  38506. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38507. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38508. /**
  38509. * Default behaviour for cors in the application.
  38510. * It can be a string if the expected behavior is identical in the entire app.
  38511. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38512. */
  38513. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38514. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38515. /**
  38516. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38517. * @ignorenaming
  38518. */
  38519. static get UseFallbackTexture(): boolean;
  38520. static set UseFallbackTexture(value: boolean);
  38521. /**
  38522. * Use this object to register external classes like custom textures or material
  38523. * to allow the laoders to instantiate them
  38524. */
  38525. static get RegisteredExternalClasses(): {
  38526. [key: string]: Object;
  38527. };
  38528. static set RegisteredExternalClasses(classes: {
  38529. [key: string]: Object;
  38530. });
  38531. /**
  38532. * Texture content used if a texture cannot loaded
  38533. * @ignorenaming
  38534. */
  38535. static get fallbackTexture(): string;
  38536. static set fallbackTexture(value: string);
  38537. /**
  38538. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38539. * @param u defines the coordinate on X axis
  38540. * @param v defines the coordinate on Y axis
  38541. * @param width defines the width of the source data
  38542. * @param height defines the height of the source data
  38543. * @param pixels defines the source byte array
  38544. * @param color defines the output color
  38545. */
  38546. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38547. /**
  38548. * Interpolates between a and b via alpha
  38549. * @param a The lower value (returned when alpha = 0)
  38550. * @param b The upper value (returned when alpha = 1)
  38551. * @param alpha The interpolation-factor
  38552. * @return The mixed value
  38553. */
  38554. static Mix(a: number, b: number, alpha: number): number;
  38555. /**
  38556. * Tries to instantiate a new object from a given class name
  38557. * @param className defines the class name to instantiate
  38558. * @returns the new object or null if the system was not able to do the instantiation
  38559. */
  38560. static Instantiate(className: string): any;
  38561. /**
  38562. * Provides a slice function that will work even on IE
  38563. * @param data defines the array to slice
  38564. * @param start defines the start of the data (optional)
  38565. * @param end defines the end of the data (optional)
  38566. * @returns the new sliced array
  38567. */
  38568. static Slice<T>(data: T, start?: number, end?: number): T;
  38569. /**
  38570. * Polyfill for setImmediate
  38571. * @param action defines the action to execute after the current execution block
  38572. */
  38573. static SetImmediate(action: () => void): void;
  38574. /**
  38575. * Function indicating if a number is an exponent of 2
  38576. * @param value defines the value to test
  38577. * @returns true if the value is an exponent of 2
  38578. */
  38579. static IsExponentOfTwo(value: number): boolean;
  38580. private static _tmpFloatArray;
  38581. /**
  38582. * Returns the nearest 32-bit single precision float representation of a Number
  38583. * @param value A Number. If the parameter is of a different type, it will get converted
  38584. * to a number or to NaN if it cannot be converted
  38585. * @returns number
  38586. */
  38587. static FloatRound(value: number): number;
  38588. /**
  38589. * Extracts the filename from a path
  38590. * @param path defines the path to use
  38591. * @returns the filename
  38592. */
  38593. static GetFilename(path: string): string;
  38594. /**
  38595. * Extracts the "folder" part of a path (everything before the filename).
  38596. * @param uri The URI to extract the info from
  38597. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38598. * @returns The "folder" part of the path
  38599. */
  38600. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38601. /**
  38602. * Extracts text content from a DOM element hierarchy
  38603. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38604. */
  38605. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38606. /**
  38607. * Convert an angle in radians to degrees
  38608. * @param angle defines the angle to convert
  38609. * @returns the angle in degrees
  38610. */
  38611. static ToDegrees(angle: number): number;
  38612. /**
  38613. * Convert an angle in degrees to radians
  38614. * @param angle defines the angle to convert
  38615. * @returns the angle in radians
  38616. */
  38617. static ToRadians(angle: number): number;
  38618. /**
  38619. * Returns an array if obj is not an array
  38620. * @param obj defines the object to evaluate as an array
  38621. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38622. * @returns either obj directly if obj is an array or a new array containing obj
  38623. */
  38624. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38625. /**
  38626. * Gets the pointer prefix to use
  38627. * @param engine defines the engine we are finding the prefix for
  38628. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38629. */
  38630. static GetPointerPrefix(engine: Engine): string;
  38631. /**
  38632. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38633. * @param url define the url we are trying
  38634. * @param element define the dom element where to configure the cors policy
  38635. */
  38636. static SetCorsBehavior(url: string | string[], element: {
  38637. crossOrigin: string | null;
  38638. }): void;
  38639. /**
  38640. * Removes unwanted characters from an url
  38641. * @param url defines the url to clean
  38642. * @returns the cleaned url
  38643. */
  38644. static CleanUrl(url: string): string;
  38645. /**
  38646. * Gets or sets a function used to pre-process url before using them to load assets
  38647. */
  38648. static get PreprocessUrl(): (url: string) => string;
  38649. static set PreprocessUrl(processor: (url: string) => string);
  38650. /**
  38651. * Loads an image as an HTMLImageElement.
  38652. * @param input url string, ArrayBuffer, or Blob to load
  38653. * @param onLoad callback called when the image successfully loads
  38654. * @param onError callback called when the image fails to load
  38655. * @param offlineProvider offline provider for caching
  38656. * @param mimeType optional mime type
  38657. * @returns the HTMLImageElement of the loaded image
  38658. */
  38659. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38660. /**
  38661. * Loads a file from a url
  38662. * @param url url string, ArrayBuffer, or Blob to load
  38663. * @param onSuccess callback called when the file successfully loads
  38664. * @param onProgress callback called while file is loading (if the server supports this mode)
  38665. * @param offlineProvider defines the offline provider for caching
  38666. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38667. * @param onError callback called when the file fails to load
  38668. * @returns a file request object
  38669. */
  38670. 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;
  38671. /**
  38672. * Loads a file from a url
  38673. * @param url the file url to load
  38674. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38675. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38676. */
  38677. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38678. /**
  38679. * Load a script (identified by an url). When the url returns, the
  38680. * content of this file is added into a new script element, attached to the DOM (body element)
  38681. * @param scriptUrl defines the url of the script to laod
  38682. * @param onSuccess defines the callback called when the script is loaded
  38683. * @param onError defines the callback to call if an error occurs
  38684. * @param scriptId defines the id of the script element
  38685. */
  38686. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38687. /**
  38688. * Load an asynchronous script (identified by an url). When the url returns, the
  38689. * content of this file is added into a new script element, attached to the DOM (body element)
  38690. * @param scriptUrl defines the url of the script to laod
  38691. * @param scriptId defines the id of the script element
  38692. * @returns a promise request object
  38693. */
  38694. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38695. /**
  38696. * Loads a file from a blob
  38697. * @param fileToLoad defines the blob to use
  38698. * @param callback defines the callback to call when data is loaded
  38699. * @param progressCallback defines the callback to call during loading process
  38700. * @returns a file request object
  38701. */
  38702. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38703. /**
  38704. * Reads a file from a File object
  38705. * @param file defines the file to load
  38706. * @param onSuccess defines the callback to call when data is loaded
  38707. * @param onProgress defines the callback to call during loading process
  38708. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38709. * @param onError defines the callback to call when an error occurs
  38710. * @returns a file request object
  38711. */
  38712. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38713. /**
  38714. * Creates a data url from a given string content
  38715. * @param content defines the content to convert
  38716. * @returns the new data url link
  38717. */
  38718. static FileAsURL(content: string): string;
  38719. /**
  38720. * Format the given number to a specific decimal format
  38721. * @param value defines the number to format
  38722. * @param decimals defines the number of decimals to use
  38723. * @returns the formatted string
  38724. */
  38725. static Format(value: number, decimals?: number): string;
  38726. /**
  38727. * Tries to copy an object by duplicating every property
  38728. * @param source defines the source object
  38729. * @param destination defines the target object
  38730. * @param doNotCopyList defines a list of properties to avoid
  38731. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38732. */
  38733. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38734. /**
  38735. * Gets a boolean indicating if the given object has no own property
  38736. * @param obj defines the object to test
  38737. * @returns true if object has no own property
  38738. */
  38739. static IsEmpty(obj: any): boolean;
  38740. /**
  38741. * Function used to register events at window level
  38742. * @param windowElement defines the Window object to use
  38743. * @param events defines the events to register
  38744. */
  38745. static RegisterTopRootEvents(windowElement: Window, events: {
  38746. name: string;
  38747. handler: Nullable<(e: FocusEvent) => any>;
  38748. }[]): void;
  38749. /**
  38750. * Function used to unregister events from window level
  38751. * @param windowElement defines the Window object to use
  38752. * @param events defines the events to unregister
  38753. */
  38754. static UnregisterTopRootEvents(windowElement: Window, events: {
  38755. name: string;
  38756. handler: Nullable<(e: FocusEvent) => any>;
  38757. }[]): void;
  38758. /**
  38759. * @ignore
  38760. */
  38761. static _ScreenshotCanvas: HTMLCanvasElement;
  38762. /**
  38763. * Dumps the current bound framebuffer
  38764. * @param width defines the rendering width
  38765. * @param height defines the rendering height
  38766. * @param engine defines the hosting engine
  38767. * @param successCallback defines the callback triggered once the data are available
  38768. * @param mimeType defines the mime type of the result
  38769. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38770. */
  38771. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38772. /**
  38773. * Converts the canvas data to blob.
  38774. * This acts as a polyfill for browsers not supporting the to blob function.
  38775. * @param canvas Defines the canvas to extract the data from
  38776. * @param successCallback Defines the callback triggered once the data are available
  38777. * @param mimeType Defines the mime type of the result
  38778. */
  38779. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38780. /**
  38781. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38782. * @param successCallback defines the callback triggered once the data are available
  38783. * @param mimeType defines the mime type of the result
  38784. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38785. */
  38786. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38787. /**
  38788. * Downloads a blob in the browser
  38789. * @param blob defines the blob to download
  38790. * @param fileName defines the name of the downloaded file
  38791. */
  38792. static Download(blob: Blob, fileName: string): void;
  38793. /**
  38794. * Captures a screenshot of the current rendering
  38795. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38796. * @param engine defines the rendering engine
  38797. * @param camera defines the source camera
  38798. * @param size This parameter can be set to a single number or to an object with the
  38799. * following (optional) properties: precision, width, height. If a single number is passed,
  38800. * it will be used for both width and height. If an object is passed, the screenshot size
  38801. * will be derived from the parameters. The precision property is a multiplier allowing
  38802. * rendering at a higher or lower resolution
  38803. * @param successCallback defines the callback receives a single parameter which contains the
  38804. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38805. * src parameter of an <img> to display it
  38806. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38807. * Check your browser for supported MIME types
  38808. */
  38809. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38810. /**
  38811. * Captures a screenshot of the current rendering
  38812. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38813. * @param engine defines the rendering engine
  38814. * @param camera defines the source camera
  38815. * @param size This parameter can be set to a single number or to an object with the
  38816. * following (optional) properties: precision, width, height. If a single number is passed,
  38817. * it will be used for both width and height. If an object is passed, the screenshot size
  38818. * will be derived from the parameters. The precision property is a multiplier allowing
  38819. * rendering at a higher or lower resolution
  38820. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38821. * Check your browser for supported MIME types
  38822. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38823. * to the src parameter of an <img> to display it
  38824. */
  38825. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38826. /**
  38827. * Generates an image screenshot from the specified camera.
  38828. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38829. * @param engine The engine to use for rendering
  38830. * @param camera The camera to use for rendering
  38831. * @param size This parameter can be set to a single number or to an object with the
  38832. * following (optional) properties: precision, width, height. If a single number is passed,
  38833. * it will be used for both width and height. If an object is passed, the screenshot size
  38834. * will be derived from the parameters. The precision property is a multiplier allowing
  38835. * rendering at a higher or lower resolution
  38836. * @param successCallback The callback receives a single parameter which contains the
  38837. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38838. * src parameter of an <img> to display it
  38839. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38840. * Check your browser for supported MIME types
  38841. * @param samples Texture samples (default: 1)
  38842. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38843. * @param fileName A name for for the downloaded file.
  38844. */
  38845. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38846. /**
  38847. * Generates an image screenshot from the specified camera.
  38848. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38849. * @param engine The engine to use for rendering
  38850. * @param camera The camera to use for rendering
  38851. * @param size This parameter can be set to a single number or to an object with the
  38852. * following (optional) properties: precision, width, height. If a single number is passed,
  38853. * it will be used for both width and height. If an object is passed, the screenshot size
  38854. * will be derived from the parameters. The precision property is a multiplier allowing
  38855. * rendering at a higher or lower resolution
  38856. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38857. * Check your browser for supported MIME types
  38858. * @param samples Texture samples (default: 1)
  38859. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38860. * @param fileName A name for for the downloaded file.
  38861. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38862. * to the src parameter of an <img> to display it
  38863. */
  38864. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38865. /**
  38866. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38867. * Be aware Math.random() could cause collisions, but:
  38868. * "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"
  38869. * @returns a pseudo random id
  38870. */
  38871. static RandomId(): string;
  38872. /**
  38873. * Test if the given uri is a base64 string
  38874. * @param uri The uri to test
  38875. * @return True if the uri is a base64 string or false otherwise
  38876. */
  38877. static IsBase64(uri: string): boolean;
  38878. /**
  38879. * Decode the given base64 uri.
  38880. * @param uri The uri to decode
  38881. * @return The decoded base64 data.
  38882. */
  38883. static DecodeBase64(uri: string): ArrayBuffer;
  38884. /**
  38885. * Gets the absolute url.
  38886. * @param url the input url
  38887. * @return the absolute url
  38888. */
  38889. static GetAbsoluteUrl(url: string): string;
  38890. /**
  38891. * No log
  38892. */
  38893. static readonly NoneLogLevel: number;
  38894. /**
  38895. * Only message logs
  38896. */
  38897. static readonly MessageLogLevel: number;
  38898. /**
  38899. * Only warning logs
  38900. */
  38901. static readonly WarningLogLevel: number;
  38902. /**
  38903. * Only error logs
  38904. */
  38905. static readonly ErrorLogLevel: number;
  38906. /**
  38907. * All logs
  38908. */
  38909. static readonly AllLogLevel: number;
  38910. /**
  38911. * Gets a value indicating the number of loading errors
  38912. * @ignorenaming
  38913. */
  38914. static get errorsCount(): number;
  38915. /**
  38916. * Callback called when a new log is added
  38917. */
  38918. static OnNewCacheEntry: (entry: string) => void;
  38919. /**
  38920. * Log a message to the console
  38921. * @param message defines the message to log
  38922. */
  38923. static Log(message: string): void;
  38924. /**
  38925. * Write a warning message to the console
  38926. * @param message defines the message to log
  38927. */
  38928. static Warn(message: string): void;
  38929. /**
  38930. * Write an error message to the console
  38931. * @param message defines the message to log
  38932. */
  38933. static Error(message: string): void;
  38934. /**
  38935. * Gets current log cache (list of logs)
  38936. */
  38937. static get LogCache(): string;
  38938. /**
  38939. * Clears the log cache
  38940. */
  38941. static ClearLogCache(): void;
  38942. /**
  38943. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38944. */
  38945. static set LogLevels(level: number);
  38946. /**
  38947. * Checks if the window object exists
  38948. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38949. */
  38950. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38951. /**
  38952. * No performance log
  38953. */
  38954. static readonly PerformanceNoneLogLevel: number;
  38955. /**
  38956. * Use user marks to log performance
  38957. */
  38958. static readonly PerformanceUserMarkLogLevel: number;
  38959. /**
  38960. * Log performance to the console
  38961. */
  38962. static readonly PerformanceConsoleLogLevel: number;
  38963. private static _performance;
  38964. /**
  38965. * Sets the current performance log level
  38966. */
  38967. static set PerformanceLogLevel(level: number);
  38968. private static _StartPerformanceCounterDisabled;
  38969. private static _EndPerformanceCounterDisabled;
  38970. private static _StartUserMark;
  38971. private static _EndUserMark;
  38972. private static _StartPerformanceConsole;
  38973. private static _EndPerformanceConsole;
  38974. /**
  38975. * Starts a performance counter
  38976. */
  38977. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38978. /**
  38979. * Ends a specific performance coutner
  38980. */
  38981. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38982. /**
  38983. * Gets either window.performance.now() if supported or Date.now() else
  38984. */
  38985. static get Now(): number;
  38986. /**
  38987. * This method will return the name of the class used to create the instance of the given object.
  38988. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38989. * @param object the object to get the class name from
  38990. * @param isType defines if the object is actually a type
  38991. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38992. */
  38993. static GetClassName(object: any, isType?: boolean): string;
  38994. /**
  38995. * Gets the first element of an array satisfying a given predicate
  38996. * @param array defines the array to browse
  38997. * @param predicate defines the predicate to use
  38998. * @returns null if not found or the element
  38999. */
  39000. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39001. /**
  39002. * This method will return the name of the full name of the class, including its owning module (if any).
  39003. * 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).
  39004. * @param object the object to get the class name from
  39005. * @param isType defines if the object is actually a type
  39006. * @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.
  39007. * @ignorenaming
  39008. */
  39009. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39010. /**
  39011. * Returns a promise that resolves after the given amount of time.
  39012. * @param delay Number of milliseconds to delay
  39013. * @returns Promise that resolves after the given amount of time
  39014. */
  39015. static DelayAsync(delay: number): Promise<void>;
  39016. /**
  39017. * Utility function to detect if the current user agent is Safari
  39018. * @returns whether or not the current user agent is safari
  39019. */
  39020. static IsSafari(): boolean;
  39021. }
  39022. /**
  39023. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39024. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39025. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39026. * @param name The name of the class, case should be preserved
  39027. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39028. */
  39029. export function className(name: string, module?: string): (target: Object) => void;
  39030. /**
  39031. * An implementation of a loop for asynchronous functions.
  39032. */
  39033. export class AsyncLoop {
  39034. /**
  39035. * Defines the number of iterations for the loop
  39036. */
  39037. iterations: number;
  39038. /**
  39039. * Defines the current index of the loop.
  39040. */
  39041. index: number;
  39042. private _done;
  39043. private _fn;
  39044. private _successCallback;
  39045. /**
  39046. * Constructor.
  39047. * @param iterations the number of iterations.
  39048. * @param func the function to run each iteration
  39049. * @param successCallback the callback that will be called upon succesful execution
  39050. * @param offset starting offset.
  39051. */
  39052. constructor(
  39053. /**
  39054. * Defines the number of iterations for the loop
  39055. */
  39056. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39057. /**
  39058. * Execute the next iteration. Must be called after the last iteration was finished.
  39059. */
  39060. executeNext(): void;
  39061. /**
  39062. * Break the loop and run the success callback.
  39063. */
  39064. breakLoop(): void;
  39065. /**
  39066. * Create and run an async loop.
  39067. * @param iterations the number of iterations.
  39068. * @param fn the function to run each iteration
  39069. * @param successCallback the callback that will be called upon succesful execution
  39070. * @param offset starting offset.
  39071. * @returns the created async loop object
  39072. */
  39073. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39074. /**
  39075. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39076. * @param iterations total number of iterations
  39077. * @param syncedIterations number of synchronous iterations in each async iteration.
  39078. * @param fn the function to call each iteration.
  39079. * @param callback a success call back that will be called when iterating stops.
  39080. * @param breakFunction a break condition (optional)
  39081. * @param timeout timeout settings for the setTimeout function. default - 0.
  39082. * @returns the created async loop object
  39083. */
  39084. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39085. }
  39086. }
  39087. declare module "babylonjs/Misc/stringDictionary" {
  39088. import { Nullable } from "babylonjs/types";
  39089. /**
  39090. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39091. * The underlying implementation relies on an associative array to ensure the best performances.
  39092. * The value can be anything including 'null' but except 'undefined'
  39093. */
  39094. export class StringDictionary<T> {
  39095. /**
  39096. * This will clear this dictionary and copy the content from the 'source' one.
  39097. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39098. * @param source the dictionary to take the content from and copy to this dictionary
  39099. */
  39100. copyFrom(source: StringDictionary<T>): void;
  39101. /**
  39102. * Get a value based from its key
  39103. * @param key the given key to get the matching value from
  39104. * @return the value if found, otherwise undefined is returned
  39105. */
  39106. get(key: string): T | undefined;
  39107. /**
  39108. * Get a value from its key or add it if it doesn't exist.
  39109. * This method will ensure you that a given key/data will be present in the dictionary.
  39110. * @param key the given key to get the matching value from
  39111. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39112. * The factory will only be invoked if there's no data for the given key.
  39113. * @return the value corresponding to the key.
  39114. */
  39115. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39116. /**
  39117. * Get a value from its key if present in the dictionary otherwise add it
  39118. * @param key the key to get the value from
  39119. * @param val if there's no such key/value pair in the dictionary add it with this value
  39120. * @return the value corresponding to the key
  39121. */
  39122. getOrAdd(key: string, val: T): T;
  39123. /**
  39124. * Check if there's a given key in the dictionary
  39125. * @param key the key to check for
  39126. * @return true if the key is present, false otherwise
  39127. */
  39128. contains(key: string): boolean;
  39129. /**
  39130. * Add a new key and its corresponding value
  39131. * @param key the key to add
  39132. * @param value the value corresponding to the key
  39133. * @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
  39134. */
  39135. add(key: string, value: T): boolean;
  39136. /**
  39137. * Update a specific value associated to a key
  39138. * @param key defines the key to use
  39139. * @param value defines the value to store
  39140. * @returns true if the value was updated (or false if the key was not found)
  39141. */
  39142. set(key: string, value: T): boolean;
  39143. /**
  39144. * Get the element of the given key and remove it from the dictionary
  39145. * @param key defines the key to search
  39146. * @returns the value associated with the key or null if not found
  39147. */
  39148. getAndRemove(key: string): Nullable<T>;
  39149. /**
  39150. * Remove a key/value from the dictionary.
  39151. * @param key the key to remove
  39152. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39153. */
  39154. remove(key: string): boolean;
  39155. /**
  39156. * Clear the whole content of the dictionary
  39157. */
  39158. clear(): void;
  39159. /**
  39160. * Gets the current count
  39161. */
  39162. get count(): number;
  39163. /**
  39164. * Execute a callback on each key/val of the dictionary.
  39165. * Note that you can remove any element in this dictionary in the callback implementation
  39166. * @param callback the callback to execute on a given key/value pair
  39167. */
  39168. forEach(callback: (key: string, val: T) => void): void;
  39169. /**
  39170. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39171. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39172. * Note that you can remove any element in this dictionary in the callback implementation
  39173. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39174. * @returns the first item
  39175. */
  39176. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39177. private _count;
  39178. private _data;
  39179. }
  39180. }
  39181. declare module "babylonjs/Collisions/collisionCoordinator" {
  39182. import { Nullable } from "babylonjs/types";
  39183. import { Scene } from "babylonjs/scene";
  39184. import { Vector3 } from "babylonjs/Maths/math.vector";
  39185. import { Collider } from "babylonjs/Collisions/collider";
  39186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39187. /** @hidden */
  39188. export interface ICollisionCoordinator {
  39189. createCollider(): Collider;
  39190. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39191. init(scene: Scene): void;
  39192. }
  39193. /** @hidden */
  39194. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39195. private _scene;
  39196. private _scaledPosition;
  39197. private _scaledVelocity;
  39198. private _finalPosition;
  39199. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39200. createCollider(): Collider;
  39201. init(scene: Scene): void;
  39202. private _collideWithWorld;
  39203. }
  39204. }
  39205. declare module "babylonjs/Inputs/scene.inputManager" {
  39206. import { Nullable } from "babylonjs/types";
  39207. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39208. import { Vector2 } from "babylonjs/Maths/math.vector";
  39209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39210. import { Scene } from "babylonjs/scene";
  39211. /**
  39212. * Class used to manage all inputs for the scene.
  39213. */
  39214. export class InputManager {
  39215. /** The distance in pixel that you have to move to prevent some events */
  39216. static DragMovementThreshold: number;
  39217. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39218. static LongPressDelay: number;
  39219. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39220. static DoubleClickDelay: number;
  39221. /** If you need to check double click without raising a single click at first click, enable this flag */
  39222. static ExclusiveDoubleClickMode: boolean;
  39223. private _wheelEventName;
  39224. private _onPointerMove;
  39225. private _onPointerDown;
  39226. private _onPointerUp;
  39227. private _initClickEvent;
  39228. private _initActionManager;
  39229. private _delayedSimpleClick;
  39230. private _delayedSimpleClickTimeout;
  39231. private _previousDelayedSimpleClickTimeout;
  39232. private _meshPickProceed;
  39233. private _previousButtonPressed;
  39234. private _currentPickResult;
  39235. private _previousPickResult;
  39236. private _totalPointersPressed;
  39237. private _doubleClickOccured;
  39238. private _pointerOverMesh;
  39239. private _pickedDownMesh;
  39240. private _pickedUpMesh;
  39241. private _pointerX;
  39242. private _pointerY;
  39243. private _unTranslatedPointerX;
  39244. private _unTranslatedPointerY;
  39245. private _startingPointerPosition;
  39246. private _previousStartingPointerPosition;
  39247. private _startingPointerTime;
  39248. private _previousStartingPointerTime;
  39249. private _pointerCaptures;
  39250. private _onKeyDown;
  39251. private _onKeyUp;
  39252. private _onCanvasFocusObserver;
  39253. private _onCanvasBlurObserver;
  39254. private _scene;
  39255. /**
  39256. * Creates a new InputManager
  39257. * @param scene defines the hosting scene
  39258. */
  39259. constructor(scene: Scene);
  39260. /**
  39261. * Gets the mesh that is currently under the pointer
  39262. */
  39263. get meshUnderPointer(): Nullable<AbstractMesh>;
  39264. /**
  39265. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39266. */
  39267. get unTranslatedPointer(): Vector2;
  39268. /**
  39269. * Gets or sets the current on-screen X position of the pointer
  39270. */
  39271. get pointerX(): number;
  39272. set pointerX(value: number);
  39273. /**
  39274. * Gets or sets the current on-screen Y position of the pointer
  39275. */
  39276. get pointerY(): number;
  39277. set pointerY(value: number);
  39278. private _updatePointerPosition;
  39279. private _processPointerMove;
  39280. private _setRayOnPointerInfo;
  39281. private _checkPrePointerObservable;
  39282. /**
  39283. * Use this method to simulate a pointer move on a mesh
  39284. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39285. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39286. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39287. */
  39288. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39289. /**
  39290. * Use this method to simulate a pointer down on a mesh
  39291. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39292. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39293. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39294. */
  39295. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39296. private _processPointerDown;
  39297. /** @hidden */
  39298. _isPointerSwiping(): boolean;
  39299. /**
  39300. * Use this method to simulate a pointer up on a mesh
  39301. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39302. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39303. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39304. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39305. */
  39306. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39307. private _processPointerUp;
  39308. /**
  39309. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39310. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39311. * @returns true if the pointer was captured
  39312. */
  39313. isPointerCaptured(pointerId?: number): boolean;
  39314. /**
  39315. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39316. * @param attachUp defines if you want to attach events to pointerup
  39317. * @param attachDown defines if you want to attach events to pointerdown
  39318. * @param attachMove defines if you want to attach events to pointermove
  39319. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39320. */
  39321. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39322. /**
  39323. * Detaches all event handlers
  39324. */
  39325. detachControl(): void;
  39326. /**
  39327. * Force the value of meshUnderPointer
  39328. * @param mesh defines the mesh to use
  39329. */
  39330. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39331. /**
  39332. * Gets the mesh under the pointer
  39333. * @returns a Mesh or null if no mesh is under the pointer
  39334. */
  39335. getPointerOverMesh(): Nullable<AbstractMesh>;
  39336. }
  39337. }
  39338. declare module "babylonjs/Animations/animationGroup" {
  39339. import { Animatable } from "babylonjs/Animations/animatable";
  39340. import { Animation } from "babylonjs/Animations/animation";
  39341. import { Scene, IDisposable } from "babylonjs/scene";
  39342. import { Observable } from "babylonjs/Misc/observable";
  39343. import { Nullable } from "babylonjs/types";
  39344. import "babylonjs/Animations/animatable";
  39345. /**
  39346. * This class defines the direct association between an animation and a target
  39347. */
  39348. export class TargetedAnimation {
  39349. /**
  39350. * Animation to perform
  39351. */
  39352. animation: Animation;
  39353. /**
  39354. * Target to animate
  39355. */
  39356. target: any;
  39357. /**
  39358. * Returns the string "TargetedAnimation"
  39359. * @returns "TargetedAnimation"
  39360. */
  39361. getClassName(): string;
  39362. /**
  39363. * Serialize the object
  39364. * @returns the JSON object representing the current entity
  39365. */
  39366. serialize(): any;
  39367. }
  39368. /**
  39369. * Use this class to create coordinated animations on multiple targets
  39370. */
  39371. export class AnimationGroup implements IDisposable {
  39372. /** The name of the animation group */
  39373. name: string;
  39374. private _scene;
  39375. private _targetedAnimations;
  39376. private _animatables;
  39377. private _from;
  39378. private _to;
  39379. private _isStarted;
  39380. private _isPaused;
  39381. private _speedRatio;
  39382. private _loopAnimation;
  39383. private _isAdditive;
  39384. /**
  39385. * Gets or sets the unique id of the node
  39386. */
  39387. uniqueId: number;
  39388. /**
  39389. * This observable will notify when one animation have ended
  39390. */
  39391. onAnimationEndObservable: Observable<TargetedAnimation>;
  39392. /**
  39393. * Observer raised when one animation loops
  39394. */
  39395. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39396. /**
  39397. * Observer raised when all animations have looped
  39398. */
  39399. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39400. /**
  39401. * This observable will notify when all animations have ended.
  39402. */
  39403. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39404. /**
  39405. * This observable will notify when all animations have paused.
  39406. */
  39407. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39408. /**
  39409. * This observable will notify when all animations are playing.
  39410. */
  39411. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39412. /**
  39413. * Gets the first frame
  39414. */
  39415. get from(): number;
  39416. /**
  39417. * Gets the last frame
  39418. */
  39419. get to(): number;
  39420. /**
  39421. * Define if the animations are started
  39422. */
  39423. get isStarted(): boolean;
  39424. /**
  39425. * Gets a value indicating that the current group is playing
  39426. */
  39427. get isPlaying(): boolean;
  39428. /**
  39429. * Gets or sets the speed ratio to use for all animations
  39430. */
  39431. get speedRatio(): number;
  39432. /**
  39433. * Gets or sets the speed ratio to use for all animations
  39434. */
  39435. set speedRatio(value: number);
  39436. /**
  39437. * Gets or sets if all animations should loop or not
  39438. */
  39439. get loopAnimation(): boolean;
  39440. set loopAnimation(value: boolean);
  39441. /**
  39442. * Gets or sets if all animations should be evaluated additively
  39443. */
  39444. get isAdditive(): boolean;
  39445. set isAdditive(value: boolean);
  39446. /**
  39447. * Gets the targeted animations for this animation group
  39448. */
  39449. get targetedAnimations(): Array<TargetedAnimation>;
  39450. /**
  39451. * returning the list of animatables controlled by this animation group.
  39452. */
  39453. get animatables(): Array<Animatable>;
  39454. /**
  39455. * Gets the list of target animations
  39456. */
  39457. get children(): TargetedAnimation[];
  39458. /**
  39459. * Instantiates a new Animation Group.
  39460. * This helps managing several animations at once.
  39461. * @see https://doc.babylonjs.com/how_to/group
  39462. * @param name Defines the name of the group
  39463. * @param scene Defines the scene the group belongs to
  39464. */
  39465. constructor(
  39466. /** The name of the animation group */
  39467. name: string, scene?: Nullable<Scene>);
  39468. /**
  39469. * Add an animation (with its target) in the group
  39470. * @param animation defines the animation we want to add
  39471. * @param target defines the target of the animation
  39472. * @returns the TargetedAnimation object
  39473. */
  39474. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39475. /**
  39476. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39477. * It can add constant keys at begin or end
  39478. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39479. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39480. * @returns the animation group
  39481. */
  39482. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39483. private _animationLoopCount;
  39484. private _animationLoopFlags;
  39485. private _processLoop;
  39486. /**
  39487. * Start all animations on given targets
  39488. * @param loop defines if animations must loop
  39489. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39490. * @param from defines the from key (optional)
  39491. * @param to defines the to key (optional)
  39492. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39493. * @returns the current animation group
  39494. */
  39495. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39496. /**
  39497. * Pause all animations
  39498. * @returns the animation group
  39499. */
  39500. pause(): AnimationGroup;
  39501. /**
  39502. * Play all animations to initial state
  39503. * This function will start() the animations if they were not started or will restart() them if they were paused
  39504. * @param loop defines if animations must loop
  39505. * @returns the animation group
  39506. */
  39507. play(loop?: boolean): AnimationGroup;
  39508. /**
  39509. * Reset all animations to initial state
  39510. * @returns the animation group
  39511. */
  39512. reset(): AnimationGroup;
  39513. /**
  39514. * Restart animations from key 0
  39515. * @returns the animation group
  39516. */
  39517. restart(): AnimationGroup;
  39518. /**
  39519. * Stop all animations
  39520. * @returns the animation group
  39521. */
  39522. stop(): AnimationGroup;
  39523. /**
  39524. * Set animation weight for all animatables
  39525. * @param weight defines the weight to use
  39526. * @return the animationGroup
  39527. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39528. */
  39529. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39530. /**
  39531. * Synchronize and normalize all animatables with a source animatable
  39532. * @param root defines the root animatable to synchronize with
  39533. * @return the animationGroup
  39534. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39535. */
  39536. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39537. /**
  39538. * Goes to a specific frame in this animation group
  39539. * @param frame the frame number to go to
  39540. * @return the animationGroup
  39541. */
  39542. goToFrame(frame: number): AnimationGroup;
  39543. /**
  39544. * Dispose all associated resources
  39545. */
  39546. dispose(): void;
  39547. private _checkAnimationGroupEnded;
  39548. /**
  39549. * Clone the current animation group and returns a copy
  39550. * @param newName defines the name of the new group
  39551. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39552. * @returns the new aniamtion group
  39553. */
  39554. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39555. /**
  39556. * Serializes the animationGroup to an object
  39557. * @returns Serialized object
  39558. */
  39559. serialize(): any;
  39560. /**
  39561. * Returns a new AnimationGroup object parsed from the source provided.
  39562. * @param parsedAnimationGroup defines the source
  39563. * @param scene defines the scene that will receive the animationGroup
  39564. * @returns a new AnimationGroup
  39565. */
  39566. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39567. /**
  39568. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39569. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39570. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39571. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39572. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39573. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39574. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39575. */
  39576. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39577. /**
  39578. * Returns the string "AnimationGroup"
  39579. * @returns "AnimationGroup"
  39580. */
  39581. getClassName(): string;
  39582. /**
  39583. * Creates a detailled string about the object
  39584. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39585. * @returns a string representing the object
  39586. */
  39587. toString(fullDetails?: boolean): string;
  39588. }
  39589. }
  39590. declare module "babylonjs/scene" {
  39591. import { Nullable } from "babylonjs/types";
  39592. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39593. import { Observable } from "babylonjs/Misc/observable";
  39594. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39595. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39596. import { Geometry } from "babylonjs/Meshes/geometry";
  39597. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39598. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39600. import { Mesh } from "babylonjs/Meshes/mesh";
  39601. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39602. import { Bone } from "babylonjs/Bones/bone";
  39603. import { Skeleton } from "babylonjs/Bones/skeleton";
  39604. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39605. import { Camera } from "babylonjs/Cameras/camera";
  39606. import { AbstractScene } from "babylonjs/abstractScene";
  39607. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39608. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39609. import { Material } from "babylonjs/Materials/material";
  39610. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39611. import { Effect } from "babylonjs/Materials/effect";
  39612. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39613. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39614. import { Light } from "babylonjs/Lights/light";
  39615. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39616. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39617. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39618. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39619. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39620. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39621. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39622. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39623. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39624. import { Engine } from "babylonjs/Engines/engine";
  39625. import { Node } from "babylonjs/node";
  39626. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39627. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39628. import { WebRequest } from "babylonjs/Misc/webRequest";
  39629. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39630. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39631. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39632. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39633. import { Plane } from "babylonjs/Maths/math.plane";
  39634. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39635. import { Ray } from "babylonjs/Culling/ray";
  39636. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39637. import { Animation } from "babylonjs/Animations/animation";
  39638. import { Animatable } from "babylonjs/Animations/animatable";
  39639. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39640. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39641. import { Collider } from "babylonjs/Collisions/collider";
  39642. /**
  39643. * Define an interface for all classes that will hold resources
  39644. */
  39645. export interface IDisposable {
  39646. /**
  39647. * Releases all held resources
  39648. */
  39649. dispose(): void;
  39650. }
  39651. /** Interface defining initialization parameters for Scene class */
  39652. export interface SceneOptions {
  39653. /**
  39654. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39655. * It will improve performance when the number of geometries becomes important.
  39656. */
  39657. useGeometryUniqueIdsMap?: boolean;
  39658. /**
  39659. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39660. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39661. */
  39662. useMaterialMeshMap?: boolean;
  39663. /**
  39664. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39665. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39666. */
  39667. useClonedMeshMap?: boolean;
  39668. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39669. virtual?: boolean;
  39670. }
  39671. /**
  39672. * Represents a scene to be rendered by the engine.
  39673. * @see https://doc.babylonjs.com/features/scene
  39674. */
  39675. export class Scene extends AbstractScene implements IAnimatable {
  39676. /** The fog is deactivated */
  39677. static readonly FOGMODE_NONE: number;
  39678. /** The fog density is following an exponential function */
  39679. static readonly FOGMODE_EXP: number;
  39680. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39681. static readonly FOGMODE_EXP2: number;
  39682. /** The fog density is following a linear function. */
  39683. static readonly FOGMODE_LINEAR: number;
  39684. /**
  39685. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39686. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39687. */
  39688. static MinDeltaTime: number;
  39689. /**
  39690. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39691. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39692. */
  39693. static MaxDeltaTime: number;
  39694. /**
  39695. * Factory used to create the default material.
  39696. * @param name The name of the material to create
  39697. * @param scene The scene to create the material for
  39698. * @returns The default material
  39699. */
  39700. static DefaultMaterialFactory(scene: Scene): Material;
  39701. /**
  39702. * Factory used to create the a collision coordinator.
  39703. * @returns The collision coordinator
  39704. */
  39705. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39706. /** @hidden */
  39707. _inputManager: InputManager;
  39708. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39709. cameraToUseForPointers: Nullable<Camera>;
  39710. /** @hidden */
  39711. readonly _isScene: boolean;
  39712. /** @hidden */
  39713. _blockEntityCollection: boolean;
  39714. /**
  39715. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39716. */
  39717. autoClear: boolean;
  39718. /**
  39719. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39720. */
  39721. autoClearDepthAndStencil: boolean;
  39722. /**
  39723. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39724. */
  39725. clearColor: Color4;
  39726. /**
  39727. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39728. */
  39729. ambientColor: Color3;
  39730. /**
  39731. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39732. * It should only be one of the following (if not the default embedded one):
  39733. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39734. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39735. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39736. * The material properties need to be setup according to the type of texture in use.
  39737. */
  39738. environmentBRDFTexture: BaseTexture;
  39739. /** @hidden */
  39740. protected _environmentTexture: Nullable<BaseTexture>;
  39741. /**
  39742. * Texture used in all pbr material as the reflection texture.
  39743. * As in the majority of the scene they are the same (exception for multi room and so on),
  39744. * this is easier to reference from here than from all the materials.
  39745. */
  39746. get environmentTexture(): Nullable<BaseTexture>;
  39747. /**
  39748. * Texture used in all pbr material as the reflection texture.
  39749. * As in the majority of the scene they are the same (exception for multi room and so on),
  39750. * this is easier to set here than in all the materials.
  39751. */
  39752. set environmentTexture(value: Nullable<BaseTexture>);
  39753. /** @hidden */
  39754. protected _environmentIntensity: number;
  39755. /**
  39756. * Intensity of the environment in all pbr material.
  39757. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39758. * As in the majority of the scene they are the same (exception for multi room and so on),
  39759. * this is easier to reference from here than from all the materials.
  39760. */
  39761. get environmentIntensity(): number;
  39762. /**
  39763. * Intensity of the environment in all pbr material.
  39764. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39765. * As in the majority of the scene they are the same (exception for multi room and so on),
  39766. * this is easier to set here than in all the materials.
  39767. */
  39768. set environmentIntensity(value: number);
  39769. /** @hidden */
  39770. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39771. /**
  39772. * Default image processing configuration used either in the rendering
  39773. * Forward main pass or through the imageProcessingPostProcess if present.
  39774. * As in the majority of the scene they are the same (exception for multi camera),
  39775. * this is easier to reference from here than from all the materials and post process.
  39776. *
  39777. * No setter as we it is a shared configuration, you can set the values instead.
  39778. */
  39779. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39780. private _forceWireframe;
  39781. /**
  39782. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39783. */
  39784. set forceWireframe(value: boolean);
  39785. get forceWireframe(): boolean;
  39786. private _skipFrustumClipping;
  39787. /**
  39788. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39789. */
  39790. set skipFrustumClipping(value: boolean);
  39791. get skipFrustumClipping(): boolean;
  39792. private _forcePointsCloud;
  39793. /**
  39794. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39795. */
  39796. set forcePointsCloud(value: boolean);
  39797. get forcePointsCloud(): boolean;
  39798. /**
  39799. * Gets or sets the active clipplane 1
  39800. */
  39801. clipPlane: Nullable<Plane>;
  39802. /**
  39803. * Gets or sets the active clipplane 2
  39804. */
  39805. clipPlane2: Nullable<Plane>;
  39806. /**
  39807. * Gets or sets the active clipplane 3
  39808. */
  39809. clipPlane3: Nullable<Plane>;
  39810. /**
  39811. * Gets or sets the active clipplane 4
  39812. */
  39813. clipPlane4: Nullable<Plane>;
  39814. /**
  39815. * Gets or sets the active clipplane 5
  39816. */
  39817. clipPlane5: Nullable<Plane>;
  39818. /**
  39819. * Gets or sets the active clipplane 6
  39820. */
  39821. clipPlane6: Nullable<Plane>;
  39822. /**
  39823. * Gets or sets a boolean indicating if animations are enabled
  39824. */
  39825. animationsEnabled: boolean;
  39826. private _animationPropertiesOverride;
  39827. /**
  39828. * Gets or sets the animation properties override
  39829. */
  39830. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39831. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39832. /**
  39833. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39834. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39835. */
  39836. useConstantAnimationDeltaTime: boolean;
  39837. /**
  39838. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39839. * Please note that it requires to run a ray cast through the scene on every frame
  39840. */
  39841. constantlyUpdateMeshUnderPointer: boolean;
  39842. /**
  39843. * Defines the HTML cursor to use when hovering over interactive elements
  39844. */
  39845. hoverCursor: string;
  39846. /**
  39847. * Defines the HTML default cursor to use (empty by default)
  39848. */
  39849. defaultCursor: string;
  39850. /**
  39851. * Defines whether cursors are handled by the scene.
  39852. */
  39853. doNotHandleCursors: boolean;
  39854. /**
  39855. * This is used to call preventDefault() on pointer down
  39856. * in order to block unwanted artifacts like system double clicks
  39857. */
  39858. preventDefaultOnPointerDown: boolean;
  39859. /**
  39860. * This is used to call preventDefault() on pointer up
  39861. * in order to block unwanted artifacts like system double clicks
  39862. */
  39863. preventDefaultOnPointerUp: boolean;
  39864. /**
  39865. * Gets or sets user defined metadata
  39866. */
  39867. metadata: any;
  39868. /**
  39869. * For internal use only. Please do not use.
  39870. */
  39871. reservedDataStore: any;
  39872. /**
  39873. * Gets the name of the plugin used to load this scene (null by default)
  39874. */
  39875. loadingPluginName: string;
  39876. /**
  39877. * Use this array to add regular expressions used to disable offline support for specific urls
  39878. */
  39879. disableOfflineSupportExceptionRules: RegExp[];
  39880. /**
  39881. * An event triggered when the scene is disposed.
  39882. */
  39883. onDisposeObservable: Observable<Scene>;
  39884. private _onDisposeObserver;
  39885. /** Sets a function to be executed when this scene is disposed. */
  39886. set onDispose(callback: () => void);
  39887. /**
  39888. * An event triggered before rendering the scene (right after animations and physics)
  39889. */
  39890. onBeforeRenderObservable: Observable<Scene>;
  39891. private _onBeforeRenderObserver;
  39892. /** Sets a function to be executed before rendering this scene */
  39893. set beforeRender(callback: Nullable<() => void>);
  39894. /**
  39895. * An event triggered after rendering the scene
  39896. */
  39897. onAfterRenderObservable: Observable<Scene>;
  39898. /**
  39899. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39900. */
  39901. onAfterRenderCameraObservable: Observable<Camera>;
  39902. private _onAfterRenderObserver;
  39903. /** Sets a function to be executed after rendering this scene */
  39904. set afterRender(callback: Nullable<() => void>);
  39905. /**
  39906. * An event triggered before animating the scene
  39907. */
  39908. onBeforeAnimationsObservable: Observable<Scene>;
  39909. /**
  39910. * An event triggered after animations processing
  39911. */
  39912. onAfterAnimationsObservable: Observable<Scene>;
  39913. /**
  39914. * An event triggered before draw calls are ready to be sent
  39915. */
  39916. onBeforeDrawPhaseObservable: Observable<Scene>;
  39917. /**
  39918. * An event triggered after draw calls have been sent
  39919. */
  39920. onAfterDrawPhaseObservable: Observable<Scene>;
  39921. /**
  39922. * An event triggered when the scene is ready
  39923. */
  39924. onReadyObservable: Observable<Scene>;
  39925. /**
  39926. * An event triggered before rendering a camera
  39927. */
  39928. onBeforeCameraRenderObservable: Observable<Camera>;
  39929. private _onBeforeCameraRenderObserver;
  39930. /** Sets a function to be executed before rendering a camera*/
  39931. set beforeCameraRender(callback: () => void);
  39932. /**
  39933. * An event triggered after rendering a camera
  39934. */
  39935. onAfterCameraRenderObservable: Observable<Camera>;
  39936. private _onAfterCameraRenderObserver;
  39937. /** Sets a function to be executed after rendering a camera*/
  39938. set afterCameraRender(callback: () => void);
  39939. /**
  39940. * An event triggered when active meshes evaluation is about to start
  39941. */
  39942. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39943. /**
  39944. * An event triggered when active meshes evaluation is done
  39945. */
  39946. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39947. /**
  39948. * An event triggered when particles rendering is about to start
  39949. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39950. */
  39951. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39952. /**
  39953. * An event triggered when particles rendering is done
  39954. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39955. */
  39956. onAfterParticlesRenderingObservable: Observable<Scene>;
  39957. /**
  39958. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39959. */
  39960. onDataLoadedObservable: Observable<Scene>;
  39961. /**
  39962. * An event triggered when a camera is created
  39963. */
  39964. onNewCameraAddedObservable: Observable<Camera>;
  39965. /**
  39966. * An event triggered when a camera is removed
  39967. */
  39968. onCameraRemovedObservable: Observable<Camera>;
  39969. /**
  39970. * An event triggered when a light is created
  39971. */
  39972. onNewLightAddedObservable: Observable<Light>;
  39973. /**
  39974. * An event triggered when a light is removed
  39975. */
  39976. onLightRemovedObservable: Observable<Light>;
  39977. /**
  39978. * An event triggered when a geometry is created
  39979. */
  39980. onNewGeometryAddedObservable: Observable<Geometry>;
  39981. /**
  39982. * An event triggered when a geometry is removed
  39983. */
  39984. onGeometryRemovedObservable: Observable<Geometry>;
  39985. /**
  39986. * An event triggered when a transform node is created
  39987. */
  39988. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39989. /**
  39990. * An event triggered when a transform node is removed
  39991. */
  39992. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39993. /**
  39994. * An event triggered when a mesh is created
  39995. */
  39996. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39997. /**
  39998. * An event triggered when a mesh is removed
  39999. */
  40000. onMeshRemovedObservable: Observable<AbstractMesh>;
  40001. /**
  40002. * An event triggered when a skeleton is created
  40003. */
  40004. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40005. /**
  40006. * An event triggered when a skeleton is removed
  40007. */
  40008. onSkeletonRemovedObservable: Observable<Skeleton>;
  40009. /**
  40010. * An event triggered when a material is created
  40011. */
  40012. onNewMaterialAddedObservable: Observable<Material>;
  40013. /**
  40014. * An event triggered when a material is removed
  40015. */
  40016. onMaterialRemovedObservable: Observable<Material>;
  40017. /**
  40018. * An event triggered when a texture is created
  40019. */
  40020. onNewTextureAddedObservable: Observable<BaseTexture>;
  40021. /**
  40022. * An event triggered when a texture is removed
  40023. */
  40024. onTextureRemovedObservable: Observable<BaseTexture>;
  40025. /**
  40026. * An event triggered when render targets are about to be rendered
  40027. * Can happen multiple times per frame.
  40028. */
  40029. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40030. /**
  40031. * An event triggered when render targets were rendered.
  40032. * Can happen multiple times per frame.
  40033. */
  40034. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40035. /**
  40036. * An event triggered before calculating deterministic simulation step
  40037. */
  40038. onBeforeStepObservable: Observable<Scene>;
  40039. /**
  40040. * An event triggered after calculating deterministic simulation step
  40041. */
  40042. onAfterStepObservable: Observable<Scene>;
  40043. /**
  40044. * An event triggered when the activeCamera property is updated
  40045. */
  40046. onActiveCameraChanged: Observable<Scene>;
  40047. /**
  40048. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40049. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40050. * 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)
  40051. */
  40052. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40053. /**
  40054. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40055. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40056. * 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)
  40057. */
  40058. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40059. /**
  40060. * This Observable will when a mesh has been imported into the scene.
  40061. */
  40062. onMeshImportedObservable: Observable<AbstractMesh>;
  40063. /**
  40064. * This Observable will when an animation file has been imported into the scene.
  40065. */
  40066. onAnimationFileImportedObservable: Observable<Scene>;
  40067. /**
  40068. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40069. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40070. */
  40071. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40072. /** @hidden */
  40073. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40074. /**
  40075. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40076. */
  40077. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40078. /**
  40079. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40080. */
  40081. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40082. /**
  40083. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40084. */
  40085. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40086. /** Callback called when a pointer move is detected */
  40087. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40088. /** Callback called when a pointer down is detected */
  40089. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40090. /** Callback called when a pointer up is detected */
  40091. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40092. /** Callback called when a pointer pick is detected */
  40093. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40094. /**
  40095. * 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).
  40096. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40097. */
  40098. onPrePointerObservable: Observable<PointerInfoPre>;
  40099. /**
  40100. * Observable event triggered each time an input event is received from the rendering canvas
  40101. */
  40102. onPointerObservable: Observable<PointerInfo>;
  40103. /**
  40104. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40105. */
  40106. get unTranslatedPointer(): Vector2;
  40107. /**
  40108. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40109. */
  40110. static get DragMovementThreshold(): number;
  40111. static set DragMovementThreshold(value: number);
  40112. /**
  40113. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40114. */
  40115. static get LongPressDelay(): number;
  40116. static set LongPressDelay(value: number);
  40117. /**
  40118. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40119. */
  40120. static get DoubleClickDelay(): number;
  40121. static set DoubleClickDelay(value: number);
  40122. /** If you need to check double click without raising a single click at first click, enable this flag */
  40123. static get ExclusiveDoubleClickMode(): boolean;
  40124. static set ExclusiveDoubleClickMode(value: boolean);
  40125. /** @hidden */
  40126. _mirroredCameraPosition: Nullable<Vector3>;
  40127. /**
  40128. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40129. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40130. */
  40131. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40132. /**
  40133. * Observable event triggered each time an keyboard event is received from the hosting window
  40134. */
  40135. onKeyboardObservable: Observable<KeyboardInfo>;
  40136. private _useRightHandedSystem;
  40137. /**
  40138. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40139. */
  40140. set useRightHandedSystem(value: boolean);
  40141. get useRightHandedSystem(): boolean;
  40142. private _timeAccumulator;
  40143. private _currentStepId;
  40144. private _currentInternalStep;
  40145. /**
  40146. * Sets the step Id used by deterministic lock step
  40147. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40148. * @param newStepId defines the step Id
  40149. */
  40150. setStepId(newStepId: number): void;
  40151. /**
  40152. * Gets the step Id used by deterministic lock step
  40153. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40154. * @returns the step Id
  40155. */
  40156. getStepId(): number;
  40157. /**
  40158. * Gets the internal step used by deterministic lock step
  40159. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40160. * @returns the internal step
  40161. */
  40162. getInternalStep(): number;
  40163. private _fogEnabled;
  40164. /**
  40165. * Gets or sets a boolean indicating if fog is enabled on this scene
  40166. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40167. * (Default is true)
  40168. */
  40169. set fogEnabled(value: boolean);
  40170. get fogEnabled(): boolean;
  40171. private _fogMode;
  40172. /**
  40173. * Gets or sets the fog mode to use
  40174. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40175. * | mode | value |
  40176. * | --- | --- |
  40177. * | FOGMODE_NONE | 0 |
  40178. * | FOGMODE_EXP | 1 |
  40179. * | FOGMODE_EXP2 | 2 |
  40180. * | FOGMODE_LINEAR | 3 |
  40181. */
  40182. set fogMode(value: number);
  40183. get fogMode(): number;
  40184. /**
  40185. * Gets or sets the fog color to use
  40186. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40187. * (Default is Color3(0.2, 0.2, 0.3))
  40188. */
  40189. fogColor: Color3;
  40190. /**
  40191. * Gets or sets the fog density to use
  40192. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40193. * (Default is 0.1)
  40194. */
  40195. fogDensity: number;
  40196. /**
  40197. * Gets or sets the fog start distance to use
  40198. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40199. * (Default is 0)
  40200. */
  40201. fogStart: number;
  40202. /**
  40203. * Gets or sets the fog end distance to use
  40204. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40205. * (Default is 1000)
  40206. */
  40207. fogEnd: number;
  40208. /**
  40209. * Flag indicating that the frame buffer binding is handled by another component
  40210. */
  40211. prePass: boolean;
  40212. private _shadowsEnabled;
  40213. /**
  40214. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40215. */
  40216. set shadowsEnabled(value: boolean);
  40217. get shadowsEnabled(): boolean;
  40218. private _lightsEnabled;
  40219. /**
  40220. * Gets or sets a boolean indicating if lights are enabled on this scene
  40221. */
  40222. set lightsEnabled(value: boolean);
  40223. get lightsEnabled(): boolean;
  40224. /** All of the active cameras added to this scene. */
  40225. activeCameras: Camera[];
  40226. /** @hidden */
  40227. _activeCamera: Nullable<Camera>;
  40228. /** Gets or sets the current active camera */
  40229. get activeCamera(): Nullable<Camera>;
  40230. set activeCamera(value: Nullable<Camera>);
  40231. private _defaultMaterial;
  40232. /** The default material used on meshes when no material is affected */
  40233. get defaultMaterial(): Material;
  40234. /** The default material used on meshes when no material is affected */
  40235. set defaultMaterial(value: Material);
  40236. private _texturesEnabled;
  40237. /**
  40238. * Gets or sets a boolean indicating if textures are enabled on this scene
  40239. */
  40240. set texturesEnabled(value: boolean);
  40241. get texturesEnabled(): boolean;
  40242. /**
  40243. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40244. */
  40245. physicsEnabled: boolean;
  40246. /**
  40247. * Gets or sets a boolean indicating if particles are enabled on this scene
  40248. */
  40249. particlesEnabled: boolean;
  40250. /**
  40251. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40252. */
  40253. spritesEnabled: boolean;
  40254. private _skeletonsEnabled;
  40255. /**
  40256. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40257. */
  40258. set skeletonsEnabled(value: boolean);
  40259. get skeletonsEnabled(): boolean;
  40260. /**
  40261. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40262. */
  40263. lensFlaresEnabled: boolean;
  40264. /**
  40265. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40266. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40267. */
  40268. collisionsEnabled: boolean;
  40269. private _collisionCoordinator;
  40270. /** @hidden */
  40271. get collisionCoordinator(): ICollisionCoordinator;
  40272. /**
  40273. * Defines the gravity applied to this scene (used only for collisions)
  40274. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40275. */
  40276. gravity: Vector3;
  40277. /**
  40278. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40279. */
  40280. postProcessesEnabled: boolean;
  40281. /**
  40282. * The list of postprocesses added to the scene
  40283. */
  40284. postProcesses: PostProcess[];
  40285. /**
  40286. * Gets the current postprocess manager
  40287. */
  40288. postProcessManager: PostProcessManager;
  40289. /**
  40290. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40291. */
  40292. renderTargetsEnabled: boolean;
  40293. /**
  40294. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40295. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40296. */
  40297. dumpNextRenderTargets: boolean;
  40298. /**
  40299. * The list of user defined render targets added to the scene
  40300. */
  40301. customRenderTargets: RenderTargetTexture[];
  40302. /**
  40303. * Defines if texture loading must be delayed
  40304. * If true, textures will only be loaded when they need to be rendered
  40305. */
  40306. useDelayedTextureLoading: boolean;
  40307. /**
  40308. * Gets the list of meshes imported to the scene through SceneLoader
  40309. */
  40310. importedMeshesFiles: String[];
  40311. /**
  40312. * Gets or sets a boolean indicating if probes are enabled on this scene
  40313. */
  40314. probesEnabled: boolean;
  40315. /**
  40316. * Gets or sets the current offline provider to use to store scene data
  40317. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40318. */
  40319. offlineProvider: IOfflineProvider;
  40320. /**
  40321. * Gets or sets the action manager associated with the scene
  40322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40323. */
  40324. actionManager: AbstractActionManager;
  40325. private _meshesForIntersections;
  40326. /**
  40327. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40328. */
  40329. proceduralTexturesEnabled: boolean;
  40330. private _engine;
  40331. private _totalVertices;
  40332. /** @hidden */
  40333. _activeIndices: PerfCounter;
  40334. /** @hidden */
  40335. _activeParticles: PerfCounter;
  40336. /** @hidden */
  40337. _activeBones: PerfCounter;
  40338. private _animationRatio;
  40339. /** @hidden */
  40340. _animationTimeLast: number;
  40341. /** @hidden */
  40342. _animationTime: number;
  40343. /**
  40344. * Gets or sets a general scale for animation speed
  40345. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40346. */
  40347. animationTimeScale: number;
  40348. /** @hidden */
  40349. _cachedMaterial: Nullable<Material>;
  40350. /** @hidden */
  40351. _cachedEffect: Nullable<Effect>;
  40352. /** @hidden */
  40353. _cachedVisibility: Nullable<number>;
  40354. private _renderId;
  40355. private _frameId;
  40356. private _executeWhenReadyTimeoutId;
  40357. private _intermediateRendering;
  40358. private _viewUpdateFlag;
  40359. private _projectionUpdateFlag;
  40360. /** @hidden */
  40361. _toBeDisposed: Nullable<IDisposable>[];
  40362. private _activeRequests;
  40363. /** @hidden */
  40364. _pendingData: any[];
  40365. private _isDisposed;
  40366. /**
  40367. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40368. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40369. */
  40370. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40371. private _activeMeshes;
  40372. private _processedMaterials;
  40373. private _renderTargets;
  40374. /** @hidden */
  40375. _activeParticleSystems: SmartArray<IParticleSystem>;
  40376. private _activeSkeletons;
  40377. private _softwareSkinnedMeshes;
  40378. private _renderingManager;
  40379. /** @hidden */
  40380. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40381. private _transformMatrix;
  40382. private _sceneUbo;
  40383. /** @hidden */
  40384. _viewMatrix: Matrix;
  40385. private _projectionMatrix;
  40386. /** @hidden */
  40387. _forcedViewPosition: Nullable<Vector3>;
  40388. /** @hidden */
  40389. _frustumPlanes: Plane[];
  40390. /**
  40391. * Gets the list of frustum planes (built from the active camera)
  40392. */
  40393. get frustumPlanes(): Plane[];
  40394. /**
  40395. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40396. * This is useful if there are more lights that the maximum simulteanous authorized
  40397. */
  40398. requireLightSorting: boolean;
  40399. /** @hidden */
  40400. readonly useMaterialMeshMap: boolean;
  40401. /** @hidden */
  40402. readonly useClonedMeshMap: boolean;
  40403. private _externalData;
  40404. private _uid;
  40405. /**
  40406. * @hidden
  40407. * Backing store of defined scene components.
  40408. */
  40409. _components: ISceneComponent[];
  40410. /**
  40411. * @hidden
  40412. * Backing store of defined scene components.
  40413. */
  40414. _serializableComponents: ISceneSerializableComponent[];
  40415. /**
  40416. * List of components to register on the next registration step.
  40417. */
  40418. private _transientComponents;
  40419. /**
  40420. * Registers the transient components if needed.
  40421. */
  40422. private _registerTransientComponents;
  40423. /**
  40424. * @hidden
  40425. * Add a component to the scene.
  40426. * Note that the ccomponent could be registered on th next frame if this is called after
  40427. * the register component stage.
  40428. * @param component Defines the component to add to the scene
  40429. */
  40430. _addComponent(component: ISceneComponent): void;
  40431. /**
  40432. * @hidden
  40433. * Gets a component from the scene.
  40434. * @param name defines the name of the component to retrieve
  40435. * @returns the component or null if not present
  40436. */
  40437. _getComponent(name: string): Nullable<ISceneComponent>;
  40438. /**
  40439. * @hidden
  40440. * Defines the actions happening before camera updates.
  40441. */
  40442. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40443. /**
  40444. * @hidden
  40445. * Defines the actions happening before clear the canvas.
  40446. */
  40447. _beforeClearStage: Stage<SimpleStageAction>;
  40448. /**
  40449. * @hidden
  40450. * Defines the actions when collecting render targets for the frame.
  40451. */
  40452. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40453. /**
  40454. * @hidden
  40455. * Defines the actions happening for one camera in the frame.
  40456. */
  40457. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40458. /**
  40459. * @hidden
  40460. * Defines the actions happening during the per mesh ready checks.
  40461. */
  40462. _isReadyForMeshStage: Stage<MeshStageAction>;
  40463. /**
  40464. * @hidden
  40465. * Defines the actions happening before evaluate active mesh checks.
  40466. */
  40467. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40468. /**
  40469. * @hidden
  40470. * Defines the actions happening during the evaluate sub mesh checks.
  40471. */
  40472. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40473. /**
  40474. * @hidden
  40475. * Defines the actions happening during the active mesh stage.
  40476. */
  40477. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40478. /**
  40479. * @hidden
  40480. * Defines the actions happening during the per camera render target step.
  40481. */
  40482. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40483. /**
  40484. * @hidden
  40485. * Defines the actions happening just before the active camera is drawing.
  40486. */
  40487. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40488. /**
  40489. * @hidden
  40490. * Defines the actions happening just before a render target is drawing.
  40491. */
  40492. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40493. /**
  40494. * @hidden
  40495. * Defines the actions happening just before a rendering group is drawing.
  40496. */
  40497. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40498. /**
  40499. * @hidden
  40500. * Defines the actions happening just before a mesh is drawing.
  40501. */
  40502. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40503. /**
  40504. * @hidden
  40505. * Defines the actions happening just after a mesh has been drawn.
  40506. */
  40507. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40508. /**
  40509. * @hidden
  40510. * Defines the actions happening just after a rendering group has been drawn.
  40511. */
  40512. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40513. /**
  40514. * @hidden
  40515. * Defines the actions happening just after the active camera has been drawn.
  40516. */
  40517. _afterCameraDrawStage: Stage<CameraStageAction>;
  40518. /**
  40519. * @hidden
  40520. * Defines the actions happening just after a render target has been drawn.
  40521. */
  40522. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40523. /**
  40524. * @hidden
  40525. * Defines the actions happening just after rendering all cameras and computing intersections.
  40526. */
  40527. _afterRenderStage: Stage<SimpleStageAction>;
  40528. /**
  40529. * @hidden
  40530. * Defines the actions happening when a pointer move event happens.
  40531. */
  40532. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40533. /**
  40534. * @hidden
  40535. * Defines the actions happening when a pointer down event happens.
  40536. */
  40537. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40538. /**
  40539. * @hidden
  40540. * Defines the actions happening when a pointer up event happens.
  40541. */
  40542. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40543. /**
  40544. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40545. */
  40546. private geometriesByUniqueId;
  40547. /**
  40548. * Creates a new Scene
  40549. * @param engine defines the engine to use to render this scene
  40550. * @param options defines the scene options
  40551. */
  40552. constructor(engine: Engine, options?: SceneOptions);
  40553. /**
  40554. * Gets a string idenfifying the name of the class
  40555. * @returns "Scene" string
  40556. */
  40557. getClassName(): string;
  40558. private _defaultMeshCandidates;
  40559. /**
  40560. * @hidden
  40561. */
  40562. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40563. private _defaultSubMeshCandidates;
  40564. /**
  40565. * @hidden
  40566. */
  40567. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40568. /**
  40569. * Sets the default candidate providers for the scene.
  40570. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40571. * and getCollidingSubMeshCandidates to their default function
  40572. */
  40573. setDefaultCandidateProviders(): void;
  40574. /**
  40575. * Gets the mesh that is currently under the pointer
  40576. */
  40577. get meshUnderPointer(): Nullable<AbstractMesh>;
  40578. /**
  40579. * Gets or sets the current on-screen X position of the pointer
  40580. */
  40581. get pointerX(): number;
  40582. set pointerX(value: number);
  40583. /**
  40584. * Gets or sets the current on-screen Y position of the pointer
  40585. */
  40586. get pointerY(): number;
  40587. set pointerY(value: number);
  40588. /**
  40589. * Gets the cached material (ie. the latest rendered one)
  40590. * @returns the cached material
  40591. */
  40592. getCachedMaterial(): Nullable<Material>;
  40593. /**
  40594. * Gets the cached effect (ie. the latest rendered one)
  40595. * @returns the cached effect
  40596. */
  40597. getCachedEffect(): Nullable<Effect>;
  40598. /**
  40599. * Gets the cached visibility state (ie. the latest rendered one)
  40600. * @returns the cached visibility state
  40601. */
  40602. getCachedVisibility(): Nullable<number>;
  40603. /**
  40604. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40605. * @param material defines the current material
  40606. * @param effect defines the current effect
  40607. * @param visibility defines the current visibility state
  40608. * @returns true if one parameter is not cached
  40609. */
  40610. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40611. /**
  40612. * Gets the engine associated with the scene
  40613. * @returns an Engine
  40614. */
  40615. getEngine(): Engine;
  40616. /**
  40617. * Gets the total number of vertices rendered per frame
  40618. * @returns the total number of vertices rendered per frame
  40619. */
  40620. getTotalVertices(): number;
  40621. /**
  40622. * Gets the performance counter for total vertices
  40623. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40624. */
  40625. get totalVerticesPerfCounter(): PerfCounter;
  40626. /**
  40627. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40628. * @returns the total number of active indices rendered per frame
  40629. */
  40630. getActiveIndices(): number;
  40631. /**
  40632. * Gets the performance counter for active indices
  40633. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40634. */
  40635. get totalActiveIndicesPerfCounter(): PerfCounter;
  40636. /**
  40637. * Gets the total number of active particles rendered per frame
  40638. * @returns the total number of active particles rendered per frame
  40639. */
  40640. getActiveParticles(): number;
  40641. /**
  40642. * Gets the performance counter for active particles
  40643. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40644. */
  40645. get activeParticlesPerfCounter(): PerfCounter;
  40646. /**
  40647. * Gets the total number of active bones rendered per frame
  40648. * @returns the total number of active bones rendered per frame
  40649. */
  40650. getActiveBones(): number;
  40651. /**
  40652. * Gets the performance counter for active bones
  40653. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40654. */
  40655. get activeBonesPerfCounter(): PerfCounter;
  40656. /**
  40657. * Gets the array of active meshes
  40658. * @returns an array of AbstractMesh
  40659. */
  40660. getActiveMeshes(): SmartArray<AbstractMesh>;
  40661. /**
  40662. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40663. * @returns a number
  40664. */
  40665. getAnimationRatio(): number;
  40666. /**
  40667. * Gets an unique Id for the current render phase
  40668. * @returns a number
  40669. */
  40670. getRenderId(): number;
  40671. /**
  40672. * Gets an unique Id for the current frame
  40673. * @returns a number
  40674. */
  40675. getFrameId(): number;
  40676. /** Call this function if you want to manually increment the render Id*/
  40677. incrementRenderId(): void;
  40678. private _createUbo;
  40679. /**
  40680. * Use this method to simulate a pointer move on a mesh
  40681. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40682. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40683. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40684. * @returns the current scene
  40685. */
  40686. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40687. /**
  40688. * Use this method to simulate a pointer down on a mesh
  40689. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40690. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40691. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40692. * @returns the current scene
  40693. */
  40694. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40695. /**
  40696. * Use this method to simulate a pointer up on a mesh
  40697. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40698. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40699. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40700. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40701. * @returns the current scene
  40702. */
  40703. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40704. /**
  40705. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40706. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40707. * @returns true if the pointer was captured
  40708. */
  40709. isPointerCaptured(pointerId?: number): boolean;
  40710. /**
  40711. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40712. * @param attachUp defines if you want to attach events to pointerup
  40713. * @param attachDown defines if you want to attach events to pointerdown
  40714. * @param attachMove defines if you want to attach events to pointermove
  40715. */
  40716. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40717. /** Detaches all event handlers*/
  40718. detachControl(): void;
  40719. /**
  40720. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40721. * Delay loaded resources are not taking in account
  40722. * @return true if all required resources are ready
  40723. */
  40724. isReady(): boolean;
  40725. /** Resets all cached information relative to material (including effect and visibility) */
  40726. resetCachedMaterial(): void;
  40727. /**
  40728. * Registers a function to be called before every frame render
  40729. * @param func defines the function to register
  40730. */
  40731. registerBeforeRender(func: () => void): void;
  40732. /**
  40733. * Unregisters a function called before every frame render
  40734. * @param func defines the function to unregister
  40735. */
  40736. unregisterBeforeRender(func: () => void): void;
  40737. /**
  40738. * Registers a function to be called after every frame render
  40739. * @param func defines the function to register
  40740. */
  40741. registerAfterRender(func: () => void): void;
  40742. /**
  40743. * Unregisters a function called after every frame render
  40744. * @param func defines the function to unregister
  40745. */
  40746. unregisterAfterRender(func: () => void): void;
  40747. private _executeOnceBeforeRender;
  40748. /**
  40749. * The provided function will run before render once and will be disposed afterwards.
  40750. * A timeout delay can be provided so that the function will be executed in N ms.
  40751. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40752. * @param func The function to be executed.
  40753. * @param timeout optional delay in ms
  40754. */
  40755. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40756. /** @hidden */
  40757. _addPendingData(data: any): void;
  40758. /** @hidden */
  40759. _removePendingData(data: any): void;
  40760. /**
  40761. * Returns the number of items waiting to be loaded
  40762. * @returns the number of items waiting to be loaded
  40763. */
  40764. getWaitingItemsCount(): number;
  40765. /**
  40766. * Returns a boolean indicating if the scene is still loading data
  40767. */
  40768. get isLoading(): boolean;
  40769. /**
  40770. * Registers a function to be executed when the scene is ready
  40771. * @param {Function} func - the function to be executed
  40772. */
  40773. executeWhenReady(func: () => void): void;
  40774. /**
  40775. * Returns a promise that resolves when the scene is ready
  40776. * @returns A promise that resolves when the scene is ready
  40777. */
  40778. whenReadyAsync(): Promise<void>;
  40779. /** @hidden */
  40780. _checkIsReady(): void;
  40781. /**
  40782. * Gets all animatable attached to the scene
  40783. */
  40784. get animatables(): Animatable[];
  40785. /**
  40786. * Resets the last animation time frame.
  40787. * Useful to override when animations start running when loading a scene for the first time.
  40788. */
  40789. resetLastAnimationTimeFrame(): void;
  40790. /**
  40791. * Gets the current view matrix
  40792. * @returns a Matrix
  40793. */
  40794. getViewMatrix(): Matrix;
  40795. /**
  40796. * Gets the current projection matrix
  40797. * @returns a Matrix
  40798. */
  40799. getProjectionMatrix(): Matrix;
  40800. /**
  40801. * Gets the current transform matrix
  40802. * @returns a Matrix made of View * Projection
  40803. */
  40804. getTransformMatrix(): Matrix;
  40805. /**
  40806. * Sets the current transform matrix
  40807. * @param viewL defines the View matrix to use
  40808. * @param projectionL defines the Projection matrix to use
  40809. * @param viewR defines the right View matrix to use (if provided)
  40810. * @param projectionR defines the right Projection matrix to use (if provided)
  40811. */
  40812. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40813. /**
  40814. * Gets the uniform buffer used to store scene data
  40815. * @returns a UniformBuffer
  40816. */
  40817. getSceneUniformBuffer(): UniformBuffer;
  40818. /**
  40819. * Gets an unique (relatively to the current scene) Id
  40820. * @returns an unique number for the scene
  40821. */
  40822. getUniqueId(): number;
  40823. /**
  40824. * Add a mesh to the list of scene's meshes
  40825. * @param newMesh defines the mesh to add
  40826. * @param recursive if all child meshes should also be added to the scene
  40827. */
  40828. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40829. /**
  40830. * Remove a mesh for the list of scene's meshes
  40831. * @param toRemove defines the mesh to remove
  40832. * @param recursive if all child meshes should also be removed from the scene
  40833. * @returns the index where the mesh was in the mesh list
  40834. */
  40835. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40836. /**
  40837. * Add a transform node to the list of scene's transform nodes
  40838. * @param newTransformNode defines the transform node to add
  40839. */
  40840. addTransformNode(newTransformNode: TransformNode): void;
  40841. /**
  40842. * Remove a transform node for the list of scene's transform nodes
  40843. * @param toRemove defines the transform node to remove
  40844. * @returns the index where the transform node was in the transform node list
  40845. */
  40846. removeTransformNode(toRemove: TransformNode): number;
  40847. /**
  40848. * Remove a skeleton for the list of scene's skeletons
  40849. * @param toRemove defines the skeleton to remove
  40850. * @returns the index where the skeleton was in the skeleton list
  40851. */
  40852. removeSkeleton(toRemove: Skeleton): number;
  40853. /**
  40854. * Remove a morph target for the list of scene's morph targets
  40855. * @param toRemove defines the morph target to remove
  40856. * @returns the index where the morph target was in the morph target list
  40857. */
  40858. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40859. /**
  40860. * Remove a light for the list of scene's lights
  40861. * @param toRemove defines the light to remove
  40862. * @returns the index where the light was in the light list
  40863. */
  40864. removeLight(toRemove: Light): number;
  40865. /**
  40866. * Remove a camera for the list of scene's cameras
  40867. * @param toRemove defines the camera to remove
  40868. * @returns the index where the camera was in the camera list
  40869. */
  40870. removeCamera(toRemove: Camera): number;
  40871. /**
  40872. * Remove a particle system for the list of scene's particle systems
  40873. * @param toRemove defines the particle system to remove
  40874. * @returns the index where the particle system was in the particle system list
  40875. */
  40876. removeParticleSystem(toRemove: IParticleSystem): number;
  40877. /**
  40878. * Remove a animation for the list of scene's animations
  40879. * @param toRemove defines the animation to remove
  40880. * @returns the index where the animation was in the animation list
  40881. */
  40882. removeAnimation(toRemove: Animation): number;
  40883. /**
  40884. * Will stop the animation of the given target
  40885. * @param target - the target
  40886. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40887. * @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)
  40888. */
  40889. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40890. /**
  40891. * Removes the given animation group from this scene.
  40892. * @param toRemove The animation group to remove
  40893. * @returns The index of the removed animation group
  40894. */
  40895. removeAnimationGroup(toRemove: AnimationGroup): number;
  40896. /**
  40897. * Removes the given multi-material from this scene.
  40898. * @param toRemove The multi-material to remove
  40899. * @returns The index of the removed multi-material
  40900. */
  40901. removeMultiMaterial(toRemove: MultiMaterial): number;
  40902. /**
  40903. * Removes the given material from this scene.
  40904. * @param toRemove The material to remove
  40905. * @returns The index of the removed material
  40906. */
  40907. removeMaterial(toRemove: Material): number;
  40908. /**
  40909. * Removes the given action manager from this scene.
  40910. * @param toRemove The action manager to remove
  40911. * @returns The index of the removed action manager
  40912. */
  40913. removeActionManager(toRemove: AbstractActionManager): number;
  40914. /**
  40915. * Removes the given texture from this scene.
  40916. * @param toRemove The texture to remove
  40917. * @returns The index of the removed texture
  40918. */
  40919. removeTexture(toRemove: BaseTexture): number;
  40920. /**
  40921. * Adds the given light to this scene
  40922. * @param newLight The light to add
  40923. */
  40924. addLight(newLight: Light): void;
  40925. /**
  40926. * Sorts the list list based on light priorities
  40927. */
  40928. sortLightsByPriority(): void;
  40929. /**
  40930. * Adds the given camera to this scene
  40931. * @param newCamera The camera to add
  40932. */
  40933. addCamera(newCamera: Camera): void;
  40934. /**
  40935. * Adds the given skeleton to this scene
  40936. * @param newSkeleton The skeleton to add
  40937. */
  40938. addSkeleton(newSkeleton: Skeleton): void;
  40939. /**
  40940. * Adds the given particle system to this scene
  40941. * @param newParticleSystem The particle system to add
  40942. */
  40943. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40944. /**
  40945. * Adds the given animation to this scene
  40946. * @param newAnimation The animation to add
  40947. */
  40948. addAnimation(newAnimation: Animation): void;
  40949. /**
  40950. * Adds the given animation group to this scene.
  40951. * @param newAnimationGroup The animation group to add
  40952. */
  40953. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40954. /**
  40955. * Adds the given multi-material to this scene
  40956. * @param newMultiMaterial The multi-material to add
  40957. */
  40958. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40959. /**
  40960. * Adds the given material to this scene
  40961. * @param newMaterial The material to add
  40962. */
  40963. addMaterial(newMaterial: Material): void;
  40964. /**
  40965. * Adds the given morph target to this scene
  40966. * @param newMorphTargetManager The morph target to add
  40967. */
  40968. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40969. /**
  40970. * Adds the given geometry to this scene
  40971. * @param newGeometry The geometry to add
  40972. */
  40973. addGeometry(newGeometry: Geometry): void;
  40974. /**
  40975. * Adds the given action manager to this scene
  40976. * @param newActionManager The action manager to add
  40977. */
  40978. addActionManager(newActionManager: AbstractActionManager): void;
  40979. /**
  40980. * Adds the given texture to this scene.
  40981. * @param newTexture The texture to add
  40982. */
  40983. addTexture(newTexture: BaseTexture): void;
  40984. /**
  40985. * Switch active camera
  40986. * @param newCamera defines the new active camera
  40987. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40988. */
  40989. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40990. /**
  40991. * sets the active camera of the scene using its ID
  40992. * @param id defines the camera's ID
  40993. * @return the new active camera or null if none found.
  40994. */
  40995. setActiveCameraByID(id: string): Nullable<Camera>;
  40996. /**
  40997. * sets the active camera of the scene using its name
  40998. * @param name defines the camera's name
  40999. * @returns the new active camera or null if none found.
  41000. */
  41001. setActiveCameraByName(name: string): Nullable<Camera>;
  41002. /**
  41003. * get an animation group using its name
  41004. * @param name defines the material's name
  41005. * @return the animation group or null if none found.
  41006. */
  41007. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41008. /**
  41009. * Get a material using its unique id
  41010. * @param uniqueId defines the material's unique id
  41011. * @return the material or null if none found.
  41012. */
  41013. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41014. /**
  41015. * get a material using its id
  41016. * @param id defines the material's ID
  41017. * @return the material or null if none found.
  41018. */
  41019. getMaterialByID(id: string): Nullable<Material>;
  41020. /**
  41021. * Gets a the last added material using a given id
  41022. * @param id defines the material's ID
  41023. * @return the last material with the given id or null if none found.
  41024. */
  41025. getLastMaterialByID(id: string): Nullable<Material>;
  41026. /**
  41027. * Gets a material using its name
  41028. * @param name defines the material's name
  41029. * @return the material or null if none found.
  41030. */
  41031. getMaterialByName(name: string): Nullable<Material>;
  41032. /**
  41033. * Get a texture using its unique id
  41034. * @param uniqueId defines the texture's unique id
  41035. * @return the texture or null if none found.
  41036. */
  41037. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41038. /**
  41039. * Gets a camera using its id
  41040. * @param id defines the id to look for
  41041. * @returns the camera or null if not found
  41042. */
  41043. getCameraByID(id: string): Nullable<Camera>;
  41044. /**
  41045. * Gets a camera using its unique id
  41046. * @param uniqueId defines the unique id to look for
  41047. * @returns the camera or null if not found
  41048. */
  41049. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41050. /**
  41051. * Gets a camera using its name
  41052. * @param name defines the camera's name
  41053. * @return the camera or null if none found.
  41054. */
  41055. getCameraByName(name: string): Nullable<Camera>;
  41056. /**
  41057. * Gets a bone using its id
  41058. * @param id defines the bone's id
  41059. * @return the bone or null if not found
  41060. */
  41061. getBoneByID(id: string): Nullable<Bone>;
  41062. /**
  41063. * Gets a bone using its id
  41064. * @param name defines the bone's name
  41065. * @return the bone or null if not found
  41066. */
  41067. getBoneByName(name: string): Nullable<Bone>;
  41068. /**
  41069. * Gets a light node using its name
  41070. * @param name defines the the light's name
  41071. * @return the light or null if none found.
  41072. */
  41073. getLightByName(name: string): Nullable<Light>;
  41074. /**
  41075. * Gets a light node using its id
  41076. * @param id defines the light's id
  41077. * @return the light or null if none found.
  41078. */
  41079. getLightByID(id: string): Nullable<Light>;
  41080. /**
  41081. * Gets a light node using its scene-generated unique ID
  41082. * @param uniqueId defines the light's unique id
  41083. * @return the light or null if none found.
  41084. */
  41085. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41086. /**
  41087. * Gets a particle system by id
  41088. * @param id defines the particle system id
  41089. * @return the corresponding system or null if none found
  41090. */
  41091. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41092. /**
  41093. * Gets a geometry using its ID
  41094. * @param id defines the geometry's id
  41095. * @return the geometry or null if none found.
  41096. */
  41097. getGeometryByID(id: string): Nullable<Geometry>;
  41098. private _getGeometryByUniqueID;
  41099. /**
  41100. * Add a new geometry to this scene
  41101. * @param geometry defines the geometry to be added to the scene.
  41102. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41103. * @return a boolean defining if the geometry was added or not
  41104. */
  41105. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41106. /**
  41107. * Removes an existing geometry
  41108. * @param geometry defines the geometry to be removed from the scene
  41109. * @return a boolean defining if the geometry was removed or not
  41110. */
  41111. removeGeometry(geometry: Geometry): boolean;
  41112. /**
  41113. * Gets the list of geometries attached to the scene
  41114. * @returns an array of Geometry
  41115. */
  41116. getGeometries(): Geometry[];
  41117. /**
  41118. * Gets the first added mesh found of a given ID
  41119. * @param id defines the id to search for
  41120. * @return the mesh found or null if not found at all
  41121. */
  41122. getMeshByID(id: string): Nullable<AbstractMesh>;
  41123. /**
  41124. * Gets a list of meshes using their id
  41125. * @param id defines the id to search for
  41126. * @returns a list of meshes
  41127. */
  41128. getMeshesByID(id: string): Array<AbstractMesh>;
  41129. /**
  41130. * Gets the first added transform node found of a given ID
  41131. * @param id defines the id to search for
  41132. * @return the found transform node or null if not found at all.
  41133. */
  41134. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41135. /**
  41136. * Gets a transform node with its auto-generated unique id
  41137. * @param uniqueId efines the unique id to search for
  41138. * @return the found transform node or null if not found at all.
  41139. */
  41140. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41141. /**
  41142. * Gets a list of transform nodes using their id
  41143. * @param id defines the id to search for
  41144. * @returns a list of transform nodes
  41145. */
  41146. getTransformNodesByID(id: string): Array<TransformNode>;
  41147. /**
  41148. * Gets a mesh with its auto-generated unique id
  41149. * @param uniqueId defines the unique id to search for
  41150. * @return the found mesh or null if not found at all.
  41151. */
  41152. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41153. /**
  41154. * Gets a the last added mesh using a given id
  41155. * @param id defines the id to search for
  41156. * @return the found mesh or null if not found at all.
  41157. */
  41158. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41159. /**
  41160. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41161. * @param id defines the id to search for
  41162. * @return the found node or null if not found at all
  41163. */
  41164. getLastEntryByID(id: string): Nullable<Node>;
  41165. /**
  41166. * Gets a node (Mesh, Camera, Light) using a given id
  41167. * @param id defines the id to search for
  41168. * @return the found node or null if not found at all
  41169. */
  41170. getNodeByID(id: string): Nullable<Node>;
  41171. /**
  41172. * Gets a node (Mesh, Camera, Light) using a given name
  41173. * @param name defines the name to search for
  41174. * @return the found node or null if not found at all.
  41175. */
  41176. getNodeByName(name: string): Nullable<Node>;
  41177. /**
  41178. * Gets a mesh using a given name
  41179. * @param name defines the name to search for
  41180. * @return the found mesh or null if not found at all.
  41181. */
  41182. getMeshByName(name: string): Nullable<AbstractMesh>;
  41183. /**
  41184. * Gets a transform node using a given name
  41185. * @param name defines the name to search for
  41186. * @return the found transform node or null if not found at all.
  41187. */
  41188. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41189. /**
  41190. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41191. * @param id defines the id to search for
  41192. * @return the found skeleton or null if not found at all.
  41193. */
  41194. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41195. /**
  41196. * Gets a skeleton using a given auto generated unique id
  41197. * @param uniqueId defines the unique id to search for
  41198. * @return the found skeleton or null if not found at all.
  41199. */
  41200. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41201. /**
  41202. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41203. * @param id defines the id to search for
  41204. * @return the found skeleton or null if not found at all.
  41205. */
  41206. getSkeletonById(id: string): Nullable<Skeleton>;
  41207. /**
  41208. * Gets a skeleton using a given name
  41209. * @param name defines the name to search for
  41210. * @return the found skeleton or null if not found at all.
  41211. */
  41212. getSkeletonByName(name: string): Nullable<Skeleton>;
  41213. /**
  41214. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41215. * @param id defines the id to search for
  41216. * @return the found morph target manager or null if not found at all.
  41217. */
  41218. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41219. /**
  41220. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41221. * @param id defines the id to search for
  41222. * @return the found morph target or null if not found at all.
  41223. */
  41224. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41225. /**
  41226. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41227. * @param name defines the name to search for
  41228. * @return the found morph target or null if not found at all.
  41229. */
  41230. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41231. /**
  41232. * Gets a boolean indicating if the given mesh is active
  41233. * @param mesh defines the mesh to look for
  41234. * @returns true if the mesh is in the active list
  41235. */
  41236. isActiveMesh(mesh: AbstractMesh): boolean;
  41237. /**
  41238. * Return a unique id as a string which can serve as an identifier for the scene
  41239. */
  41240. get uid(): string;
  41241. /**
  41242. * Add an externaly attached data from its key.
  41243. * This method call will fail and return false, if such key already exists.
  41244. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41245. * @param key the unique key that identifies the data
  41246. * @param data the data object to associate to the key for this Engine instance
  41247. * @return true if no such key were already present and the data was added successfully, false otherwise
  41248. */
  41249. addExternalData<T>(key: string, data: T): boolean;
  41250. /**
  41251. * Get an externaly attached data from its key
  41252. * @param key the unique key that identifies the data
  41253. * @return the associated data, if present (can be null), or undefined if not present
  41254. */
  41255. getExternalData<T>(key: string): Nullable<T>;
  41256. /**
  41257. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41258. * @param key the unique key that identifies the data
  41259. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41260. * @return the associated data, can be null if the factory returned null.
  41261. */
  41262. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41263. /**
  41264. * Remove an externaly attached data from the Engine instance
  41265. * @param key the unique key that identifies the data
  41266. * @return true if the data was successfully removed, false if it doesn't exist
  41267. */
  41268. removeExternalData(key: string): boolean;
  41269. private _evaluateSubMesh;
  41270. /**
  41271. * Clear the processed materials smart array preventing retention point in material dispose.
  41272. */
  41273. freeProcessedMaterials(): void;
  41274. private _preventFreeActiveMeshesAndRenderingGroups;
  41275. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41276. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41277. * when disposing several meshes in a row or a hierarchy of meshes.
  41278. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41279. */
  41280. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41281. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41282. /**
  41283. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41284. */
  41285. freeActiveMeshes(): void;
  41286. /**
  41287. * Clear the info related to rendering groups preventing retention points during dispose.
  41288. */
  41289. freeRenderingGroups(): void;
  41290. /** @hidden */
  41291. _isInIntermediateRendering(): boolean;
  41292. /**
  41293. * Lambda returning the list of potentially active meshes.
  41294. */
  41295. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41296. /**
  41297. * Lambda returning the list of potentially active sub meshes.
  41298. */
  41299. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41300. /**
  41301. * Lambda returning the list of potentially intersecting sub meshes.
  41302. */
  41303. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41304. /**
  41305. * Lambda returning the list of potentially colliding sub meshes.
  41306. */
  41307. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41308. private _activeMeshesFrozen;
  41309. private _skipEvaluateActiveMeshesCompletely;
  41310. /**
  41311. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41312. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41313. * @returns the current scene
  41314. */
  41315. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41316. /**
  41317. * Use this function to restart evaluating active meshes on every frame
  41318. * @returns the current scene
  41319. */
  41320. unfreezeActiveMeshes(): Scene;
  41321. private _evaluateActiveMeshes;
  41322. private _activeMesh;
  41323. /**
  41324. * Update the transform matrix to update from the current active camera
  41325. * @param force defines a boolean used to force the update even if cache is up to date
  41326. */
  41327. updateTransformMatrix(force?: boolean): void;
  41328. private _bindFrameBuffer;
  41329. /** @hidden */
  41330. _allowPostProcessClearColor: boolean;
  41331. /** @hidden */
  41332. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41333. private _processSubCameras;
  41334. private _checkIntersections;
  41335. /** @hidden */
  41336. _advancePhysicsEngineStep(step: number): void;
  41337. /**
  41338. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41339. */
  41340. getDeterministicFrameTime: () => number;
  41341. /** @hidden */
  41342. _animate(): void;
  41343. /** Execute all animations (for a frame) */
  41344. animate(): void;
  41345. /**
  41346. * Render the scene
  41347. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41348. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41349. */
  41350. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41351. /**
  41352. * Freeze all materials
  41353. * A frozen material will not be updatable but should be faster to render
  41354. */
  41355. freezeMaterials(): void;
  41356. /**
  41357. * Unfreeze all materials
  41358. * A frozen material will not be updatable but should be faster to render
  41359. */
  41360. unfreezeMaterials(): void;
  41361. /**
  41362. * Releases all held ressources
  41363. */
  41364. dispose(): void;
  41365. /**
  41366. * Gets if the scene is already disposed
  41367. */
  41368. get isDisposed(): boolean;
  41369. /**
  41370. * Call this function to reduce memory footprint of the scene.
  41371. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41372. */
  41373. clearCachedVertexData(): void;
  41374. /**
  41375. * This function will remove the local cached buffer data from texture.
  41376. * It will save memory but will prevent the texture from being rebuilt
  41377. */
  41378. cleanCachedTextureBuffer(): void;
  41379. /**
  41380. * Get the world extend vectors with an optional filter
  41381. *
  41382. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41383. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41384. */
  41385. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41386. min: Vector3;
  41387. max: Vector3;
  41388. };
  41389. /**
  41390. * Creates a ray that can be used to pick in the scene
  41391. * @param x defines the x coordinate of the origin (on-screen)
  41392. * @param y defines the y coordinate of the origin (on-screen)
  41393. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41394. * @param camera defines the camera to use for the picking
  41395. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41396. * @returns a Ray
  41397. */
  41398. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41399. /**
  41400. * Creates a ray that can be used to pick in the scene
  41401. * @param x defines the x coordinate of the origin (on-screen)
  41402. * @param y defines the y coordinate of the origin (on-screen)
  41403. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41404. * @param result defines the ray where to store the picking ray
  41405. * @param camera defines the camera to use for the picking
  41406. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41407. * @returns the current scene
  41408. */
  41409. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41410. /**
  41411. * Creates a ray that can be used to pick in the scene
  41412. * @param x defines the x coordinate of the origin (on-screen)
  41413. * @param y defines the y coordinate of the origin (on-screen)
  41414. * @param camera defines the camera to use for the picking
  41415. * @returns a Ray
  41416. */
  41417. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41418. /**
  41419. * Creates a ray that can be used to pick in the scene
  41420. * @param x defines the x coordinate of the origin (on-screen)
  41421. * @param y defines the y coordinate of the origin (on-screen)
  41422. * @param result defines the ray where to store the picking ray
  41423. * @param camera defines the camera to use for the picking
  41424. * @returns the current scene
  41425. */
  41426. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41427. /** Launch a ray to try to pick a mesh in the scene
  41428. * @param x position on screen
  41429. * @param y position on screen
  41430. * @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
  41431. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41432. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41433. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41434. * @returns a PickingInfo
  41435. */
  41436. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41437. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41438. * @param x position on screen
  41439. * @param y position on screen
  41440. * @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
  41441. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41442. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41443. * @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)
  41444. */
  41445. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41446. /** Use the given ray to pick a mesh in the scene
  41447. * @param ray The ray to use to pick meshes
  41448. * @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
  41449. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41450. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41451. * @returns a PickingInfo
  41452. */
  41453. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41454. /**
  41455. * Launch a ray to try to pick a mesh in the scene
  41456. * @param x X position on screen
  41457. * @param y Y position on screen
  41458. * @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
  41459. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41460. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41461. * @returns an array of PickingInfo
  41462. */
  41463. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41464. /**
  41465. * Launch a ray to try to pick a mesh in the scene
  41466. * @param ray Ray to use
  41467. * @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
  41468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41469. * @returns an array of PickingInfo
  41470. */
  41471. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41472. /**
  41473. * Force the value of meshUnderPointer
  41474. * @param mesh defines the mesh to use
  41475. */
  41476. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41477. /**
  41478. * Gets the mesh under the pointer
  41479. * @returns a Mesh or null if no mesh is under the pointer
  41480. */
  41481. getPointerOverMesh(): Nullable<AbstractMesh>;
  41482. /** @hidden */
  41483. _rebuildGeometries(): void;
  41484. /** @hidden */
  41485. _rebuildTextures(): void;
  41486. private _getByTags;
  41487. /**
  41488. * Get a list of meshes by tags
  41489. * @param tagsQuery defines the tags query to use
  41490. * @param forEach defines a predicate used to filter results
  41491. * @returns an array of Mesh
  41492. */
  41493. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41494. /**
  41495. * Get a list of cameras by tags
  41496. * @param tagsQuery defines the tags query to use
  41497. * @param forEach defines a predicate used to filter results
  41498. * @returns an array of Camera
  41499. */
  41500. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41501. /**
  41502. * Get a list of lights by tags
  41503. * @param tagsQuery defines the tags query to use
  41504. * @param forEach defines a predicate used to filter results
  41505. * @returns an array of Light
  41506. */
  41507. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41508. /**
  41509. * Get a list of materials by tags
  41510. * @param tagsQuery defines the tags query to use
  41511. * @param forEach defines a predicate used to filter results
  41512. * @returns an array of Material
  41513. */
  41514. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41515. /**
  41516. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41517. * This allowed control for front to back rendering or reversly depending of the special needs.
  41518. *
  41519. * @param renderingGroupId The rendering group id corresponding to its index
  41520. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41521. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41522. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41523. */
  41524. 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;
  41525. /**
  41526. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41527. *
  41528. * @param renderingGroupId The rendering group id corresponding to its index
  41529. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41530. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41531. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41532. */
  41533. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41534. /**
  41535. * Gets the current auto clear configuration for one rendering group of the rendering
  41536. * manager.
  41537. * @param index the rendering group index to get the information for
  41538. * @returns The auto clear setup for the requested rendering group
  41539. */
  41540. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41541. private _blockMaterialDirtyMechanism;
  41542. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41543. get blockMaterialDirtyMechanism(): boolean;
  41544. set blockMaterialDirtyMechanism(value: boolean);
  41545. /**
  41546. * Will flag all materials as dirty to trigger new shader compilation
  41547. * @param flag defines the flag used to specify which material part must be marked as dirty
  41548. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41549. */
  41550. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41551. /** @hidden */
  41552. _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;
  41553. /** @hidden */
  41554. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41555. /** @hidden */
  41556. _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;
  41557. /** @hidden */
  41558. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41559. /** @hidden */
  41560. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41561. /** @hidden */
  41562. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41563. }
  41564. }
  41565. declare module "babylonjs/assetContainer" {
  41566. import { AbstractScene } from "babylonjs/abstractScene";
  41567. import { Scene } from "babylonjs/scene";
  41568. import { Mesh } from "babylonjs/Meshes/mesh";
  41569. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41570. import { Skeleton } from "babylonjs/Bones/skeleton";
  41571. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41572. import { Animatable } from "babylonjs/Animations/animatable";
  41573. import { Nullable } from "babylonjs/types";
  41574. import { Node } from "babylonjs/node";
  41575. /**
  41576. * Set of assets to keep when moving a scene into an asset container.
  41577. */
  41578. export class KeepAssets extends AbstractScene {
  41579. }
  41580. /**
  41581. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41582. */
  41583. export class InstantiatedEntries {
  41584. /**
  41585. * List of new root nodes (eg. nodes with no parent)
  41586. */
  41587. rootNodes: TransformNode[];
  41588. /**
  41589. * List of new skeletons
  41590. */
  41591. skeletons: Skeleton[];
  41592. /**
  41593. * List of new animation groups
  41594. */
  41595. animationGroups: AnimationGroup[];
  41596. }
  41597. /**
  41598. * Container with a set of assets that can be added or removed from a scene.
  41599. */
  41600. export class AssetContainer extends AbstractScene {
  41601. private _wasAddedToScene;
  41602. /**
  41603. * The scene the AssetContainer belongs to.
  41604. */
  41605. scene: Scene;
  41606. /**
  41607. * Instantiates an AssetContainer.
  41608. * @param scene The scene the AssetContainer belongs to.
  41609. */
  41610. constructor(scene: Scene);
  41611. /**
  41612. * Instantiate or clone all meshes and add the new ones to the scene.
  41613. * Skeletons and animation groups will all be cloned
  41614. * @param nameFunction defines an optional function used to get new names for clones
  41615. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41616. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41617. */
  41618. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41619. /**
  41620. * Adds all the assets from the container to the scene.
  41621. */
  41622. addAllToScene(): void;
  41623. /**
  41624. * Removes all the assets in the container from the scene
  41625. */
  41626. removeAllFromScene(): void;
  41627. /**
  41628. * Disposes all the assets in the container
  41629. */
  41630. dispose(): void;
  41631. private _moveAssets;
  41632. /**
  41633. * Removes all the assets contained in the scene and adds them to the container.
  41634. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41635. */
  41636. moveAllFromScene(keepAssets?: KeepAssets): void;
  41637. /**
  41638. * 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.
  41639. * @returns the root mesh
  41640. */
  41641. createRootMesh(): Mesh;
  41642. /**
  41643. * Merge animations (direct and animation groups) from this asset container into a scene
  41644. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41645. * @param animatables set of animatables to retarget to a node from the scene
  41646. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41647. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41648. */
  41649. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41650. }
  41651. }
  41652. declare module "babylonjs/abstractScene" {
  41653. import { Scene } from "babylonjs/scene";
  41654. import { Nullable } from "babylonjs/types";
  41655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41656. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41657. import { Geometry } from "babylonjs/Meshes/geometry";
  41658. import { Skeleton } from "babylonjs/Bones/skeleton";
  41659. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41660. import { AssetContainer } from "babylonjs/assetContainer";
  41661. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41662. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41663. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41664. import { Material } from "babylonjs/Materials/material";
  41665. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41666. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41667. import { Camera } from "babylonjs/Cameras/camera";
  41668. import { Light } from "babylonjs/Lights/light";
  41669. import { Node } from "babylonjs/node";
  41670. import { Animation } from "babylonjs/Animations/animation";
  41671. /**
  41672. * Defines how the parser contract is defined.
  41673. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41674. */
  41675. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41676. /**
  41677. * Defines how the individual parser contract is defined.
  41678. * These parser can parse an individual asset
  41679. */
  41680. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41681. /**
  41682. * Base class of the scene acting as a container for the different elements composing a scene.
  41683. * This class is dynamically extended by the different components of the scene increasing
  41684. * flexibility and reducing coupling
  41685. */
  41686. export abstract class AbstractScene {
  41687. /**
  41688. * Stores the list of available parsers in the application.
  41689. */
  41690. private static _BabylonFileParsers;
  41691. /**
  41692. * Stores the list of available individual parsers in the application.
  41693. */
  41694. private static _IndividualBabylonFileParsers;
  41695. /**
  41696. * Adds a parser in the list of available ones
  41697. * @param name Defines the name of the parser
  41698. * @param parser Defines the parser to add
  41699. */
  41700. static AddParser(name: string, parser: BabylonFileParser): void;
  41701. /**
  41702. * Gets a general parser from the list of avaialble ones
  41703. * @param name Defines the name of the parser
  41704. * @returns the requested parser or null
  41705. */
  41706. static GetParser(name: string): Nullable<BabylonFileParser>;
  41707. /**
  41708. * Adds n individual parser in the list of available ones
  41709. * @param name Defines the name of the parser
  41710. * @param parser Defines the parser to add
  41711. */
  41712. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41713. /**
  41714. * Gets an individual parser from the list of avaialble ones
  41715. * @param name Defines the name of the parser
  41716. * @returns the requested parser or null
  41717. */
  41718. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41719. /**
  41720. * Parser json data and populate both a scene and its associated container object
  41721. * @param jsonData Defines the data to parse
  41722. * @param scene Defines the scene to parse the data for
  41723. * @param container Defines the container attached to the parsing sequence
  41724. * @param rootUrl Defines the root url of the data
  41725. */
  41726. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41727. /**
  41728. * Gets the list of root nodes (ie. nodes with no parent)
  41729. */
  41730. rootNodes: Node[];
  41731. /** All of the cameras added to this scene
  41732. * @see https://doc.babylonjs.com/babylon101/cameras
  41733. */
  41734. cameras: Camera[];
  41735. /**
  41736. * All of the lights added to this scene
  41737. * @see https://doc.babylonjs.com/babylon101/lights
  41738. */
  41739. lights: Light[];
  41740. /**
  41741. * All of the (abstract) meshes added to this scene
  41742. */
  41743. meshes: AbstractMesh[];
  41744. /**
  41745. * The list of skeletons added to the scene
  41746. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41747. */
  41748. skeletons: Skeleton[];
  41749. /**
  41750. * All of the particle systems added to this scene
  41751. * @see https://doc.babylonjs.com/babylon101/particles
  41752. */
  41753. particleSystems: IParticleSystem[];
  41754. /**
  41755. * Gets a list of Animations associated with the scene
  41756. */
  41757. animations: Animation[];
  41758. /**
  41759. * All of the animation groups added to this scene
  41760. * @see https://doc.babylonjs.com/how_to/group
  41761. */
  41762. animationGroups: AnimationGroup[];
  41763. /**
  41764. * All of the multi-materials added to this scene
  41765. * @see https://doc.babylonjs.com/how_to/multi_materials
  41766. */
  41767. multiMaterials: MultiMaterial[];
  41768. /**
  41769. * All of the materials added to this scene
  41770. * In the context of a Scene, it is not supposed to be modified manually.
  41771. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41772. * Note also that the order of the Material within the array is not significant and might change.
  41773. * @see https://doc.babylonjs.com/babylon101/materials
  41774. */
  41775. materials: Material[];
  41776. /**
  41777. * The list of morph target managers added to the scene
  41778. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41779. */
  41780. morphTargetManagers: MorphTargetManager[];
  41781. /**
  41782. * The list of geometries used in the scene.
  41783. */
  41784. geometries: Geometry[];
  41785. /**
  41786. * All of the tranform nodes added to this scene
  41787. * In the context of a Scene, it is not supposed to be modified manually.
  41788. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41789. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41790. * @see https://doc.babylonjs.com/how_to/transformnode
  41791. */
  41792. transformNodes: TransformNode[];
  41793. /**
  41794. * ActionManagers available on the scene.
  41795. */
  41796. actionManagers: AbstractActionManager[];
  41797. /**
  41798. * Textures to keep.
  41799. */
  41800. textures: BaseTexture[];
  41801. /**
  41802. * Environment texture for the scene
  41803. */
  41804. environmentTexture: Nullable<BaseTexture>;
  41805. /**
  41806. * @returns all meshes, lights, cameras, transformNodes and bones
  41807. */
  41808. getNodes(): Array<Node>;
  41809. }
  41810. }
  41811. declare module "babylonjs/Audio/sound" {
  41812. import { Observable } from "babylonjs/Misc/observable";
  41813. import { Vector3 } from "babylonjs/Maths/math.vector";
  41814. import { Nullable } from "babylonjs/types";
  41815. import { Scene } from "babylonjs/scene";
  41816. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41817. /**
  41818. * Interface used to define options for Sound class
  41819. */
  41820. export interface ISoundOptions {
  41821. /**
  41822. * Does the sound autoplay once loaded.
  41823. */
  41824. autoplay?: boolean;
  41825. /**
  41826. * Does the sound loop after it finishes playing once.
  41827. */
  41828. loop?: boolean;
  41829. /**
  41830. * Sound's volume
  41831. */
  41832. volume?: number;
  41833. /**
  41834. * Is it a spatial sound?
  41835. */
  41836. spatialSound?: boolean;
  41837. /**
  41838. * Maximum distance to hear that sound
  41839. */
  41840. maxDistance?: number;
  41841. /**
  41842. * Uses user defined attenuation function
  41843. */
  41844. useCustomAttenuation?: boolean;
  41845. /**
  41846. * Define the roll off factor of spatial sounds.
  41847. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41848. */
  41849. rolloffFactor?: number;
  41850. /**
  41851. * Define the reference distance the sound should be heard perfectly.
  41852. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41853. */
  41854. refDistance?: number;
  41855. /**
  41856. * Define the distance attenuation model the sound will follow.
  41857. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41858. */
  41859. distanceModel?: string;
  41860. /**
  41861. * Defines the playback speed (1 by default)
  41862. */
  41863. playbackRate?: number;
  41864. /**
  41865. * Defines if the sound is from a streaming source
  41866. */
  41867. streaming?: boolean;
  41868. /**
  41869. * Defines an optional length (in seconds) inside the sound file
  41870. */
  41871. length?: number;
  41872. /**
  41873. * Defines an optional offset (in seconds) inside the sound file
  41874. */
  41875. offset?: number;
  41876. /**
  41877. * If true, URLs will not be required to state the audio file codec to use.
  41878. */
  41879. skipCodecCheck?: boolean;
  41880. }
  41881. /**
  41882. * Defines a sound that can be played in the application.
  41883. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41884. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41885. */
  41886. export class Sound {
  41887. /**
  41888. * The name of the sound in the scene.
  41889. */
  41890. name: string;
  41891. /**
  41892. * Does the sound autoplay once loaded.
  41893. */
  41894. autoplay: boolean;
  41895. /**
  41896. * Does the sound loop after it finishes playing once.
  41897. */
  41898. loop: boolean;
  41899. /**
  41900. * Does the sound use a custom attenuation curve to simulate the falloff
  41901. * happening when the source gets further away from the camera.
  41902. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41903. */
  41904. useCustomAttenuation: boolean;
  41905. /**
  41906. * The sound track id this sound belongs to.
  41907. */
  41908. soundTrackId: number;
  41909. /**
  41910. * Is this sound currently played.
  41911. */
  41912. isPlaying: boolean;
  41913. /**
  41914. * Is this sound currently paused.
  41915. */
  41916. isPaused: boolean;
  41917. /**
  41918. * Does this sound enables spatial sound.
  41919. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41920. */
  41921. spatialSound: boolean;
  41922. /**
  41923. * Define the reference distance the sound should be heard perfectly.
  41924. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41925. */
  41926. refDistance: number;
  41927. /**
  41928. * Define the roll off factor of spatial sounds.
  41929. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41930. */
  41931. rolloffFactor: number;
  41932. /**
  41933. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41934. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41935. */
  41936. maxDistance: number;
  41937. /**
  41938. * Define the distance attenuation model the sound will follow.
  41939. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41940. */
  41941. distanceModel: string;
  41942. /**
  41943. * @hidden
  41944. * Back Compat
  41945. **/
  41946. onended: () => any;
  41947. /**
  41948. * Gets or sets an object used to store user defined information for the sound.
  41949. */
  41950. metadata: any;
  41951. /**
  41952. * Observable event when the current playing sound finishes.
  41953. */
  41954. onEndedObservable: Observable<Sound>;
  41955. private _panningModel;
  41956. private _playbackRate;
  41957. private _streaming;
  41958. private _startTime;
  41959. private _startOffset;
  41960. private _position;
  41961. /** @hidden */
  41962. _positionInEmitterSpace: boolean;
  41963. private _localDirection;
  41964. private _volume;
  41965. private _isReadyToPlay;
  41966. private _isDirectional;
  41967. private _readyToPlayCallback;
  41968. private _audioBuffer;
  41969. private _soundSource;
  41970. private _streamingSource;
  41971. private _soundPanner;
  41972. private _soundGain;
  41973. private _inputAudioNode;
  41974. private _outputAudioNode;
  41975. private _coneInnerAngle;
  41976. private _coneOuterAngle;
  41977. private _coneOuterGain;
  41978. private _scene;
  41979. private _connectedTransformNode;
  41980. private _customAttenuationFunction;
  41981. private _registerFunc;
  41982. private _isOutputConnected;
  41983. private _htmlAudioElement;
  41984. private _urlType;
  41985. private _length?;
  41986. private _offset?;
  41987. /** @hidden */
  41988. static _SceneComponentInitialization: (scene: Scene) => void;
  41989. /**
  41990. * Create a sound and attach it to a scene
  41991. * @param name Name of your sound
  41992. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41993. * @param scene defines the scene the sound belongs to
  41994. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41995. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41996. */
  41997. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41998. /**
  41999. * Release the sound and its associated resources
  42000. */
  42001. dispose(): void;
  42002. /**
  42003. * Gets if the sounds is ready to be played or not.
  42004. * @returns true if ready, otherwise false
  42005. */
  42006. isReady(): boolean;
  42007. private _soundLoaded;
  42008. /**
  42009. * Sets the data of the sound from an audiobuffer
  42010. * @param audioBuffer The audioBuffer containing the data
  42011. */
  42012. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42013. /**
  42014. * Updates the current sounds options such as maxdistance, loop...
  42015. * @param options A JSON object containing values named as the object properties
  42016. */
  42017. updateOptions(options: ISoundOptions): void;
  42018. private _createSpatialParameters;
  42019. private _updateSpatialParameters;
  42020. /**
  42021. * Switch the panning model to HRTF:
  42022. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42023. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42024. */
  42025. switchPanningModelToHRTF(): void;
  42026. /**
  42027. * Switch the panning model to Equal Power:
  42028. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42029. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42030. */
  42031. switchPanningModelToEqualPower(): void;
  42032. private _switchPanningModel;
  42033. /**
  42034. * Connect this sound to a sound track audio node like gain...
  42035. * @param soundTrackAudioNode the sound track audio node to connect to
  42036. */
  42037. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42038. /**
  42039. * Transform this sound into a directional source
  42040. * @param coneInnerAngle Size of the inner cone in degree
  42041. * @param coneOuterAngle Size of the outer cone in degree
  42042. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42043. */
  42044. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42045. /**
  42046. * Gets or sets the inner angle for the directional cone.
  42047. */
  42048. get directionalConeInnerAngle(): number;
  42049. /**
  42050. * Gets or sets the inner angle for the directional cone.
  42051. */
  42052. set directionalConeInnerAngle(value: number);
  42053. /**
  42054. * Gets or sets the outer angle for the directional cone.
  42055. */
  42056. get directionalConeOuterAngle(): number;
  42057. /**
  42058. * Gets or sets the outer angle for the directional cone.
  42059. */
  42060. set directionalConeOuterAngle(value: number);
  42061. /**
  42062. * Sets the position of the emitter if spatial sound is enabled
  42063. * @param newPosition Defines the new posisiton
  42064. */
  42065. setPosition(newPosition: Vector3): void;
  42066. /**
  42067. * Sets the local direction of the emitter if spatial sound is enabled
  42068. * @param newLocalDirection Defines the new local direction
  42069. */
  42070. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42071. private _updateDirection;
  42072. /** @hidden */
  42073. updateDistanceFromListener(): void;
  42074. /**
  42075. * Sets a new custom attenuation function for the sound.
  42076. * @param callback Defines the function used for the attenuation
  42077. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42078. */
  42079. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42080. /**
  42081. * Play the sound
  42082. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42083. * @param offset (optional) Start the sound at a specific time in seconds
  42084. * @param length (optional) Sound duration (in seconds)
  42085. */
  42086. play(time?: number, offset?: number, length?: number): void;
  42087. private _onended;
  42088. /**
  42089. * Stop the sound
  42090. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42091. */
  42092. stop(time?: number): void;
  42093. /**
  42094. * Put the sound in pause
  42095. */
  42096. pause(): void;
  42097. /**
  42098. * Sets a dedicated volume for this sounds
  42099. * @param newVolume Define the new volume of the sound
  42100. * @param time Define time for gradual change to new volume
  42101. */
  42102. setVolume(newVolume: number, time?: number): void;
  42103. /**
  42104. * Set the sound play back rate
  42105. * @param newPlaybackRate Define the playback rate the sound should be played at
  42106. */
  42107. setPlaybackRate(newPlaybackRate: number): void;
  42108. /**
  42109. * Gets the volume of the sound.
  42110. * @returns the volume of the sound
  42111. */
  42112. getVolume(): number;
  42113. /**
  42114. * Attach the sound to a dedicated mesh
  42115. * @param transformNode The transform node to connect the sound with
  42116. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42117. */
  42118. attachToMesh(transformNode: TransformNode): void;
  42119. /**
  42120. * Detach the sound from the previously attached mesh
  42121. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42122. */
  42123. detachFromMesh(): void;
  42124. private _onRegisterAfterWorldMatrixUpdate;
  42125. /**
  42126. * Clone the current sound in the scene.
  42127. * @returns the new sound clone
  42128. */
  42129. clone(): Nullable<Sound>;
  42130. /**
  42131. * Gets the current underlying audio buffer containing the data
  42132. * @returns the audio buffer
  42133. */
  42134. getAudioBuffer(): Nullable<AudioBuffer>;
  42135. /**
  42136. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42137. * @returns the source node
  42138. */
  42139. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42140. /**
  42141. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42142. * @returns the gain node
  42143. */
  42144. getSoundGain(): Nullable<GainNode>;
  42145. /**
  42146. * Serializes the Sound in a JSON representation
  42147. * @returns the JSON representation of the sound
  42148. */
  42149. serialize(): any;
  42150. /**
  42151. * Parse a JSON representation of a sound to innstantiate in a given scene
  42152. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42153. * @param scene Define the scene the new parsed sound should be created in
  42154. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42155. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42156. * @returns the newly parsed sound
  42157. */
  42158. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42159. }
  42160. }
  42161. declare module "babylonjs/Actions/directAudioActions" {
  42162. import { Action } from "babylonjs/Actions/action";
  42163. import { Condition } from "babylonjs/Actions/condition";
  42164. import { Sound } from "babylonjs/Audio/sound";
  42165. /**
  42166. * This defines an action helpful to play a defined sound on a triggered action.
  42167. */
  42168. export class PlaySoundAction extends Action {
  42169. private _sound;
  42170. /**
  42171. * Instantiate the action
  42172. * @param triggerOptions defines the trigger options
  42173. * @param sound defines the sound to play
  42174. * @param condition defines the trigger related conditions
  42175. */
  42176. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42177. /** @hidden */
  42178. _prepare(): void;
  42179. /**
  42180. * Execute the action and play the sound.
  42181. */
  42182. execute(): void;
  42183. /**
  42184. * Serializes the actions and its related information.
  42185. * @param parent defines the object to serialize in
  42186. * @returns the serialized object
  42187. */
  42188. serialize(parent: any): any;
  42189. }
  42190. /**
  42191. * This defines an action helpful to stop a defined sound on a triggered action.
  42192. */
  42193. export class StopSoundAction extends Action {
  42194. private _sound;
  42195. /**
  42196. * Instantiate the action
  42197. * @param triggerOptions defines the trigger options
  42198. * @param sound defines the sound to stop
  42199. * @param condition defines the trigger related conditions
  42200. */
  42201. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42202. /** @hidden */
  42203. _prepare(): void;
  42204. /**
  42205. * Execute the action and stop the sound.
  42206. */
  42207. execute(): void;
  42208. /**
  42209. * Serializes the actions and its related information.
  42210. * @param parent defines the object to serialize in
  42211. * @returns the serialized object
  42212. */
  42213. serialize(parent: any): any;
  42214. }
  42215. }
  42216. declare module "babylonjs/Actions/interpolateValueAction" {
  42217. import { Action } from "babylonjs/Actions/action";
  42218. import { Condition } from "babylonjs/Actions/condition";
  42219. import { Observable } from "babylonjs/Misc/observable";
  42220. /**
  42221. * This defines an action responsible to change the value of a property
  42222. * by interpolating between its current value and the newly set one once triggered.
  42223. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  42224. */
  42225. export class InterpolateValueAction extends Action {
  42226. /**
  42227. * Defines the path of the property where the value should be interpolated
  42228. */
  42229. propertyPath: string;
  42230. /**
  42231. * Defines the target value at the end of the interpolation.
  42232. */
  42233. value: any;
  42234. /**
  42235. * Defines the time it will take for the property to interpolate to the value.
  42236. */
  42237. duration: number;
  42238. /**
  42239. * Defines if the other scene animations should be stopped when the action has been triggered
  42240. */
  42241. stopOtherAnimations?: boolean;
  42242. /**
  42243. * Defines a callback raised once the interpolation animation has been done.
  42244. */
  42245. onInterpolationDone?: () => void;
  42246. /**
  42247. * Observable triggered once the interpolation animation has been done.
  42248. */
  42249. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42250. private _target;
  42251. private _effectiveTarget;
  42252. private _property;
  42253. /**
  42254. * Instantiate the action
  42255. * @param triggerOptions defines the trigger options
  42256. * @param target defines the object containing the value to interpolate
  42257. * @param propertyPath defines the path to the property in the target object
  42258. * @param value defines the target value at the end of the interpolation
  42259. * @param duration deines the time it will take for the property to interpolate to the value.
  42260. * @param condition defines the trigger related conditions
  42261. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42262. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42263. */
  42264. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42265. /** @hidden */
  42266. _prepare(): void;
  42267. /**
  42268. * Execute the action starts the value interpolation.
  42269. */
  42270. execute(): void;
  42271. /**
  42272. * Serializes the actions and its related information.
  42273. * @param parent defines the object to serialize in
  42274. * @returns the serialized object
  42275. */
  42276. serialize(parent: any): any;
  42277. }
  42278. }
  42279. declare module "babylonjs/Actions/index" {
  42280. export * from "babylonjs/Actions/abstractActionManager";
  42281. export * from "babylonjs/Actions/action";
  42282. export * from "babylonjs/Actions/actionEvent";
  42283. export * from "babylonjs/Actions/actionManager";
  42284. export * from "babylonjs/Actions/condition";
  42285. export * from "babylonjs/Actions/directActions";
  42286. export * from "babylonjs/Actions/directAudioActions";
  42287. export * from "babylonjs/Actions/interpolateValueAction";
  42288. }
  42289. declare module "babylonjs/Animations/index" {
  42290. export * from "babylonjs/Animations/animatable";
  42291. export * from "babylonjs/Animations/animation";
  42292. export * from "babylonjs/Animations/animationGroup";
  42293. export * from "babylonjs/Animations/animationPropertiesOverride";
  42294. export * from "babylonjs/Animations/easing";
  42295. export * from "babylonjs/Animations/runtimeAnimation";
  42296. export * from "babylonjs/Animations/animationEvent";
  42297. export * from "babylonjs/Animations/animationGroup";
  42298. export * from "babylonjs/Animations/animationKey";
  42299. export * from "babylonjs/Animations/animationRange";
  42300. export * from "babylonjs/Animations/animatable.interface";
  42301. }
  42302. declare module "babylonjs/Audio/soundTrack" {
  42303. import { Sound } from "babylonjs/Audio/sound";
  42304. import { Analyser } from "babylonjs/Audio/analyser";
  42305. import { Scene } from "babylonjs/scene";
  42306. /**
  42307. * Options allowed during the creation of a sound track.
  42308. */
  42309. export interface ISoundTrackOptions {
  42310. /**
  42311. * The volume the sound track should take during creation
  42312. */
  42313. volume?: number;
  42314. /**
  42315. * Define if the sound track is the main sound track of the scene
  42316. */
  42317. mainTrack?: boolean;
  42318. }
  42319. /**
  42320. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42321. * It will be also used in a future release to apply effects on a specific track.
  42322. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42323. */
  42324. export class SoundTrack {
  42325. /**
  42326. * The unique identifier of the sound track in the scene.
  42327. */
  42328. id: number;
  42329. /**
  42330. * The list of sounds included in the sound track.
  42331. */
  42332. soundCollection: Array<Sound>;
  42333. private _outputAudioNode;
  42334. private _scene;
  42335. private _connectedAnalyser;
  42336. private _options;
  42337. private _isInitialized;
  42338. /**
  42339. * Creates a new sound track.
  42340. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42341. * @param scene Define the scene the sound track belongs to
  42342. * @param options
  42343. */
  42344. constructor(scene: Scene, options?: ISoundTrackOptions);
  42345. private _initializeSoundTrackAudioGraph;
  42346. /**
  42347. * Release the sound track and its associated resources
  42348. */
  42349. dispose(): void;
  42350. /**
  42351. * Adds a sound to this sound track
  42352. * @param sound define the cound to add
  42353. * @ignoreNaming
  42354. */
  42355. AddSound(sound: Sound): void;
  42356. /**
  42357. * Removes a sound to this sound track
  42358. * @param sound define the cound to remove
  42359. * @ignoreNaming
  42360. */
  42361. RemoveSound(sound: Sound): void;
  42362. /**
  42363. * Set a global volume for the full sound track.
  42364. * @param newVolume Define the new volume of the sound track
  42365. */
  42366. setVolume(newVolume: number): void;
  42367. /**
  42368. * Switch the panning model to HRTF:
  42369. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42370. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42371. */
  42372. switchPanningModelToHRTF(): void;
  42373. /**
  42374. * Switch the panning model to Equal Power:
  42375. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42376. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42377. */
  42378. switchPanningModelToEqualPower(): void;
  42379. /**
  42380. * Connect the sound track to an audio analyser allowing some amazing
  42381. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42382. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42383. * @param analyser The analyser to connect to the engine
  42384. */
  42385. connectToAnalyser(analyser: Analyser): void;
  42386. }
  42387. }
  42388. declare module "babylonjs/Audio/audioSceneComponent" {
  42389. import { Sound } from "babylonjs/Audio/sound";
  42390. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42391. import { Nullable } from "babylonjs/types";
  42392. import { Vector3 } from "babylonjs/Maths/math.vector";
  42393. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42394. import { Scene } from "babylonjs/scene";
  42395. import { AbstractScene } from "babylonjs/abstractScene";
  42396. import "babylonjs/Audio/audioEngine";
  42397. module "babylonjs/abstractScene" {
  42398. interface AbstractScene {
  42399. /**
  42400. * The list of sounds used in the scene.
  42401. */
  42402. sounds: Nullable<Array<Sound>>;
  42403. }
  42404. }
  42405. module "babylonjs/scene" {
  42406. interface Scene {
  42407. /**
  42408. * @hidden
  42409. * Backing field
  42410. */
  42411. _mainSoundTrack: SoundTrack;
  42412. /**
  42413. * The main sound track played by the scene.
  42414. * It cotains your primary collection of sounds.
  42415. */
  42416. mainSoundTrack: SoundTrack;
  42417. /**
  42418. * The list of sound tracks added to the scene
  42419. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42420. */
  42421. soundTracks: Nullable<Array<SoundTrack>>;
  42422. /**
  42423. * Gets a sound using a given name
  42424. * @param name defines the name to search for
  42425. * @return the found sound or null if not found at all.
  42426. */
  42427. getSoundByName(name: string): Nullable<Sound>;
  42428. /**
  42429. * Gets or sets if audio support is enabled
  42430. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42431. */
  42432. audioEnabled: boolean;
  42433. /**
  42434. * Gets or sets if audio will be output to headphones
  42435. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42436. */
  42437. headphone: boolean;
  42438. /**
  42439. * Gets or sets custom audio listener position provider
  42440. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42441. */
  42442. audioListenerPositionProvider: Nullable<() => Vector3>;
  42443. /**
  42444. * Gets or sets a refresh rate when using 3D audio positioning
  42445. */
  42446. audioPositioningRefreshRate: number;
  42447. }
  42448. }
  42449. /**
  42450. * Defines the sound scene component responsible to manage any sounds
  42451. * in a given scene.
  42452. */
  42453. export class AudioSceneComponent implements ISceneSerializableComponent {
  42454. /**
  42455. * The component name helpfull to identify the component in the list of scene components.
  42456. */
  42457. readonly name: string;
  42458. /**
  42459. * The scene the component belongs to.
  42460. */
  42461. scene: Scene;
  42462. private _audioEnabled;
  42463. /**
  42464. * Gets whether audio is enabled or not.
  42465. * Please use related enable/disable method to switch state.
  42466. */
  42467. get audioEnabled(): boolean;
  42468. private _headphone;
  42469. /**
  42470. * Gets whether audio is outputing to headphone or not.
  42471. * Please use the according Switch methods to change output.
  42472. */
  42473. get headphone(): boolean;
  42474. /**
  42475. * Gets or sets a refresh rate when using 3D audio positioning
  42476. */
  42477. audioPositioningRefreshRate: number;
  42478. private _audioListenerPositionProvider;
  42479. /**
  42480. * Gets the current audio listener position provider
  42481. */
  42482. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42483. /**
  42484. * Sets a custom listener position for all sounds in the scene
  42485. * By default, this is the position of the first active camera
  42486. */
  42487. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42488. /**
  42489. * Creates a new instance of the component for the given scene
  42490. * @param scene Defines the scene to register the component in
  42491. */
  42492. constructor(scene: Scene);
  42493. /**
  42494. * Registers the component in a given scene
  42495. */
  42496. register(): void;
  42497. /**
  42498. * Rebuilds the elements related to this component in case of
  42499. * context lost for instance.
  42500. */
  42501. rebuild(): void;
  42502. /**
  42503. * Serializes the component data to the specified json object
  42504. * @param serializationObject The object to serialize to
  42505. */
  42506. serialize(serializationObject: any): void;
  42507. /**
  42508. * Adds all the elements from the container to the scene
  42509. * @param container the container holding the elements
  42510. */
  42511. addFromContainer(container: AbstractScene): void;
  42512. /**
  42513. * Removes all the elements in the container from the scene
  42514. * @param container contains the elements to remove
  42515. * @param dispose if the removed element should be disposed (default: false)
  42516. */
  42517. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42518. /**
  42519. * Disposes the component and the associated ressources.
  42520. */
  42521. dispose(): void;
  42522. /**
  42523. * Disables audio in the associated scene.
  42524. */
  42525. disableAudio(): void;
  42526. /**
  42527. * Enables audio in the associated scene.
  42528. */
  42529. enableAudio(): void;
  42530. /**
  42531. * Switch audio to headphone output.
  42532. */
  42533. switchAudioModeForHeadphones(): void;
  42534. /**
  42535. * Switch audio to normal speakers.
  42536. */
  42537. switchAudioModeForNormalSpeakers(): void;
  42538. private _cachedCameraDirection;
  42539. private _cachedCameraPosition;
  42540. private _lastCheck;
  42541. private _afterRender;
  42542. }
  42543. }
  42544. declare module "babylonjs/Audio/weightedsound" {
  42545. import { Sound } from "babylonjs/Audio/sound";
  42546. /**
  42547. * Wraps one or more Sound objects and selects one with random weight for playback.
  42548. */
  42549. export class WeightedSound {
  42550. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42551. loop: boolean;
  42552. private _coneInnerAngle;
  42553. private _coneOuterAngle;
  42554. private _volume;
  42555. /** A Sound is currently playing. */
  42556. isPlaying: boolean;
  42557. /** A Sound is currently paused. */
  42558. isPaused: boolean;
  42559. private _sounds;
  42560. private _weights;
  42561. private _currentIndex?;
  42562. /**
  42563. * Creates a new WeightedSound from the list of sounds given.
  42564. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42565. * @param sounds Array of Sounds that will be selected from.
  42566. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42567. */
  42568. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42569. /**
  42570. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42571. */
  42572. get directionalConeInnerAngle(): number;
  42573. /**
  42574. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42575. */
  42576. set directionalConeInnerAngle(value: number);
  42577. /**
  42578. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42579. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42580. */
  42581. get directionalConeOuterAngle(): number;
  42582. /**
  42583. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42584. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42585. */
  42586. set directionalConeOuterAngle(value: number);
  42587. /**
  42588. * Playback volume.
  42589. */
  42590. get volume(): number;
  42591. /**
  42592. * Playback volume.
  42593. */
  42594. set volume(value: number);
  42595. private _onended;
  42596. /**
  42597. * Suspend playback
  42598. */
  42599. pause(): void;
  42600. /**
  42601. * Stop playback
  42602. */
  42603. stop(): void;
  42604. /**
  42605. * Start playback.
  42606. * @param startOffset Position the clip head at a specific time in seconds.
  42607. */
  42608. play(startOffset?: number): void;
  42609. }
  42610. }
  42611. declare module "babylonjs/Audio/index" {
  42612. export * from "babylonjs/Audio/analyser";
  42613. export * from "babylonjs/Audio/audioEngine";
  42614. export * from "babylonjs/Audio/audioSceneComponent";
  42615. export * from "babylonjs/Audio/sound";
  42616. export * from "babylonjs/Audio/soundTrack";
  42617. export * from "babylonjs/Audio/weightedsound";
  42618. }
  42619. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42620. import { Behavior } from "babylonjs/Behaviors/behavior";
  42621. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42622. import { BackEase } from "babylonjs/Animations/easing";
  42623. /**
  42624. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42625. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42626. */
  42627. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42628. /**
  42629. * Gets the name of the behavior.
  42630. */
  42631. get name(): string;
  42632. /**
  42633. * The easing function used by animations
  42634. */
  42635. static EasingFunction: BackEase;
  42636. /**
  42637. * The easing mode used by animations
  42638. */
  42639. static EasingMode: number;
  42640. /**
  42641. * The duration of the animation, in milliseconds
  42642. */
  42643. transitionDuration: number;
  42644. /**
  42645. * Length of the distance animated by the transition when lower radius is reached
  42646. */
  42647. lowerRadiusTransitionRange: number;
  42648. /**
  42649. * Length of the distance animated by the transition when upper radius is reached
  42650. */
  42651. upperRadiusTransitionRange: number;
  42652. private _autoTransitionRange;
  42653. /**
  42654. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42655. */
  42656. get autoTransitionRange(): boolean;
  42657. /**
  42658. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42659. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42660. */
  42661. set autoTransitionRange(value: boolean);
  42662. private _attachedCamera;
  42663. private _onAfterCheckInputsObserver;
  42664. private _onMeshTargetChangedObserver;
  42665. /**
  42666. * Initializes the behavior.
  42667. */
  42668. init(): void;
  42669. /**
  42670. * Attaches the behavior to its arc rotate camera.
  42671. * @param camera Defines the camera to attach the behavior to
  42672. */
  42673. attach(camera: ArcRotateCamera): void;
  42674. /**
  42675. * Detaches the behavior from its current arc rotate camera.
  42676. */
  42677. detach(): void;
  42678. private _radiusIsAnimating;
  42679. private _radiusBounceTransition;
  42680. private _animatables;
  42681. private _cachedWheelPrecision;
  42682. /**
  42683. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42684. * @param radiusLimit The limit to check against.
  42685. * @return Bool to indicate if at limit.
  42686. */
  42687. private _isRadiusAtLimit;
  42688. /**
  42689. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42690. * @param radiusDelta The delta by which to animate to. Can be negative.
  42691. */
  42692. private _applyBoundRadiusAnimation;
  42693. /**
  42694. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42695. */
  42696. protected _clearAnimationLocks(): void;
  42697. /**
  42698. * Stops and removes all animations that have been applied to the camera
  42699. */
  42700. stopAllAnimations(): void;
  42701. }
  42702. }
  42703. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42704. import { Behavior } from "babylonjs/Behaviors/behavior";
  42705. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42706. import { ExponentialEase } from "babylonjs/Animations/easing";
  42707. import { Nullable } from "babylonjs/types";
  42708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42709. import { Vector3 } from "babylonjs/Maths/math.vector";
  42710. /**
  42711. * 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.
  42712. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42713. */
  42714. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42715. /**
  42716. * Gets the name of the behavior.
  42717. */
  42718. get name(): string;
  42719. private _mode;
  42720. private _radiusScale;
  42721. private _positionScale;
  42722. private _defaultElevation;
  42723. private _elevationReturnTime;
  42724. private _elevationReturnWaitTime;
  42725. private _zoomStopsAnimation;
  42726. private _framingTime;
  42727. /**
  42728. * The easing function used by animations
  42729. */
  42730. static EasingFunction: ExponentialEase;
  42731. /**
  42732. * The easing mode used by animations
  42733. */
  42734. static EasingMode: number;
  42735. /**
  42736. * Sets the current mode used by the behavior
  42737. */
  42738. set mode(mode: number);
  42739. /**
  42740. * Gets current mode used by the behavior.
  42741. */
  42742. get mode(): number;
  42743. /**
  42744. * Sets the scale applied to the radius (1 by default)
  42745. */
  42746. set radiusScale(radius: number);
  42747. /**
  42748. * Gets the scale applied to the radius
  42749. */
  42750. get radiusScale(): number;
  42751. /**
  42752. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42753. */
  42754. set positionScale(scale: number);
  42755. /**
  42756. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42757. */
  42758. get positionScale(): number;
  42759. /**
  42760. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42761. * behaviour is triggered, in radians.
  42762. */
  42763. set defaultElevation(elevation: number);
  42764. /**
  42765. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42766. * behaviour is triggered, in radians.
  42767. */
  42768. get defaultElevation(): number;
  42769. /**
  42770. * Sets the time (in milliseconds) taken to return to the default beta position.
  42771. * Negative value indicates camera should not return to default.
  42772. */
  42773. set elevationReturnTime(speed: number);
  42774. /**
  42775. * Gets the time (in milliseconds) taken to return to the default beta position.
  42776. * Negative value indicates camera should not return to default.
  42777. */
  42778. get elevationReturnTime(): number;
  42779. /**
  42780. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42781. */
  42782. set elevationReturnWaitTime(time: number);
  42783. /**
  42784. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42785. */
  42786. get elevationReturnWaitTime(): number;
  42787. /**
  42788. * Sets the flag that indicates if user zooming should stop animation.
  42789. */
  42790. set zoomStopsAnimation(flag: boolean);
  42791. /**
  42792. * Gets the flag that indicates if user zooming should stop animation.
  42793. */
  42794. get zoomStopsAnimation(): boolean;
  42795. /**
  42796. * Sets the transition time when framing the mesh, in milliseconds
  42797. */
  42798. set framingTime(time: number);
  42799. /**
  42800. * Gets the transition time when framing the mesh, in milliseconds
  42801. */
  42802. get framingTime(): number;
  42803. /**
  42804. * Define if the behavior should automatically change the configured
  42805. * camera limits and sensibilities.
  42806. */
  42807. autoCorrectCameraLimitsAndSensibility: boolean;
  42808. private _onPrePointerObservableObserver;
  42809. private _onAfterCheckInputsObserver;
  42810. private _onMeshTargetChangedObserver;
  42811. private _attachedCamera;
  42812. private _isPointerDown;
  42813. private _lastInteractionTime;
  42814. /**
  42815. * Initializes the behavior.
  42816. */
  42817. init(): void;
  42818. /**
  42819. * Attaches the behavior to its arc rotate camera.
  42820. * @param camera Defines the camera to attach the behavior to
  42821. */
  42822. attach(camera: ArcRotateCamera): void;
  42823. /**
  42824. * Detaches the behavior from its current arc rotate camera.
  42825. */
  42826. detach(): void;
  42827. private _animatables;
  42828. private _betaIsAnimating;
  42829. private _betaTransition;
  42830. private _radiusTransition;
  42831. private _vectorTransition;
  42832. /**
  42833. * Targets the given mesh and updates zoom level accordingly.
  42834. * @param mesh The mesh to target.
  42835. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42836. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42837. */
  42838. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42839. /**
  42840. * Targets the given mesh with its children and updates zoom level accordingly.
  42841. * @param mesh The mesh to target.
  42842. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42843. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42844. */
  42845. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42846. /**
  42847. * Targets the given meshes with their children and updates zoom level accordingly.
  42848. * @param meshes The mesh to target.
  42849. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42850. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42851. */
  42852. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42853. /**
  42854. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42855. * @param minimumWorld Determines the smaller position of the bounding box extend
  42856. * @param maximumWorld Determines the bigger position of the bounding box extend
  42857. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42858. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42859. */
  42860. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42861. /**
  42862. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42863. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42864. * frustum width.
  42865. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42866. * to fully enclose the mesh in the viewing frustum.
  42867. */
  42868. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42869. /**
  42870. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42871. * is automatically returned to its default position (expected to be above ground plane).
  42872. */
  42873. private _maintainCameraAboveGround;
  42874. /**
  42875. * Returns the frustum slope based on the canvas ratio and camera FOV
  42876. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42877. */
  42878. private _getFrustumSlope;
  42879. /**
  42880. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42881. */
  42882. private _clearAnimationLocks;
  42883. /**
  42884. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42885. */
  42886. private _applyUserInteraction;
  42887. /**
  42888. * Stops and removes all animations that have been applied to the camera
  42889. */
  42890. stopAllAnimations(): void;
  42891. /**
  42892. * Gets a value indicating if the user is moving the camera
  42893. */
  42894. get isUserIsMoving(): boolean;
  42895. /**
  42896. * The camera can move all the way towards the mesh.
  42897. */
  42898. static IgnoreBoundsSizeMode: number;
  42899. /**
  42900. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42901. */
  42902. static FitFrustumSidesMode: number;
  42903. }
  42904. }
  42905. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42906. import { Nullable } from "babylonjs/types";
  42907. import { Camera } from "babylonjs/Cameras/camera";
  42908. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42909. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42910. /**
  42911. * Base class for Camera Pointer Inputs.
  42912. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42913. * for example usage.
  42914. */
  42915. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42916. /**
  42917. * Defines the camera the input is attached to.
  42918. */
  42919. abstract camera: Camera;
  42920. /**
  42921. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42922. */
  42923. protected _altKey: boolean;
  42924. protected _ctrlKey: boolean;
  42925. protected _metaKey: boolean;
  42926. protected _shiftKey: boolean;
  42927. /**
  42928. * Which mouse buttons were pressed at time of last mouse event.
  42929. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42930. */
  42931. protected _buttonsPressed: number;
  42932. /**
  42933. * Defines the buttons associated with the input to handle camera move.
  42934. */
  42935. buttons: number[];
  42936. /**
  42937. * Attach the input controls to a specific dom element to get the input from.
  42938. * @param element Defines the element the controls should be listened from
  42939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42940. */
  42941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42942. /**
  42943. * Detach the current controls from the specified dom element.
  42944. * @param element Defines the element to stop listening the inputs from
  42945. */
  42946. detachControl(element: Nullable<HTMLElement>): void;
  42947. /**
  42948. * Gets the class name of the current input.
  42949. * @returns the class name
  42950. */
  42951. getClassName(): string;
  42952. /**
  42953. * Get the friendly name associated with the input class.
  42954. * @returns the input friendly name
  42955. */
  42956. getSimpleName(): string;
  42957. /**
  42958. * Called on pointer POINTERDOUBLETAP event.
  42959. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42960. */
  42961. protected onDoubleTap(type: string): void;
  42962. /**
  42963. * Called on pointer POINTERMOVE event if only a single touch is active.
  42964. * Override this method to provide functionality.
  42965. */
  42966. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42967. /**
  42968. * Called on pointer POINTERMOVE event if multiple touches are active.
  42969. * Override this method to provide functionality.
  42970. */
  42971. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42972. /**
  42973. * Called on JS contextmenu event.
  42974. * Override this method to provide functionality.
  42975. */
  42976. protected onContextMenu(evt: PointerEvent): void;
  42977. /**
  42978. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42979. * press.
  42980. * Override this method to provide functionality.
  42981. */
  42982. protected onButtonDown(evt: PointerEvent): void;
  42983. /**
  42984. * Called each time a new POINTERUP event occurs. Ie, for each button
  42985. * release.
  42986. * Override this method to provide functionality.
  42987. */
  42988. protected onButtonUp(evt: PointerEvent): void;
  42989. /**
  42990. * Called when window becomes inactive.
  42991. * Override this method to provide functionality.
  42992. */
  42993. protected onLostFocus(): void;
  42994. private _pointerInput;
  42995. private _observer;
  42996. private _onLostFocus;
  42997. private pointA;
  42998. private pointB;
  42999. }
  43000. }
  43001. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43002. import { Nullable } from "babylonjs/types";
  43003. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43004. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43005. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43006. /**
  43007. * Manage the pointers inputs to control an arc rotate camera.
  43008. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43009. */
  43010. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43011. /**
  43012. * Defines the camera the input is attached to.
  43013. */
  43014. camera: ArcRotateCamera;
  43015. /**
  43016. * Gets the class name of the current input.
  43017. * @returns the class name
  43018. */
  43019. getClassName(): string;
  43020. /**
  43021. * Defines the buttons associated with the input to handle camera move.
  43022. */
  43023. buttons: number[];
  43024. /**
  43025. * Defines the pointer angular sensibility along the X axis or how fast is
  43026. * the camera rotating.
  43027. */
  43028. angularSensibilityX: number;
  43029. /**
  43030. * Defines the pointer angular sensibility along the Y axis or how fast is
  43031. * the camera rotating.
  43032. */
  43033. angularSensibilityY: number;
  43034. /**
  43035. * Defines the pointer pinch precision or how fast is the camera zooming.
  43036. */
  43037. pinchPrecision: number;
  43038. /**
  43039. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43040. * from 0.
  43041. * It defines the percentage of current camera.radius to use as delta when
  43042. * pinch zoom is used.
  43043. */
  43044. pinchDeltaPercentage: number;
  43045. /**
  43046. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43047. * that any object in the plane at the camera's target point will scale
  43048. * perfectly with finger motion.
  43049. * Overrides pinchDeltaPercentage and pinchPrecision.
  43050. */
  43051. useNaturalPinchZoom: boolean;
  43052. /**
  43053. * Defines the pointer panning sensibility or how fast is the camera moving.
  43054. */
  43055. panningSensibility: number;
  43056. /**
  43057. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43058. */
  43059. multiTouchPanning: boolean;
  43060. /**
  43061. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43062. * zoom (pinch) through multitouch.
  43063. */
  43064. multiTouchPanAndZoom: boolean;
  43065. /**
  43066. * Revers pinch action direction.
  43067. */
  43068. pinchInwards: boolean;
  43069. private _isPanClick;
  43070. private _twoFingerActivityCount;
  43071. private _isPinching;
  43072. /**
  43073. * Called on pointer POINTERMOVE event if only a single touch is active.
  43074. */
  43075. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43076. /**
  43077. * Called on pointer POINTERDOUBLETAP event.
  43078. */
  43079. protected onDoubleTap(type: string): void;
  43080. /**
  43081. * Called on pointer POINTERMOVE event if multiple touches are active.
  43082. */
  43083. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43084. /**
  43085. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43086. * press.
  43087. */
  43088. protected onButtonDown(evt: PointerEvent): void;
  43089. /**
  43090. * Called each time a new POINTERUP event occurs. Ie, for each button
  43091. * release.
  43092. */
  43093. protected onButtonUp(evt: PointerEvent): void;
  43094. /**
  43095. * Called when window becomes inactive.
  43096. */
  43097. protected onLostFocus(): void;
  43098. }
  43099. }
  43100. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43101. import { Nullable } from "babylonjs/types";
  43102. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43103. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43104. /**
  43105. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43106. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43107. */
  43108. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43109. /**
  43110. * Defines the camera the input is attached to.
  43111. */
  43112. camera: ArcRotateCamera;
  43113. /**
  43114. * Defines the list of key codes associated with the up action (increase alpha)
  43115. */
  43116. keysUp: number[];
  43117. /**
  43118. * Defines the list of key codes associated with the down action (decrease alpha)
  43119. */
  43120. keysDown: number[];
  43121. /**
  43122. * Defines the list of key codes associated with the left action (increase beta)
  43123. */
  43124. keysLeft: number[];
  43125. /**
  43126. * Defines the list of key codes associated with the right action (decrease beta)
  43127. */
  43128. keysRight: number[];
  43129. /**
  43130. * Defines the list of key codes associated with the reset action.
  43131. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43132. */
  43133. keysReset: number[];
  43134. /**
  43135. * Defines the panning sensibility of the inputs.
  43136. * (How fast is the camera panning)
  43137. */
  43138. panningSensibility: number;
  43139. /**
  43140. * Defines the zooming sensibility of the inputs.
  43141. * (How fast is the camera zooming)
  43142. */
  43143. zoomingSensibility: number;
  43144. /**
  43145. * Defines whether maintaining the alt key down switch the movement mode from
  43146. * orientation to zoom.
  43147. */
  43148. useAltToZoom: boolean;
  43149. /**
  43150. * Rotation speed of the camera
  43151. */
  43152. angularSpeed: number;
  43153. private _keys;
  43154. private _ctrlPressed;
  43155. private _altPressed;
  43156. private _onCanvasBlurObserver;
  43157. private _onKeyboardObserver;
  43158. private _engine;
  43159. private _scene;
  43160. /**
  43161. * Attach the input controls to a specific dom element to get the input from.
  43162. * @param element Defines the element the controls should be listened from
  43163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43164. */
  43165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43166. /**
  43167. * Detach the current controls from the specified dom element.
  43168. * @param element Defines the element to stop listening the inputs from
  43169. */
  43170. detachControl(element: Nullable<HTMLElement>): void;
  43171. /**
  43172. * Update the current camera state depending on the inputs that have been used this frame.
  43173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43174. */
  43175. checkInputs(): void;
  43176. /**
  43177. * Gets the class name of the current intput.
  43178. * @returns the class name
  43179. */
  43180. getClassName(): string;
  43181. /**
  43182. * Get the friendly name associated with the input class.
  43183. * @returns the input friendly name
  43184. */
  43185. getSimpleName(): string;
  43186. }
  43187. }
  43188. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  43189. import { Nullable } from "babylonjs/types";
  43190. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43191. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43192. /**
  43193. * Manage the mouse wheel inputs to control an arc rotate camera.
  43194. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43195. */
  43196. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  43197. /**
  43198. * Defines the camera the input is attached to.
  43199. */
  43200. camera: ArcRotateCamera;
  43201. /**
  43202. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43203. */
  43204. wheelPrecision: number;
  43205. /**
  43206. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43207. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43208. */
  43209. wheelDeltaPercentage: number;
  43210. private _wheel;
  43211. private _observer;
  43212. private computeDeltaFromMouseWheelLegacyEvent;
  43213. /**
  43214. * Attach the input controls to a specific dom element to get the input from.
  43215. * @param element Defines the element the controls should be listened from
  43216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43217. */
  43218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43219. /**
  43220. * Detach the current controls from the specified dom element.
  43221. * @param element Defines the element to stop listening the inputs from
  43222. */
  43223. detachControl(element: Nullable<HTMLElement>): void;
  43224. /**
  43225. * Gets the class name of the current intput.
  43226. * @returns the class name
  43227. */
  43228. getClassName(): string;
  43229. /**
  43230. * Get the friendly name associated with the input class.
  43231. * @returns the input friendly name
  43232. */
  43233. getSimpleName(): string;
  43234. }
  43235. }
  43236. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43237. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43238. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  43239. /**
  43240. * Default Inputs manager for the ArcRotateCamera.
  43241. * It groups all the default supported inputs for ease of use.
  43242. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43243. */
  43244. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43245. /**
  43246. * Instantiates a new ArcRotateCameraInputsManager.
  43247. * @param camera Defines the camera the inputs belong to
  43248. */
  43249. constructor(camera: ArcRotateCamera);
  43250. /**
  43251. * Add mouse wheel input support to the input manager.
  43252. * @returns the current input manager
  43253. */
  43254. addMouseWheel(): ArcRotateCameraInputsManager;
  43255. /**
  43256. * Add pointers input support to the input manager.
  43257. * @returns the current input manager
  43258. */
  43259. addPointers(): ArcRotateCameraInputsManager;
  43260. /**
  43261. * Add keyboard input support to the input manager.
  43262. * @returns the current input manager
  43263. */
  43264. addKeyboard(): ArcRotateCameraInputsManager;
  43265. }
  43266. }
  43267. declare module "babylonjs/Cameras/arcRotateCamera" {
  43268. import { Observable } from "babylonjs/Misc/observable";
  43269. import { Nullable } from "babylonjs/types";
  43270. import { Scene } from "babylonjs/scene";
  43271. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43273. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43274. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43275. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43276. import { Camera } from "babylonjs/Cameras/camera";
  43277. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43278. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43279. import { Collider } from "babylonjs/Collisions/collider";
  43280. /**
  43281. * This represents an orbital type of camera.
  43282. *
  43283. * 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.
  43284. * 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.
  43285. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43286. */
  43287. export class ArcRotateCamera extends TargetCamera {
  43288. /**
  43289. * Defines the rotation angle of the camera along the longitudinal axis.
  43290. */
  43291. alpha: number;
  43292. /**
  43293. * Defines the rotation angle of the camera along the latitudinal axis.
  43294. */
  43295. beta: number;
  43296. /**
  43297. * Defines the radius of the camera from it s target point.
  43298. */
  43299. radius: number;
  43300. protected _target: Vector3;
  43301. protected _targetHost: Nullable<AbstractMesh>;
  43302. /**
  43303. * Defines the target point of the camera.
  43304. * The camera looks towards it form the radius distance.
  43305. */
  43306. get target(): Vector3;
  43307. set target(value: Vector3);
  43308. /**
  43309. * Define the current local position of the camera in the scene
  43310. */
  43311. get position(): Vector3;
  43312. set position(newPosition: Vector3);
  43313. protected _upVector: Vector3;
  43314. protected _upToYMatrix: Matrix;
  43315. protected _YToUpMatrix: Matrix;
  43316. /**
  43317. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43318. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43319. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43320. */
  43321. set upVector(vec: Vector3);
  43322. get upVector(): Vector3;
  43323. /**
  43324. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43325. */
  43326. setMatUp(): void;
  43327. /**
  43328. * Current inertia value on the longitudinal axis.
  43329. * The bigger this number the longer it will take for the camera to stop.
  43330. */
  43331. inertialAlphaOffset: number;
  43332. /**
  43333. * Current inertia value on the latitudinal axis.
  43334. * The bigger this number the longer it will take for the camera to stop.
  43335. */
  43336. inertialBetaOffset: number;
  43337. /**
  43338. * Current inertia value on the radius axis.
  43339. * The bigger this number the longer it will take for the camera to stop.
  43340. */
  43341. inertialRadiusOffset: number;
  43342. /**
  43343. * Minimum allowed angle on the longitudinal axis.
  43344. * This can help limiting how the Camera is able to move in the scene.
  43345. */
  43346. lowerAlphaLimit: Nullable<number>;
  43347. /**
  43348. * Maximum allowed angle on the longitudinal axis.
  43349. * This can help limiting how the Camera is able to move in the scene.
  43350. */
  43351. upperAlphaLimit: Nullable<number>;
  43352. /**
  43353. * Minimum allowed angle on the latitudinal axis.
  43354. * This can help limiting how the Camera is able to move in the scene.
  43355. */
  43356. lowerBetaLimit: number;
  43357. /**
  43358. * Maximum allowed angle on the latitudinal axis.
  43359. * This can help limiting how the Camera is able to move in the scene.
  43360. */
  43361. upperBetaLimit: number;
  43362. /**
  43363. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43364. * This can help limiting how the Camera is able to move in the scene.
  43365. */
  43366. lowerRadiusLimit: Nullable<number>;
  43367. /**
  43368. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43369. * This can help limiting how the Camera is able to move in the scene.
  43370. */
  43371. upperRadiusLimit: Nullable<number>;
  43372. /**
  43373. * Defines the current inertia value used during panning of the camera along the X axis.
  43374. */
  43375. inertialPanningX: number;
  43376. /**
  43377. * Defines the current inertia value used during panning of the camera along the Y axis.
  43378. */
  43379. inertialPanningY: number;
  43380. /**
  43381. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43382. * Basically if your fingers moves away from more than this distance you will be considered
  43383. * in pinch mode.
  43384. */
  43385. pinchToPanMaxDistance: number;
  43386. /**
  43387. * Defines the maximum distance the camera can pan.
  43388. * This could help keeping the cammera always in your scene.
  43389. */
  43390. panningDistanceLimit: Nullable<number>;
  43391. /**
  43392. * Defines the target of the camera before paning.
  43393. */
  43394. panningOriginTarget: Vector3;
  43395. /**
  43396. * Defines the value of the inertia used during panning.
  43397. * 0 would mean stop inertia and one would mean no decelleration at all.
  43398. */
  43399. panningInertia: number;
  43400. /**
  43401. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43402. */
  43403. get angularSensibilityX(): number;
  43404. set angularSensibilityX(value: number);
  43405. /**
  43406. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43407. */
  43408. get angularSensibilityY(): number;
  43409. set angularSensibilityY(value: number);
  43410. /**
  43411. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43412. */
  43413. get pinchPrecision(): number;
  43414. set pinchPrecision(value: number);
  43415. /**
  43416. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43417. * It will be used instead of pinchDeltaPrecision if different from 0.
  43418. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43419. */
  43420. get pinchDeltaPercentage(): number;
  43421. set pinchDeltaPercentage(value: number);
  43422. /**
  43423. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43424. * and pinch delta percentage.
  43425. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43426. * that any object in the plane at the camera's target point will scale
  43427. * perfectly with finger motion.
  43428. */
  43429. get useNaturalPinchZoom(): boolean;
  43430. set useNaturalPinchZoom(value: boolean);
  43431. /**
  43432. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43433. */
  43434. get panningSensibility(): number;
  43435. set panningSensibility(value: number);
  43436. /**
  43437. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43438. */
  43439. get keysUp(): number[];
  43440. set keysUp(value: number[]);
  43441. /**
  43442. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43443. */
  43444. get keysDown(): number[];
  43445. set keysDown(value: number[]);
  43446. /**
  43447. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43448. */
  43449. get keysLeft(): number[];
  43450. set keysLeft(value: number[]);
  43451. /**
  43452. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43453. */
  43454. get keysRight(): number[];
  43455. set keysRight(value: number[]);
  43456. /**
  43457. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43458. */
  43459. get wheelPrecision(): number;
  43460. set wheelPrecision(value: number);
  43461. /**
  43462. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43463. * It will be used instead of pinchDeltaPrecision if different from 0.
  43464. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43465. */
  43466. get wheelDeltaPercentage(): number;
  43467. set wheelDeltaPercentage(value: number);
  43468. /**
  43469. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43470. */
  43471. zoomOnFactor: number;
  43472. /**
  43473. * Defines a screen offset for the camera position.
  43474. */
  43475. targetScreenOffset: Vector2;
  43476. /**
  43477. * Allows the camera to be completely reversed.
  43478. * If false the camera can not arrive upside down.
  43479. */
  43480. allowUpsideDown: boolean;
  43481. /**
  43482. * Define if double tap/click is used to restore the previously saved state of the camera.
  43483. */
  43484. useInputToRestoreState: boolean;
  43485. /** @hidden */
  43486. _viewMatrix: Matrix;
  43487. /** @hidden */
  43488. _useCtrlForPanning: boolean;
  43489. /** @hidden */
  43490. _panningMouseButton: number;
  43491. /**
  43492. * Defines the input associated to the camera.
  43493. */
  43494. inputs: ArcRotateCameraInputsManager;
  43495. /** @hidden */
  43496. _reset: () => void;
  43497. /**
  43498. * Defines the allowed panning axis.
  43499. */
  43500. panningAxis: Vector3;
  43501. protected _localDirection: Vector3;
  43502. protected _transformedDirection: Vector3;
  43503. private _bouncingBehavior;
  43504. /**
  43505. * Gets the bouncing behavior of the camera if it has been enabled.
  43506. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43507. */
  43508. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43509. /**
  43510. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43511. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43512. */
  43513. get useBouncingBehavior(): boolean;
  43514. set useBouncingBehavior(value: boolean);
  43515. private _framingBehavior;
  43516. /**
  43517. * Gets the framing behavior of the camera if it has been enabled.
  43518. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43519. */
  43520. get framingBehavior(): Nullable<FramingBehavior>;
  43521. /**
  43522. * Defines if the framing behavior of the camera is enabled on the camera.
  43523. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43524. */
  43525. get useFramingBehavior(): boolean;
  43526. set useFramingBehavior(value: boolean);
  43527. private _autoRotationBehavior;
  43528. /**
  43529. * Gets the auto rotation behavior of the camera if it has been enabled.
  43530. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43531. */
  43532. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43533. /**
  43534. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43535. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43536. */
  43537. get useAutoRotationBehavior(): boolean;
  43538. set useAutoRotationBehavior(value: boolean);
  43539. /**
  43540. * Observable triggered when the mesh target has been changed on the camera.
  43541. */
  43542. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43543. /**
  43544. * Event raised when the camera is colliding with a mesh.
  43545. */
  43546. onCollide: (collidedMesh: AbstractMesh) => void;
  43547. /**
  43548. * Defines whether the camera should check collision with the objects oh the scene.
  43549. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43550. */
  43551. checkCollisions: boolean;
  43552. /**
  43553. * Defines the collision radius of the camera.
  43554. * This simulates a sphere around the camera.
  43555. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43556. */
  43557. collisionRadius: Vector3;
  43558. protected _collider: Collider;
  43559. protected _previousPosition: Vector3;
  43560. protected _collisionVelocity: Vector3;
  43561. protected _newPosition: Vector3;
  43562. protected _previousAlpha: number;
  43563. protected _previousBeta: number;
  43564. protected _previousRadius: number;
  43565. protected _collisionTriggered: boolean;
  43566. protected _targetBoundingCenter: Nullable<Vector3>;
  43567. private _computationVector;
  43568. /**
  43569. * Instantiates a new ArcRotateCamera in a given scene
  43570. * @param name Defines the name of the camera
  43571. * @param alpha Defines the camera rotation along the logitudinal axis
  43572. * @param beta Defines the camera rotation along the latitudinal axis
  43573. * @param radius Defines the camera distance from its target
  43574. * @param target Defines the camera target
  43575. * @param scene Defines the scene the camera belongs to
  43576. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43577. */
  43578. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43579. /** @hidden */
  43580. _initCache(): void;
  43581. /** @hidden */
  43582. _updateCache(ignoreParentClass?: boolean): void;
  43583. protected _getTargetPosition(): Vector3;
  43584. private _storedAlpha;
  43585. private _storedBeta;
  43586. private _storedRadius;
  43587. private _storedTarget;
  43588. private _storedTargetScreenOffset;
  43589. /**
  43590. * Stores the current state of the camera (alpha, beta, radius and target)
  43591. * @returns the camera itself
  43592. */
  43593. storeState(): Camera;
  43594. /**
  43595. * @hidden
  43596. * Restored camera state. You must call storeState() first
  43597. */
  43598. _restoreStateValues(): boolean;
  43599. /** @hidden */
  43600. _isSynchronizedViewMatrix(): boolean;
  43601. /**
  43602. * Attached controls to the current camera.
  43603. * @param element Defines the element the controls should be listened from
  43604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43605. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43606. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43607. */
  43608. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43609. /**
  43610. * Detach the current controls from the camera.
  43611. * The camera will stop reacting to inputs.
  43612. * @param element Defines the element to stop listening the inputs from
  43613. */
  43614. detachControl(element: HTMLElement): void;
  43615. /** @hidden */
  43616. _checkInputs(): void;
  43617. protected _checkLimits(): void;
  43618. /**
  43619. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43620. */
  43621. rebuildAnglesAndRadius(): void;
  43622. /**
  43623. * Use a position to define the current camera related information like alpha, beta and radius
  43624. * @param position Defines the position to set the camera at
  43625. */
  43626. setPosition(position: Vector3): void;
  43627. /**
  43628. * Defines the target the camera should look at.
  43629. * This will automatically adapt alpha beta and radius to fit within the new target.
  43630. * @param target Defines the new target as a Vector or a mesh
  43631. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43632. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43633. */
  43634. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43635. /** @hidden */
  43636. _getViewMatrix(): Matrix;
  43637. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43638. /**
  43639. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43640. * @param meshes Defines the mesh to zoom on
  43641. * @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)
  43642. */
  43643. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43644. /**
  43645. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43646. * The target will be changed but the radius
  43647. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43648. * @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)
  43649. */
  43650. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43651. min: Vector3;
  43652. max: Vector3;
  43653. distance: number;
  43654. }, doNotUpdateMaxZ?: boolean): void;
  43655. /**
  43656. * @override
  43657. * Override Camera.createRigCamera
  43658. */
  43659. createRigCamera(name: string, cameraIndex: number): Camera;
  43660. /**
  43661. * @hidden
  43662. * @override
  43663. * Override Camera._updateRigCameras
  43664. */
  43665. _updateRigCameras(): void;
  43666. /**
  43667. * Destroy the camera and release the current resources hold by it.
  43668. */
  43669. dispose(): void;
  43670. /**
  43671. * Gets the current object class name.
  43672. * @return the class name
  43673. */
  43674. getClassName(): string;
  43675. }
  43676. }
  43677. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43678. import { Behavior } from "babylonjs/Behaviors/behavior";
  43679. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43680. /**
  43681. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43682. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43683. */
  43684. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43685. /**
  43686. * Gets the name of the behavior.
  43687. */
  43688. get name(): string;
  43689. private _zoomStopsAnimation;
  43690. private _idleRotationSpeed;
  43691. private _idleRotationWaitTime;
  43692. private _idleRotationSpinupTime;
  43693. /**
  43694. * Sets the flag that indicates if user zooming should stop animation.
  43695. */
  43696. set zoomStopsAnimation(flag: boolean);
  43697. /**
  43698. * Gets the flag that indicates if user zooming should stop animation.
  43699. */
  43700. get zoomStopsAnimation(): boolean;
  43701. /**
  43702. * Sets the default speed at which the camera rotates around the model.
  43703. */
  43704. set idleRotationSpeed(speed: number);
  43705. /**
  43706. * Gets the default speed at which the camera rotates around the model.
  43707. */
  43708. get idleRotationSpeed(): number;
  43709. /**
  43710. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43711. */
  43712. set idleRotationWaitTime(time: number);
  43713. /**
  43714. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43715. */
  43716. get idleRotationWaitTime(): number;
  43717. /**
  43718. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43719. */
  43720. set idleRotationSpinupTime(time: number);
  43721. /**
  43722. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43723. */
  43724. get idleRotationSpinupTime(): number;
  43725. /**
  43726. * Gets a value indicating if the camera is currently rotating because of this behavior
  43727. */
  43728. get rotationInProgress(): boolean;
  43729. private _onPrePointerObservableObserver;
  43730. private _onAfterCheckInputsObserver;
  43731. private _attachedCamera;
  43732. private _isPointerDown;
  43733. private _lastFrameTime;
  43734. private _lastInteractionTime;
  43735. private _cameraRotationSpeed;
  43736. /**
  43737. * Initializes the behavior.
  43738. */
  43739. init(): void;
  43740. /**
  43741. * Attaches the behavior to its arc rotate camera.
  43742. * @param camera Defines the camera to attach the behavior to
  43743. */
  43744. attach(camera: ArcRotateCamera): void;
  43745. /**
  43746. * Detaches the behavior from its current arc rotate camera.
  43747. */
  43748. detach(): void;
  43749. /**
  43750. * Returns true if user is scrolling.
  43751. * @return true if user is scrolling.
  43752. */
  43753. private _userIsZooming;
  43754. private _lastFrameRadius;
  43755. private _shouldAnimationStopForInteraction;
  43756. /**
  43757. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43758. */
  43759. private _applyUserInteraction;
  43760. private _userIsMoving;
  43761. }
  43762. }
  43763. declare module "babylonjs/Behaviors/Cameras/index" {
  43764. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43765. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43766. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43767. }
  43768. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43769. import { Mesh } from "babylonjs/Meshes/mesh";
  43770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43771. import { Behavior } from "babylonjs/Behaviors/behavior";
  43772. /**
  43773. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43774. */
  43775. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43776. private ui;
  43777. /**
  43778. * The name of the behavior
  43779. */
  43780. name: string;
  43781. /**
  43782. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43783. */
  43784. distanceAwayFromFace: number;
  43785. /**
  43786. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43787. */
  43788. distanceAwayFromBottomOfFace: number;
  43789. private _faceVectors;
  43790. private _target;
  43791. private _scene;
  43792. private _onRenderObserver;
  43793. private _tmpMatrix;
  43794. private _tmpVector;
  43795. /**
  43796. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43797. * @param ui The transform node that should be attched to the mesh
  43798. */
  43799. constructor(ui: TransformNode);
  43800. /**
  43801. * Initializes the behavior
  43802. */
  43803. init(): void;
  43804. private _closestFace;
  43805. private _zeroVector;
  43806. private _lookAtTmpMatrix;
  43807. private _lookAtToRef;
  43808. /**
  43809. * Attaches the AttachToBoxBehavior to the passed in mesh
  43810. * @param target The mesh that the specified node will be attached to
  43811. */
  43812. attach(target: Mesh): void;
  43813. /**
  43814. * Detaches the behavior from the mesh
  43815. */
  43816. detach(): void;
  43817. }
  43818. }
  43819. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43820. import { Behavior } from "babylonjs/Behaviors/behavior";
  43821. import { Mesh } from "babylonjs/Meshes/mesh";
  43822. /**
  43823. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43824. */
  43825. export class FadeInOutBehavior implements Behavior<Mesh> {
  43826. /**
  43827. * Time in milliseconds to delay before fading in (Default: 0)
  43828. */
  43829. delay: number;
  43830. /**
  43831. * Time in milliseconds for the mesh to fade in (Default: 300)
  43832. */
  43833. fadeInTime: number;
  43834. private _millisecondsPerFrame;
  43835. private _hovered;
  43836. private _hoverValue;
  43837. private _ownerNode;
  43838. /**
  43839. * Instatiates the FadeInOutBehavior
  43840. */
  43841. constructor();
  43842. /**
  43843. * The name of the behavior
  43844. */
  43845. get name(): string;
  43846. /**
  43847. * Initializes the behavior
  43848. */
  43849. init(): void;
  43850. /**
  43851. * Attaches the fade behavior on the passed in mesh
  43852. * @param ownerNode The mesh that will be faded in/out once attached
  43853. */
  43854. attach(ownerNode: Mesh): void;
  43855. /**
  43856. * Detaches the behavior from the mesh
  43857. */
  43858. detach(): void;
  43859. /**
  43860. * Triggers the mesh to begin fading in or out
  43861. * @param value if the object should fade in or out (true to fade in)
  43862. */
  43863. fadeIn(value: boolean): void;
  43864. private _update;
  43865. private _setAllVisibility;
  43866. }
  43867. }
  43868. declare module "babylonjs/Misc/pivotTools" {
  43869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43870. /**
  43871. * Class containing a set of static utilities functions for managing Pivots
  43872. * @hidden
  43873. */
  43874. export class PivotTools {
  43875. private static _PivotCached;
  43876. private static _OldPivotPoint;
  43877. private static _PivotTranslation;
  43878. private static _PivotTmpVector;
  43879. /** @hidden */
  43880. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43881. /** @hidden */
  43882. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43883. }
  43884. }
  43885. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43886. import { Scene } from "babylonjs/scene";
  43887. import { Vector4 } from "babylonjs/Maths/math.vector";
  43888. import { Mesh } from "babylonjs/Meshes/mesh";
  43889. import { Nullable } from "babylonjs/types";
  43890. import { Plane } from "babylonjs/Maths/math.plane";
  43891. /**
  43892. * Class containing static functions to help procedurally build meshes
  43893. */
  43894. export class PlaneBuilder {
  43895. /**
  43896. * Creates a plane mesh
  43897. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43898. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43899. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43903. * @param name defines the name of the mesh
  43904. * @param options defines the options used to create the mesh
  43905. * @param scene defines the hosting scene
  43906. * @returns the plane mesh
  43907. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43908. */
  43909. static CreatePlane(name: string, options: {
  43910. size?: number;
  43911. width?: number;
  43912. height?: number;
  43913. sideOrientation?: number;
  43914. frontUVs?: Vector4;
  43915. backUVs?: Vector4;
  43916. updatable?: boolean;
  43917. sourcePlane?: Plane;
  43918. }, scene?: Nullable<Scene>): Mesh;
  43919. }
  43920. }
  43921. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43922. import { Behavior } from "babylonjs/Behaviors/behavior";
  43923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43924. import { Observable } from "babylonjs/Misc/observable";
  43925. import { Vector3 } from "babylonjs/Maths/math.vector";
  43926. import { Ray } from "babylonjs/Culling/ray";
  43927. import "babylonjs/Meshes/Builders/planeBuilder";
  43928. /**
  43929. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43930. */
  43931. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43932. private static _AnyMouseID;
  43933. /**
  43934. * Abstract mesh the behavior is set on
  43935. */
  43936. attachedNode: AbstractMesh;
  43937. private _dragPlane;
  43938. private _scene;
  43939. private _pointerObserver;
  43940. private _beforeRenderObserver;
  43941. private static _planeScene;
  43942. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43943. /**
  43944. * 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)
  43945. */
  43946. maxDragAngle: number;
  43947. /**
  43948. * @hidden
  43949. */
  43950. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43951. /**
  43952. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43953. */
  43954. currentDraggingPointerID: number;
  43955. /**
  43956. * The last position where the pointer hit the drag plane in world space
  43957. */
  43958. lastDragPosition: Vector3;
  43959. /**
  43960. * If the behavior is currently in a dragging state
  43961. */
  43962. dragging: boolean;
  43963. /**
  43964. * 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)
  43965. */
  43966. dragDeltaRatio: number;
  43967. /**
  43968. * If the drag plane orientation should be updated during the dragging (Default: true)
  43969. */
  43970. updateDragPlane: boolean;
  43971. private _debugMode;
  43972. private _moving;
  43973. /**
  43974. * Fires each time the attached mesh is dragged with the pointer
  43975. * * delta between last drag position and current drag position in world space
  43976. * * dragDistance along the drag axis
  43977. * * dragPlaneNormal normal of the current drag plane used during the drag
  43978. * * dragPlanePoint in world space where the drag intersects the drag plane
  43979. */
  43980. onDragObservable: Observable<{
  43981. delta: Vector3;
  43982. dragPlanePoint: Vector3;
  43983. dragPlaneNormal: Vector3;
  43984. dragDistance: number;
  43985. pointerId: number;
  43986. }>;
  43987. /**
  43988. * Fires each time a drag begins (eg. mouse down on mesh)
  43989. */
  43990. onDragStartObservable: Observable<{
  43991. dragPlanePoint: Vector3;
  43992. pointerId: number;
  43993. }>;
  43994. /**
  43995. * Fires each time a drag ends (eg. mouse release after drag)
  43996. */
  43997. onDragEndObservable: Observable<{
  43998. dragPlanePoint: Vector3;
  43999. pointerId: number;
  44000. }>;
  44001. /**
  44002. * If the attached mesh should be moved when dragged
  44003. */
  44004. moveAttached: boolean;
  44005. /**
  44006. * If the drag behavior will react to drag events (Default: true)
  44007. */
  44008. enabled: boolean;
  44009. /**
  44010. * If pointer events should start and release the drag (Default: true)
  44011. */
  44012. startAndReleaseDragOnPointerEvents: boolean;
  44013. /**
  44014. * If camera controls should be detached during the drag
  44015. */
  44016. detachCameraControls: boolean;
  44017. /**
  44018. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44019. */
  44020. useObjectOrientationForDragging: boolean;
  44021. private _options;
  44022. /**
  44023. * Gets the options used by the behavior
  44024. */
  44025. get options(): {
  44026. dragAxis?: Vector3;
  44027. dragPlaneNormal?: Vector3;
  44028. };
  44029. /**
  44030. * Sets the options used by the behavior
  44031. */
  44032. set options(options: {
  44033. dragAxis?: Vector3;
  44034. dragPlaneNormal?: Vector3;
  44035. });
  44036. /**
  44037. * Creates a pointer drag behavior that can be attached to a mesh
  44038. * @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)
  44039. */
  44040. constructor(options?: {
  44041. dragAxis?: Vector3;
  44042. dragPlaneNormal?: Vector3;
  44043. });
  44044. /**
  44045. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44046. */
  44047. validateDrag: (targetPosition: Vector3) => boolean;
  44048. /**
  44049. * The name of the behavior
  44050. */
  44051. get name(): string;
  44052. /**
  44053. * Initializes the behavior
  44054. */
  44055. init(): void;
  44056. private _tmpVector;
  44057. private _alternatePickedPoint;
  44058. private _worldDragAxis;
  44059. private _targetPosition;
  44060. private _attachedElement;
  44061. /**
  44062. * Attaches the drag behavior the passed in mesh
  44063. * @param ownerNode The mesh that will be dragged around once attached
  44064. * @param predicate Predicate to use for pick filtering
  44065. */
  44066. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44067. /**
  44068. * Force relase the drag action by code.
  44069. */
  44070. releaseDrag(): void;
  44071. private _startDragRay;
  44072. private _lastPointerRay;
  44073. /**
  44074. * Simulates the start of a pointer drag event on the behavior
  44075. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44076. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44077. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44078. */
  44079. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44080. private _startDrag;
  44081. private _dragDelta;
  44082. private _moveDrag;
  44083. private _pickWithRayOnDragPlane;
  44084. private _pointA;
  44085. private _pointB;
  44086. private _pointC;
  44087. private _lineA;
  44088. private _lineB;
  44089. private _localAxis;
  44090. private _lookAt;
  44091. private _updateDragPlanePosition;
  44092. /**
  44093. * Detaches the behavior from the mesh
  44094. */
  44095. detach(): void;
  44096. }
  44097. }
  44098. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44099. import { Mesh } from "babylonjs/Meshes/mesh";
  44100. import { Behavior } from "babylonjs/Behaviors/behavior";
  44101. /**
  44102. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44103. */
  44104. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44105. private _dragBehaviorA;
  44106. private _dragBehaviorB;
  44107. private _startDistance;
  44108. private _initialScale;
  44109. private _targetScale;
  44110. private _ownerNode;
  44111. private _sceneRenderObserver;
  44112. /**
  44113. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44114. */
  44115. constructor();
  44116. /**
  44117. * The name of the behavior
  44118. */
  44119. get name(): string;
  44120. /**
  44121. * Initializes the behavior
  44122. */
  44123. init(): void;
  44124. private _getCurrentDistance;
  44125. /**
  44126. * Attaches the scale behavior the passed in mesh
  44127. * @param ownerNode The mesh that will be scaled around once attached
  44128. */
  44129. attach(ownerNode: Mesh): void;
  44130. /**
  44131. * Detaches the behavior from the mesh
  44132. */
  44133. detach(): void;
  44134. }
  44135. }
  44136. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44137. import { Behavior } from "babylonjs/Behaviors/behavior";
  44138. import { Mesh } from "babylonjs/Meshes/mesh";
  44139. import { Observable } from "babylonjs/Misc/observable";
  44140. /**
  44141. * 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
  44142. */
  44143. export class SixDofDragBehavior implements Behavior<Mesh> {
  44144. private static _virtualScene;
  44145. private _ownerNode;
  44146. private _sceneRenderObserver;
  44147. private _scene;
  44148. private _targetPosition;
  44149. private _virtualOriginMesh;
  44150. private _virtualDragMesh;
  44151. private _pointerObserver;
  44152. private _moving;
  44153. private _startingOrientation;
  44154. private _attachedElement;
  44155. /**
  44156. * 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)
  44157. */
  44158. private zDragFactor;
  44159. /**
  44160. * If the object should rotate to face the drag origin
  44161. */
  44162. rotateDraggedObject: boolean;
  44163. /**
  44164. * If the behavior is currently in a dragging state
  44165. */
  44166. dragging: boolean;
  44167. /**
  44168. * 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)
  44169. */
  44170. dragDeltaRatio: number;
  44171. /**
  44172. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44173. */
  44174. currentDraggingPointerID: number;
  44175. /**
  44176. * If camera controls should be detached during the drag
  44177. */
  44178. detachCameraControls: boolean;
  44179. /**
  44180. * Fires each time a drag starts
  44181. */
  44182. onDragStartObservable: Observable<{}>;
  44183. /**
  44184. * Fires each time a drag ends (eg. mouse release after drag)
  44185. */
  44186. onDragEndObservable: Observable<{}>;
  44187. /**
  44188. * 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
  44189. */
  44190. constructor();
  44191. /**
  44192. * The name of the behavior
  44193. */
  44194. get name(): string;
  44195. /**
  44196. * Initializes the behavior
  44197. */
  44198. init(): void;
  44199. /**
  44200. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  44201. */
  44202. private get _pointerCamera();
  44203. /**
  44204. * Attaches the scale behavior the passed in mesh
  44205. * @param ownerNode The mesh that will be scaled around once attached
  44206. */
  44207. attach(ownerNode: Mesh): void;
  44208. /**
  44209. * Detaches the behavior from the mesh
  44210. */
  44211. detach(): void;
  44212. }
  44213. }
  44214. declare module "babylonjs/Behaviors/Meshes/index" {
  44215. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  44216. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  44217. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  44218. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44219. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44220. }
  44221. declare module "babylonjs/Behaviors/index" {
  44222. export * from "babylonjs/Behaviors/behavior";
  44223. export * from "babylonjs/Behaviors/Cameras/index";
  44224. export * from "babylonjs/Behaviors/Meshes/index";
  44225. }
  44226. declare module "babylonjs/Bones/boneIKController" {
  44227. import { Bone } from "babylonjs/Bones/bone";
  44228. import { Vector3 } from "babylonjs/Maths/math.vector";
  44229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44230. import { Nullable } from "babylonjs/types";
  44231. /**
  44232. * Class used to apply inverse kinematics to bones
  44233. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  44234. */
  44235. export class BoneIKController {
  44236. private static _tmpVecs;
  44237. private static _tmpQuat;
  44238. private static _tmpMats;
  44239. /**
  44240. * Gets or sets the target mesh
  44241. */
  44242. targetMesh: AbstractMesh;
  44243. /** Gets or sets the mesh used as pole */
  44244. poleTargetMesh: AbstractMesh;
  44245. /**
  44246. * Gets or sets the bone used as pole
  44247. */
  44248. poleTargetBone: Nullable<Bone>;
  44249. /**
  44250. * Gets or sets the target position
  44251. */
  44252. targetPosition: Vector3;
  44253. /**
  44254. * Gets or sets the pole target position
  44255. */
  44256. poleTargetPosition: Vector3;
  44257. /**
  44258. * Gets or sets the pole target local offset
  44259. */
  44260. poleTargetLocalOffset: Vector3;
  44261. /**
  44262. * Gets or sets the pole angle
  44263. */
  44264. poleAngle: number;
  44265. /**
  44266. * Gets or sets the mesh associated with the controller
  44267. */
  44268. mesh: AbstractMesh;
  44269. /**
  44270. * 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)
  44271. */
  44272. slerpAmount: number;
  44273. private _bone1Quat;
  44274. private _bone1Mat;
  44275. private _bone2Ang;
  44276. private _bone1;
  44277. private _bone2;
  44278. private _bone1Length;
  44279. private _bone2Length;
  44280. private _maxAngle;
  44281. private _maxReach;
  44282. private _rightHandedSystem;
  44283. private _bendAxis;
  44284. private _slerping;
  44285. private _adjustRoll;
  44286. /**
  44287. * Gets or sets maximum allowed angle
  44288. */
  44289. get maxAngle(): number;
  44290. set maxAngle(value: number);
  44291. /**
  44292. * Creates a new BoneIKController
  44293. * @param mesh defines the mesh to control
  44294. * @param bone defines the bone to control
  44295. * @param options defines options to set up the controller
  44296. */
  44297. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44298. targetMesh?: AbstractMesh;
  44299. poleTargetMesh?: AbstractMesh;
  44300. poleTargetBone?: Bone;
  44301. poleTargetLocalOffset?: Vector3;
  44302. poleAngle?: number;
  44303. bendAxis?: Vector3;
  44304. maxAngle?: number;
  44305. slerpAmount?: number;
  44306. });
  44307. private _setMaxAngle;
  44308. /**
  44309. * Force the controller to update the bones
  44310. */
  44311. update(): void;
  44312. }
  44313. }
  44314. declare module "babylonjs/Bones/boneLookController" {
  44315. import { Vector3 } from "babylonjs/Maths/math.vector";
  44316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44317. import { Bone } from "babylonjs/Bones/bone";
  44318. import { Space } from "babylonjs/Maths/math.axis";
  44319. /**
  44320. * Class used to make a bone look toward a point in space
  44321. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44322. */
  44323. export class BoneLookController {
  44324. private static _tmpVecs;
  44325. private static _tmpQuat;
  44326. private static _tmpMats;
  44327. /**
  44328. * The target Vector3 that the bone will look at
  44329. */
  44330. target: Vector3;
  44331. /**
  44332. * The mesh that the bone is attached to
  44333. */
  44334. mesh: AbstractMesh;
  44335. /**
  44336. * The bone that will be looking to the target
  44337. */
  44338. bone: Bone;
  44339. /**
  44340. * The up axis of the coordinate system that is used when the bone is rotated
  44341. */
  44342. upAxis: Vector3;
  44343. /**
  44344. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44345. */
  44346. upAxisSpace: Space;
  44347. /**
  44348. * Used to make an adjustment to the yaw of the bone
  44349. */
  44350. adjustYaw: number;
  44351. /**
  44352. * Used to make an adjustment to the pitch of the bone
  44353. */
  44354. adjustPitch: number;
  44355. /**
  44356. * Used to make an adjustment to the roll of the bone
  44357. */
  44358. adjustRoll: number;
  44359. /**
  44360. * 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)
  44361. */
  44362. slerpAmount: number;
  44363. private _minYaw;
  44364. private _maxYaw;
  44365. private _minPitch;
  44366. private _maxPitch;
  44367. private _minYawSin;
  44368. private _minYawCos;
  44369. private _maxYawSin;
  44370. private _maxYawCos;
  44371. private _midYawConstraint;
  44372. private _minPitchTan;
  44373. private _maxPitchTan;
  44374. private _boneQuat;
  44375. private _slerping;
  44376. private _transformYawPitch;
  44377. private _transformYawPitchInv;
  44378. private _firstFrameSkipped;
  44379. private _yawRange;
  44380. private _fowardAxis;
  44381. /**
  44382. * Gets or sets the minimum yaw angle that the bone can look to
  44383. */
  44384. get minYaw(): number;
  44385. set minYaw(value: number);
  44386. /**
  44387. * Gets or sets the maximum yaw angle that the bone can look to
  44388. */
  44389. get maxYaw(): number;
  44390. set maxYaw(value: number);
  44391. /**
  44392. * Gets or sets the minimum pitch angle that the bone can look to
  44393. */
  44394. get minPitch(): number;
  44395. set minPitch(value: number);
  44396. /**
  44397. * Gets or sets the maximum pitch angle that the bone can look to
  44398. */
  44399. get maxPitch(): number;
  44400. set maxPitch(value: number);
  44401. /**
  44402. * Create a BoneLookController
  44403. * @param mesh the mesh that the bone belongs to
  44404. * @param bone the bone that will be looking to the target
  44405. * @param target the target Vector3 to look at
  44406. * @param options optional settings:
  44407. * * maxYaw: the maximum angle the bone will yaw to
  44408. * * minYaw: the minimum angle the bone will yaw to
  44409. * * maxPitch: the maximum angle the bone will pitch to
  44410. * * minPitch: the minimum angle the bone will yaw to
  44411. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44412. * * upAxis: the up axis of the coordinate system
  44413. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44414. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44415. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44416. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44417. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44418. * * adjustRoll: used to make an adjustment to the roll of the bone
  44419. **/
  44420. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44421. maxYaw?: number;
  44422. minYaw?: number;
  44423. maxPitch?: number;
  44424. minPitch?: number;
  44425. slerpAmount?: number;
  44426. upAxis?: Vector3;
  44427. upAxisSpace?: Space;
  44428. yawAxis?: Vector3;
  44429. pitchAxis?: Vector3;
  44430. adjustYaw?: number;
  44431. adjustPitch?: number;
  44432. adjustRoll?: number;
  44433. });
  44434. /**
  44435. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44436. */
  44437. update(): void;
  44438. private _getAngleDiff;
  44439. private _getAngleBetween;
  44440. private _isAngleBetween;
  44441. }
  44442. }
  44443. declare module "babylonjs/Bones/index" {
  44444. export * from "babylonjs/Bones/bone";
  44445. export * from "babylonjs/Bones/boneIKController";
  44446. export * from "babylonjs/Bones/boneLookController";
  44447. export * from "babylonjs/Bones/skeleton";
  44448. }
  44449. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44450. import { Nullable } from "babylonjs/types";
  44451. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44452. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44453. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44454. /**
  44455. * Manage the gamepad inputs to control an arc rotate camera.
  44456. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44457. */
  44458. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44459. /**
  44460. * Defines the camera the input is attached to.
  44461. */
  44462. camera: ArcRotateCamera;
  44463. /**
  44464. * Defines the gamepad the input is gathering event from.
  44465. */
  44466. gamepad: Nullable<Gamepad>;
  44467. /**
  44468. * Defines the gamepad rotation sensiblity.
  44469. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44470. */
  44471. gamepadRotationSensibility: number;
  44472. /**
  44473. * Defines the gamepad move sensiblity.
  44474. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44475. */
  44476. gamepadMoveSensibility: number;
  44477. private _yAxisScale;
  44478. /**
  44479. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44480. */
  44481. get invertYAxis(): boolean;
  44482. set invertYAxis(value: boolean);
  44483. private _onGamepadConnectedObserver;
  44484. private _onGamepadDisconnectedObserver;
  44485. /**
  44486. * Attach the input controls to a specific dom element to get the input from.
  44487. * @param element Defines the element the controls should be listened from
  44488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44489. */
  44490. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44491. /**
  44492. * Detach the current controls from the specified dom element.
  44493. * @param element Defines the element to stop listening the inputs from
  44494. */
  44495. detachControl(element: Nullable<HTMLElement>): void;
  44496. /**
  44497. * Update the current camera state depending on the inputs that have been used this frame.
  44498. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44499. */
  44500. checkInputs(): void;
  44501. /**
  44502. * Gets the class name of the current intput.
  44503. * @returns the class name
  44504. */
  44505. getClassName(): string;
  44506. /**
  44507. * Get the friendly name associated with the input class.
  44508. * @returns the input friendly name
  44509. */
  44510. getSimpleName(): string;
  44511. }
  44512. }
  44513. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44514. import { Nullable } from "babylonjs/types";
  44515. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44516. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44517. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44518. interface ArcRotateCameraInputsManager {
  44519. /**
  44520. * Add orientation input support to the input manager.
  44521. * @returns the current input manager
  44522. */
  44523. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44524. }
  44525. }
  44526. /**
  44527. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44528. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44529. */
  44530. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44531. /**
  44532. * Defines the camera the input is attached to.
  44533. */
  44534. camera: ArcRotateCamera;
  44535. /**
  44536. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44537. */
  44538. alphaCorrection: number;
  44539. /**
  44540. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44541. */
  44542. gammaCorrection: number;
  44543. private _alpha;
  44544. private _gamma;
  44545. private _dirty;
  44546. private _deviceOrientationHandler;
  44547. /**
  44548. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44549. */
  44550. constructor();
  44551. /**
  44552. * Attach the input controls to a specific dom element to get the input from.
  44553. * @param element Defines the element the controls should be listened from
  44554. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44555. */
  44556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44557. /** @hidden */
  44558. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44559. /**
  44560. * Update the current camera state depending on the inputs that have been used this frame.
  44561. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44562. */
  44563. checkInputs(): void;
  44564. /**
  44565. * Detach the current controls from the specified dom element.
  44566. * @param element Defines the element to stop listening the inputs from
  44567. */
  44568. detachControl(element: Nullable<HTMLElement>): void;
  44569. /**
  44570. * Gets the class name of the current intput.
  44571. * @returns the class name
  44572. */
  44573. getClassName(): string;
  44574. /**
  44575. * Get the friendly name associated with the input class.
  44576. * @returns the input friendly name
  44577. */
  44578. getSimpleName(): string;
  44579. }
  44580. }
  44581. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44582. import { Nullable } from "babylonjs/types";
  44583. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44584. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44585. /**
  44586. * Listen to mouse events to control the camera.
  44587. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44588. */
  44589. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44590. /**
  44591. * Defines the camera the input is attached to.
  44592. */
  44593. camera: FlyCamera;
  44594. /**
  44595. * Defines if touch is enabled. (Default is true.)
  44596. */
  44597. touchEnabled: boolean;
  44598. /**
  44599. * Defines the buttons associated with the input to handle camera rotation.
  44600. */
  44601. buttons: number[];
  44602. /**
  44603. * Assign buttons for Yaw control.
  44604. */
  44605. buttonsYaw: number[];
  44606. /**
  44607. * Assign buttons for Pitch control.
  44608. */
  44609. buttonsPitch: number[];
  44610. /**
  44611. * Assign buttons for Roll control.
  44612. */
  44613. buttonsRoll: number[];
  44614. /**
  44615. * Detect if any button is being pressed while mouse is moved.
  44616. * -1 = Mouse locked.
  44617. * 0 = Left button.
  44618. * 1 = Middle Button.
  44619. * 2 = Right Button.
  44620. */
  44621. activeButton: number;
  44622. /**
  44623. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44624. * Higher values reduce its sensitivity.
  44625. */
  44626. angularSensibility: number;
  44627. private _mousemoveCallback;
  44628. private _observer;
  44629. private _rollObserver;
  44630. private previousPosition;
  44631. private noPreventDefault;
  44632. private element;
  44633. /**
  44634. * Listen to mouse events to control the camera.
  44635. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44636. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44637. */
  44638. constructor(touchEnabled?: boolean);
  44639. /**
  44640. * Attach the mouse control to the HTML DOM element.
  44641. * @param element Defines the element that listens to the input events.
  44642. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44643. */
  44644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44645. /**
  44646. * Detach the current controls from the specified dom element.
  44647. * @param element Defines the element to stop listening the inputs from
  44648. */
  44649. detachControl(element: Nullable<HTMLElement>): void;
  44650. /**
  44651. * Gets the class name of the current input.
  44652. * @returns the class name.
  44653. */
  44654. getClassName(): string;
  44655. /**
  44656. * Get the friendly name associated with the input class.
  44657. * @returns the input's friendly name.
  44658. */
  44659. getSimpleName(): string;
  44660. private _pointerInput;
  44661. private _onMouseMove;
  44662. /**
  44663. * Rotate camera by mouse offset.
  44664. */
  44665. private rotateCamera;
  44666. }
  44667. }
  44668. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44669. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44670. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44671. /**
  44672. * Default Inputs manager for the FlyCamera.
  44673. * It groups all the default supported inputs for ease of use.
  44674. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44675. */
  44676. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44677. /**
  44678. * Instantiates a new FlyCameraInputsManager.
  44679. * @param camera Defines the camera the inputs belong to.
  44680. */
  44681. constructor(camera: FlyCamera);
  44682. /**
  44683. * Add keyboard input support to the input manager.
  44684. * @returns the new FlyCameraKeyboardMoveInput().
  44685. */
  44686. addKeyboard(): FlyCameraInputsManager;
  44687. /**
  44688. * Add mouse input support to the input manager.
  44689. * @param touchEnabled Enable touch screen support.
  44690. * @returns the new FlyCameraMouseInput().
  44691. */
  44692. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44693. }
  44694. }
  44695. declare module "babylonjs/Cameras/flyCamera" {
  44696. import { Scene } from "babylonjs/scene";
  44697. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44699. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44700. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44701. /**
  44702. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44703. * such as in a 3D Space Shooter or a Flight Simulator.
  44704. */
  44705. export class FlyCamera extends TargetCamera {
  44706. /**
  44707. * Define the collision ellipsoid of the camera.
  44708. * This is helpful for simulating a camera body, like a player's body.
  44709. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44710. */
  44711. ellipsoid: Vector3;
  44712. /**
  44713. * Define an offset for the position of the ellipsoid around the camera.
  44714. * This can be helpful if the camera is attached away from the player's body center,
  44715. * such as at its head.
  44716. */
  44717. ellipsoidOffset: Vector3;
  44718. /**
  44719. * Enable or disable collisions of the camera with the rest of the scene objects.
  44720. */
  44721. checkCollisions: boolean;
  44722. /**
  44723. * Enable or disable gravity on the camera.
  44724. */
  44725. applyGravity: boolean;
  44726. /**
  44727. * Define the current direction the camera is moving to.
  44728. */
  44729. cameraDirection: Vector3;
  44730. /**
  44731. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44732. * This overrides and empties cameraRotation.
  44733. */
  44734. rotationQuaternion: Quaternion;
  44735. /**
  44736. * Track Roll to maintain the wanted Rolling when looking around.
  44737. */
  44738. _trackRoll: number;
  44739. /**
  44740. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44741. */
  44742. rollCorrect: number;
  44743. /**
  44744. * Mimic a banked turn, Rolling the camera when Yawing.
  44745. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44746. */
  44747. bankedTurn: boolean;
  44748. /**
  44749. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44750. */
  44751. bankedTurnLimit: number;
  44752. /**
  44753. * Value of 0 disables the banked Roll.
  44754. * Value of 1 is equal to the Yaw angle in radians.
  44755. */
  44756. bankedTurnMultiplier: number;
  44757. /**
  44758. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44759. */
  44760. inputs: FlyCameraInputsManager;
  44761. /**
  44762. * Gets the input sensibility for mouse input.
  44763. * Higher values reduce sensitivity.
  44764. */
  44765. get angularSensibility(): number;
  44766. /**
  44767. * Sets the input sensibility for a mouse input.
  44768. * Higher values reduce sensitivity.
  44769. */
  44770. set angularSensibility(value: number);
  44771. /**
  44772. * Get the keys for camera movement forward.
  44773. */
  44774. get keysForward(): number[];
  44775. /**
  44776. * Set the keys for camera movement forward.
  44777. */
  44778. set keysForward(value: number[]);
  44779. /**
  44780. * Get the keys for camera movement backward.
  44781. */
  44782. get keysBackward(): number[];
  44783. set keysBackward(value: number[]);
  44784. /**
  44785. * Get the keys for camera movement up.
  44786. */
  44787. get keysUp(): number[];
  44788. /**
  44789. * Set the keys for camera movement up.
  44790. */
  44791. set keysUp(value: number[]);
  44792. /**
  44793. * Get the keys for camera movement down.
  44794. */
  44795. get keysDown(): number[];
  44796. /**
  44797. * Set the keys for camera movement down.
  44798. */
  44799. set keysDown(value: number[]);
  44800. /**
  44801. * Get the keys for camera movement left.
  44802. */
  44803. get keysLeft(): number[];
  44804. /**
  44805. * Set the keys for camera movement left.
  44806. */
  44807. set keysLeft(value: number[]);
  44808. /**
  44809. * Set the keys for camera movement right.
  44810. */
  44811. get keysRight(): number[];
  44812. /**
  44813. * Set the keys for camera movement right.
  44814. */
  44815. set keysRight(value: number[]);
  44816. /**
  44817. * Event raised when the camera collides with a mesh in the scene.
  44818. */
  44819. onCollide: (collidedMesh: AbstractMesh) => void;
  44820. private _collider;
  44821. private _needMoveForGravity;
  44822. private _oldPosition;
  44823. private _diffPosition;
  44824. private _newPosition;
  44825. /** @hidden */
  44826. _localDirection: Vector3;
  44827. /** @hidden */
  44828. _transformedDirection: Vector3;
  44829. /**
  44830. * Instantiates a FlyCamera.
  44831. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44832. * such as in a 3D Space Shooter or a Flight Simulator.
  44833. * @param name Define the name of the camera in the scene.
  44834. * @param position Define the starting position of the camera in the scene.
  44835. * @param scene Define the scene the camera belongs to.
  44836. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44837. */
  44838. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44839. /**
  44840. * Attach a control to the HTML DOM element.
  44841. * @param element Defines the element that listens to the input events.
  44842. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44843. */
  44844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44845. /**
  44846. * Detach a control from the HTML DOM element.
  44847. * The camera will stop reacting to that input.
  44848. * @param element Defines the element that listens to the input events.
  44849. */
  44850. detachControl(element: HTMLElement): void;
  44851. private _collisionMask;
  44852. /**
  44853. * Get the mask that the camera ignores in collision events.
  44854. */
  44855. get collisionMask(): number;
  44856. /**
  44857. * Set the mask that the camera ignores in collision events.
  44858. */
  44859. set collisionMask(mask: number);
  44860. /** @hidden */
  44861. _collideWithWorld(displacement: Vector3): void;
  44862. /** @hidden */
  44863. private _onCollisionPositionChange;
  44864. /** @hidden */
  44865. _checkInputs(): void;
  44866. /** @hidden */
  44867. _decideIfNeedsToMove(): boolean;
  44868. /** @hidden */
  44869. _updatePosition(): void;
  44870. /**
  44871. * Restore the Roll to its target value at the rate specified.
  44872. * @param rate - Higher means slower restoring.
  44873. * @hidden
  44874. */
  44875. restoreRoll(rate: number): void;
  44876. /**
  44877. * Destroy the camera and release the current resources held by it.
  44878. */
  44879. dispose(): void;
  44880. /**
  44881. * Get the current object class name.
  44882. * @returns the class name.
  44883. */
  44884. getClassName(): string;
  44885. }
  44886. }
  44887. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44888. import { Nullable } from "babylonjs/types";
  44889. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44890. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44891. /**
  44892. * Listen to keyboard events to control the camera.
  44893. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44894. */
  44895. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44896. /**
  44897. * Defines the camera the input is attached to.
  44898. */
  44899. camera: FlyCamera;
  44900. /**
  44901. * The list of keyboard keys used to control the forward move of the camera.
  44902. */
  44903. keysForward: number[];
  44904. /**
  44905. * The list of keyboard keys used to control the backward move of the camera.
  44906. */
  44907. keysBackward: number[];
  44908. /**
  44909. * The list of keyboard keys used to control the forward move of the camera.
  44910. */
  44911. keysUp: number[];
  44912. /**
  44913. * The list of keyboard keys used to control the backward move of the camera.
  44914. */
  44915. keysDown: number[];
  44916. /**
  44917. * The list of keyboard keys used to control the right strafe move of the camera.
  44918. */
  44919. keysRight: number[];
  44920. /**
  44921. * The list of keyboard keys used to control the left strafe move of the camera.
  44922. */
  44923. keysLeft: number[];
  44924. private _keys;
  44925. private _onCanvasBlurObserver;
  44926. private _onKeyboardObserver;
  44927. private _engine;
  44928. private _scene;
  44929. /**
  44930. * Attach the input controls to a specific dom element to get the input from.
  44931. * @param element Defines the element the controls should be listened from
  44932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44933. */
  44934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44935. /**
  44936. * Detach the current controls from the specified dom element.
  44937. * @param element Defines the element to stop listening the inputs from
  44938. */
  44939. detachControl(element: Nullable<HTMLElement>): void;
  44940. /**
  44941. * Gets the class name of the current intput.
  44942. * @returns the class name
  44943. */
  44944. getClassName(): string;
  44945. /** @hidden */
  44946. _onLostFocus(e: FocusEvent): void;
  44947. /**
  44948. * Get the friendly name associated with the input class.
  44949. * @returns the input friendly name
  44950. */
  44951. getSimpleName(): string;
  44952. /**
  44953. * Update the current camera state depending on the inputs that have been used this frame.
  44954. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44955. */
  44956. checkInputs(): void;
  44957. }
  44958. }
  44959. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44960. import { Nullable } from "babylonjs/types";
  44961. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44962. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44963. /**
  44964. * Manage the mouse wheel inputs to control a follow camera.
  44965. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44966. */
  44967. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44968. /**
  44969. * Defines the camera the input is attached to.
  44970. */
  44971. camera: FollowCamera;
  44972. /**
  44973. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44974. */
  44975. axisControlRadius: boolean;
  44976. /**
  44977. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44978. */
  44979. axisControlHeight: boolean;
  44980. /**
  44981. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44982. */
  44983. axisControlRotation: boolean;
  44984. /**
  44985. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44986. * relation to mouseWheel events.
  44987. */
  44988. wheelPrecision: number;
  44989. /**
  44990. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44991. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44992. */
  44993. wheelDeltaPercentage: number;
  44994. private _wheel;
  44995. private _observer;
  44996. /**
  44997. * Attach the input controls to a specific dom element to get the input from.
  44998. * @param element Defines the element the controls should be listened from
  44999. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45000. */
  45001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45002. /**
  45003. * Detach the current controls from the specified dom element.
  45004. * @param element Defines the element to stop listening the inputs from
  45005. */
  45006. detachControl(element: Nullable<HTMLElement>): void;
  45007. /**
  45008. * Gets the class name of the current intput.
  45009. * @returns the class name
  45010. */
  45011. getClassName(): string;
  45012. /**
  45013. * Get the friendly name associated with the input class.
  45014. * @returns the input friendly name
  45015. */
  45016. getSimpleName(): string;
  45017. }
  45018. }
  45019. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45020. import { Nullable } from "babylonjs/types";
  45021. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45022. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45023. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45024. /**
  45025. * Manage the pointers inputs to control an follow camera.
  45026. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45027. */
  45028. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45029. /**
  45030. * Defines the camera the input is attached to.
  45031. */
  45032. camera: FollowCamera;
  45033. /**
  45034. * Gets the class name of the current input.
  45035. * @returns the class name
  45036. */
  45037. getClassName(): string;
  45038. /**
  45039. * Defines the pointer angular sensibility along the X axis or how fast is
  45040. * the camera rotating.
  45041. * A negative number will reverse the axis direction.
  45042. */
  45043. angularSensibilityX: number;
  45044. /**
  45045. * Defines the pointer angular sensibility along the Y axis or how fast is
  45046. * the camera rotating.
  45047. * A negative number will reverse the axis direction.
  45048. */
  45049. angularSensibilityY: number;
  45050. /**
  45051. * Defines the pointer pinch precision or how fast is the camera zooming.
  45052. * A negative number will reverse the axis direction.
  45053. */
  45054. pinchPrecision: number;
  45055. /**
  45056. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45057. * from 0.
  45058. * It defines the percentage of current camera.radius to use as delta when
  45059. * pinch zoom is used.
  45060. */
  45061. pinchDeltaPercentage: number;
  45062. /**
  45063. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45064. */
  45065. axisXControlRadius: boolean;
  45066. /**
  45067. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45068. */
  45069. axisXControlHeight: boolean;
  45070. /**
  45071. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45072. */
  45073. axisXControlRotation: boolean;
  45074. /**
  45075. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45076. */
  45077. axisYControlRadius: boolean;
  45078. /**
  45079. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45080. */
  45081. axisYControlHeight: boolean;
  45082. /**
  45083. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45084. */
  45085. axisYControlRotation: boolean;
  45086. /**
  45087. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45088. */
  45089. axisPinchControlRadius: boolean;
  45090. /**
  45091. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45092. */
  45093. axisPinchControlHeight: boolean;
  45094. /**
  45095. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45096. */
  45097. axisPinchControlRotation: boolean;
  45098. /**
  45099. * Log error messages if basic misconfiguration has occurred.
  45100. */
  45101. warningEnable: boolean;
  45102. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45103. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45104. private _warningCounter;
  45105. private _warning;
  45106. }
  45107. }
  45108. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45109. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45110. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45111. /**
  45112. * Default Inputs manager for the FollowCamera.
  45113. * It groups all the default supported inputs for ease of use.
  45114. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45115. */
  45116. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45117. /**
  45118. * Instantiates a new FollowCameraInputsManager.
  45119. * @param camera Defines the camera the inputs belong to
  45120. */
  45121. constructor(camera: FollowCamera);
  45122. /**
  45123. * Add keyboard input support to the input manager.
  45124. * @returns the current input manager
  45125. */
  45126. addKeyboard(): FollowCameraInputsManager;
  45127. /**
  45128. * Add mouse wheel input support to the input manager.
  45129. * @returns the current input manager
  45130. */
  45131. addMouseWheel(): FollowCameraInputsManager;
  45132. /**
  45133. * Add pointers input support to the input manager.
  45134. * @returns the current input manager
  45135. */
  45136. addPointers(): FollowCameraInputsManager;
  45137. /**
  45138. * Add orientation input support to the input manager.
  45139. * @returns the current input manager
  45140. */
  45141. addVRDeviceOrientation(): FollowCameraInputsManager;
  45142. }
  45143. }
  45144. declare module "babylonjs/Cameras/followCamera" {
  45145. import { Nullable } from "babylonjs/types";
  45146. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45147. import { Scene } from "babylonjs/scene";
  45148. import { Vector3 } from "babylonjs/Maths/math.vector";
  45149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45150. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45151. /**
  45152. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45153. * an arc rotate version arcFollowCamera are available.
  45154. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45155. */
  45156. export class FollowCamera extends TargetCamera {
  45157. /**
  45158. * Distance the follow camera should follow an object at
  45159. */
  45160. radius: number;
  45161. /**
  45162. * Minimum allowed distance of the camera to the axis of rotation
  45163. * (The camera can not get closer).
  45164. * This can help limiting how the Camera is able to move in the scene.
  45165. */
  45166. lowerRadiusLimit: Nullable<number>;
  45167. /**
  45168. * Maximum allowed distance of the camera to the axis of rotation
  45169. * (The camera can not get further).
  45170. * This can help limiting how the Camera is able to move in the scene.
  45171. */
  45172. upperRadiusLimit: Nullable<number>;
  45173. /**
  45174. * Define a rotation offset between the camera and the object it follows
  45175. */
  45176. rotationOffset: number;
  45177. /**
  45178. * Minimum allowed angle to camera position relative to target object.
  45179. * This can help limiting how the Camera is able to move in the scene.
  45180. */
  45181. lowerRotationOffsetLimit: Nullable<number>;
  45182. /**
  45183. * Maximum allowed angle to camera position relative to target object.
  45184. * This can help limiting how the Camera is able to move in the scene.
  45185. */
  45186. upperRotationOffsetLimit: Nullable<number>;
  45187. /**
  45188. * Define a height offset between the camera and the object it follows.
  45189. * It can help following an object from the top (like a car chaing a plane)
  45190. */
  45191. heightOffset: number;
  45192. /**
  45193. * Minimum allowed height of camera position relative to target object.
  45194. * This can help limiting how the Camera is able to move in the scene.
  45195. */
  45196. lowerHeightOffsetLimit: Nullable<number>;
  45197. /**
  45198. * Maximum allowed height of camera position relative to target object.
  45199. * This can help limiting how the Camera is able to move in the scene.
  45200. */
  45201. upperHeightOffsetLimit: Nullable<number>;
  45202. /**
  45203. * Define how fast the camera can accelerate to follow it s target.
  45204. */
  45205. cameraAcceleration: number;
  45206. /**
  45207. * Define the speed limit of the camera following an object.
  45208. */
  45209. maxCameraSpeed: number;
  45210. /**
  45211. * Define the target of the camera.
  45212. */
  45213. lockedTarget: Nullable<AbstractMesh>;
  45214. /**
  45215. * Defines the input associated with the camera.
  45216. */
  45217. inputs: FollowCameraInputsManager;
  45218. /**
  45219. * Instantiates the follow camera.
  45220. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45221. * @param name Define the name of the camera in the scene
  45222. * @param position Define the position of the camera
  45223. * @param scene Define the scene the camera belong to
  45224. * @param lockedTarget Define the target of the camera
  45225. */
  45226. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  45227. private _follow;
  45228. /**
  45229. * Attached controls to the current camera.
  45230. * @param element Defines the element the controls should be listened from
  45231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45232. */
  45233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45234. /**
  45235. * Detach the current controls from the camera.
  45236. * The camera will stop reacting to inputs.
  45237. * @param element Defines the element to stop listening the inputs from
  45238. */
  45239. detachControl(element: HTMLElement): void;
  45240. /** @hidden */
  45241. _checkInputs(): void;
  45242. private _checkLimits;
  45243. /**
  45244. * Gets the camera class name.
  45245. * @returns the class name
  45246. */
  45247. getClassName(): string;
  45248. }
  45249. /**
  45250. * Arc Rotate version of the follow camera.
  45251. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45252. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45253. */
  45254. export class ArcFollowCamera extends TargetCamera {
  45255. /** The longitudinal angle of the camera */
  45256. alpha: number;
  45257. /** The latitudinal angle of the camera */
  45258. beta: number;
  45259. /** The radius of the camera from its target */
  45260. radius: number;
  45261. /** Define the camera target (the mesh it should follow) */
  45262. target: Nullable<AbstractMesh>;
  45263. private _cartesianCoordinates;
  45264. /**
  45265. * Instantiates a new ArcFollowCamera
  45266. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45267. * @param name Define the name of the camera
  45268. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45269. * @param beta Define the rotation angle of the camera around the elevation axis
  45270. * @param radius Define the radius of the camera from its target point
  45271. * @param target Define the target of the camera
  45272. * @param scene Define the scene the camera belongs to
  45273. */
  45274. constructor(name: string,
  45275. /** The longitudinal angle of the camera */
  45276. alpha: number,
  45277. /** The latitudinal angle of the camera */
  45278. beta: number,
  45279. /** The radius of the camera from its target */
  45280. radius: number,
  45281. /** Define the camera target (the mesh it should follow) */
  45282. target: Nullable<AbstractMesh>, scene: Scene);
  45283. private _follow;
  45284. /** @hidden */
  45285. _checkInputs(): void;
  45286. /**
  45287. * Returns the class name of the object.
  45288. * It is mostly used internally for serialization purposes.
  45289. */
  45290. getClassName(): string;
  45291. }
  45292. }
  45293. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45294. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45295. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45296. import { Nullable } from "babylonjs/types";
  45297. /**
  45298. * Manage the keyboard inputs to control the movement of a follow camera.
  45299. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45300. */
  45301. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45302. /**
  45303. * Defines the camera the input is attached to.
  45304. */
  45305. camera: FollowCamera;
  45306. /**
  45307. * Defines the list of key codes associated with the up action (increase heightOffset)
  45308. */
  45309. keysHeightOffsetIncr: number[];
  45310. /**
  45311. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45312. */
  45313. keysHeightOffsetDecr: number[];
  45314. /**
  45315. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45316. */
  45317. keysHeightOffsetModifierAlt: boolean;
  45318. /**
  45319. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45320. */
  45321. keysHeightOffsetModifierCtrl: boolean;
  45322. /**
  45323. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45324. */
  45325. keysHeightOffsetModifierShift: boolean;
  45326. /**
  45327. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45328. */
  45329. keysRotationOffsetIncr: number[];
  45330. /**
  45331. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45332. */
  45333. keysRotationOffsetDecr: number[];
  45334. /**
  45335. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45336. */
  45337. keysRotationOffsetModifierAlt: boolean;
  45338. /**
  45339. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45340. */
  45341. keysRotationOffsetModifierCtrl: boolean;
  45342. /**
  45343. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45344. */
  45345. keysRotationOffsetModifierShift: boolean;
  45346. /**
  45347. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45348. */
  45349. keysRadiusIncr: number[];
  45350. /**
  45351. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45352. */
  45353. keysRadiusDecr: number[];
  45354. /**
  45355. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45356. */
  45357. keysRadiusModifierAlt: boolean;
  45358. /**
  45359. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45360. */
  45361. keysRadiusModifierCtrl: boolean;
  45362. /**
  45363. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45364. */
  45365. keysRadiusModifierShift: boolean;
  45366. /**
  45367. * Defines the rate of change of heightOffset.
  45368. */
  45369. heightSensibility: number;
  45370. /**
  45371. * Defines the rate of change of rotationOffset.
  45372. */
  45373. rotationSensibility: number;
  45374. /**
  45375. * Defines the rate of change of radius.
  45376. */
  45377. radiusSensibility: number;
  45378. private _keys;
  45379. private _ctrlPressed;
  45380. private _altPressed;
  45381. private _shiftPressed;
  45382. private _onCanvasBlurObserver;
  45383. private _onKeyboardObserver;
  45384. private _engine;
  45385. private _scene;
  45386. /**
  45387. * Attach the input controls to a specific dom element to get the input from.
  45388. * @param element Defines the element the controls should be listened from
  45389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45390. */
  45391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45392. /**
  45393. * Detach the current controls from the specified dom element.
  45394. * @param element Defines the element to stop listening the inputs from
  45395. */
  45396. detachControl(element: Nullable<HTMLElement>): void;
  45397. /**
  45398. * Update the current camera state depending on the inputs that have been used this frame.
  45399. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45400. */
  45401. checkInputs(): void;
  45402. /**
  45403. * Gets the class name of the current input.
  45404. * @returns the class name
  45405. */
  45406. getClassName(): string;
  45407. /**
  45408. * Get the friendly name associated with the input class.
  45409. * @returns the input friendly name
  45410. */
  45411. getSimpleName(): string;
  45412. /**
  45413. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45414. * allow modification of the heightOffset value.
  45415. */
  45416. private _modifierHeightOffset;
  45417. /**
  45418. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45419. * allow modification of the rotationOffset value.
  45420. */
  45421. private _modifierRotationOffset;
  45422. /**
  45423. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45424. * allow modification of the radius value.
  45425. */
  45426. private _modifierRadius;
  45427. }
  45428. }
  45429. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45430. import { Nullable } from "babylonjs/types";
  45431. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45432. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45433. import { Observable } from "babylonjs/Misc/observable";
  45434. module "babylonjs/Cameras/freeCameraInputsManager" {
  45435. interface FreeCameraInputsManager {
  45436. /**
  45437. * @hidden
  45438. */
  45439. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45440. /**
  45441. * Add orientation input support to the input manager.
  45442. * @returns the current input manager
  45443. */
  45444. addDeviceOrientation(): FreeCameraInputsManager;
  45445. }
  45446. }
  45447. /**
  45448. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45449. * Screen rotation is taken into account.
  45450. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45451. */
  45452. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45453. private _camera;
  45454. private _screenOrientationAngle;
  45455. private _constantTranform;
  45456. private _screenQuaternion;
  45457. private _alpha;
  45458. private _beta;
  45459. private _gamma;
  45460. /**
  45461. * Can be used to detect if a device orientation sensor is available on a device
  45462. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45463. * @returns a promise that will resolve on orientation change
  45464. */
  45465. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45466. /**
  45467. * @hidden
  45468. */
  45469. _onDeviceOrientationChangedObservable: Observable<void>;
  45470. /**
  45471. * Instantiates a new input
  45472. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45473. */
  45474. constructor();
  45475. /**
  45476. * Define the camera controlled by the input.
  45477. */
  45478. get camera(): FreeCamera;
  45479. set camera(camera: FreeCamera);
  45480. /**
  45481. * Attach the input controls to a specific dom element to get the input from.
  45482. * @param element Defines the element the controls should be listened from
  45483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45484. */
  45485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45486. private _orientationChanged;
  45487. private _deviceOrientation;
  45488. /**
  45489. * Detach the current controls from the specified dom element.
  45490. * @param element Defines the element to stop listening the inputs from
  45491. */
  45492. detachControl(element: Nullable<HTMLElement>): void;
  45493. /**
  45494. * Update the current camera state depending on the inputs that have been used this frame.
  45495. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45496. */
  45497. checkInputs(): void;
  45498. /**
  45499. * Gets the class name of the current intput.
  45500. * @returns the class name
  45501. */
  45502. getClassName(): string;
  45503. /**
  45504. * Get the friendly name associated with the input class.
  45505. * @returns the input friendly name
  45506. */
  45507. getSimpleName(): string;
  45508. }
  45509. }
  45510. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45511. import { Nullable } from "babylonjs/types";
  45512. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45513. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45514. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45515. /**
  45516. * Manage the gamepad inputs to control a free camera.
  45517. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45518. */
  45519. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45520. /**
  45521. * Define the camera the input is attached to.
  45522. */
  45523. camera: FreeCamera;
  45524. /**
  45525. * Define the Gamepad controlling the input
  45526. */
  45527. gamepad: Nullable<Gamepad>;
  45528. /**
  45529. * Defines the gamepad rotation sensiblity.
  45530. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45531. */
  45532. gamepadAngularSensibility: number;
  45533. /**
  45534. * Defines the gamepad move sensiblity.
  45535. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45536. */
  45537. gamepadMoveSensibility: number;
  45538. private _yAxisScale;
  45539. /**
  45540. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45541. */
  45542. get invertYAxis(): boolean;
  45543. set invertYAxis(value: boolean);
  45544. private _onGamepadConnectedObserver;
  45545. private _onGamepadDisconnectedObserver;
  45546. private _cameraTransform;
  45547. private _deltaTransform;
  45548. private _vector3;
  45549. private _vector2;
  45550. /**
  45551. * Attach the input controls to a specific dom element to get the input from.
  45552. * @param element Defines the element the controls should be listened from
  45553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45554. */
  45555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45556. /**
  45557. * Detach the current controls from the specified dom element.
  45558. * @param element Defines the element to stop listening the inputs from
  45559. */
  45560. detachControl(element: Nullable<HTMLElement>): void;
  45561. /**
  45562. * Update the current camera state depending on the inputs that have been used this frame.
  45563. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45564. */
  45565. checkInputs(): void;
  45566. /**
  45567. * Gets the class name of the current intput.
  45568. * @returns the class name
  45569. */
  45570. getClassName(): string;
  45571. /**
  45572. * Get the friendly name associated with the input class.
  45573. * @returns the input friendly name
  45574. */
  45575. getSimpleName(): string;
  45576. }
  45577. }
  45578. declare module "babylonjs/Misc/virtualJoystick" {
  45579. import { Nullable } from "babylonjs/types";
  45580. import { Vector3 } from "babylonjs/Maths/math.vector";
  45581. /**
  45582. * Defines the potential axis of a Joystick
  45583. */
  45584. export enum JoystickAxis {
  45585. /** X axis */
  45586. X = 0,
  45587. /** Y axis */
  45588. Y = 1,
  45589. /** Z axis */
  45590. Z = 2
  45591. }
  45592. /**
  45593. * Represents the different customization options available
  45594. * for VirtualJoystick
  45595. */
  45596. interface VirtualJoystickCustomizations {
  45597. /**
  45598. * Size of the joystick's puck
  45599. */
  45600. puckSize: number;
  45601. /**
  45602. * Size of the joystick's container
  45603. */
  45604. containerSize: number;
  45605. /**
  45606. * Color of the joystick && puck
  45607. */
  45608. color: string;
  45609. /**
  45610. * Image URL for the joystick's puck
  45611. */
  45612. puckImage?: string;
  45613. /**
  45614. * Image URL for the joystick's container
  45615. */
  45616. containerImage?: string;
  45617. /**
  45618. * Defines the unmoving position of the joystick container
  45619. */
  45620. position?: {
  45621. x: number;
  45622. y: number;
  45623. };
  45624. /**
  45625. * Defines whether or not the joystick container is always visible
  45626. */
  45627. alwaysVisible: boolean;
  45628. /**
  45629. * Defines whether or not to limit the movement of the puck to the joystick's container
  45630. */
  45631. limitToContainer: boolean;
  45632. }
  45633. /**
  45634. * Class used to define virtual joystick (used in touch mode)
  45635. */
  45636. export class VirtualJoystick {
  45637. /**
  45638. * Gets or sets a boolean indicating that left and right values must be inverted
  45639. */
  45640. reverseLeftRight: boolean;
  45641. /**
  45642. * Gets or sets a boolean indicating that up and down values must be inverted
  45643. */
  45644. reverseUpDown: boolean;
  45645. /**
  45646. * Gets the offset value for the position (ie. the change of the position value)
  45647. */
  45648. deltaPosition: Vector3;
  45649. /**
  45650. * Gets a boolean indicating if the virtual joystick was pressed
  45651. */
  45652. pressed: boolean;
  45653. /**
  45654. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45655. */
  45656. static Canvas: Nullable<HTMLCanvasElement>;
  45657. /**
  45658. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45659. */
  45660. limitToContainer: boolean;
  45661. private static _globalJoystickIndex;
  45662. private static _alwaysVisibleSticks;
  45663. private static vjCanvasContext;
  45664. private static vjCanvasWidth;
  45665. private static vjCanvasHeight;
  45666. private static halfWidth;
  45667. private static _GetDefaultOptions;
  45668. private _action;
  45669. private _axisTargetedByLeftAndRight;
  45670. private _axisTargetedByUpAndDown;
  45671. private _joystickSensibility;
  45672. private _inversedSensibility;
  45673. private _joystickPointerID;
  45674. private _joystickColor;
  45675. private _joystickPointerPos;
  45676. private _joystickPreviousPointerPos;
  45677. private _joystickPointerStartPos;
  45678. private _deltaJoystickVector;
  45679. private _leftJoystick;
  45680. private _touches;
  45681. private _joystickPosition;
  45682. private _alwaysVisible;
  45683. private _puckImage;
  45684. private _containerImage;
  45685. private _joystickPuckSize;
  45686. private _joystickContainerSize;
  45687. private _clearPuckSize;
  45688. private _clearContainerSize;
  45689. private _clearPuckSizeOffset;
  45690. private _clearContainerSizeOffset;
  45691. private _onPointerDownHandlerRef;
  45692. private _onPointerMoveHandlerRef;
  45693. private _onPointerUpHandlerRef;
  45694. private _onResize;
  45695. /**
  45696. * Creates a new virtual joystick
  45697. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45698. * @param customizations Defines the options we want to customize the VirtualJoystick
  45699. */
  45700. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45701. /**
  45702. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45703. * @param newJoystickSensibility defines the new sensibility
  45704. */
  45705. setJoystickSensibility(newJoystickSensibility: number): void;
  45706. private _onPointerDown;
  45707. private _onPointerMove;
  45708. private _onPointerUp;
  45709. /**
  45710. * Change the color of the virtual joystick
  45711. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45712. */
  45713. setJoystickColor(newColor: string): void;
  45714. /**
  45715. * Size of the joystick's container
  45716. */
  45717. set containerSize(newSize: number);
  45718. get containerSize(): number;
  45719. /**
  45720. * Size of the joystick's puck
  45721. */
  45722. set puckSize(newSize: number);
  45723. get puckSize(): number;
  45724. /**
  45725. * Clears the set position of the joystick
  45726. */
  45727. clearPosition(): void;
  45728. /**
  45729. * Defines whether or not the joystick container is always visible
  45730. */
  45731. set alwaysVisible(value: boolean);
  45732. get alwaysVisible(): boolean;
  45733. /**
  45734. * Sets the constant position of the Joystick container
  45735. * @param x X axis coordinate
  45736. * @param y Y axis coordinate
  45737. */
  45738. setPosition(x: number, y: number): void;
  45739. /**
  45740. * Defines a callback to call when the joystick is touched
  45741. * @param action defines the callback
  45742. */
  45743. setActionOnTouch(action: () => any): void;
  45744. /**
  45745. * Defines which axis you'd like to control for left & right
  45746. * @param axis defines the axis to use
  45747. */
  45748. setAxisForLeftRight(axis: JoystickAxis): void;
  45749. /**
  45750. * Defines which axis you'd like to control for up & down
  45751. * @param axis defines the axis to use
  45752. */
  45753. setAxisForUpDown(axis: JoystickAxis): void;
  45754. /**
  45755. * Clears the canvas from the previous puck / container draw
  45756. */
  45757. private _clearPreviousDraw;
  45758. /**
  45759. * Loads `urlPath` to be used for the container's image
  45760. * @param urlPath defines the urlPath of an image to use
  45761. */
  45762. setContainerImage(urlPath: string): void;
  45763. /**
  45764. * Loads `urlPath` to be used for the puck's image
  45765. * @param urlPath defines the urlPath of an image to use
  45766. */
  45767. setPuckImage(urlPath: string): void;
  45768. /**
  45769. * Draws the Virtual Joystick's container
  45770. */
  45771. private _drawContainer;
  45772. /**
  45773. * Draws the Virtual Joystick's puck
  45774. */
  45775. private _drawPuck;
  45776. private _drawVirtualJoystick;
  45777. /**
  45778. * Release internal HTML canvas
  45779. */
  45780. releaseCanvas(): void;
  45781. }
  45782. }
  45783. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45784. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45785. import { Nullable } from "babylonjs/types";
  45786. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45787. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45788. module "babylonjs/Cameras/freeCameraInputsManager" {
  45789. interface FreeCameraInputsManager {
  45790. /**
  45791. * Add virtual joystick input support to the input manager.
  45792. * @returns the current input manager
  45793. */
  45794. addVirtualJoystick(): FreeCameraInputsManager;
  45795. }
  45796. }
  45797. /**
  45798. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45799. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45800. */
  45801. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45802. /**
  45803. * Defines the camera the input is attached to.
  45804. */
  45805. camera: FreeCamera;
  45806. private _leftjoystick;
  45807. private _rightjoystick;
  45808. /**
  45809. * Gets the left stick of the virtual joystick.
  45810. * @returns The virtual Joystick
  45811. */
  45812. getLeftJoystick(): VirtualJoystick;
  45813. /**
  45814. * Gets the right stick of the virtual joystick.
  45815. * @returns The virtual Joystick
  45816. */
  45817. getRightJoystick(): VirtualJoystick;
  45818. /**
  45819. * Update the current camera state depending on the inputs that have been used this frame.
  45820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45821. */
  45822. checkInputs(): void;
  45823. /**
  45824. * Attach the input controls to a specific dom element to get the input from.
  45825. * @param element Defines the element the controls should be listened from
  45826. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45827. */
  45828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45829. /**
  45830. * Detach the current controls from the specified dom element.
  45831. * @param element Defines the element to stop listening the inputs from
  45832. */
  45833. detachControl(element: Nullable<HTMLElement>): void;
  45834. /**
  45835. * Gets the class name of the current intput.
  45836. * @returns the class name
  45837. */
  45838. getClassName(): string;
  45839. /**
  45840. * Get the friendly name associated with the input class.
  45841. * @returns the input friendly name
  45842. */
  45843. getSimpleName(): string;
  45844. }
  45845. }
  45846. declare module "babylonjs/Cameras/Inputs/index" {
  45847. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45848. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45849. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45850. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45851. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45852. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45853. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45854. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45855. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45856. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45857. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45858. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45859. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45860. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45861. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45862. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45863. }
  45864. declare module "babylonjs/Cameras/touchCamera" {
  45865. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45866. import { Scene } from "babylonjs/scene";
  45867. import { Vector3 } from "babylonjs/Maths/math.vector";
  45868. /**
  45869. * This represents a FPS type of camera controlled by touch.
  45870. * This is like a universal camera minus the Gamepad controls.
  45871. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45872. */
  45873. export class TouchCamera extends FreeCamera {
  45874. /**
  45875. * Defines the touch sensibility for rotation.
  45876. * The higher the faster.
  45877. */
  45878. get touchAngularSensibility(): number;
  45879. set touchAngularSensibility(value: number);
  45880. /**
  45881. * Defines the touch sensibility for move.
  45882. * The higher the faster.
  45883. */
  45884. get touchMoveSensibility(): number;
  45885. set touchMoveSensibility(value: number);
  45886. /**
  45887. * Instantiates a new touch camera.
  45888. * This represents a FPS type of camera controlled by touch.
  45889. * This is like a universal camera minus the Gamepad controls.
  45890. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45891. * @param name Define the name of the camera in the scene
  45892. * @param position Define the start position of the camera in the scene
  45893. * @param scene Define the scene the camera belongs to
  45894. */
  45895. constructor(name: string, position: Vector3, scene: Scene);
  45896. /**
  45897. * Gets the current object class name.
  45898. * @return the class name
  45899. */
  45900. getClassName(): string;
  45901. /** @hidden */
  45902. _setupInputs(): void;
  45903. }
  45904. }
  45905. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45906. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45907. import { Scene } from "babylonjs/scene";
  45908. import { Vector3 } from "babylonjs/Maths/math.vector";
  45909. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45910. import { Axis } from "babylonjs/Maths/math.axis";
  45911. /**
  45912. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45913. * being tilted forward or back and left or right.
  45914. */
  45915. export class DeviceOrientationCamera extends FreeCamera {
  45916. private _initialQuaternion;
  45917. private _quaternionCache;
  45918. private _tmpDragQuaternion;
  45919. private _disablePointerInputWhenUsingDeviceOrientation;
  45920. /**
  45921. * Creates a new device orientation camera
  45922. * @param name The name of the camera
  45923. * @param position The start position camera
  45924. * @param scene The scene the camera belongs to
  45925. */
  45926. constructor(name: string, position: Vector3, scene: Scene);
  45927. /**
  45928. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45929. */
  45930. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45931. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45932. private _dragFactor;
  45933. /**
  45934. * Enabled turning on the y axis when the orientation sensor is active
  45935. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45936. */
  45937. enableHorizontalDragging(dragFactor?: number): void;
  45938. /**
  45939. * Gets the current instance class name ("DeviceOrientationCamera").
  45940. * This helps avoiding instanceof at run time.
  45941. * @returns the class name
  45942. */
  45943. getClassName(): string;
  45944. /**
  45945. * @hidden
  45946. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45947. */
  45948. _checkInputs(): void;
  45949. /**
  45950. * Reset the camera to its default orientation on the specified axis only.
  45951. * @param axis The axis to reset
  45952. */
  45953. resetToCurrentRotation(axis?: Axis): void;
  45954. }
  45955. }
  45956. declare module "babylonjs/Gamepads/xboxGamepad" {
  45957. import { Observable } from "babylonjs/Misc/observable";
  45958. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45959. /**
  45960. * Defines supported buttons for XBox360 compatible gamepads
  45961. */
  45962. export enum Xbox360Button {
  45963. /** A */
  45964. A = 0,
  45965. /** B */
  45966. B = 1,
  45967. /** X */
  45968. X = 2,
  45969. /** Y */
  45970. Y = 3,
  45971. /** Left button */
  45972. LB = 4,
  45973. /** Right button */
  45974. RB = 5,
  45975. /** Back */
  45976. Back = 8,
  45977. /** Start */
  45978. Start = 9,
  45979. /** Left stick */
  45980. LeftStick = 10,
  45981. /** Right stick */
  45982. RightStick = 11
  45983. }
  45984. /** Defines values for XBox360 DPad */
  45985. export enum Xbox360Dpad {
  45986. /** Up */
  45987. Up = 12,
  45988. /** Down */
  45989. Down = 13,
  45990. /** Left */
  45991. Left = 14,
  45992. /** Right */
  45993. Right = 15
  45994. }
  45995. /**
  45996. * Defines a XBox360 gamepad
  45997. */
  45998. export class Xbox360Pad extends Gamepad {
  45999. private _leftTrigger;
  46000. private _rightTrigger;
  46001. private _onlefttriggerchanged;
  46002. private _onrighttriggerchanged;
  46003. private _onbuttondown;
  46004. private _onbuttonup;
  46005. private _ondpaddown;
  46006. private _ondpadup;
  46007. /** Observable raised when a button is pressed */
  46008. onButtonDownObservable: Observable<Xbox360Button>;
  46009. /** Observable raised when a button is released */
  46010. onButtonUpObservable: Observable<Xbox360Button>;
  46011. /** Observable raised when a pad is pressed */
  46012. onPadDownObservable: Observable<Xbox360Dpad>;
  46013. /** Observable raised when a pad is released */
  46014. onPadUpObservable: Observable<Xbox360Dpad>;
  46015. private _buttonA;
  46016. private _buttonB;
  46017. private _buttonX;
  46018. private _buttonY;
  46019. private _buttonBack;
  46020. private _buttonStart;
  46021. private _buttonLB;
  46022. private _buttonRB;
  46023. private _buttonLeftStick;
  46024. private _buttonRightStick;
  46025. private _dPadUp;
  46026. private _dPadDown;
  46027. private _dPadLeft;
  46028. private _dPadRight;
  46029. private _isXboxOnePad;
  46030. /**
  46031. * Creates a new XBox360 gamepad object
  46032. * @param id defines the id of this gamepad
  46033. * @param index defines its index
  46034. * @param gamepad defines the internal HTML gamepad object
  46035. * @param xboxOne defines if it is a XBox One gamepad
  46036. */
  46037. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  46038. /**
  46039. * Defines the callback to call when left trigger is pressed
  46040. * @param callback defines the callback to use
  46041. */
  46042. onlefttriggerchanged(callback: (value: number) => void): void;
  46043. /**
  46044. * Defines the callback to call when right trigger is pressed
  46045. * @param callback defines the callback to use
  46046. */
  46047. onrighttriggerchanged(callback: (value: number) => void): void;
  46048. /**
  46049. * Gets the left trigger value
  46050. */
  46051. get leftTrigger(): number;
  46052. /**
  46053. * Sets the left trigger value
  46054. */
  46055. set leftTrigger(newValue: number);
  46056. /**
  46057. * Gets the right trigger value
  46058. */
  46059. get rightTrigger(): number;
  46060. /**
  46061. * Sets the right trigger value
  46062. */
  46063. set rightTrigger(newValue: number);
  46064. /**
  46065. * Defines the callback to call when a button is pressed
  46066. * @param callback defines the callback to use
  46067. */
  46068. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  46069. /**
  46070. * Defines the callback to call when a button is released
  46071. * @param callback defines the callback to use
  46072. */
  46073. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  46074. /**
  46075. * Defines the callback to call when a pad is pressed
  46076. * @param callback defines the callback to use
  46077. */
  46078. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  46079. /**
  46080. * Defines the callback to call when a pad is released
  46081. * @param callback defines the callback to use
  46082. */
  46083. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  46084. private _setButtonValue;
  46085. private _setDPadValue;
  46086. /**
  46087. * Gets the value of the `A` button
  46088. */
  46089. get buttonA(): number;
  46090. /**
  46091. * Sets the value of the `A` button
  46092. */
  46093. set buttonA(value: number);
  46094. /**
  46095. * Gets the value of the `B` button
  46096. */
  46097. get buttonB(): number;
  46098. /**
  46099. * Sets the value of the `B` button
  46100. */
  46101. set buttonB(value: number);
  46102. /**
  46103. * Gets the value of the `X` button
  46104. */
  46105. get buttonX(): number;
  46106. /**
  46107. * Sets the value of the `X` button
  46108. */
  46109. set buttonX(value: number);
  46110. /**
  46111. * Gets the value of the `Y` button
  46112. */
  46113. get buttonY(): number;
  46114. /**
  46115. * Sets the value of the `Y` button
  46116. */
  46117. set buttonY(value: number);
  46118. /**
  46119. * Gets the value of the `Start` button
  46120. */
  46121. get buttonStart(): number;
  46122. /**
  46123. * Sets the value of the `Start` button
  46124. */
  46125. set buttonStart(value: number);
  46126. /**
  46127. * Gets the value of the `Back` button
  46128. */
  46129. get buttonBack(): number;
  46130. /**
  46131. * Sets the value of the `Back` button
  46132. */
  46133. set buttonBack(value: number);
  46134. /**
  46135. * Gets the value of the `Left` button
  46136. */
  46137. get buttonLB(): number;
  46138. /**
  46139. * Sets the value of the `Left` button
  46140. */
  46141. set buttonLB(value: number);
  46142. /**
  46143. * Gets the value of the `Right` button
  46144. */
  46145. get buttonRB(): number;
  46146. /**
  46147. * Sets the value of the `Right` button
  46148. */
  46149. set buttonRB(value: number);
  46150. /**
  46151. * Gets the value of the Left joystick
  46152. */
  46153. get buttonLeftStick(): number;
  46154. /**
  46155. * Sets the value of the Left joystick
  46156. */
  46157. set buttonLeftStick(value: number);
  46158. /**
  46159. * Gets the value of the Right joystick
  46160. */
  46161. get buttonRightStick(): number;
  46162. /**
  46163. * Sets the value of the Right joystick
  46164. */
  46165. set buttonRightStick(value: number);
  46166. /**
  46167. * Gets the value of D-pad up
  46168. */
  46169. get dPadUp(): number;
  46170. /**
  46171. * Sets the value of D-pad up
  46172. */
  46173. set dPadUp(value: number);
  46174. /**
  46175. * Gets the value of D-pad down
  46176. */
  46177. get dPadDown(): number;
  46178. /**
  46179. * Sets the value of D-pad down
  46180. */
  46181. set dPadDown(value: number);
  46182. /**
  46183. * Gets the value of D-pad left
  46184. */
  46185. get dPadLeft(): number;
  46186. /**
  46187. * Sets the value of D-pad left
  46188. */
  46189. set dPadLeft(value: number);
  46190. /**
  46191. * Gets the value of D-pad right
  46192. */
  46193. get dPadRight(): number;
  46194. /**
  46195. * Sets the value of D-pad right
  46196. */
  46197. set dPadRight(value: number);
  46198. /**
  46199. * Force the gamepad to synchronize with device values
  46200. */
  46201. update(): void;
  46202. /**
  46203. * Disposes the gamepad
  46204. */
  46205. dispose(): void;
  46206. }
  46207. }
  46208. declare module "babylonjs/Gamepads/dualShockGamepad" {
  46209. import { Observable } from "babylonjs/Misc/observable";
  46210. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46211. /**
  46212. * Defines supported buttons for DualShock compatible gamepads
  46213. */
  46214. export enum DualShockButton {
  46215. /** Cross */
  46216. Cross = 0,
  46217. /** Circle */
  46218. Circle = 1,
  46219. /** Square */
  46220. Square = 2,
  46221. /** Triangle */
  46222. Triangle = 3,
  46223. /** L1 */
  46224. L1 = 4,
  46225. /** R1 */
  46226. R1 = 5,
  46227. /** Share */
  46228. Share = 8,
  46229. /** Options */
  46230. Options = 9,
  46231. /** Left stick */
  46232. LeftStick = 10,
  46233. /** Right stick */
  46234. RightStick = 11
  46235. }
  46236. /** Defines values for DualShock DPad */
  46237. export enum DualShockDpad {
  46238. /** Up */
  46239. Up = 12,
  46240. /** Down */
  46241. Down = 13,
  46242. /** Left */
  46243. Left = 14,
  46244. /** Right */
  46245. Right = 15
  46246. }
  46247. /**
  46248. * Defines a DualShock gamepad
  46249. */
  46250. export class DualShockPad extends Gamepad {
  46251. private _leftTrigger;
  46252. private _rightTrigger;
  46253. private _onlefttriggerchanged;
  46254. private _onrighttriggerchanged;
  46255. private _onbuttondown;
  46256. private _onbuttonup;
  46257. private _ondpaddown;
  46258. private _ondpadup;
  46259. /** Observable raised when a button is pressed */
  46260. onButtonDownObservable: Observable<DualShockButton>;
  46261. /** Observable raised when a button is released */
  46262. onButtonUpObservable: Observable<DualShockButton>;
  46263. /** Observable raised when a pad is pressed */
  46264. onPadDownObservable: Observable<DualShockDpad>;
  46265. /** Observable raised when a pad is released */
  46266. onPadUpObservable: Observable<DualShockDpad>;
  46267. private _buttonCross;
  46268. private _buttonCircle;
  46269. private _buttonSquare;
  46270. private _buttonTriangle;
  46271. private _buttonShare;
  46272. private _buttonOptions;
  46273. private _buttonL1;
  46274. private _buttonR1;
  46275. private _buttonLeftStick;
  46276. private _buttonRightStick;
  46277. private _dPadUp;
  46278. private _dPadDown;
  46279. private _dPadLeft;
  46280. private _dPadRight;
  46281. /**
  46282. * Creates a new DualShock gamepad object
  46283. * @param id defines the id of this gamepad
  46284. * @param index defines its index
  46285. * @param gamepad defines the internal HTML gamepad object
  46286. */
  46287. constructor(id: string, index: number, gamepad: any);
  46288. /**
  46289. * Defines the callback to call when left trigger is pressed
  46290. * @param callback defines the callback to use
  46291. */
  46292. onlefttriggerchanged(callback: (value: number) => void): void;
  46293. /**
  46294. * Defines the callback to call when right trigger is pressed
  46295. * @param callback defines the callback to use
  46296. */
  46297. onrighttriggerchanged(callback: (value: number) => void): void;
  46298. /**
  46299. * Gets the left trigger value
  46300. */
  46301. get leftTrigger(): number;
  46302. /**
  46303. * Sets the left trigger value
  46304. */
  46305. set leftTrigger(newValue: number);
  46306. /**
  46307. * Gets the right trigger value
  46308. */
  46309. get rightTrigger(): number;
  46310. /**
  46311. * Sets the right trigger value
  46312. */
  46313. set rightTrigger(newValue: number);
  46314. /**
  46315. * Defines the callback to call when a button is pressed
  46316. * @param callback defines the callback to use
  46317. */
  46318. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  46319. /**
  46320. * Defines the callback to call when a button is released
  46321. * @param callback defines the callback to use
  46322. */
  46323. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  46324. /**
  46325. * Defines the callback to call when a pad is pressed
  46326. * @param callback defines the callback to use
  46327. */
  46328. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  46329. /**
  46330. * Defines the callback to call when a pad is released
  46331. * @param callback defines the callback to use
  46332. */
  46333. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  46334. private _setButtonValue;
  46335. private _setDPadValue;
  46336. /**
  46337. * Gets the value of the `Cross` button
  46338. */
  46339. get buttonCross(): number;
  46340. /**
  46341. * Sets the value of the `Cross` button
  46342. */
  46343. set buttonCross(value: number);
  46344. /**
  46345. * Gets the value of the `Circle` button
  46346. */
  46347. get buttonCircle(): number;
  46348. /**
  46349. * Sets the value of the `Circle` button
  46350. */
  46351. set buttonCircle(value: number);
  46352. /**
  46353. * Gets the value of the `Square` button
  46354. */
  46355. get buttonSquare(): number;
  46356. /**
  46357. * Sets the value of the `Square` button
  46358. */
  46359. set buttonSquare(value: number);
  46360. /**
  46361. * Gets the value of the `Triangle` button
  46362. */
  46363. get buttonTriangle(): number;
  46364. /**
  46365. * Sets the value of the `Triangle` button
  46366. */
  46367. set buttonTriangle(value: number);
  46368. /**
  46369. * Gets the value of the `Options` button
  46370. */
  46371. get buttonOptions(): number;
  46372. /**
  46373. * Sets the value of the `Options` button
  46374. */
  46375. set buttonOptions(value: number);
  46376. /**
  46377. * Gets the value of the `Share` button
  46378. */
  46379. get buttonShare(): number;
  46380. /**
  46381. * Sets the value of the `Share` button
  46382. */
  46383. set buttonShare(value: number);
  46384. /**
  46385. * Gets the value of the `L1` button
  46386. */
  46387. get buttonL1(): number;
  46388. /**
  46389. * Sets the value of the `L1` button
  46390. */
  46391. set buttonL1(value: number);
  46392. /**
  46393. * Gets the value of the `R1` button
  46394. */
  46395. get buttonR1(): number;
  46396. /**
  46397. * Sets the value of the `R1` button
  46398. */
  46399. set buttonR1(value: number);
  46400. /**
  46401. * Gets the value of the Left joystick
  46402. */
  46403. get buttonLeftStick(): number;
  46404. /**
  46405. * Sets the value of the Left joystick
  46406. */
  46407. set buttonLeftStick(value: number);
  46408. /**
  46409. * Gets the value of the Right joystick
  46410. */
  46411. get buttonRightStick(): number;
  46412. /**
  46413. * Sets the value of the Right joystick
  46414. */
  46415. set buttonRightStick(value: number);
  46416. /**
  46417. * Gets the value of D-pad up
  46418. */
  46419. get dPadUp(): number;
  46420. /**
  46421. * Sets the value of D-pad up
  46422. */
  46423. set dPadUp(value: number);
  46424. /**
  46425. * Gets the value of D-pad down
  46426. */
  46427. get dPadDown(): number;
  46428. /**
  46429. * Sets the value of D-pad down
  46430. */
  46431. set dPadDown(value: number);
  46432. /**
  46433. * Gets the value of D-pad left
  46434. */
  46435. get dPadLeft(): number;
  46436. /**
  46437. * Sets the value of D-pad left
  46438. */
  46439. set dPadLeft(value: number);
  46440. /**
  46441. * Gets the value of D-pad right
  46442. */
  46443. get dPadRight(): number;
  46444. /**
  46445. * Sets the value of D-pad right
  46446. */
  46447. set dPadRight(value: number);
  46448. /**
  46449. * Force the gamepad to synchronize with device values
  46450. */
  46451. update(): void;
  46452. /**
  46453. * Disposes the gamepad
  46454. */
  46455. dispose(): void;
  46456. }
  46457. }
  46458. declare module "babylonjs/Gamepads/gamepadManager" {
  46459. import { Observable } from "babylonjs/Misc/observable";
  46460. import { Nullable } from "babylonjs/types";
  46461. import { Scene } from "babylonjs/scene";
  46462. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46463. /**
  46464. * Manager for handling gamepads
  46465. */
  46466. export class GamepadManager {
  46467. private _scene?;
  46468. private _babylonGamepads;
  46469. private _oneGamepadConnected;
  46470. /** @hidden */
  46471. _isMonitoring: boolean;
  46472. private _gamepadEventSupported;
  46473. private _gamepadSupport?;
  46474. /**
  46475. * observable to be triggered when the gamepad controller has been connected
  46476. */
  46477. onGamepadConnectedObservable: Observable<Gamepad>;
  46478. /**
  46479. * observable to be triggered when the gamepad controller has been disconnected
  46480. */
  46481. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46482. private _onGamepadConnectedEvent;
  46483. private _onGamepadDisconnectedEvent;
  46484. /**
  46485. * Initializes the gamepad manager
  46486. * @param _scene BabylonJS scene
  46487. */
  46488. constructor(_scene?: Scene | undefined);
  46489. /**
  46490. * The gamepads in the game pad manager
  46491. */
  46492. get gamepads(): Gamepad[];
  46493. /**
  46494. * Get the gamepad controllers based on type
  46495. * @param type The type of gamepad controller
  46496. * @returns Nullable gamepad
  46497. */
  46498. getGamepadByType(type?: number): Nullable<Gamepad>;
  46499. /**
  46500. * Disposes the gamepad manager
  46501. */
  46502. dispose(): void;
  46503. private _addNewGamepad;
  46504. private _startMonitoringGamepads;
  46505. private _stopMonitoringGamepads;
  46506. /** @hidden */
  46507. _checkGamepadsStatus(): void;
  46508. private _updateGamepadObjects;
  46509. }
  46510. }
  46511. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46512. import { Nullable } from "babylonjs/types";
  46513. import { Scene } from "babylonjs/scene";
  46514. import { ISceneComponent } from "babylonjs/sceneComponent";
  46515. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46516. module "babylonjs/scene" {
  46517. interface Scene {
  46518. /** @hidden */
  46519. _gamepadManager: Nullable<GamepadManager>;
  46520. /**
  46521. * Gets the gamepad manager associated with the scene
  46522. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  46523. */
  46524. gamepadManager: GamepadManager;
  46525. }
  46526. }
  46527. module "babylonjs/Cameras/freeCameraInputsManager" {
  46528. /**
  46529. * Interface representing a free camera inputs manager
  46530. */
  46531. interface FreeCameraInputsManager {
  46532. /**
  46533. * Adds gamepad input support to the FreeCameraInputsManager.
  46534. * @returns the FreeCameraInputsManager
  46535. */
  46536. addGamepad(): FreeCameraInputsManager;
  46537. }
  46538. }
  46539. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46540. /**
  46541. * Interface representing an arc rotate camera inputs manager
  46542. */
  46543. interface ArcRotateCameraInputsManager {
  46544. /**
  46545. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46546. * @returns the camera inputs manager
  46547. */
  46548. addGamepad(): ArcRotateCameraInputsManager;
  46549. }
  46550. }
  46551. /**
  46552. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46553. */
  46554. export class GamepadSystemSceneComponent implements ISceneComponent {
  46555. /**
  46556. * The component name helpfull to identify the component in the list of scene components.
  46557. */
  46558. readonly name: string;
  46559. /**
  46560. * The scene the component belongs to.
  46561. */
  46562. scene: Scene;
  46563. /**
  46564. * Creates a new instance of the component for the given scene
  46565. * @param scene Defines the scene to register the component in
  46566. */
  46567. constructor(scene: Scene);
  46568. /**
  46569. * Registers the component in a given scene
  46570. */
  46571. register(): void;
  46572. /**
  46573. * Rebuilds the elements related to this component in case of
  46574. * context lost for instance.
  46575. */
  46576. rebuild(): void;
  46577. /**
  46578. * Disposes the component and the associated ressources
  46579. */
  46580. dispose(): void;
  46581. private _beforeCameraUpdate;
  46582. }
  46583. }
  46584. declare module "babylonjs/Cameras/universalCamera" {
  46585. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46586. import { Scene } from "babylonjs/scene";
  46587. import { Vector3 } from "babylonjs/Maths/math.vector";
  46588. import "babylonjs/Gamepads/gamepadSceneComponent";
  46589. /**
  46590. * 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,
  46591. * which still works and will still be found in many Playgrounds.
  46592. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46593. */
  46594. export class UniversalCamera extends TouchCamera {
  46595. /**
  46596. * Defines the gamepad rotation sensiblity.
  46597. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46598. */
  46599. get gamepadAngularSensibility(): number;
  46600. set gamepadAngularSensibility(value: number);
  46601. /**
  46602. * Defines the gamepad move sensiblity.
  46603. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46604. */
  46605. get gamepadMoveSensibility(): number;
  46606. set gamepadMoveSensibility(value: number);
  46607. /**
  46608. * 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,
  46609. * which still works and will still be found in many Playgrounds.
  46610. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46611. * @param name Define the name of the camera in the scene
  46612. * @param position Define the start position of the camera in the scene
  46613. * @param scene Define the scene the camera belongs to
  46614. */
  46615. constructor(name: string, position: Vector3, scene: Scene);
  46616. /**
  46617. * Gets the current object class name.
  46618. * @return the class name
  46619. */
  46620. getClassName(): string;
  46621. }
  46622. }
  46623. declare module "babylonjs/Cameras/gamepadCamera" {
  46624. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46625. import { Scene } from "babylonjs/scene";
  46626. import { Vector3 } from "babylonjs/Maths/math.vector";
  46627. /**
  46628. * This represents a FPS type of camera. This is only here for back compat purpose.
  46629. * Please use the UniversalCamera instead as both are identical.
  46630. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46631. */
  46632. export class GamepadCamera extends UniversalCamera {
  46633. /**
  46634. * Instantiates a new Gamepad Camera
  46635. * This represents a FPS type of camera. This is only here for back compat purpose.
  46636. * Please use the UniversalCamera instead as both are identical.
  46637. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46638. * @param name Define the name of the camera in the scene
  46639. * @param position Define the start position of the camera in the scene
  46640. * @param scene Define the scene the camera belongs to
  46641. */
  46642. constructor(name: string, position: Vector3, scene: Scene);
  46643. /**
  46644. * Gets the current object class name.
  46645. * @return the class name
  46646. */
  46647. getClassName(): string;
  46648. }
  46649. }
  46650. declare module "babylonjs/Shaders/pass.fragment" {
  46651. /** @hidden */
  46652. export var passPixelShader: {
  46653. name: string;
  46654. shader: string;
  46655. };
  46656. }
  46657. declare module "babylonjs/Shaders/passCube.fragment" {
  46658. /** @hidden */
  46659. export var passCubePixelShader: {
  46660. name: string;
  46661. shader: string;
  46662. };
  46663. }
  46664. declare module "babylonjs/PostProcesses/passPostProcess" {
  46665. import { Nullable } from "babylonjs/types";
  46666. import { Camera } from "babylonjs/Cameras/camera";
  46667. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46668. import { Engine } from "babylonjs/Engines/engine";
  46669. import "babylonjs/Shaders/pass.fragment";
  46670. import "babylonjs/Shaders/passCube.fragment";
  46671. /**
  46672. * PassPostProcess which produces an output the same as it's input
  46673. */
  46674. export class PassPostProcess extends PostProcess {
  46675. /**
  46676. * Creates the PassPostProcess
  46677. * @param name The name of the effect.
  46678. * @param options The required width/height ratio to downsize to before computing the render pass.
  46679. * @param camera The camera to apply the render pass to.
  46680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46681. * @param engine The engine which the post process will be applied. (default: current engine)
  46682. * @param reusable If the post process can be reused on the same frame. (default: false)
  46683. * @param textureType The type of texture to be used when performing the post processing.
  46684. * @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)
  46685. */
  46686. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46687. }
  46688. /**
  46689. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46690. */
  46691. export class PassCubePostProcess extends PostProcess {
  46692. private _face;
  46693. /**
  46694. * Gets or sets the cube face to display.
  46695. * * 0 is +X
  46696. * * 1 is -X
  46697. * * 2 is +Y
  46698. * * 3 is -Y
  46699. * * 4 is +Z
  46700. * * 5 is -Z
  46701. */
  46702. get face(): number;
  46703. set face(value: number);
  46704. /**
  46705. * Creates the PassCubePostProcess
  46706. * @param name The name of the effect.
  46707. * @param options The required width/height ratio to downsize to before computing the render pass.
  46708. * @param camera The camera to apply the render pass to.
  46709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46710. * @param engine The engine which the post process will be applied. (default: current engine)
  46711. * @param reusable If the post process can be reused on the same frame. (default: false)
  46712. * @param textureType The type of texture to be used when performing the post processing.
  46713. * @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)
  46714. */
  46715. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46716. }
  46717. }
  46718. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46719. /** @hidden */
  46720. export var anaglyphPixelShader: {
  46721. name: string;
  46722. shader: string;
  46723. };
  46724. }
  46725. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46726. import { Engine } from "babylonjs/Engines/engine";
  46727. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46728. import { Camera } from "babylonjs/Cameras/camera";
  46729. import "babylonjs/Shaders/anaglyph.fragment";
  46730. /**
  46731. * Postprocess used to generate anaglyphic rendering
  46732. */
  46733. export class AnaglyphPostProcess extends PostProcess {
  46734. private _passedProcess;
  46735. /**
  46736. * Creates a new AnaglyphPostProcess
  46737. * @param name defines postprocess name
  46738. * @param options defines creation options or target ratio scale
  46739. * @param rigCameras defines cameras using this postprocess
  46740. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46741. * @param engine defines hosting engine
  46742. * @param reusable defines if the postprocess will be reused multiple times per frame
  46743. */
  46744. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46745. }
  46746. }
  46747. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46748. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46749. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46750. import { Scene } from "babylonjs/scene";
  46751. import { Vector3 } from "babylonjs/Maths/math.vector";
  46752. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46753. /**
  46754. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46755. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46756. */
  46757. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46758. /**
  46759. * Creates a new AnaglyphArcRotateCamera
  46760. * @param name defines camera name
  46761. * @param alpha defines alpha angle (in radians)
  46762. * @param beta defines beta angle (in radians)
  46763. * @param radius defines radius
  46764. * @param target defines camera target
  46765. * @param interaxialDistance defines distance between each color axis
  46766. * @param scene defines the hosting scene
  46767. */
  46768. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46769. /**
  46770. * Gets camera class name
  46771. * @returns AnaglyphArcRotateCamera
  46772. */
  46773. getClassName(): string;
  46774. }
  46775. }
  46776. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46777. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46778. import { Scene } from "babylonjs/scene";
  46779. import { Vector3 } from "babylonjs/Maths/math.vector";
  46780. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46781. /**
  46782. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46783. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46784. */
  46785. export class AnaglyphFreeCamera extends FreeCamera {
  46786. /**
  46787. * Creates a new AnaglyphFreeCamera
  46788. * @param name defines camera name
  46789. * @param position defines initial position
  46790. * @param interaxialDistance defines distance between each color axis
  46791. * @param scene defines the hosting scene
  46792. */
  46793. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46794. /**
  46795. * Gets camera class name
  46796. * @returns AnaglyphFreeCamera
  46797. */
  46798. getClassName(): string;
  46799. }
  46800. }
  46801. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46802. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46803. import { Scene } from "babylonjs/scene";
  46804. import { Vector3 } from "babylonjs/Maths/math.vector";
  46805. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46806. /**
  46807. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46808. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46809. */
  46810. export class AnaglyphGamepadCamera extends GamepadCamera {
  46811. /**
  46812. * Creates a new AnaglyphGamepadCamera
  46813. * @param name defines camera name
  46814. * @param position defines initial position
  46815. * @param interaxialDistance defines distance between each color axis
  46816. * @param scene defines the hosting scene
  46817. */
  46818. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46819. /**
  46820. * Gets camera class name
  46821. * @returns AnaglyphGamepadCamera
  46822. */
  46823. getClassName(): string;
  46824. }
  46825. }
  46826. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46827. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46828. import { Scene } from "babylonjs/scene";
  46829. import { Vector3 } from "babylonjs/Maths/math.vector";
  46830. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46831. /**
  46832. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46833. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46834. */
  46835. export class AnaglyphUniversalCamera extends UniversalCamera {
  46836. /**
  46837. * Creates a new AnaglyphUniversalCamera
  46838. * @param name defines camera name
  46839. * @param position defines initial position
  46840. * @param interaxialDistance defines distance between each color axis
  46841. * @param scene defines the hosting scene
  46842. */
  46843. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46844. /**
  46845. * Gets camera class name
  46846. * @returns AnaglyphUniversalCamera
  46847. */
  46848. getClassName(): string;
  46849. }
  46850. }
  46851. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46852. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46853. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46854. import { Scene } from "babylonjs/scene";
  46855. import { Vector3 } from "babylonjs/Maths/math.vector";
  46856. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46857. /**
  46858. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46859. * @see https://doc.babylonjs.com/features/cameras
  46860. */
  46861. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46862. /**
  46863. * Creates a new StereoscopicArcRotateCamera
  46864. * @param name defines camera name
  46865. * @param alpha defines alpha angle (in radians)
  46866. * @param beta defines beta angle (in radians)
  46867. * @param radius defines radius
  46868. * @param target defines camera target
  46869. * @param interaxialDistance defines distance between each color axis
  46870. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46871. * @param scene defines the hosting scene
  46872. */
  46873. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46874. /**
  46875. * Gets camera class name
  46876. * @returns StereoscopicArcRotateCamera
  46877. */
  46878. getClassName(): string;
  46879. }
  46880. }
  46881. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46882. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46883. import { Scene } from "babylonjs/scene";
  46884. import { Vector3 } from "babylonjs/Maths/math.vector";
  46885. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46886. /**
  46887. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46888. * @see https://doc.babylonjs.com/features/cameras
  46889. */
  46890. export class StereoscopicFreeCamera extends FreeCamera {
  46891. /**
  46892. * Creates a new StereoscopicFreeCamera
  46893. * @param name defines camera name
  46894. * @param position defines initial position
  46895. * @param interaxialDistance defines distance between each color axis
  46896. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46897. * @param scene defines the hosting scene
  46898. */
  46899. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46900. /**
  46901. * Gets camera class name
  46902. * @returns StereoscopicFreeCamera
  46903. */
  46904. getClassName(): string;
  46905. }
  46906. }
  46907. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46908. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46909. import { Scene } from "babylonjs/scene";
  46910. import { Vector3 } from "babylonjs/Maths/math.vector";
  46911. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46912. /**
  46913. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46914. * @see https://doc.babylonjs.com/features/cameras
  46915. */
  46916. export class StereoscopicGamepadCamera extends GamepadCamera {
  46917. /**
  46918. * Creates a new StereoscopicGamepadCamera
  46919. * @param name defines camera name
  46920. * @param position defines initial position
  46921. * @param interaxialDistance defines distance between each color axis
  46922. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46923. * @param scene defines the hosting scene
  46924. */
  46925. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46926. /**
  46927. * Gets camera class name
  46928. * @returns StereoscopicGamepadCamera
  46929. */
  46930. getClassName(): string;
  46931. }
  46932. }
  46933. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46934. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46935. import { Scene } from "babylonjs/scene";
  46936. import { Vector3 } from "babylonjs/Maths/math.vector";
  46937. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46938. /**
  46939. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46940. * @see https://doc.babylonjs.com/features/cameras
  46941. */
  46942. export class StereoscopicUniversalCamera extends UniversalCamera {
  46943. /**
  46944. * Creates a new StereoscopicUniversalCamera
  46945. * @param name defines camera name
  46946. * @param position defines initial position
  46947. * @param interaxialDistance defines distance between each color axis
  46948. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46949. * @param scene defines the hosting scene
  46950. */
  46951. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46952. /**
  46953. * Gets camera class name
  46954. * @returns StereoscopicUniversalCamera
  46955. */
  46956. getClassName(): string;
  46957. }
  46958. }
  46959. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46960. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46961. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46962. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46963. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46964. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46965. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46966. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46967. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46968. }
  46969. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46970. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46971. import { Scene } from "babylonjs/scene";
  46972. import { Vector3 } from "babylonjs/Maths/math.vector";
  46973. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46974. /**
  46975. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46976. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46977. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46978. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46979. */
  46980. export class VirtualJoysticksCamera extends FreeCamera {
  46981. /**
  46982. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46983. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46984. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46985. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46986. * @param name Define the name of the camera in the scene
  46987. * @param position Define the start position of the camera in the scene
  46988. * @param scene Define the scene the camera belongs to
  46989. */
  46990. constructor(name: string, position: Vector3, scene: Scene);
  46991. /**
  46992. * Gets the current object class name.
  46993. * @return the class name
  46994. */
  46995. getClassName(): string;
  46996. }
  46997. }
  46998. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46999. import { Matrix } from "babylonjs/Maths/math.vector";
  47000. /**
  47001. * This represents all the required metrics to create a VR camera.
  47002. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  47003. */
  47004. export class VRCameraMetrics {
  47005. /**
  47006. * Define the horizontal resolution off the screen.
  47007. */
  47008. hResolution: number;
  47009. /**
  47010. * Define the vertical resolution off the screen.
  47011. */
  47012. vResolution: number;
  47013. /**
  47014. * Define the horizontal screen size.
  47015. */
  47016. hScreenSize: number;
  47017. /**
  47018. * Define the vertical screen size.
  47019. */
  47020. vScreenSize: number;
  47021. /**
  47022. * Define the vertical screen center position.
  47023. */
  47024. vScreenCenter: number;
  47025. /**
  47026. * Define the distance of the eyes to the screen.
  47027. */
  47028. eyeToScreenDistance: number;
  47029. /**
  47030. * Define the distance between both lenses
  47031. */
  47032. lensSeparationDistance: number;
  47033. /**
  47034. * Define the distance between both viewer's eyes.
  47035. */
  47036. interpupillaryDistance: number;
  47037. /**
  47038. * Define the distortion factor of the VR postprocess.
  47039. * Please, touch with care.
  47040. */
  47041. distortionK: number[];
  47042. /**
  47043. * Define the chromatic aberration correction factors for the VR post process.
  47044. */
  47045. chromaAbCorrection: number[];
  47046. /**
  47047. * Define the scale factor of the post process.
  47048. * The smaller the better but the slower.
  47049. */
  47050. postProcessScaleFactor: number;
  47051. /**
  47052. * Define an offset for the lens center.
  47053. */
  47054. lensCenterOffset: number;
  47055. /**
  47056. * Define if the current vr camera should compensate the distortion of the lense or not.
  47057. */
  47058. compensateDistortion: boolean;
  47059. /**
  47060. * Defines if multiview should be enabled when rendering (Default: false)
  47061. */
  47062. multiviewEnabled: boolean;
  47063. /**
  47064. * Gets the rendering aspect ratio based on the provided resolutions.
  47065. */
  47066. get aspectRatio(): number;
  47067. /**
  47068. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  47069. */
  47070. get aspectRatioFov(): number;
  47071. /**
  47072. * @hidden
  47073. */
  47074. get leftHMatrix(): Matrix;
  47075. /**
  47076. * @hidden
  47077. */
  47078. get rightHMatrix(): Matrix;
  47079. /**
  47080. * @hidden
  47081. */
  47082. get leftPreViewMatrix(): Matrix;
  47083. /**
  47084. * @hidden
  47085. */
  47086. get rightPreViewMatrix(): Matrix;
  47087. /**
  47088. * Get the default VRMetrics based on the most generic setup.
  47089. * @returns the default vr metrics
  47090. */
  47091. static GetDefault(): VRCameraMetrics;
  47092. }
  47093. }
  47094. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47095. /** @hidden */
  47096. export var vrDistortionCorrectionPixelShader: {
  47097. name: string;
  47098. shader: string;
  47099. };
  47100. }
  47101. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47102. import { Camera } from "babylonjs/Cameras/camera";
  47103. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47104. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47105. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47106. /**
  47107. * VRDistortionCorrectionPostProcess used for mobile VR
  47108. */
  47109. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47110. private _isRightEye;
  47111. private _distortionFactors;
  47112. private _postProcessScaleFactor;
  47113. private _lensCenterOffset;
  47114. private _scaleIn;
  47115. private _scaleFactor;
  47116. private _lensCenter;
  47117. /**
  47118. * Initializes the VRDistortionCorrectionPostProcess
  47119. * @param name The name of the effect.
  47120. * @param camera The camera to apply the render pass to.
  47121. * @param isRightEye If this is for the right eye distortion
  47122. * @param vrMetrics All the required metrics for the VR camera
  47123. */
  47124. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47125. }
  47126. }
  47127. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  47128. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  47129. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47130. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47131. import { Scene } from "babylonjs/scene";
  47132. import { Vector3 } from "babylonjs/Maths/math.vector";
  47133. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47134. import "babylonjs/Cameras/RigModes/vrRigMode";
  47135. /**
  47136. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  47137. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47138. */
  47139. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  47140. /**
  47141. * Creates a new VRDeviceOrientationArcRotateCamera
  47142. * @param name defines camera name
  47143. * @param alpha defines the camera rotation along the logitudinal axis
  47144. * @param beta defines the camera rotation along the latitudinal axis
  47145. * @param radius defines the camera distance from its target
  47146. * @param target defines the camera target
  47147. * @param scene defines the scene the camera belongs to
  47148. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47149. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47150. */
  47151. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47152. /**
  47153. * Gets camera class name
  47154. * @returns VRDeviceOrientationArcRotateCamera
  47155. */
  47156. getClassName(): string;
  47157. }
  47158. }
  47159. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  47160. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47161. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47162. import { Scene } from "babylonjs/scene";
  47163. import { Vector3 } from "babylonjs/Maths/math.vector";
  47164. import "babylonjs/Cameras/RigModes/vrRigMode";
  47165. /**
  47166. * Camera used to simulate VR rendering (based on FreeCamera)
  47167. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47168. */
  47169. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  47170. /**
  47171. * Creates a new VRDeviceOrientationFreeCamera
  47172. * @param name defines camera name
  47173. * @param position defines the start position of the camera
  47174. * @param scene defines the scene the camera belongs to
  47175. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47176. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47177. */
  47178. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47179. /**
  47180. * Gets camera class name
  47181. * @returns VRDeviceOrientationFreeCamera
  47182. */
  47183. getClassName(): string;
  47184. }
  47185. }
  47186. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  47187. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47188. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47189. import { Scene } from "babylonjs/scene";
  47190. import { Vector3 } from "babylonjs/Maths/math.vector";
  47191. import "babylonjs/Gamepads/gamepadSceneComponent";
  47192. /**
  47193. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  47194. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47195. */
  47196. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  47197. /**
  47198. * Creates a new VRDeviceOrientationGamepadCamera
  47199. * @param name defines camera name
  47200. * @param position defines the start position of the camera
  47201. * @param scene defines the scene the camera belongs to
  47202. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47203. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47204. */
  47205. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47206. /**
  47207. * Gets camera class name
  47208. * @returns VRDeviceOrientationGamepadCamera
  47209. */
  47210. getClassName(): string;
  47211. }
  47212. }
  47213. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  47214. import { Scene } from "babylonjs/scene";
  47215. import { Texture } from "babylonjs/Materials/Textures/texture";
  47216. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47217. /**
  47218. * A class extending Texture allowing drawing on a texture
  47219. * @see https://doc.babylonjs.com/how_to/dynamictexture
  47220. */
  47221. export class DynamicTexture extends Texture {
  47222. private _generateMipMaps;
  47223. private _canvas;
  47224. private _context;
  47225. /**
  47226. * Creates a DynamicTexture
  47227. * @param name defines the name of the texture
  47228. * @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
  47229. * @param scene defines the scene where you want the texture
  47230. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  47231. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  47232. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  47233. */
  47234. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  47235. /**
  47236. * Get the current class name of the texture useful for serialization or dynamic coding.
  47237. * @returns "DynamicTexture"
  47238. */
  47239. getClassName(): string;
  47240. /**
  47241. * Gets the current state of canRescale
  47242. */
  47243. get canRescale(): boolean;
  47244. private _recreate;
  47245. /**
  47246. * Scales the texture
  47247. * @param ratio the scale factor to apply to both width and height
  47248. */
  47249. scale(ratio: number): void;
  47250. /**
  47251. * Resizes the texture
  47252. * @param width the new width
  47253. * @param height the new height
  47254. */
  47255. scaleTo(width: number, height: number): void;
  47256. /**
  47257. * Gets the context of the canvas used by the texture
  47258. * @returns the canvas context of the dynamic texture
  47259. */
  47260. getContext(): CanvasRenderingContext2D;
  47261. /**
  47262. * Clears the texture
  47263. */
  47264. clear(): void;
  47265. /**
  47266. * Updates the texture
  47267. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47268. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  47269. */
  47270. update(invertY?: boolean, premulAlpha?: boolean): void;
  47271. /**
  47272. * Draws text onto the texture
  47273. * @param text defines the text to be drawn
  47274. * @param x defines the placement of the text from the left
  47275. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  47276. * @param font defines the font to be used with font-style, font-size, font-name
  47277. * @param color defines the color used for the text
  47278. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  47279. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47280. * @param update defines whether texture is immediately update (default is true)
  47281. */
  47282. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  47283. /**
  47284. * Clones the texture
  47285. * @returns the clone of the texture.
  47286. */
  47287. clone(): DynamicTexture;
  47288. /**
  47289. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  47290. * @returns a serialized dynamic texture object
  47291. */
  47292. serialize(): any;
  47293. private _IsCanvasElement;
  47294. /** @hidden */
  47295. _rebuild(): void;
  47296. }
  47297. }
  47298. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  47299. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47300. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47301. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47302. /** @hidden */
  47303. export var imageProcessingPixelShader: {
  47304. name: string;
  47305. shader: string;
  47306. };
  47307. }
  47308. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  47309. import { Nullable } from "babylonjs/types";
  47310. import { Color4 } from "babylonjs/Maths/math.color";
  47311. import { Camera } from "babylonjs/Cameras/camera";
  47312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47313. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47314. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47315. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47316. import { Engine } from "babylonjs/Engines/engine";
  47317. import "babylonjs/Shaders/imageProcessing.fragment";
  47318. import "babylonjs/Shaders/postprocess.vertex";
  47319. /**
  47320. * ImageProcessingPostProcess
  47321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  47322. */
  47323. export class ImageProcessingPostProcess extends PostProcess {
  47324. /**
  47325. * Default configuration related to image processing available in the PBR Material.
  47326. */
  47327. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47328. /**
  47329. * Gets the image processing configuration used either in this material.
  47330. */
  47331. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47332. /**
  47333. * Sets the Default image processing configuration used either in the this material.
  47334. *
  47335. * If sets to null, the scene one is in use.
  47336. */
  47337. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  47338. /**
  47339. * Keep track of the image processing observer to allow dispose and replace.
  47340. */
  47341. private _imageProcessingObserver;
  47342. /**
  47343. * Attaches a new image processing configuration to the PBR Material.
  47344. * @param configuration
  47345. */
  47346. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  47347. /**
  47348. * If the post process is supported.
  47349. */
  47350. get isSupported(): boolean;
  47351. /**
  47352. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47353. */
  47354. get colorCurves(): Nullable<ColorCurves>;
  47355. /**
  47356. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47357. */
  47358. set colorCurves(value: Nullable<ColorCurves>);
  47359. /**
  47360. * Gets wether the color curves effect is enabled.
  47361. */
  47362. get colorCurvesEnabled(): boolean;
  47363. /**
  47364. * Sets wether the color curves effect is enabled.
  47365. */
  47366. set colorCurvesEnabled(value: boolean);
  47367. /**
  47368. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47369. */
  47370. get colorGradingTexture(): Nullable<BaseTexture>;
  47371. /**
  47372. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47373. */
  47374. set colorGradingTexture(value: Nullable<BaseTexture>);
  47375. /**
  47376. * Gets wether the color grading effect is enabled.
  47377. */
  47378. get colorGradingEnabled(): boolean;
  47379. /**
  47380. * Gets wether the color grading effect is enabled.
  47381. */
  47382. set colorGradingEnabled(value: boolean);
  47383. /**
  47384. * Gets exposure used in the effect.
  47385. */
  47386. get exposure(): number;
  47387. /**
  47388. * Sets exposure used in the effect.
  47389. */
  47390. set exposure(value: number);
  47391. /**
  47392. * Gets wether tonemapping is enabled or not.
  47393. */
  47394. get toneMappingEnabled(): boolean;
  47395. /**
  47396. * Sets wether tonemapping is enabled or not
  47397. */
  47398. set toneMappingEnabled(value: boolean);
  47399. /**
  47400. * Gets the type of tone mapping effect.
  47401. */
  47402. get toneMappingType(): number;
  47403. /**
  47404. * Sets the type of tone mapping effect.
  47405. */
  47406. set toneMappingType(value: number);
  47407. /**
  47408. * Gets contrast used in the effect.
  47409. */
  47410. get contrast(): number;
  47411. /**
  47412. * Sets contrast used in the effect.
  47413. */
  47414. set contrast(value: number);
  47415. /**
  47416. * Gets Vignette stretch size.
  47417. */
  47418. get vignetteStretch(): number;
  47419. /**
  47420. * Sets Vignette stretch size.
  47421. */
  47422. set vignetteStretch(value: number);
  47423. /**
  47424. * Gets Vignette centre X Offset.
  47425. */
  47426. get vignetteCentreX(): number;
  47427. /**
  47428. * Sets Vignette centre X Offset.
  47429. */
  47430. set vignetteCentreX(value: number);
  47431. /**
  47432. * Gets Vignette centre Y Offset.
  47433. */
  47434. get vignetteCentreY(): number;
  47435. /**
  47436. * Sets Vignette centre Y Offset.
  47437. */
  47438. set vignetteCentreY(value: number);
  47439. /**
  47440. * Gets Vignette weight or intensity of the vignette effect.
  47441. */
  47442. get vignetteWeight(): number;
  47443. /**
  47444. * Sets Vignette weight or intensity of the vignette effect.
  47445. */
  47446. set vignetteWeight(value: number);
  47447. /**
  47448. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47449. * if vignetteEnabled is set to true.
  47450. */
  47451. get vignetteColor(): Color4;
  47452. /**
  47453. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47454. * if vignetteEnabled is set to true.
  47455. */
  47456. set vignetteColor(value: Color4);
  47457. /**
  47458. * Gets Camera field of view used by the Vignette effect.
  47459. */
  47460. get vignetteCameraFov(): number;
  47461. /**
  47462. * Sets Camera field of view used by the Vignette effect.
  47463. */
  47464. set vignetteCameraFov(value: number);
  47465. /**
  47466. * Gets the vignette blend mode allowing different kind of effect.
  47467. */
  47468. get vignetteBlendMode(): number;
  47469. /**
  47470. * Sets the vignette blend mode allowing different kind of effect.
  47471. */
  47472. set vignetteBlendMode(value: number);
  47473. /**
  47474. * Gets wether the vignette effect is enabled.
  47475. */
  47476. get vignetteEnabled(): boolean;
  47477. /**
  47478. * Sets wether the vignette effect is enabled.
  47479. */
  47480. set vignetteEnabled(value: boolean);
  47481. private _fromLinearSpace;
  47482. /**
  47483. * Gets wether the input of the processing is in Gamma or Linear Space.
  47484. */
  47485. get fromLinearSpace(): boolean;
  47486. /**
  47487. * Sets wether the input of the processing is in Gamma or Linear Space.
  47488. */
  47489. set fromLinearSpace(value: boolean);
  47490. /**
  47491. * Defines cache preventing GC.
  47492. */
  47493. private _defines;
  47494. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47495. /**
  47496. * "ImageProcessingPostProcess"
  47497. * @returns "ImageProcessingPostProcess"
  47498. */
  47499. getClassName(): string;
  47500. protected _updateParameters(): void;
  47501. dispose(camera?: Camera): void;
  47502. }
  47503. }
  47504. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47505. import { Scene } from "babylonjs/scene";
  47506. import { Color3 } from "babylonjs/Maths/math.color";
  47507. import { Mesh } from "babylonjs/Meshes/mesh";
  47508. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47509. import { Nullable } from "babylonjs/types";
  47510. /**
  47511. * Class containing static functions to help procedurally build meshes
  47512. */
  47513. export class GroundBuilder {
  47514. /**
  47515. * Creates a ground mesh
  47516. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47517. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47519. * @param name defines the name of the mesh
  47520. * @param options defines the options used to create the mesh
  47521. * @param scene defines the hosting scene
  47522. * @returns the ground mesh
  47523. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47524. */
  47525. static CreateGround(name: string, options: {
  47526. width?: number;
  47527. height?: number;
  47528. subdivisions?: number;
  47529. subdivisionsX?: number;
  47530. subdivisionsY?: number;
  47531. updatable?: boolean;
  47532. }, scene: any): Mesh;
  47533. /**
  47534. * Creates a tiled ground mesh
  47535. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47536. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47537. * * 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
  47538. * * 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
  47539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47540. * @param name defines the name of the mesh
  47541. * @param options defines the options used to create the mesh
  47542. * @param scene defines the hosting scene
  47543. * @returns the tiled ground mesh
  47544. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47545. */
  47546. static CreateTiledGround(name: string, options: {
  47547. xmin: number;
  47548. zmin: number;
  47549. xmax: number;
  47550. zmax: number;
  47551. subdivisions?: {
  47552. w: number;
  47553. h: number;
  47554. };
  47555. precision?: {
  47556. w: number;
  47557. h: number;
  47558. };
  47559. updatable?: boolean;
  47560. }, scene?: Nullable<Scene>): Mesh;
  47561. /**
  47562. * Creates a ground mesh from a height map
  47563. * * The parameter `url` sets the URL of the height map image resource.
  47564. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47565. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47566. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47567. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47568. * * 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.
  47569. * * 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).
  47570. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47572. * @param name defines the name of the mesh
  47573. * @param url defines the url to the height map
  47574. * @param options defines the options used to create the mesh
  47575. * @param scene defines the hosting scene
  47576. * @returns the ground mesh
  47577. * @see https://doc.babylonjs.com/babylon101/height_map
  47578. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47579. */
  47580. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47581. width?: number;
  47582. height?: number;
  47583. subdivisions?: number;
  47584. minHeight?: number;
  47585. maxHeight?: number;
  47586. colorFilter?: Color3;
  47587. alphaFilter?: number;
  47588. updatable?: boolean;
  47589. onReady?: (mesh: GroundMesh) => void;
  47590. }, scene?: Nullable<Scene>): GroundMesh;
  47591. }
  47592. }
  47593. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47594. import { Vector4 } from "babylonjs/Maths/math.vector";
  47595. import { Mesh } from "babylonjs/Meshes/mesh";
  47596. /**
  47597. * Class containing static functions to help procedurally build meshes
  47598. */
  47599. export class TorusBuilder {
  47600. /**
  47601. * Creates a torus mesh
  47602. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47603. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47604. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47608. * @param name defines the name of the mesh
  47609. * @param options defines the options used to create the mesh
  47610. * @param scene defines the hosting scene
  47611. * @returns the torus mesh
  47612. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47613. */
  47614. static CreateTorus(name: string, options: {
  47615. diameter?: number;
  47616. thickness?: number;
  47617. tessellation?: number;
  47618. updatable?: boolean;
  47619. sideOrientation?: number;
  47620. frontUVs?: Vector4;
  47621. backUVs?: Vector4;
  47622. }, scene: any): Mesh;
  47623. }
  47624. }
  47625. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47626. import { Vector4 } from "babylonjs/Maths/math.vector";
  47627. import { Color4 } from "babylonjs/Maths/math.color";
  47628. import { Mesh } from "babylonjs/Meshes/mesh";
  47629. /**
  47630. * Class containing static functions to help procedurally build meshes
  47631. */
  47632. export class CylinderBuilder {
  47633. /**
  47634. * Creates a cylinder or a cone mesh
  47635. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47636. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47637. * * 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.
  47638. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47639. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47640. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47641. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47642. * * 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).
  47643. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47644. * * 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).
  47645. * * 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
  47646. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47647. * * 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
  47648. * * 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.
  47649. * * If `enclose` is false, a ring surface is one element.
  47650. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47651. * * 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
  47652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47653. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47655. * @param name defines the name of the mesh
  47656. * @param options defines the options used to create the mesh
  47657. * @param scene defines the hosting scene
  47658. * @returns the cylinder mesh
  47659. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47660. */
  47661. static CreateCylinder(name: string, options: {
  47662. height?: number;
  47663. diameterTop?: number;
  47664. diameterBottom?: number;
  47665. diameter?: number;
  47666. tessellation?: number;
  47667. subdivisions?: number;
  47668. arc?: number;
  47669. faceColors?: Color4[];
  47670. faceUV?: Vector4[];
  47671. updatable?: boolean;
  47672. hasRings?: boolean;
  47673. enclose?: boolean;
  47674. cap?: number;
  47675. sideOrientation?: number;
  47676. frontUVs?: Vector4;
  47677. backUVs?: Vector4;
  47678. }, scene: any): Mesh;
  47679. }
  47680. }
  47681. declare module "babylonjs/XR/webXRTypes" {
  47682. import { Nullable } from "babylonjs/types";
  47683. import { IDisposable } from "babylonjs/scene";
  47684. /**
  47685. * States of the webXR experience
  47686. */
  47687. export enum WebXRState {
  47688. /**
  47689. * Transitioning to being in XR mode
  47690. */
  47691. ENTERING_XR = 0,
  47692. /**
  47693. * Transitioning to non XR mode
  47694. */
  47695. EXITING_XR = 1,
  47696. /**
  47697. * In XR mode and presenting
  47698. */
  47699. IN_XR = 2,
  47700. /**
  47701. * Not entered XR mode
  47702. */
  47703. NOT_IN_XR = 3
  47704. }
  47705. /**
  47706. * Abstraction of the XR render target
  47707. */
  47708. export interface WebXRRenderTarget extends IDisposable {
  47709. /**
  47710. * xrpresent context of the canvas which can be used to display/mirror xr content
  47711. */
  47712. canvasContext: WebGLRenderingContext;
  47713. /**
  47714. * xr layer for the canvas
  47715. */
  47716. xrLayer: Nullable<XRWebGLLayer>;
  47717. /**
  47718. * Initializes the xr layer for the session
  47719. * @param xrSession xr session
  47720. * @returns a promise that will resolve once the XR Layer has been created
  47721. */
  47722. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47723. }
  47724. }
  47725. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47726. import { Nullable } from "babylonjs/types";
  47727. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47728. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47729. import { Observable } from "babylonjs/Misc/observable";
  47730. /**
  47731. * COnfiguration object for WebXR output canvas
  47732. */
  47733. export class WebXRManagedOutputCanvasOptions {
  47734. /**
  47735. * An optional canvas in case you wish to create it yourself and provide it here.
  47736. * If not provided, a new canvas will be created
  47737. */
  47738. canvasElement?: HTMLCanvasElement;
  47739. /**
  47740. * Options for this XR Layer output
  47741. */
  47742. canvasOptions?: XRWebGLLayerOptions;
  47743. /**
  47744. * CSS styling for a newly created canvas (if not provided)
  47745. */
  47746. newCanvasCssStyle?: string;
  47747. /**
  47748. * Get the default values of the configuration object
  47749. * @returns default values of this configuration object
  47750. */
  47751. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47752. }
  47753. /**
  47754. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47755. */
  47756. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47757. private _options;
  47758. private _canvas;
  47759. private _engine;
  47760. private _originalCanvasSize;
  47761. /**
  47762. * Rendering context of the canvas which can be used to display/mirror xr content
  47763. */
  47764. canvasContext: WebGLRenderingContext;
  47765. /**
  47766. * xr layer for the canvas
  47767. */
  47768. xrLayer: Nullable<XRWebGLLayer>;
  47769. /**
  47770. * Obseervers registered here will be triggered when the xr layer was initialized
  47771. */
  47772. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  47773. /**
  47774. * Initializes the canvas to be added/removed upon entering/exiting xr
  47775. * @param _xrSessionManager The XR Session manager
  47776. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47777. */
  47778. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47779. /**
  47780. * Disposes of the object
  47781. */
  47782. dispose(): void;
  47783. /**
  47784. * Initializes the xr layer for the session
  47785. * @param xrSession xr session
  47786. * @returns a promise that will resolve once the XR Layer has been created
  47787. */
  47788. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47789. private _addCanvas;
  47790. private _removeCanvas;
  47791. private _setCanvasSize;
  47792. private _setManagedOutputCanvas;
  47793. }
  47794. }
  47795. declare module "babylonjs/XR/webXRSessionManager" {
  47796. import { Observable } from "babylonjs/Misc/observable";
  47797. import { Nullable } from "babylonjs/types";
  47798. import { IDisposable, Scene } from "babylonjs/scene";
  47799. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47800. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47801. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47802. /**
  47803. * Manages an XRSession to work with Babylon's engine
  47804. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  47805. */
  47806. export class WebXRSessionManager implements IDisposable {
  47807. /** The scene which the session should be created for */
  47808. scene: Scene;
  47809. private _referenceSpace;
  47810. private _rttProvider;
  47811. private _sessionEnded;
  47812. private _xrNavigator;
  47813. private baseLayer;
  47814. /**
  47815. * The base reference space from which the session started. good if you want to reset your
  47816. * reference space
  47817. */
  47818. baseReferenceSpace: XRReferenceSpace;
  47819. /**
  47820. * Current XR frame
  47821. */
  47822. currentFrame: Nullable<XRFrame>;
  47823. /** WebXR timestamp updated every frame */
  47824. currentTimestamp: number;
  47825. /**
  47826. * Used just in case of a failure to initialize an immersive session.
  47827. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47828. */
  47829. defaultHeightCompensation: number;
  47830. /**
  47831. * Fires every time a new xrFrame arrives which can be used to update the camera
  47832. */
  47833. onXRFrameObservable: Observable<XRFrame>;
  47834. /**
  47835. * Fires when the reference space changed
  47836. */
  47837. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47838. /**
  47839. * Fires when the xr session is ended either by the device or manually done
  47840. */
  47841. onXRSessionEnded: Observable<any>;
  47842. /**
  47843. * Fires when the xr session is ended either by the device or manually done
  47844. */
  47845. onXRSessionInit: Observable<XRSession>;
  47846. /**
  47847. * Underlying xr session
  47848. */
  47849. session: XRSession;
  47850. /**
  47851. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47852. * or get the offset the player is currently at.
  47853. */
  47854. viewerReferenceSpace: XRReferenceSpace;
  47855. /**
  47856. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47857. * @param scene The scene which the session should be created for
  47858. */
  47859. constructor(
  47860. /** The scene which the session should be created for */
  47861. scene: Scene);
  47862. /**
  47863. * The current reference space used in this session. This reference space can constantly change!
  47864. * It is mainly used to offset the camera's position.
  47865. */
  47866. get referenceSpace(): XRReferenceSpace;
  47867. /**
  47868. * Set a new reference space and triggers the observable
  47869. */
  47870. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47871. /**
  47872. * Disposes of the session manager
  47873. */
  47874. dispose(): void;
  47875. /**
  47876. * Stops the xrSession and restores the render loop
  47877. * @returns Promise which resolves after it exits XR
  47878. */
  47879. exitXRAsync(): Promise<void>;
  47880. /**
  47881. * Gets the correct render target texture to be rendered this frame for this eye
  47882. * @param eye the eye for which to get the render target
  47883. * @returns the render target for the specified eye
  47884. */
  47885. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47886. /**
  47887. * Creates a WebXRRenderTarget object for the XR session
  47888. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47889. * @param options optional options to provide when creating a new render target
  47890. * @returns a WebXR render target to which the session can render
  47891. */
  47892. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47893. /**
  47894. * Initializes the manager
  47895. * After initialization enterXR can be called to start an XR session
  47896. * @returns Promise which resolves after it is initialized
  47897. */
  47898. initializeAsync(): Promise<void>;
  47899. /**
  47900. * Initializes an xr session
  47901. * @param xrSessionMode mode to initialize
  47902. * @param xrSessionInit defines optional and required values to pass to the session builder
  47903. * @returns a promise which will resolve once the session has been initialized
  47904. */
  47905. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47906. /**
  47907. * Checks if a session would be supported for the creation options specified
  47908. * @param sessionMode session mode to check if supported eg. immersive-vr
  47909. * @returns A Promise that resolves to true if supported and false if not
  47910. */
  47911. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47912. /**
  47913. * Resets the reference space to the one started the session
  47914. */
  47915. resetReferenceSpace(): void;
  47916. /**
  47917. * Starts rendering to the xr layer
  47918. */
  47919. runXRRenderLoop(): void;
  47920. /**
  47921. * Sets the reference space on the xr session
  47922. * @param referenceSpaceType space to set
  47923. * @returns a promise that will resolve once the reference space has been set
  47924. */
  47925. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47926. /**
  47927. * Updates the render state of the session
  47928. * @param state state to set
  47929. * @returns a promise that resolves once the render state has been updated
  47930. */
  47931. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47932. /**
  47933. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47934. * @param sessionMode defines the session to test
  47935. * @returns a promise with boolean as final value
  47936. */
  47937. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47938. private _createRenderTargetTexture;
  47939. }
  47940. }
  47941. declare module "babylonjs/XR/webXRCamera" {
  47942. import { Scene } from "babylonjs/scene";
  47943. import { Camera } from "babylonjs/Cameras/camera";
  47944. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47945. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47946. /**
  47947. * WebXR Camera which holds the views for the xrSession
  47948. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47949. */
  47950. export class WebXRCamera extends FreeCamera {
  47951. private _xrSessionManager;
  47952. private _firstFrame;
  47953. private _referenceQuaternion;
  47954. private _referencedPosition;
  47955. private _xrInvPositionCache;
  47956. private _xrInvQuaternionCache;
  47957. /**
  47958. * Should position compensation execute on first frame.
  47959. * This is used when copying the position from a native (non XR) camera
  47960. */
  47961. compensateOnFirstFrame: boolean;
  47962. /**
  47963. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47964. * @param name the name of the camera
  47965. * @param scene the scene to add the camera to
  47966. * @param _xrSessionManager a constructed xr session manager
  47967. */
  47968. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47969. /**
  47970. * Return the user's height, unrelated to the current ground.
  47971. * This will be the y position of this camera, when ground level is 0.
  47972. */
  47973. get realWorldHeight(): number;
  47974. /** @hidden */
  47975. _updateForDualEyeDebugging(): void;
  47976. /**
  47977. * Sets this camera's transformation based on a non-vr camera
  47978. * @param otherCamera the non-vr camera to copy the transformation from
  47979. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47980. */
  47981. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47982. /**
  47983. * Gets the current instance class name ("WebXRCamera").
  47984. * @returns the class name
  47985. */
  47986. getClassName(): string;
  47987. private _rotate180;
  47988. private _updateFromXRSession;
  47989. private _updateNumberOfRigCameras;
  47990. private _updateReferenceSpace;
  47991. private _updateReferenceSpaceOffset;
  47992. }
  47993. }
  47994. declare module "babylonjs/XR/webXRFeaturesManager" {
  47995. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47996. import { IDisposable } from "babylonjs/scene";
  47997. /**
  47998. * Defining the interface required for a (webxr) feature
  47999. */
  48000. export interface IWebXRFeature extends IDisposable {
  48001. /**
  48002. * Is this feature attached
  48003. */
  48004. attached: boolean;
  48005. /**
  48006. * Should auto-attach be disabled?
  48007. */
  48008. disableAutoAttach: boolean;
  48009. /**
  48010. * Attach the feature to the session
  48011. * Will usually be called by the features manager
  48012. *
  48013. * @param force should attachment be forced (even when already attached)
  48014. * @returns true if successful.
  48015. */
  48016. attach(force?: boolean): boolean;
  48017. /**
  48018. * Detach the feature from the session
  48019. * Will usually be called by the features manager
  48020. *
  48021. * @returns true if successful.
  48022. */
  48023. detach(): boolean;
  48024. }
  48025. /**
  48026. * A list of the currently available features without referencing them
  48027. */
  48028. export class WebXRFeatureName {
  48029. /**
  48030. * The name of the anchor system feature
  48031. */
  48032. static ANCHOR_SYSTEM: string;
  48033. /**
  48034. * The name of the background remover feature
  48035. */
  48036. static BACKGROUND_REMOVER: string;
  48037. /**
  48038. * The name of the hit test feature
  48039. */
  48040. static HIT_TEST: string;
  48041. /**
  48042. * physics impostors for xr controllers feature
  48043. */
  48044. static PHYSICS_CONTROLLERS: string;
  48045. /**
  48046. * The name of the plane detection feature
  48047. */
  48048. static PLANE_DETECTION: string;
  48049. /**
  48050. * The name of the pointer selection feature
  48051. */
  48052. static POINTER_SELECTION: string;
  48053. /**
  48054. * The name of the teleportation feature
  48055. */
  48056. static TELEPORTATION: string;
  48057. }
  48058. /**
  48059. * Defining the constructor of a feature. Used to register the modules.
  48060. */
  48061. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  48062. /**
  48063. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48064. * It is mainly used in AR sessions.
  48065. *
  48066. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48067. */
  48068. export class WebXRFeaturesManager implements IDisposable {
  48069. private _xrSessionManager;
  48070. private static readonly _AvailableFeatures;
  48071. private _features;
  48072. /**
  48073. * constructs a new features manages.
  48074. *
  48075. * @param _xrSessionManager an instance of WebXRSessionManager
  48076. */
  48077. constructor(_xrSessionManager: WebXRSessionManager);
  48078. /**
  48079. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48080. * Mainly used internally.
  48081. *
  48082. * @param featureName the name of the feature to register
  48083. * @param constructorFunction the function used to construct the module
  48084. * @param version the (babylon) version of the module
  48085. * @param stable is that a stable version of this module
  48086. */
  48087. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48088. /**
  48089. * Returns a constructor of a specific feature.
  48090. *
  48091. * @param featureName the name of the feature to construct
  48092. * @param version the version of the feature to load
  48093. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48094. * @param options optional options provided to the module.
  48095. * @returns a function that, when called, will return a new instance of this feature
  48096. */
  48097. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  48098. /**
  48099. * Can be used to return the list of features currently registered
  48100. *
  48101. * @returns an Array of available features
  48102. */
  48103. static GetAvailableFeatures(): string[];
  48104. /**
  48105. * Gets the versions available for a specific feature
  48106. * @param featureName the name of the feature
  48107. * @returns an array with the available versions
  48108. */
  48109. static GetAvailableVersions(featureName: string): string[];
  48110. /**
  48111. * Return the latest unstable version of this feature
  48112. * @param featureName the name of the feature to search
  48113. * @returns the version number. if not found will return -1
  48114. */
  48115. static GetLatestVersionOfFeature(featureName: string): number;
  48116. /**
  48117. * Return the latest stable version of this feature
  48118. * @param featureName the name of the feature to search
  48119. * @returns the version number. if not found will return -1
  48120. */
  48121. static GetStableVersionOfFeature(featureName: string): number;
  48122. /**
  48123. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48124. * Can be used during a session to start a feature
  48125. * @param featureName the name of feature to attach
  48126. */
  48127. attachFeature(featureName: string): void;
  48128. /**
  48129. * Can be used inside a session or when the session ends to detach a specific feature
  48130. * @param featureName the name of the feature to detach
  48131. */
  48132. detachFeature(featureName: string): void;
  48133. /**
  48134. * Used to disable an already-enabled feature
  48135. * The feature will be disposed and will be recreated once enabled.
  48136. * @param featureName the feature to disable
  48137. * @returns true if disable was successful
  48138. */
  48139. disableFeature(featureName: string | {
  48140. Name: string;
  48141. }): boolean;
  48142. /**
  48143. * dispose this features manager
  48144. */
  48145. dispose(): void;
  48146. /**
  48147. * 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.
  48148. * 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.
  48149. *
  48150. * @param featureName the name of the feature to load or the class of the feature
  48151. * @param version optional version to load. if not provided the latest version will be enabled
  48152. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48153. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48154. * @returns a new constructed feature or throws an error if feature not found.
  48155. */
  48156. enableFeature(featureName: string | {
  48157. Name: string;
  48158. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  48159. /**
  48160. * get the implementation of an enabled feature.
  48161. * @param featureName the name of the feature to load
  48162. * @returns the feature class, if found
  48163. */
  48164. getEnabledFeature(featureName: string): IWebXRFeature;
  48165. /**
  48166. * Get the list of enabled features
  48167. * @returns an array of enabled features
  48168. */
  48169. getEnabledFeatures(): string[];
  48170. }
  48171. }
  48172. declare module "babylonjs/XR/webXRExperienceHelper" {
  48173. import { Observable } from "babylonjs/Misc/observable";
  48174. import { IDisposable, Scene } from "babylonjs/scene";
  48175. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48176. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48177. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48178. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48179. /**
  48180. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48181. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  48182. */
  48183. export class WebXRExperienceHelper implements IDisposable {
  48184. private scene;
  48185. private _nonVRCamera;
  48186. private _originalSceneAutoClear;
  48187. private _supported;
  48188. /**
  48189. * Camera used to render xr content
  48190. */
  48191. camera: WebXRCamera;
  48192. /** A features manager for this xr session */
  48193. featuresManager: WebXRFeaturesManager;
  48194. /**
  48195. * Observers registered here will be triggered after the camera's initial transformation is set
  48196. * This can be used to set a different ground level or an extra rotation.
  48197. *
  48198. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48199. * to the position set after this observable is done executing.
  48200. */
  48201. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48202. /**
  48203. * Fires when the state of the experience helper has changed
  48204. */
  48205. onStateChangedObservable: Observable<WebXRState>;
  48206. /** Session manager used to keep track of xr session */
  48207. sessionManager: WebXRSessionManager;
  48208. /**
  48209. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48210. */
  48211. state: WebXRState;
  48212. /**
  48213. * Creates a WebXRExperienceHelper
  48214. * @param scene The scene the helper should be created in
  48215. */
  48216. private constructor();
  48217. /**
  48218. * Creates the experience helper
  48219. * @param scene the scene to attach the experience helper to
  48220. * @returns a promise for the experience helper
  48221. */
  48222. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48223. /**
  48224. * Disposes of the experience helper
  48225. */
  48226. dispose(): void;
  48227. /**
  48228. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48229. * @param sessionMode options for the XR session
  48230. * @param referenceSpaceType frame of reference of the XR session
  48231. * @param renderTarget the output canvas that will be used to enter XR mode
  48232. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48233. * @returns promise that resolves after xr mode has entered
  48234. */
  48235. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48236. /**
  48237. * Exits XR mode and returns the scene to its original state
  48238. * @returns promise that resolves after xr mode has exited
  48239. */
  48240. exitXRAsync(): Promise<void>;
  48241. private _nonXRToXRCamera;
  48242. private _setState;
  48243. }
  48244. }
  48245. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48246. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48247. import { Observable } from "babylonjs/Misc/observable";
  48248. import { IDisposable } from "babylonjs/scene";
  48249. /**
  48250. * X-Y values for axes in WebXR
  48251. */
  48252. export interface IWebXRMotionControllerAxesValue {
  48253. /**
  48254. * The value of the x axis
  48255. */
  48256. x: number;
  48257. /**
  48258. * The value of the y-axis
  48259. */
  48260. y: number;
  48261. }
  48262. /**
  48263. * changed / previous values for the values of this component
  48264. */
  48265. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48266. /**
  48267. * current (this frame) value
  48268. */
  48269. current: T;
  48270. /**
  48271. * previous (last change) value
  48272. */
  48273. previous: T;
  48274. }
  48275. /**
  48276. * Represents changes in the component between current frame and last values recorded
  48277. */
  48278. export interface IWebXRMotionControllerComponentChanges {
  48279. /**
  48280. * will be populated with previous and current values if axes changed
  48281. */
  48282. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48283. /**
  48284. * will be populated with previous and current values if pressed changed
  48285. */
  48286. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48287. /**
  48288. * will be populated with previous and current values if touched changed
  48289. */
  48290. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48291. /**
  48292. * will be populated with previous and current values if value changed
  48293. */
  48294. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48295. }
  48296. /**
  48297. * This class represents a single component (for example button or thumbstick) of a motion controller
  48298. */
  48299. export class WebXRControllerComponent implements IDisposable {
  48300. /**
  48301. * the id of this component
  48302. */
  48303. id: string;
  48304. /**
  48305. * the type of the component
  48306. */
  48307. type: MotionControllerComponentType;
  48308. private _buttonIndex;
  48309. private _axesIndices;
  48310. private _axes;
  48311. private _changes;
  48312. private _currentValue;
  48313. private _hasChanges;
  48314. private _pressed;
  48315. private _touched;
  48316. /**
  48317. * button component type
  48318. */
  48319. static BUTTON_TYPE: MotionControllerComponentType;
  48320. /**
  48321. * squeeze component type
  48322. */
  48323. static SQUEEZE_TYPE: MotionControllerComponentType;
  48324. /**
  48325. * Thumbstick component type
  48326. */
  48327. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48328. /**
  48329. * Touchpad component type
  48330. */
  48331. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48332. /**
  48333. * trigger component type
  48334. */
  48335. static TRIGGER_TYPE: MotionControllerComponentType;
  48336. /**
  48337. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48338. * the axes data changes
  48339. */
  48340. onAxisValueChangedObservable: Observable<{
  48341. x: number;
  48342. y: number;
  48343. }>;
  48344. /**
  48345. * Observers registered here will be triggered when the state of a button changes
  48346. * State change is either pressed / touched / value
  48347. */
  48348. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48349. /**
  48350. * Creates a new component for a motion controller.
  48351. * It is created by the motion controller itself
  48352. *
  48353. * @param id the id of this component
  48354. * @param type the type of the component
  48355. * @param _buttonIndex index in the buttons array of the gamepad
  48356. * @param _axesIndices indices of the values in the axes array of the gamepad
  48357. */
  48358. constructor(
  48359. /**
  48360. * the id of this component
  48361. */
  48362. id: string,
  48363. /**
  48364. * the type of the component
  48365. */
  48366. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  48367. /**
  48368. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  48369. */
  48370. get axes(): IWebXRMotionControllerAxesValue;
  48371. /**
  48372. * Get the changes. Elements will be populated only if they changed with their previous and current value
  48373. */
  48374. get changes(): IWebXRMotionControllerComponentChanges;
  48375. /**
  48376. * Return whether or not the component changed the last frame
  48377. */
  48378. get hasChanges(): boolean;
  48379. /**
  48380. * is the button currently pressed
  48381. */
  48382. get pressed(): boolean;
  48383. /**
  48384. * is the button currently touched
  48385. */
  48386. get touched(): boolean;
  48387. /**
  48388. * Get the current value of this component
  48389. */
  48390. get value(): number;
  48391. /**
  48392. * Dispose this component
  48393. */
  48394. dispose(): void;
  48395. /**
  48396. * Are there axes correlating to this component
  48397. * @return true is axes data is available
  48398. */
  48399. isAxes(): boolean;
  48400. /**
  48401. * Is this component a button (hence - pressable)
  48402. * @returns true if can be pressed
  48403. */
  48404. isButton(): boolean;
  48405. /**
  48406. * update this component using the gamepad object it is in. Called on every frame
  48407. * @param nativeController the native gamepad controller object
  48408. */
  48409. update(nativeController: IMinimalMotionControllerObject): void;
  48410. }
  48411. }
  48412. declare module "babylonjs/Loading/sceneLoader" {
  48413. import { Observable } from "babylonjs/Misc/observable";
  48414. import { Nullable } from "babylonjs/types";
  48415. import { Scene } from "babylonjs/scene";
  48416. import { Engine } from "babylonjs/Engines/engine";
  48417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48418. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  48419. import { AssetContainer } from "babylonjs/assetContainer";
  48420. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  48421. import { Skeleton } from "babylonjs/Bones/skeleton";
  48422. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  48423. import { WebRequest } from "babylonjs/Misc/webRequest";
  48424. /**
  48425. * Interface used to represent data loading progression
  48426. */
  48427. export interface ISceneLoaderProgressEvent {
  48428. /**
  48429. * Defines if data length to load can be evaluated
  48430. */
  48431. readonly lengthComputable: boolean;
  48432. /**
  48433. * Defines the loaded data length
  48434. */
  48435. readonly loaded: number;
  48436. /**
  48437. * Defines the data length to load
  48438. */
  48439. readonly total: number;
  48440. }
  48441. /**
  48442. * Interface used by SceneLoader plugins to define supported file extensions
  48443. */
  48444. export interface ISceneLoaderPluginExtensions {
  48445. /**
  48446. * Defines the list of supported extensions
  48447. */
  48448. [extension: string]: {
  48449. isBinary: boolean;
  48450. };
  48451. }
  48452. /**
  48453. * Interface used by SceneLoader plugin factory
  48454. */
  48455. export interface ISceneLoaderPluginFactory {
  48456. /**
  48457. * Defines the name of the factory
  48458. */
  48459. name: string;
  48460. /**
  48461. * Function called to create a new plugin
  48462. * @return the new plugin
  48463. */
  48464. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48465. /**
  48466. * The callback that returns true if the data can be directly loaded.
  48467. * @param data string containing the file data
  48468. * @returns if the data can be loaded directly
  48469. */
  48470. canDirectLoad?(data: string): boolean;
  48471. }
  48472. /**
  48473. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48474. */
  48475. export interface ISceneLoaderPluginBase {
  48476. /**
  48477. * The friendly name of this plugin.
  48478. */
  48479. name: string;
  48480. /**
  48481. * The file extensions supported by this plugin.
  48482. */
  48483. extensions: string | ISceneLoaderPluginExtensions;
  48484. /**
  48485. * The callback called when loading from a url.
  48486. * @param scene scene loading this url
  48487. * @param url url to load
  48488. * @param onSuccess callback called when the file successfully loads
  48489. * @param onProgress callback called while file is loading (if the server supports this mode)
  48490. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48491. * @param onError callback called when the file fails to load
  48492. * @returns a file request object
  48493. */
  48494. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48495. /**
  48496. * The callback called when loading from a file object.
  48497. * @param scene scene loading this file
  48498. * @param file defines the file to load
  48499. * @param onSuccess defines the callback to call when data is loaded
  48500. * @param onProgress defines the callback to call during loading process
  48501. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48502. * @param onError defines the callback to call when an error occurs
  48503. * @returns a file request object
  48504. */
  48505. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48506. /**
  48507. * The callback that returns true if the data can be directly loaded.
  48508. * @param data string containing the file data
  48509. * @returns if the data can be loaded directly
  48510. */
  48511. canDirectLoad?(data: string): boolean;
  48512. /**
  48513. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48514. * @param scene scene loading this data
  48515. * @param data string containing the data
  48516. * @returns data to pass to the plugin
  48517. */
  48518. directLoad?(scene: Scene, data: string): any;
  48519. /**
  48520. * The callback that allows custom handling of the root url based on the response url.
  48521. * @param rootUrl the original root url
  48522. * @param responseURL the response url if available
  48523. * @returns the new root url
  48524. */
  48525. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48526. }
  48527. /**
  48528. * Interface used to define a SceneLoader plugin
  48529. */
  48530. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48531. /**
  48532. * Import meshes into a scene.
  48533. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48534. * @param scene The scene to import into
  48535. * @param data The data to import
  48536. * @param rootUrl The root url for scene and resources
  48537. * @param meshes The meshes array to import into
  48538. * @param particleSystems The particle systems array to import into
  48539. * @param skeletons The skeletons array to import into
  48540. * @param onError The callback when import fails
  48541. * @returns True if successful or false otherwise
  48542. */
  48543. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48544. /**
  48545. * Load into a scene.
  48546. * @param scene The scene to load into
  48547. * @param data The data to import
  48548. * @param rootUrl The root url for scene and resources
  48549. * @param onError The callback when import fails
  48550. * @returns True if successful or false otherwise
  48551. */
  48552. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48553. /**
  48554. * Load into an asset container.
  48555. * @param scene The scene to load into
  48556. * @param data The data to import
  48557. * @param rootUrl The root url for scene and resources
  48558. * @param onError The callback when import fails
  48559. * @returns The loaded asset container
  48560. */
  48561. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48562. }
  48563. /**
  48564. * Interface used to define an async SceneLoader plugin
  48565. */
  48566. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48567. /**
  48568. * Import meshes into a scene.
  48569. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48570. * @param scene The scene to import into
  48571. * @param data The data to import
  48572. * @param rootUrl The root url for scene and resources
  48573. * @param onProgress The callback when the load progresses
  48574. * @param fileName Defines the name of the file to load
  48575. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48576. */
  48577. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48578. meshes: AbstractMesh[];
  48579. particleSystems: IParticleSystem[];
  48580. skeletons: Skeleton[];
  48581. animationGroups: AnimationGroup[];
  48582. }>;
  48583. /**
  48584. * Load into a scene.
  48585. * @param scene The scene to load into
  48586. * @param data The data to import
  48587. * @param rootUrl The root url for scene and resources
  48588. * @param onProgress The callback when the load progresses
  48589. * @param fileName Defines the name of the file to load
  48590. * @returns Nothing
  48591. */
  48592. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48593. /**
  48594. * Load into an asset container.
  48595. * @param scene The scene to load into
  48596. * @param data The data to import
  48597. * @param rootUrl The root url for scene and resources
  48598. * @param onProgress The callback when the load progresses
  48599. * @param fileName Defines the name of the file to load
  48600. * @returns The loaded asset container
  48601. */
  48602. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48603. }
  48604. /**
  48605. * Mode that determines how to handle old animation groups before loading new ones.
  48606. */
  48607. export enum SceneLoaderAnimationGroupLoadingMode {
  48608. /**
  48609. * Reset all old animations to initial state then dispose them.
  48610. */
  48611. Clean = 0,
  48612. /**
  48613. * Stop all old animations.
  48614. */
  48615. Stop = 1,
  48616. /**
  48617. * Restart old animations from first frame.
  48618. */
  48619. Sync = 2,
  48620. /**
  48621. * Old animations remains untouched.
  48622. */
  48623. NoSync = 3
  48624. }
  48625. /**
  48626. * Class used to load scene from various file formats using registered plugins
  48627. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  48628. */
  48629. export class SceneLoader {
  48630. /**
  48631. * No logging while loading
  48632. */
  48633. static readonly NO_LOGGING: number;
  48634. /**
  48635. * Minimal logging while loading
  48636. */
  48637. static readonly MINIMAL_LOGGING: number;
  48638. /**
  48639. * Summary logging while loading
  48640. */
  48641. static readonly SUMMARY_LOGGING: number;
  48642. /**
  48643. * Detailled logging while loading
  48644. */
  48645. static readonly DETAILED_LOGGING: number;
  48646. /**
  48647. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48648. */
  48649. static get ForceFullSceneLoadingForIncremental(): boolean;
  48650. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48651. /**
  48652. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48653. */
  48654. static get ShowLoadingScreen(): boolean;
  48655. static set ShowLoadingScreen(value: boolean);
  48656. /**
  48657. * Defines the current logging level (while loading the scene)
  48658. * @ignorenaming
  48659. */
  48660. static get loggingLevel(): number;
  48661. static set loggingLevel(value: number);
  48662. /**
  48663. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48664. */
  48665. static get CleanBoneMatrixWeights(): boolean;
  48666. static set CleanBoneMatrixWeights(value: boolean);
  48667. /**
  48668. * Event raised when a plugin is used to load a scene
  48669. */
  48670. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48671. private static _registeredPlugins;
  48672. private static _getDefaultPlugin;
  48673. private static _getPluginForExtension;
  48674. private static _getPluginForDirectLoad;
  48675. private static _getPluginForFilename;
  48676. private static _getDirectLoad;
  48677. private static _loadData;
  48678. private static _getFileInfo;
  48679. /**
  48680. * Gets a plugin that can load the given extension
  48681. * @param extension defines the extension to load
  48682. * @returns a plugin or null if none works
  48683. */
  48684. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48685. /**
  48686. * Gets a boolean indicating that the given extension can be loaded
  48687. * @param extension defines the extension to load
  48688. * @returns true if the extension is supported
  48689. */
  48690. static IsPluginForExtensionAvailable(extension: string): boolean;
  48691. /**
  48692. * Adds a new plugin to the list of registered plugins
  48693. * @param plugin defines the plugin to add
  48694. */
  48695. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48696. /**
  48697. * Import meshes into a scene
  48698. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48699. * @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)
  48700. * @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)
  48701. * @param scene the instance of BABYLON.Scene to append to
  48702. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48703. * @param onProgress a callback with a progress event for each file being loaded
  48704. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48705. * @param pluginExtension the extension used to determine the plugin
  48706. * @returns The loaded plugin
  48707. */
  48708. 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>;
  48709. /**
  48710. * Import meshes into a scene
  48711. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48712. * @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)
  48713. * @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)
  48714. * @param scene the instance of BABYLON.Scene to append to
  48715. * @param onProgress a callback with a progress event for each file being loaded
  48716. * @param pluginExtension the extension used to determine the plugin
  48717. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48718. */
  48719. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48720. meshes: AbstractMesh[];
  48721. particleSystems: IParticleSystem[];
  48722. skeletons: Skeleton[];
  48723. animationGroups: AnimationGroup[];
  48724. }>;
  48725. /**
  48726. * Load a scene
  48727. * @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)
  48728. * @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)
  48729. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48730. * @param onSuccess a callback with the scene when import succeeds
  48731. * @param onProgress a callback with a progress event for each file being loaded
  48732. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48733. * @param pluginExtension the extension used to determine the plugin
  48734. * @returns The loaded plugin
  48735. */
  48736. 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>;
  48737. /**
  48738. * Load a scene
  48739. * @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)
  48740. * @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)
  48741. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48742. * @param onProgress a callback with a progress event for each file being loaded
  48743. * @param pluginExtension the extension used to determine the plugin
  48744. * @returns The loaded scene
  48745. */
  48746. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48747. /**
  48748. * Append a scene
  48749. * @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)
  48750. * @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)
  48751. * @param scene is the instance of BABYLON.Scene to append to
  48752. * @param onSuccess a callback with the scene when import succeeds
  48753. * @param onProgress a callback with a progress event for each file being loaded
  48754. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48755. * @param pluginExtension the extension used to determine the plugin
  48756. * @returns The loaded plugin
  48757. */
  48758. 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>;
  48759. /**
  48760. * Append a scene
  48761. * @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)
  48762. * @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)
  48763. * @param scene is the instance of BABYLON.Scene to append to
  48764. * @param onProgress a callback with a progress event for each file being loaded
  48765. * @param pluginExtension the extension used to determine the plugin
  48766. * @returns The given scene
  48767. */
  48768. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48769. /**
  48770. * Load a scene into an asset container
  48771. * @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)
  48772. * @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)
  48773. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48774. * @param onSuccess a callback with the scene when import succeeds
  48775. * @param onProgress a callback with a progress event for each file being loaded
  48776. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48777. * @param pluginExtension the extension used to determine the plugin
  48778. * @returns The loaded plugin
  48779. */
  48780. 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>;
  48781. /**
  48782. * Load a scene into an asset container
  48783. * @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)
  48784. * @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)
  48785. * @param scene is the instance of Scene to append to
  48786. * @param onProgress a callback with a progress event for each file being loaded
  48787. * @param pluginExtension the extension used to determine the plugin
  48788. * @returns The loaded asset container
  48789. */
  48790. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48791. /**
  48792. * Import animations from a file into a scene
  48793. * @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)
  48794. * @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)
  48795. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48796. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48797. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48798. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48799. * @param onSuccess a callback with the scene when import succeeds
  48800. * @param onProgress a callback with a progress event for each file being loaded
  48801. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48802. * @param pluginExtension the extension used to determine the plugin
  48803. */
  48804. 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;
  48805. /**
  48806. * Import animations from a file into a scene
  48807. * @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)
  48808. * @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)
  48809. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48810. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48811. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48812. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48813. * @param onSuccess a callback with the scene when import succeeds
  48814. * @param onProgress a callback with a progress event for each file being loaded
  48815. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48816. * @param pluginExtension the extension used to determine the plugin
  48817. * @returns the updated scene with imported animations
  48818. */
  48819. 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>;
  48820. }
  48821. }
  48822. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48823. import { IDisposable, Scene } from "babylonjs/scene";
  48824. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48825. import { Observable } from "babylonjs/Misc/observable";
  48826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48827. import { Nullable } from "babylonjs/types";
  48828. /**
  48829. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48830. */
  48831. export type MotionControllerHandedness = "none" | "left" | "right";
  48832. /**
  48833. * The type of components available in motion controllers.
  48834. * This is not the name of the component.
  48835. */
  48836. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48837. /**
  48838. * The state of a controller component
  48839. */
  48840. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48841. /**
  48842. * The schema of motion controller layout.
  48843. * No object will be initialized using this interface
  48844. * This is used just to define the profile.
  48845. */
  48846. export interface IMotionControllerLayout {
  48847. /**
  48848. * Path to load the assets. Usually relative to the base path
  48849. */
  48850. assetPath: string;
  48851. /**
  48852. * Available components (unsorted)
  48853. */
  48854. components: {
  48855. /**
  48856. * A map of component Ids
  48857. */
  48858. [componentId: string]: {
  48859. /**
  48860. * The type of input the component outputs
  48861. */
  48862. type: MotionControllerComponentType;
  48863. /**
  48864. * The indices of this component in the gamepad object
  48865. */
  48866. gamepadIndices: {
  48867. /**
  48868. * Index of button
  48869. */
  48870. button?: number;
  48871. /**
  48872. * If available, index of x-axis
  48873. */
  48874. xAxis?: number;
  48875. /**
  48876. * If available, index of y-axis
  48877. */
  48878. yAxis?: number;
  48879. };
  48880. /**
  48881. * The mesh's root node name
  48882. */
  48883. rootNodeName: string;
  48884. /**
  48885. * Animation definitions for this model
  48886. */
  48887. visualResponses: {
  48888. [stateKey: string]: {
  48889. /**
  48890. * What property will be animated
  48891. */
  48892. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48893. /**
  48894. * What states influence this visual response
  48895. */
  48896. states: MotionControllerComponentStateType[];
  48897. /**
  48898. * Type of animation - movement or visibility
  48899. */
  48900. valueNodeProperty: "transform" | "visibility";
  48901. /**
  48902. * Base node name to move. Its position will be calculated according to the min and max nodes
  48903. */
  48904. valueNodeName?: string;
  48905. /**
  48906. * Minimum movement node
  48907. */
  48908. minNodeName?: string;
  48909. /**
  48910. * Max movement node
  48911. */
  48912. maxNodeName?: string;
  48913. };
  48914. };
  48915. /**
  48916. * If touch enabled, what is the name of node to display user feedback
  48917. */
  48918. touchPointNodeName?: string;
  48919. };
  48920. };
  48921. /**
  48922. * Is it xr standard mapping or not
  48923. */
  48924. gamepadMapping: "" | "xr-standard";
  48925. /**
  48926. * Base root node of this entire model
  48927. */
  48928. rootNodeName: string;
  48929. /**
  48930. * Defines the main button component id
  48931. */
  48932. selectComponentId: string;
  48933. }
  48934. /**
  48935. * A definition for the layout map in the input profile
  48936. */
  48937. export interface IMotionControllerLayoutMap {
  48938. /**
  48939. * Layouts with handedness type as a key
  48940. */
  48941. [handedness: string]: IMotionControllerLayout;
  48942. }
  48943. /**
  48944. * The XR Input profile schema
  48945. * Profiles can be found here:
  48946. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48947. */
  48948. export interface IMotionControllerProfile {
  48949. /**
  48950. * fallback profiles for this profileId
  48951. */
  48952. fallbackProfileIds: string[];
  48953. /**
  48954. * The layout map, with handedness as key
  48955. */
  48956. layouts: IMotionControllerLayoutMap;
  48957. /**
  48958. * The id of this profile
  48959. * correlates to the profile(s) in the xrInput.profiles array
  48960. */
  48961. profileId: string;
  48962. }
  48963. /**
  48964. * A helper-interface for the 3 meshes needed for controller button animation
  48965. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48966. */
  48967. export interface IMotionControllerButtonMeshMap {
  48968. /**
  48969. * the mesh that defines the pressed value mesh position.
  48970. * This is used to find the max-position of this button
  48971. */
  48972. pressedMesh: AbstractMesh;
  48973. /**
  48974. * the mesh that defines the unpressed value mesh position.
  48975. * This is used to find the min (or initial) position of this button
  48976. */
  48977. unpressedMesh: AbstractMesh;
  48978. /**
  48979. * The mesh that will be changed when value changes
  48980. */
  48981. valueMesh: AbstractMesh;
  48982. }
  48983. /**
  48984. * A helper-interface for the 3 meshes needed for controller axis animation.
  48985. * This will be expanded when touchpad animations are fully supported
  48986. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48987. */
  48988. export interface IMotionControllerMeshMap {
  48989. /**
  48990. * the mesh that defines the maximum value mesh position.
  48991. */
  48992. maxMesh?: AbstractMesh;
  48993. /**
  48994. * the mesh that defines the minimum value mesh position.
  48995. */
  48996. minMesh?: AbstractMesh;
  48997. /**
  48998. * The mesh that will be changed when axis value changes
  48999. */
  49000. valueMesh: AbstractMesh;
  49001. }
  49002. /**
  49003. * The elements needed for change-detection of the gamepad objects in motion controllers
  49004. */
  49005. export interface IMinimalMotionControllerObject {
  49006. /**
  49007. * Available axes of this controller
  49008. */
  49009. axes: number[];
  49010. /**
  49011. * An array of available buttons
  49012. */
  49013. buttons: Array<{
  49014. /**
  49015. * Value of the button/trigger
  49016. */
  49017. value: number;
  49018. /**
  49019. * If the button/trigger is currently touched
  49020. */
  49021. touched: boolean;
  49022. /**
  49023. * If the button/trigger is currently pressed
  49024. */
  49025. pressed: boolean;
  49026. }>;
  49027. /**
  49028. * EXPERIMENTAL haptic support.
  49029. */
  49030. hapticActuators?: Array<{
  49031. pulse: (value: number, duration: number) => Promise<boolean>;
  49032. }>;
  49033. }
  49034. /**
  49035. * An Abstract Motion controller
  49036. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49037. * Each component has an observable to check for changes in value and state
  49038. */
  49039. export abstract class WebXRAbstractMotionController implements IDisposable {
  49040. protected scene: Scene;
  49041. protected layout: IMotionControllerLayout;
  49042. /**
  49043. * The gamepad object correlating to this controller
  49044. */
  49045. gamepadObject: IMinimalMotionControllerObject;
  49046. /**
  49047. * handedness (left/right/none) of this controller
  49048. */
  49049. handedness: MotionControllerHandedness;
  49050. private _initComponent;
  49051. private _modelReady;
  49052. /**
  49053. * A map of components (WebXRControllerComponent) in this motion controller
  49054. * Components have a ComponentType and can also have both button and axis definitions
  49055. */
  49056. readonly components: {
  49057. [id: string]: WebXRControllerComponent;
  49058. };
  49059. /**
  49060. * Disable the model's animation. Can be set at any time.
  49061. */
  49062. disableAnimation: boolean;
  49063. /**
  49064. * Observers registered here will be triggered when the model of this controller is done loading
  49065. */
  49066. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49067. /**
  49068. * The profile id of this motion controller
  49069. */
  49070. abstract profileId: string;
  49071. /**
  49072. * The root mesh of the model. It is null if the model was not yet initialized
  49073. */
  49074. rootMesh: Nullable<AbstractMesh>;
  49075. /**
  49076. * constructs a new abstract motion controller
  49077. * @param scene the scene to which the model of the controller will be added
  49078. * @param layout The profile layout to load
  49079. * @param gamepadObject The gamepad object correlating to this controller
  49080. * @param handedness handedness (left/right/none) of this controller
  49081. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49082. */
  49083. constructor(scene: Scene, layout: IMotionControllerLayout,
  49084. /**
  49085. * The gamepad object correlating to this controller
  49086. */
  49087. gamepadObject: IMinimalMotionControllerObject,
  49088. /**
  49089. * handedness (left/right/none) of this controller
  49090. */
  49091. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49092. /**
  49093. * Dispose this controller, the model mesh and all its components
  49094. */
  49095. dispose(): void;
  49096. /**
  49097. * Returns all components of specific type
  49098. * @param type the type to search for
  49099. * @return an array of components with this type
  49100. */
  49101. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49102. /**
  49103. * get a component based an its component id as defined in layout.components
  49104. * @param id the id of the component
  49105. * @returns the component correlates to the id or undefined if not found
  49106. */
  49107. getComponent(id: string): WebXRControllerComponent;
  49108. /**
  49109. * Get the list of components available in this motion controller
  49110. * @returns an array of strings correlating to available components
  49111. */
  49112. getComponentIds(): string[];
  49113. /**
  49114. * Get the first component of specific type
  49115. * @param type type of component to find
  49116. * @return a controller component or null if not found
  49117. */
  49118. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49119. /**
  49120. * Get the main (Select) component of this controller as defined in the layout
  49121. * @returns the main component of this controller
  49122. */
  49123. getMainComponent(): WebXRControllerComponent;
  49124. /**
  49125. * Loads the model correlating to this controller
  49126. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49127. * @returns A promise fulfilled with the result of the model loading
  49128. */
  49129. loadModel(): Promise<boolean>;
  49130. /**
  49131. * Update this model using the current XRFrame
  49132. * @param xrFrame the current xr frame to use and update the model
  49133. */
  49134. updateFromXRFrame(xrFrame: XRFrame): void;
  49135. /**
  49136. * Backwards compatibility due to a deeply-integrated typo
  49137. */
  49138. get handness(): XREye;
  49139. /**
  49140. * Pulse (vibrate) this controller
  49141. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49142. * Consecutive calls to this function will cancel the last pulse call
  49143. *
  49144. * @param value the strength of the pulse in 0.0...1.0 range
  49145. * @param duration Duration of the pulse in milliseconds
  49146. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49147. * @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
  49148. */
  49149. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49150. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49151. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49152. /**
  49153. * Moves the axis on the controller mesh based on its current state
  49154. * @param axis the index of the axis
  49155. * @param axisValue the value of the axis which determines the meshes new position
  49156. * @hidden
  49157. */
  49158. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49159. /**
  49160. * Update the model itself with the current frame data
  49161. * @param xrFrame the frame to use for updating the model mesh
  49162. */
  49163. protected updateModel(xrFrame: XRFrame): void;
  49164. /**
  49165. * Get the filename and path for this controller's model
  49166. * @returns a map of filename and path
  49167. */
  49168. protected abstract _getFilenameAndPath(): {
  49169. filename: string;
  49170. path: string;
  49171. };
  49172. /**
  49173. * This function is called before the mesh is loaded. It checks for loading constraints.
  49174. * For example, this function can check if the GLB loader is available
  49175. * If this function returns false, the generic controller will be loaded instead
  49176. * @returns Is the client ready to load the mesh
  49177. */
  49178. protected abstract _getModelLoadingConstraints(): boolean;
  49179. /**
  49180. * This function will be called after the model was successfully loaded and can be used
  49181. * for mesh transformations before it is available for the user
  49182. * @param meshes the loaded meshes
  49183. */
  49184. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49185. /**
  49186. * Set the root mesh for this controller. Important for the WebXR controller class
  49187. * @param meshes the loaded meshes
  49188. */
  49189. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49190. /**
  49191. * A function executed each frame that updates the mesh (if needed)
  49192. * @param xrFrame the current xrFrame
  49193. */
  49194. protected abstract _updateModel(xrFrame: XRFrame): void;
  49195. private _getGenericFilenameAndPath;
  49196. private _getGenericParentMesh;
  49197. }
  49198. }
  49199. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49200. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49202. import { Scene } from "babylonjs/scene";
  49203. /**
  49204. * A generic trigger-only motion controller for WebXR
  49205. */
  49206. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49207. /**
  49208. * Static version of the profile id of this controller
  49209. */
  49210. static ProfileId: string;
  49211. profileId: string;
  49212. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49213. protected _getFilenameAndPath(): {
  49214. filename: string;
  49215. path: string;
  49216. };
  49217. protected _getModelLoadingConstraints(): boolean;
  49218. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49219. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49220. protected _updateModel(): void;
  49221. }
  49222. }
  49223. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49224. import { Vector4 } from "babylonjs/Maths/math.vector";
  49225. import { Mesh } from "babylonjs/Meshes/mesh";
  49226. import { Scene } from "babylonjs/scene";
  49227. import { Nullable } from "babylonjs/types";
  49228. /**
  49229. * Class containing static functions to help procedurally build meshes
  49230. */
  49231. export class SphereBuilder {
  49232. /**
  49233. * Creates a sphere mesh
  49234. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49235. * * 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`)
  49236. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49237. * * 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
  49238. * * 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)
  49239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49242. * @param name defines the name of the mesh
  49243. * @param options defines the options used to create the mesh
  49244. * @param scene defines the hosting scene
  49245. * @returns the sphere mesh
  49246. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49247. */
  49248. static CreateSphere(name: string, options: {
  49249. segments?: number;
  49250. diameter?: number;
  49251. diameterX?: number;
  49252. diameterY?: number;
  49253. diameterZ?: number;
  49254. arc?: number;
  49255. slice?: number;
  49256. sideOrientation?: number;
  49257. frontUVs?: Vector4;
  49258. backUVs?: Vector4;
  49259. updatable?: boolean;
  49260. }, scene?: Nullable<Scene>): Mesh;
  49261. }
  49262. }
  49263. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49265. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49266. import { Scene } from "babylonjs/scene";
  49267. /**
  49268. * A profiled motion controller has its profile loaded from an online repository.
  49269. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49270. */
  49271. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49272. private _repositoryUrl;
  49273. private _buttonMeshMapping;
  49274. private _touchDots;
  49275. /**
  49276. * The profile ID of this controller. Will be populated when the controller initializes.
  49277. */
  49278. profileId: string;
  49279. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49280. dispose(): void;
  49281. protected _getFilenameAndPath(): {
  49282. filename: string;
  49283. path: string;
  49284. };
  49285. protected _getModelLoadingConstraints(): boolean;
  49286. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49287. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49288. protected _updateModel(_xrFrame: XRFrame): void;
  49289. }
  49290. }
  49291. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49292. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49293. import { Scene } from "babylonjs/scene";
  49294. /**
  49295. * A construction function type to create a new controller based on an xrInput object
  49296. */
  49297. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49298. /**
  49299. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49300. *
  49301. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49302. * it should be replaced with auto-loaded controllers.
  49303. *
  49304. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49305. */
  49306. export class WebXRMotionControllerManager {
  49307. private static _AvailableControllers;
  49308. private static _Fallbacks;
  49309. private static _ProfileLoadingPromises;
  49310. private static _ProfilesList;
  49311. /**
  49312. * The base URL of the online controller repository. Can be changed at any time.
  49313. */
  49314. static BaseRepositoryUrl: string;
  49315. /**
  49316. * Which repository gets priority - local or online
  49317. */
  49318. static PrioritizeOnlineRepository: boolean;
  49319. /**
  49320. * Use the online repository, or use only locally-defined controllers
  49321. */
  49322. static UseOnlineRepository: boolean;
  49323. /**
  49324. * Clear the cache used for profile loading and reload when requested again
  49325. */
  49326. static ClearProfilesCache(): void;
  49327. /**
  49328. * Register the default fallbacks.
  49329. * This function is called automatically when this file is imported.
  49330. */
  49331. static DefaultFallbacks(): void;
  49332. /**
  49333. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  49334. * @param profileId the profile to which a fallback needs to be found
  49335. * @return an array with corresponding fallback profiles
  49336. */
  49337. static FindFallbackWithProfileId(profileId: string): string[];
  49338. /**
  49339. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  49340. * The order of search:
  49341. *
  49342. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  49343. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  49344. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  49345. * 4) return the generic trigger controller if none were found
  49346. *
  49347. * @param xrInput the xrInput to which a new controller is initialized
  49348. * @param scene the scene to which the model will be added
  49349. * @param forceProfile force a certain profile for this controller
  49350. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  49351. */
  49352. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  49353. /**
  49354. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  49355. *
  49356. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  49357. *
  49358. * @param type the profile type to register
  49359. * @param constructFunction the function to be called when loading this profile
  49360. */
  49361. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  49362. /**
  49363. * Register a fallback to a specific profile.
  49364. * @param profileId the profileId that will receive the fallbacks
  49365. * @param fallbacks A list of fallback profiles
  49366. */
  49367. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  49368. /**
  49369. * Will update the list of profiles available in the repository
  49370. * @return a promise that resolves to a map of profiles available online
  49371. */
  49372. static UpdateProfilesList(): Promise<{
  49373. [profile: string]: string;
  49374. }>;
  49375. private static _LoadProfileFromRepository;
  49376. private static _LoadProfilesFromAvailableControllers;
  49377. }
  49378. }
  49379. declare module "babylonjs/XR/webXRInputSource" {
  49380. import { Observable } from "babylonjs/Misc/observable";
  49381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49382. import { Ray } from "babylonjs/Culling/ray";
  49383. import { Scene } from "babylonjs/scene";
  49384. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49385. /**
  49386. * Configuration options for the WebXR controller creation
  49387. */
  49388. export interface IWebXRControllerOptions {
  49389. /**
  49390. * Should the controller mesh be animated when a user interacts with it
  49391. * The pressed buttons / thumbstick and touchpad animations will be disabled
  49392. */
  49393. disableMotionControllerAnimation?: boolean;
  49394. /**
  49395. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  49396. */
  49397. doNotLoadControllerMesh?: boolean;
  49398. /**
  49399. * Force a specific controller type for this controller.
  49400. * This can be used when creating your own profile or when testing different controllers
  49401. */
  49402. forceControllerProfile?: string;
  49403. /**
  49404. * Defines a rendering group ID for meshes that will be loaded.
  49405. * This is for the default controllers only.
  49406. */
  49407. renderingGroupId?: number;
  49408. }
  49409. /**
  49410. * Represents an XR controller
  49411. */
  49412. export class WebXRInputSource {
  49413. private _scene;
  49414. /** The underlying input source for the controller */
  49415. inputSource: XRInputSource;
  49416. private _options;
  49417. private _tmpVector;
  49418. private _uniqueId;
  49419. /**
  49420. * 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
  49421. */
  49422. grip?: AbstractMesh;
  49423. /**
  49424. * If available, this is the gamepad object related to this controller.
  49425. * Using this object it is possible to get click events and trackpad changes of the
  49426. * webxr controller that is currently being used.
  49427. */
  49428. motionController?: WebXRAbstractMotionController;
  49429. /**
  49430. * Event that fires when the controller is removed/disposed.
  49431. * The object provided as event data is this controller, after associated assets were disposed.
  49432. * uniqueId is still available.
  49433. */
  49434. onDisposeObservable: Observable<WebXRInputSource>;
  49435. /**
  49436. * Will be triggered when the mesh associated with the motion controller is done loading.
  49437. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49438. * A shortened version of controller -> motion controller -> on mesh loaded.
  49439. */
  49440. onMeshLoadedObservable: Observable<AbstractMesh>;
  49441. /**
  49442. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49443. */
  49444. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49445. /**
  49446. * Pointer which can be used to select objects or attach a visible laser to
  49447. */
  49448. pointer: AbstractMesh;
  49449. /**
  49450. * Creates the input source object
  49451. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  49452. * @param _scene the scene which the controller should be associated to
  49453. * @param inputSource the underlying input source for the controller
  49454. * @param _options options for this controller creation
  49455. */
  49456. constructor(_scene: Scene,
  49457. /** The underlying input source for the controller */
  49458. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49459. /**
  49460. * Get this controllers unique id
  49461. */
  49462. get uniqueId(): string;
  49463. /**
  49464. * Disposes of the object
  49465. */
  49466. dispose(): void;
  49467. /**
  49468. * Gets a world space ray coming from the pointer or grip
  49469. * @param result the resulting ray
  49470. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49471. */
  49472. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49473. /**
  49474. * Updates the controller pose based on the given XRFrame
  49475. * @param xrFrame xr frame to update the pose with
  49476. * @param referenceSpace reference space to use
  49477. */
  49478. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49479. }
  49480. }
  49481. declare module "babylonjs/XR/webXRInput" {
  49482. import { Observable } from "babylonjs/Misc/observable";
  49483. import { IDisposable } from "babylonjs/scene";
  49484. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49485. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49486. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49487. /**
  49488. * The schema for initialization options of the XR Input class
  49489. */
  49490. export interface IWebXRInputOptions {
  49491. /**
  49492. * If set to true no model will be automatically loaded
  49493. */
  49494. doNotLoadControllerMeshes?: boolean;
  49495. /**
  49496. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49497. * If not found, the xr input profile data will be used.
  49498. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49499. */
  49500. forceInputProfile?: string;
  49501. /**
  49502. * Do not send a request to the controller repository to load the profile.
  49503. *
  49504. * Instead, use the controllers available in babylon itself.
  49505. */
  49506. disableOnlineControllerRepository?: boolean;
  49507. /**
  49508. * A custom URL for the controllers repository
  49509. */
  49510. customControllersRepositoryURL?: string;
  49511. /**
  49512. * Should the controller model's components not move according to the user input
  49513. */
  49514. disableControllerAnimation?: boolean;
  49515. /**
  49516. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49517. */
  49518. controllerOptions?: IWebXRControllerOptions;
  49519. }
  49520. /**
  49521. * XR input used to track XR inputs such as controllers/rays
  49522. */
  49523. export class WebXRInput implements IDisposable {
  49524. /**
  49525. * the xr session manager for this session
  49526. */
  49527. xrSessionManager: WebXRSessionManager;
  49528. /**
  49529. * the WebXR camera for this session. Mainly used for teleportation
  49530. */
  49531. xrCamera: WebXRCamera;
  49532. private readonly options;
  49533. /**
  49534. * XR controllers being tracked
  49535. */
  49536. controllers: Array<WebXRInputSource>;
  49537. private _frameObserver;
  49538. private _sessionEndedObserver;
  49539. private _sessionInitObserver;
  49540. /**
  49541. * Event when a controller has been connected/added
  49542. */
  49543. onControllerAddedObservable: Observable<WebXRInputSource>;
  49544. /**
  49545. * Event when a controller has been removed/disconnected
  49546. */
  49547. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49548. /**
  49549. * Initializes the WebXRInput
  49550. * @param xrSessionManager the xr session manager for this session
  49551. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49552. * @param options = initialization options for this xr input
  49553. */
  49554. constructor(
  49555. /**
  49556. * the xr session manager for this session
  49557. */
  49558. xrSessionManager: WebXRSessionManager,
  49559. /**
  49560. * the WebXR camera for this session. Mainly used for teleportation
  49561. */
  49562. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49563. private _onInputSourcesChange;
  49564. private _addAndRemoveControllers;
  49565. /**
  49566. * Disposes of the object
  49567. */
  49568. dispose(): void;
  49569. }
  49570. }
  49571. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49572. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49573. import { Observable, EventState } from "babylonjs/Misc/observable";
  49574. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49575. /**
  49576. * This is the base class for all WebXR features.
  49577. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49578. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49579. */
  49580. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49581. protected _xrSessionManager: WebXRSessionManager;
  49582. private _attached;
  49583. private _removeOnDetach;
  49584. /**
  49585. * Should auto-attach be disabled?
  49586. */
  49587. disableAutoAttach: boolean;
  49588. /**
  49589. * Construct a new (abstract) WebXR feature
  49590. * @param _xrSessionManager the xr session manager for this feature
  49591. */
  49592. constructor(_xrSessionManager: WebXRSessionManager);
  49593. /**
  49594. * Is this feature attached
  49595. */
  49596. get attached(): boolean;
  49597. /**
  49598. * attach this feature
  49599. *
  49600. * @param force should attachment be forced (even when already attached)
  49601. * @returns true if successful, false is failed or already attached
  49602. */
  49603. attach(force?: boolean): boolean;
  49604. /**
  49605. * detach this feature.
  49606. *
  49607. * @returns true if successful, false if failed or already detached
  49608. */
  49609. detach(): boolean;
  49610. /**
  49611. * Dispose this feature and all of the resources attached
  49612. */
  49613. dispose(): void;
  49614. /**
  49615. * This is used to register callbacks that will automatically be removed when detach is called.
  49616. * @param observable the observable to which the observer will be attached
  49617. * @param callback the callback to register
  49618. */
  49619. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49620. /**
  49621. * Code in this function will be executed on each xrFrame received from the browser.
  49622. * This function will not execute after the feature is detached.
  49623. * @param _xrFrame the current frame
  49624. */
  49625. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49626. }
  49627. }
  49628. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49629. import { IDisposable, Scene } from "babylonjs/scene";
  49630. import { Nullable } from "babylonjs/types";
  49631. import { Observable } from "babylonjs/Misc/observable";
  49632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49633. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49634. import { Camera } from "babylonjs/Cameras/camera";
  49635. /**
  49636. * Renders a layer on top of an existing scene
  49637. */
  49638. export class UtilityLayerRenderer implements IDisposable {
  49639. /** the original scene that will be rendered on top of */
  49640. originalScene: Scene;
  49641. private _pointerCaptures;
  49642. private _lastPointerEvents;
  49643. private static _DefaultUtilityLayer;
  49644. private static _DefaultKeepDepthUtilityLayer;
  49645. private _sharedGizmoLight;
  49646. private _renderCamera;
  49647. /**
  49648. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49649. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49650. * @returns the camera that is used when rendering the utility layer
  49651. */
  49652. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49653. /**
  49654. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49655. * @param cam the camera that should be used when rendering the utility layer
  49656. */
  49657. setRenderCamera(cam: Nullable<Camera>): void;
  49658. /**
  49659. * @hidden
  49660. * Light which used by gizmos to get light shading
  49661. */
  49662. _getSharedGizmoLight(): HemisphericLight;
  49663. /**
  49664. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49665. */
  49666. pickUtilitySceneFirst: boolean;
  49667. /**
  49668. * 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)
  49669. */
  49670. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49671. /**
  49672. * 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)
  49673. */
  49674. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49675. /**
  49676. * The scene that is rendered on top of the original scene
  49677. */
  49678. utilityLayerScene: Scene;
  49679. /**
  49680. * If the utility layer should automatically be rendered on top of existing scene
  49681. */
  49682. shouldRender: boolean;
  49683. /**
  49684. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49685. */
  49686. onlyCheckPointerDownEvents: boolean;
  49687. /**
  49688. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49689. */
  49690. processAllEvents: boolean;
  49691. /**
  49692. * Observable raised when the pointer move from the utility layer scene to the main scene
  49693. */
  49694. onPointerOutObservable: Observable<number>;
  49695. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49696. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49697. private _afterRenderObserver;
  49698. private _sceneDisposeObserver;
  49699. private _originalPointerObserver;
  49700. /**
  49701. * Instantiates a UtilityLayerRenderer
  49702. * @param originalScene the original scene that will be rendered on top of
  49703. * @param handleEvents boolean indicating if the utility layer should handle events
  49704. */
  49705. constructor(
  49706. /** the original scene that will be rendered on top of */
  49707. originalScene: Scene, handleEvents?: boolean);
  49708. private _notifyObservers;
  49709. /**
  49710. * Renders the utility layers scene on top of the original scene
  49711. */
  49712. render(): void;
  49713. /**
  49714. * Disposes of the renderer
  49715. */
  49716. dispose(): void;
  49717. private _updateCamera;
  49718. }
  49719. }
  49720. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49721. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49723. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49724. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49725. import { Scene } from "babylonjs/scene";
  49726. import { Nullable } from "babylonjs/types";
  49727. import { Color3 } from "babylonjs/Maths/math.color";
  49728. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49729. /**
  49730. * Options interface for the pointer selection module
  49731. */
  49732. export interface IWebXRControllerPointerSelectionOptions {
  49733. /**
  49734. * if provided, this scene will be used to render meshes.
  49735. */
  49736. customUtilityLayerScene?: Scene;
  49737. /**
  49738. * 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)
  49739. * If not disabled, the last picked point will be used to execute a pointer up event
  49740. * If disabled, pointer up event will be triggered right after the pointer down event.
  49741. * Used in screen and gaze target ray mode only
  49742. */
  49743. disablePointerUpOnTouchOut: boolean;
  49744. /**
  49745. * For gaze mode (time to select instead of press)
  49746. */
  49747. forceGazeMode: boolean;
  49748. /**
  49749. * 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
  49750. * to start a new countdown to the pointer down event.
  49751. * Defaults to 1.
  49752. */
  49753. gazeModePointerMovedFactor?: number;
  49754. /**
  49755. * Different button type to use instead of the main component
  49756. */
  49757. overrideButtonId?: string;
  49758. /**
  49759. * use this rendering group id for the meshes (optional)
  49760. */
  49761. renderingGroupId?: number;
  49762. /**
  49763. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49764. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49765. * 3000 means 3 seconds between pointing at something and selecting it
  49766. */
  49767. timeToSelect?: number;
  49768. /**
  49769. * Should meshes created here be added to a utility layer or the main scene
  49770. */
  49771. useUtilityLayer?: boolean;
  49772. /**
  49773. * the xr input to use with this pointer selection
  49774. */
  49775. xrInput: WebXRInput;
  49776. }
  49777. /**
  49778. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49779. */
  49780. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49781. private readonly _options;
  49782. private static _idCounter;
  49783. private _attachController;
  49784. private _controllers;
  49785. private _scene;
  49786. private _tmpVectorForPickCompare;
  49787. /**
  49788. * The module's name
  49789. */
  49790. static readonly Name: string;
  49791. /**
  49792. * The (Babylon) version of this module.
  49793. * This is an integer representing the implementation version.
  49794. * This number does not correspond to the WebXR specs version
  49795. */
  49796. static readonly Version: number;
  49797. /**
  49798. * Disable lighting on the laser pointer (so it will always be visible)
  49799. */
  49800. disablePointerLighting: boolean;
  49801. /**
  49802. * Disable lighting on the selection mesh (so it will always be visible)
  49803. */
  49804. disableSelectionMeshLighting: boolean;
  49805. /**
  49806. * Should the laser pointer be displayed
  49807. */
  49808. displayLaserPointer: boolean;
  49809. /**
  49810. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49811. */
  49812. displaySelectionMesh: boolean;
  49813. /**
  49814. * This color will be set to the laser pointer when selection is triggered
  49815. */
  49816. laserPointerPickedColor: Color3;
  49817. /**
  49818. * Default color of the laser pointer
  49819. */
  49820. laserPointerDefaultColor: Color3;
  49821. /**
  49822. * default color of the selection ring
  49823. */
  49824. selectionMeshDefaultColor: Color3;
  49825. /**
  49826. * This color will be applied to the selection ring when selection is triggered
  49827. */
  49828. selectionMeshPickedColor: Color3;
  49829. /**
  49830. * Optional filter to be used for ray selection. This predicate shares behavior with
  49831. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49832. */
  49833. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49834. /**
  49835. * constructs a new background remover module
  49836. * @param _xrSessionManager the session manager for this module
  49837. * @param _options read-only options to be used in this module
  49838. */
  49839. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49840. /**
  49841. * attach this feature
  49842. * Will usually be called by the features manager
  49843. *
  49844. * @returns true if successful.
  49845. */
  49846. attach(): boolean;
  49847. /**
  49848. * detach this feature.
  49849. * Will usually be called by the features manager
  49850. *
  49851. * @returns true if successful.
  49852. */
  49853. detach(): boolean;
  49854. /**
  49855. * Will get the mesh under a specific pointer.
  49856. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49857. * @param controllerId the controllerId to check
  49858. * @returns The mesh under pointer or null if no mesh is under the pointer
  49859. */
  49860. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49861. /**
  49862. * Get the xr controller that correlates to the pointer id in the pointer event
  49863. *
  49864. * @param id the pointer id to search for
  49865. * @returns the controller that correlates to this id or null if not found
  49866. */
  49867. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49868. protected _onXRFrame(_xrFrame: XRFrame): void;
  49869. private _attachGazeMode;
  49870. private _attachScreenRayMode;
  49871. private _attachTrackedPointerRayMode;
  49872. private _convertNormalToDirectionOfRay;
  49873. private _detachController;
  49874. private _generateNewMeshPair;
  49875. private _pickingMoved;
  49876. private _updatePointerDistance;
  49877. /** @hidden */
  49878. get lasterPointerDefaultColor(): Color3;
  49879. }
  49880. }
  49881. declare module "babylonjs/XR/webXREnterExitUI" {
  49882. import { Nullable } from "babylonjs/types";
  49883. import { Observable } from "babylonjs/Misc/observable";
  49884. import { IDisposable, Scene } from "babylonjs/scene";
  49885. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49886. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49887. /**
  49888. * Button which can be used to enter a different mode of XR
  49889. */
  49890. export class WebXREnterExitUIButton {
  49891. /** button element */
  49892. element: HTMLElement;
  49893. /** XR initialization options for the button */
  49894. sessionMode: XRSessionMode;
  49895. /** Reference space type */
  49896. referenceSpaceType: XRReferenceSpaceType;
  49897. /**
  49898. * Creates a WebXREnterExitUIButton
  49899. * @param element button element
  49900. * @param sessionMode XR initialization session mode
  49901. * @param referenceSpaceType the type of reference space to be used
  49902. */
  49903. constructor(
  49904. /** button element */
  49905. element: HTMLElement,
  49906. /** XR initialization options for the button */
  49907. sessionMode: XRSessionMode,
  49908. /** Reference space type */
  49909. referenceSpaceType: XRReferenceSpaceType);
  49910. /**
  49911. * Extendable function which can be used to update the button's visuals when the state changes
  49912. * @param activeButton the current active button in the UI
  49913. */
  49914. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49915. }
  49916. /**
  49917. * Options to create the webXR UI
  49918. */
  49919. export class WebXREnterExitUIOptions {
  49920. /**
  49921. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49922. */
  49923. customButtons?: Array<WebXREnterExitUIButton>;
  49924. /**
  49925. * A reference space type to use when creating the default button.
  49926. * Default is local-floor
  49927. */
  49928. referenceSpaceType?: XRReferenceSpaceType;
  49929. /**
  49930. * Context to enter xr with
  49931. */
  49932. renderTarget?: Nullable<WebXRRenderTarget>;
  49933. /**
  49934. * A session mode to use when creating the default button.
  49935. * Default is immersive-vr
  49936. */
  49937. sessionMode?: XRSessionMode;
  49938. /**
  49939. * A list of optional features to init the session with
  49940. */
  49941. optionalFeatures?: string[];
  49942. }
  49943. /**
  49944. * UI to allow the user to enter/exit XR mode
  49945. */
  49946. export class WebXREnterExitUI implements IDisposable {
  49947. private scene;
  49948. /** version of the options passed to this UI */
  49949. options: WebXREnterExitUIOptions;
  49950. private _activeButton;
  49951. private _buttons;
  49952. private _overlay;
  49953. /**
  49954. * Fired every time the active button is changed.
  49955. *
  49956. * When xr is entered via a button that launches xr that button will be the callback parameter
  49957. *
  49958. * When exiting xr the callback parameter will be null)
  49959. */
  49960. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49961. /**
  49962. *
  49963. * @param scene babylon scene object to use
  49964. * @param options (read-only) version of the options passed to this UI
  49965. */
  49966. private constructor();
  49967. /**
  49968. * Creates UI to allow the user to enter/exit XR mode
  49969. * @param scene the scene to add the ui to
  49970. * @param helper the xr experience helper to enter/exit xr with
  49971. * @param options options to configure the UI
  49972. * @returns the created ui
  49973. */
  49974. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49975. /**
  49976. * Disposes of the XR UI component
  49977. */
  49978. dispose(): void;
  49979. private _updateButtons;
  49980. }
  49981. }
  49982. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49983. import { Vector3 } from "babylonjs/Maths/math.vector";
  49984. import { Color4 } from "babylonjs/Maths/math.color";
  49985. import { Nullable } from "babylonjs/types";
  49986. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49987. import { Scene } from "babylonjs/scene";
  49988. /**
  49989. * Class containing static functions to help procedurally build meshes
  49990. */
  49991. export class LinesBuilder {
  49992. /**
  49993. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49994. * * 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
  49995. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49996. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49997. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49998. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49999. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50000. * * 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
  50001. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50003. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50004. * @param name defines the name of the new line system
  50005. * @param options defines the options used to create the line system
  50006. * @param scene defines the hosting scene
  50007. * @returns a new line system mesh
  50008. */
  50009. static CreateLineSystem(name: string, options: {
  50010. lines: Vector3[][];
  50011. updatable?: boolean;
  50012. instance?: Nullable<LinesMesh>;
  50013. colors?: Nullable<Color4[][]>;
  50014. useVertexAlpha?: boolean;
  50015. }, scene: Nullable<Scene>): LinesMesh;
  50016. /**
  50017. * Creates a line mesh
  50018. * 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
  50019. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50020. * * The parameter `points` is an array successive Vector3
  50021. * * 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
  50022. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50023. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50024. * * When updating an instance, remember that only point positions can change, not the number of points
  50025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50026. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50027. * @param name defines the name of the new line system
  50028. * @param options defines the options used to create the line system
  50029. * @param scene defines the hosting scene
  50030. * @returns a new line mesh
  50031. */
  50032. static CreateLines(name: string, options: {
  50033. points: Vector3[];
  50034. updatable?: boolean;
  50035. instance?: Nullable<LinesMesh>;
  50036. colors?: Color4[];
  50037. useVertexAlpha?: boolean;
  50038. }, scene?: Nullable<Scene>): LinesMesh;
  50039. /**
  50040. * Creates a dashed line mesh
  50041. * * 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
  50042. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50043. * * The parameter `points` is an array successive Vector3
  50044. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50045. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50046. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50047. * * 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
  50048. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50049. * * When updating an instance, remember that only point positions can change, not the number of points
  50050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50051. * @param name defines the name of the mesh
  50052. * @param options defines the options used to create the mesh
  50053. * @param scene defines the hosting scene
  50054. * @returns the dashed line mesh
  50055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50056. */
  50057. static CreateDashedLines(name: string, options: {
  50058. points: Vector3[];
  50059. dashSize?: number;
  50060. gapSize?: number;
  50061. dashNb?: number;
  50062. updatable?: boolean;
  50063. instance?: LinesMesh;
  50064. useVertexAlpha?: boolean;
  50065. }, scene?: Nullable<Scene>): LinesMesh;
  50066. }
  50067. }
  50068. declare module "babylonjs/Misc/timer" {
  50069. import { Observable, Observer } from "babylonjs/Misc/observable";
  50070. import { Nullable } from "babylonjs/types";
  50071. import { IDisposable } from "babylonjs/scene";
  50072. /**
  50073. * Construction options for a timer
  50074. */
  50075. export interface ITimerOptions<T> {
  50076. /**
  50077. * Time-to-end
  50078. */
  50079. timeout: number;
  50080. /**
  50081. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50082. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50083. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50084. */
  50085. contextObservable: Observable<T>;
  50086. /**
  50087. * Optional parameters when adding an observer to the observable
  50088. */
  50089. observableParameters?: {
  50090. mask?: number;
  50091. insertFirst?: boolean;
  50092. scope?: any;
  50093. };
  50094. /**
  50095. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50096. */
  50097. breakCondition?: (data?: ITimerData<T>) => boolean;
  50098. /**
  50099. * Will be triggered when the time condition has met
  50100. */
  50101. onEnded?: (data: ITimerData<any>) => void;
  50102. /**
  50103. * Will be triggered when the break condition has met (prematurely ended)
  50104. */
  50105. onAborted?: (data: ITimerData<any>) => void;
  50106. /**
  50107. * Optional function to execute on each tick (or count)
  50108. */
  50109. onTick?: (data: ITimerData<any>) => void;
  50110. }
  50111. /**
  50112. * An interface defining the data sent by the timer
  50113. */
  50114. export interface ITimerData<T> {
  50115. /**
  50116. * When did it start
  50117. */
  50118. startTime: number;
  50119. /**
  50120. * Time now
  50121. */
  50122. currentTime: number;
  50123. /**
  50124. * Time passed since started
  50125. */
  50126. deltaTime: number;
  50127. /**
  50128. * How much is completed, in [0.0...1.0].
  50129. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50130. */
  50131. completeRate: number;
  50132. /**
  50133. * What the registered observable sent in the last count
  50134. */
  50135. payload: T;
  50136. }
  50137. /**
  50138. * The current state of the timer
  50139. */
  50140. export enum TimerState {
  50141. /**
  50142. * Timer initialized, not yet started
  50143. */
  50144. INIT = 0,
  50145. /**
  50146. * Timer started and counting
  50147. */
  50148. STARTED = 1,
  50149. /**
  50150. * Timer ended (whether aborted or time reached)
  50151. */
  50152. ENDED = 2
  50153. }
  50154. /**
  50155. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50156. *
  50157. * @param options options with which to initialize this timer
  50158. */
  50159. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50160. /**
  50161. * An advanced implementation of a timer class
  50162. */
  50163. export class AdvancedTimer<T = any> implements IDisposable {
  50164. /**
  50165. * Will notify each time the timer calculates the remaining time
  50166. */
  50167. onEachCountObservable: Observable<ITimerData<T>>;
  50168. /**
  50169. * Will trigger when the timer was aborted due to the break condition
  50170. */
  50171. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50172. /**
  50173. * Will trigger when the timer ended successfully
  50174. */
  50175. onTimerEndedObservable: Observable<ITimerData<T>>;
  50176. /**
  50177. * Will trigger when the timer state has changed
  50178. */
  50179. onStateChangedObservable: Observable<TimerState>;
  50180. private _observer;
  50181. private _contextObservable;
  50182. private _observableParameters;
  50183. private _startTime;
  50184. private _timer;
  50185. private _state;
  50186. private _breakCondition;
  50187. private _timeToEnd;
  50188. private _breakOnNextTick;
  50189. /**
  50190. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50191. * @param options construction options for this advanced timer
  50192. */
  50193. constructor(options: ITimerOptions<T>);
  50194. /**
  50195. * set a breaking condition for this timer. Default is to never break during count
  50196. * @param predicate the new break condition. Returns true to break, false otherwise
  50197. */
  50198. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50199. /**
  50200. * Reset ALL associated observables in this advanced timer
  50201. */
  50202. clearObservables(): void;
  50203. /**
  50204. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50205. *
  50206. * @param timeToEnd how much time to measure until timer ended
  50207. */
  50208. start(timeToEnd?: number): void;
  50209. /**
  50210. * Will force a stop on the next tick.
  50211. */
  50212. stop(): void;
  50213. /**
  50214. * Dispose this timer, clearing all resources
  50215. */
  50216. dispose(): void;
  50217. private _setState;
  50218. private _tick;
  50219. private _stop;
  50220. }
  50221. }
  50222. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50223. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50224. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50225. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50227. import { Vector3 } from "babylonjs/Maths/math.vector";
  50228. import { Material } from "babylonjs/Materials/material";
  50229. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50230. import { Scene } from "babylonjs/scene";
  50231. /**
  50232. * The options container for the teleportation module
  50233. */
  50234. export interface IWebXRTeleportationOptions {
  50235. /**
  50236. * if provided, this scene will be used to render meshes.
  50237. */
  50238. customUtilityLayerScene?: Scene;
  50239. /**
  50240. * Values to configure the default target mesh
  50241. */
  50242. defaultTargetMeshOptions?: {
  50243. /**
  50244. * Fill color of the teleportation area
  50245. */
  50246. teleportationFillColor?: string;
  50247. /**
  50248. * Border color for the teleportation area
  50249. */
  50250. teleportationBorderColor?: string;
  50251. /**
  50252. * Disable the mesh's animation sequence
  50253. */
  50254. disableAnimation?: boolean;
  50255. /**
  50256. * Disable lighting on the material or the ring and arrow
  50257. */
  50258. disableLighting?: boolean;
  50259. /**
  50260. * Override the default material of the torus and arrow
  50261. */
  50262. torusArrowMaterial?: Material;
  50263. };
  50264. /**
  50265. * A list of meshes to use as floor meshes.
  50266. * Meshes can be added and removed after initializing the feature using the
  50267. * addFloorMesh and removeFloorMesh functions
  50268. * If empty, rotation will still work
  50269. */
  50270. floorMeshes?: AbstractMesh[];
  50271. /**
  50272. * use this rendering group id for the meshes (optional)
  50273. */
  50274. renderingGroupId?: number;
  50275. /**
  50276. * Should teleportation move only to snap points
  50277. */
  50278. snapPointsOnly?: boolean;
  50279. /**
  50280. * An array of points to which the teleportation will snap to.
  50281. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50282. */
  50283. snapPositions?: Vector3[];
  50284. /**
  50285. * How close should the teleportation ray be in order to snap to position.
  50286. * Default to 0.8 units (meters)
  50287. */
  50288. snapToPositionRadius?: number;
  50289. /**
  50290. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50291. * If you want to support rotation, make sure your mesh has a direction indicator.
  50292. *
  50293. * When left untouched, the default mesh will be initialized.
  50294. */
  50295. teleportationTargetMesh?: AbstractMesh;
  50296. /**
  50297. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50298. */
  50299. timeToTeleport?: number;
  50300. /**
  50301. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50302. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50303. */
  50304. useMainComponentOnly?: boolean;
  50305. /**
  50306. * Should meshes created here be added to a utility layer or the main scene
  50307. */
  50308. useUtilityLayer?: boolean;
  50309. /**
  50310. * Babylon XR Input class for controller
  50311. */
  50312. xrInput: WebXRInput;
  50313. }
  50314. /**
  50315. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  50316. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  50317. * the input of the attached controllers.
  50318. */
  50319. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  50320. private _options;
  50321. private _controllers;
  50322. private _currentTeleportationControllerId;
  50323. private _floorMeshes;
  50324. private _quadraticBezierCurve;
  50325. private _selectionFeature;
  50326. private _snapToPositions;
  50327. private _snappedToPoint;
  50328. private _teleportationRingMaterial?;
  50329. private _tmpRay;
  50330. private _tmpVector;
  50331. /**
  50332. * The module's name
  50333. */
  50334. static readonly Name: string;
  50335. /**
  50336. * The (Babylon) version of this module.
  50337. * This is an integer representing the implementation version.
  50338. * This number does not correspond to the webxr specs version
  50339. */
  50340. static readonly Version: number;
  50341. /**
  50342. * Is movement backwards enabled
  50343. */
  50344. backwardsMovementEnabled: boolean;
  50345. /**
  50346. * Distance to travel when moving backwards
  50347. */
  50348. backwardsTeleportationDistance: number;
  50349. /**
  50350. * The distance from the user to the inspection point in the direction of the controller
  50351. * A higher number will allow the user to move further
  50352. * defaults to 5 (meters, in xr units)
  50353. */
  50354. parabolicCheckRadius: number;
  50355. /**
  50356. * Should the module support parabolic ray on top of direct ray
  50357. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  50358. * Very helpful when moving between floors / different heights
  50359. */
  50360. parabolicRayEnabled: boolean;
  50361. /**
  50362. * How much rotation should be applied when rotating right and left
  50363. */
  50364. rotationAngle: number;
  50365. /**
  50366. * Is rotation enabled when moving forward?
  50367. * Disabling this feature will prevent the user from deciding the direction when teleporting
  50368. */
  50369. rotationEnabled: boolean;
  50370. /**
  50371. * constructs a new anchor system
  50372. * @param _xrSessionManager an instance of WebXRSessionManager
  50373. * @param _options configuration object for this feature
  50374. */
  50375. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  50376. /**
  50377. * Get the snapPointsOnly flag
  50378. */
  50379. get snapPointsOnly(): boolean;
  50380. /**
  50381. * Sets the snapPointsOnly flag
  50382. * @param snapToPoints should teleportation be exclusively to snap points
  50383. */
  50384. set snapPointsOnly(snapToPoints: boolean);
  50385. /**
  50386. * Add a new mesh to the floor meshes array
  50387. * @param mesh the mesh to use as floor mesh
  50388. */
  50389. addFloorMesh(mesh: AbstractMesh): void;
  50390. /**
  50391. * Add a new snap-to point to fix teleportation to this position
  50392. * @param newSnapPoint The new Snap-To point
  50393. */
  50394. addSnapPoint(newSnapPoint: Vector3): void;
  50395. attach(): boolean;
  50396. detach(): boolean;
  50397. dispose(): void;
  50398. /**
  50399. * Remove a mesh from the floor meshes array
  50400. * @param mesh the mesh to remove
  50401. */
  50402. removeFloorMesh(mesh: AbstractMesh): void;
  50403. /**
  50404. * Remove a mesh from the floor meshes array using its name
  50405. * @param name the mesh name to remove
  50406. */
  50407. removeFloorMeshByName(name: string): void;
  50408. /**
  50409. * 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
  50410. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  50411. * @returns was the point found and removed or not
  50412. */
  50413. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  50414. /**
  50415. * This function sets a selection feature that will be disabled when
  50416. * the forward ray is shown and will be reattached when hidden.
  50417. * This is used to remove the selection rays when moving.
  50418. * @param selectionFeature the feature to disable when forward movement is enabled
  50419. */
  50420. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  50421. protected _onXRFrame(_xrFrame: XRFrame): void;
  50422. private _attachController;
  50423. private _createDefaultTargetMesh;
  50424. private _detachController;
  50425. private _findClosestSnapPointWithRadius;
  50426. private _setTargetMeshPosition;
  50427. private _setTargetMeshVisibility;
  50428. private _showParabolicPath;
  50429. private _teleportForward;
  50430. }
  50431. }
  50432. declare module "babylonjs/XR/webXRDefaultExperience" {
  50433. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50434. import { Scene } from "babylonjs/scene";
  50435. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  50436. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  50437. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50438. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  50439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50440. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  50441. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  50442. /**
  50443. * Options for the default xr helper
  50444. */
  50445. export class WebXRDefaultExperienceOptions {
  50446. /**
  50447. * Enable or disable default UI to enter XR
  50448. */
  50449. disableDefaultUI?: boolean;
  50450. /**
  50451. * Should teleportation not initialize. defaults to false.
  50452. */
  50453. disableTeleportation?: boolean;
  50454. /**
  50455. * Floor meshes that will be used for teleport
  50456. */
  50457. floorMeshes?: Array<AbstractMesh>;
  50458. /**
  50459. * If set to true, the first frame will not be used to reset position
  50460. * The first frame is mainly used when copying transformation from the old camera
  50461. * Mainly used in AR
  50462. */
  50463. ignoreNativeCameraTransformation?: boolean;
  50464. /**
  50465. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  50466. */
  50467. inputOptions?: IWebXRInputOptions;
  50468. /**
  50469. * optional configuration for the output canvas
  50470. */
  50471. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  50472. /**
  50473. * optional UI options. This can be used among other to change session mode and reference space type
  50474. */
  50475. uiOptions?: WebXREnterExitUIOptions;
  50476. /**
  50477. * When loading teleportation and pointer select, use stable versions instead of latest.
  50478. */
  50479. useStablePlugins?: boolean;
  50480. /**
  50481. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  50482. */
  50483. renderingGroupId?: number;
  50484. /**
  50485. * A list of optional features to init the session with
  50486. * If set to true, all features we support will be added
  50487. */
  50488. optionalFeatures?: boolean | string[];
  50489. }
  50490. /**
  50491. * Default experience which provides a similar setup to the previous webVRExperience
  50492. */
  50493. export class WebXRDefaultExperience {
  50494. /**
  50495. * Base experience
  50496. */
  50497. baseExperience: WebXRExperienceHelper;
  50498. /**
  50499. * Enables ui for entering/exiting xr
  50500. */
  50501. enterExitUI: WebXREnterExitUI;
  50502. /**
  50503. * Input experience extension
  50504. */
  50505. input: WebXRInput;
  50506. /**
  50507. * Enables laser pointer and selection
  50508. */
  50509. pointerSelection: WebXRControllerPointerSelection;
  50510. /**
  50511. * Default target xr should render to
  50512. */
  50513. renderTarget: WebXRRenderTarget;
  50514. /**
  50515. * Enables teleportation
  50516. */
  50517. teleportation: WebXRMotionControllerTeleportation;
  50518. private constructor();
  50519. /**
  50520. * Creates the default xr experience
  50521. * @param scene scene
  50522. * @param options options for basic configuration
  50523. * @returns resulting WebXRDefaultExperience
  50524. */
  50525. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50526. /**
  50527. * DIsposes of the experience helper
  50528. */
  50529. dispose(): void;
  50530. }
  50531. }
  50532. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  50533. import { Observable } from "babylonjs/Misc/observable";
  50534. import { Nullable } from "babylonjs/types";
  50535. import { Camera } from "babylonjs/Cameras/camera";
  50536. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  50537. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50538. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  50539. import { Scene } from "babylonjs/scene";
  50540. import { Vector3 } from "babylonjs/Maths/math.vector";
  50541. import { Color3 } from "babylonjs/Maths/math.color";
  50542. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50544. import { Mesh } from "babylonjs/Meshes/mesh";
  50545. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  50546. import { EasingFunction } from "babylonjs/Animations/easing";
  50547. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  50548. import "babylonjs/Meshes/Builders/groundBuilder";
  50549. import "babylonjs/Meshes/Builders/torusBuilder";
  50550. import "babylonjs/Meshes/Builders/cylinderBuilder";
  50551. import "babylonjs/Gamepads/gamepadSceneComponent";
  50552. import "babylonjs/Animations/animatable";
  50553. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  50554. /**
  50555. * Options to modify the vr teleportation behavior.
  50556. */
  50557. export interface VRTeleportationOptions {
  50558. /**
  50559. * The name of the mesh which should be used as the teleportation floor. (default: null)
  50560. */
  50561. floorMeshName?: string;
  50562. /**
  50563. * A list of meshes to be used as the teleportation floor. (default: empty)
  50564. */
  50565. floorMeshes?: Mesh[];
  50566. /**
  50567. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  50568. */
  50569. teleportationMode?: number;
  50570. /**
  50571. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50572. */
  50573. teleportationTime?: number;
  50574. /**
  50575. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50576. */
  50577. teleportationSpeed?: number;
  50578. /**
  50579. * The easing function used in the animation or null for Linear. (default CircleEase)
  50580. */
  50581. easingFunction?: EasingFunction;
  50582. }
  50583. /**
  50584. * Options to modify the vr experience helper's behavior.
  50585. */
  50586. export interface VRExperienceHelperOptions extends WebVROptions {
  50587. /**
  50588. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50589. */
  50590. createDeviceOrientationCamera?: boolean;
  50591. /**
  50592. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50593. */
  50594. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50595. /**
  50596. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50597. */
  50598. laserToggle?: boolean;
  50599. /**
  50600. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50601. */
  50602. floorMeshes?: Mesh[];
  50603. /**
  50604. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50605. */
  50606. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50607. /**
  50608. * Defines if WebXR should be used instead of WebVR (if available)
  50609. */
  50610. useXR?: boolean;
  50611. }
  50612. /**
  50613. * Event containing information after VR has been entered
  50614. */
  50615. export class OnAfterEnteringVRObservableEvent {
  50616. /**
  50617. * If entering vr was successful
  50618. */
  50619. success: boolean;
  50620. }
  50621. /**
  50622. * Helps to quickly add VR support to an existing scene.
  50623. * See https://doc.babylonjs.com/how_to/webvr_helper
  50624. */
  50625. export class VRExperienceHelper {
  50626. /** Options to modify the vr experience helper's behavior. */
  50627. webVROptions: VRExperienceHelperOptions;
  50628. private _scene;
  50629. private _position;
  50630. private _btnVR;
  50631. private _btnVRDisplayed;
  50632. private _webVRsupported;
  50633. private _webVRready;
  50634. private _webVRrequesting;
  50635. private _webVRpresenting;
  50636. private _hasEnteredVR;
  50637. private _fullscreenVRpresenting;
  50638. private _inputElement;
  50639. private _webVRCamera;
  50640. private _vrDeviceOrientationCamera;
  50641. private _deviceOrientationCamera;
  50642. private _existingCamera;
  50643. private _onKeyDown;
  50644. private _onVrDisplayPresentChange;
  50645. private _onVRDisplayChanged;
  50646. private _onVRRequestPresentStart;
  50647. private _onVRRequestPresentComplete;
  50648. /**
  50649. * 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)
  50650. */
  50651. enableGazeEvenWhenNoPointerLock: boolean;
  50652. /**
  50653. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50654. */
  50655. exitVROnDoubleTap: boolean;
  50656. /**
  50657. * Observable raised right before entering VR.
  50658. */
  50659. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50660. /**
  50661. * Observable raised when entering VR has completed.
  50662. */
  50663. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50664. /**
  50665. * Observable raised when exiting VR.
  50666. */
  50667. onExitingVRObservable: Observable<VRExperienceHelper>;
  50668. /**
  50669. * Observable raised when controller mesh is loaded.
  50670. */
  50671. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50672. /** Return this.onEnteringVRObservable
  50673. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50674. */
  50675. get onEnteringVR(): Observable<VRExperienceHelper>;
  50676. /** Return this.onExitingVRObservable
  50677. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50678. */
  50679. get onExitingVR(): Observable<VRExperienceHelper>;
  50680. /** Return this.onControllerMeshLoadedObservable
  50681. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50682. */
  50683. get onControllerMeshLoaded(): Observable<WebVRController>;
  50684. private _rayLength;
  50685. private _useCustomVRButton;
  50686. private _teleportationRequested;
  50687. private _teleportActive;
  50688. private _floorMeshName;
  50689. private _floorMeshesCollection;
  50690. private _teleportationMode;
  50691. private _teleportationTime;
  50692. private _teleportationSpeed;
  50693. private _teleportationEasing;
  50694. private _rotationAllowed;
  50695. private _teleportBackwardsVector;
  50696. private _teleportationTarget;
  50697. private _isDefaultTeleportationTarget;
  50698. private _postProcessMove;
  50699. private _teleportationFillColor;
  50700. private _teleportationBorderColor;
  50701. private _rotationAngle;
  50702. private _haloCenter;
  50703. private _cameraGazer;
  50704. private _padSensibilityUp;
  50705. private _padSensibilityDown;
  50706. private _leftController;
  50707. private _rightController;
  50708. private _gazeColor;
  50709. private _laserColor;
  50710. private _pickedLaserColor;
  50711. private _pickedGazeColor;
  50712. /**
  50713. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50714. */
  50715. onNewMeshSelected: Observable<AbstractMesh>;
  50716. /**
  50717. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50718. * This observable will provide the mesh and the controller used to select the mesh
  50719. */
  50720. onMeshSelectedWithController: Observable<{
  50721. mesh: AbstractMesh;
  50722. controller: WebVRController;
  50723. }>;
  50724. /**
  50725. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50726. */
  50727. onNewMeshPicked: Observable<PickingInfo>;
  50728. private _circleEase;
  50729. /**
  50730. * Observable raised before camera teleportation
  50731. */
  50732. onBeforeCameraTeleport: Observable<Vector3>;
  50733. /**
  50734. * Observable raised after camera teleportation
  50735. */
  50736. onAfterCameraTeleport: Observable<Vector3>;
  50737. /**
  50738. * Observable raised when current selected mesh gets unselected
  50739. */
  50740. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50741. private _raySelectionPredicate;
  50742. /**
  50743. * To be optionaly changed by user to define custom ray selection
  50744. */
  50745. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50746. /**
  50747. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50748. */
  50749. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50750. /**
  50751. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50752. */
  50753. teleportationEnabled: boolean;
  50754. private _defaultHeight;
  50755. private _teleportationInitialized;
  50756. private _interactionsEnabled;
  50757. private _interactionsRequested;
  50758. private _displayGaze;
  50759. private _displayLaserPointer;
  50760. /**
  50761. * The mesh used to display where the user is going to teleport.
  50762. */
  50763. get teleportationTarget(): Mesh;
  50764. /**
  50765. * Sets the mesh to be used to display where the user is going to teleport.
  50766. */
  50767. set teleportationTarget(value: Mesh);
  50768. /**
  50769. * 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
  50770. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50771. * See https://doc.babylonjs.com/resources/baking_transformations
  50772. */
  50773. get gazeTrackerMesh(): Mesh;
  50774. set gazeTrackerMesh(value: Mesh);
  50775. /**
  50776. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50777. */
  50778. updateGazeTrackerScale: boolean;
  50779. /**
  50780. * If the gaze trackers color should be updated when selecting meshes
  50781. */
  50782. updateGazeTrackerColor: boolean;
  50783. /**
  50784. * If the controller laser color should be updated when selecting meshes
  50785. */
  50786. updateControllerLaserColor: boolean;
  50787. /**
  50788. * The gaze tracking mesh corresponding to the left controller
  50789. */
  50790. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50791. /**
  50792. * The gaze tracking mesh corresponding to the right controller
  50793. */
  50794. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50795. /**
  50796. * If the ray of the gaze should be displayed.
  50797. */
  50798. get displayGaze(): boolean;
  50799. /**
  50800. * Sets if the ray of the gaze should be displayed.
  50801. */
  50802. set displayGaze(value: boolean);
  50803. /**
  50804. * If the ray of the LaserPointer should be displayed.
  50805. */
  50806. get displayLaserPointer(): boolean;
  50807. /**
  50808. * Sets if the ray of the LaserPointer should be displayed.
  50809. */
  50810. set displayLaserPointer(value: boolean);
  50811. /**
  50812. * The deviceOrientationCamera used as the camera when not in VR.
  50813. */
  50814. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50815. /**
  50816. * Based on the current WebVR support, returns the current VR camera used.
  50817. */
  50818. get currentVRCamera(): Nullable<Camera>;
  50819. /**
  50820. * The webVRCamera which is used when in VR.
  50821. */
  50822. get webVRCamera(): WebVRFreeCamera;
  50823. /**
  50824. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50825. */
  50826. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50827. /**
  50828. * The html button that is used to trigger entering into VR.
  50829. */
  50830. get vrButton(): Nullable<HTMLButtonElement>;
  50831. private get _teleportationRequestInitiated();
  50832. /**
  50833. * Defines whether or not Pointer lock should be requested when switching to
  50834. * full screen.
  50835. */
  50836. requestPointerLockOnFullScreen: boolean;
  50837. /**
  50838. * If asking to force XR, this will be populated with the default xr experience
  50839. */
  50840. xr: WebXRDefaultExperience;
  50841. /**
  50842. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50843. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50844. */
  50845. xrTestDone: boolean;
  50846. /**
  50847. * Instantiates a VRExperienceHelper.
  50848. * Helps to quickly add VR support to an existing scene.
  50849. * @param scene The scene the VRExperienceHelper belongs to.
  50850. * @param webVROptions Options to modify the vr experience helper's behavior.
  50851. */
  50852. constructor(scene: Scene,
  50853. /** Options to modify the vr experience helper's behavior. */
  50854. webVROptions?: VRExperienceHelperOptions);
  50855. private completeVRInit;
  50856. private _onDefaultMeshLoaded;
  50857. private _onResize;
  50858. private _onFullscreenChange;
  50859. /**
  50860. * Gets a value indicating if we are currently in VR mode.
  50861. */
  50862. get isInVRMode(): boolean;
  50863. private onVrDisplayPresentChange;
  50864. private onVRDisplayChanged;
  50865. private moveButtonToBottomRight;
  50866. private displayVRButton;
  50867. private updateButtonVisibility;
  50868. private _cachedAngularSensibility;
  50869. /**
  50870. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50871. * Otherwise, will use the fullscreen API.
  50872. */
  50873. enterVR(): void;
  50874. /**
  50875. * Attempt to exit VR, or fullscreen.
  50876. */
  50877. exitVR(): void;
  50878. /**
  50879. * The position of the vr experience helper.
  50880. */
  50881. get position(): Vector3;
  50882. /**
  50883. * Sets the position of the vr experience helper.
  50884. */
  50885. set position(value: Vector3);
  50886. /**
  50887. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50888. */
  50889. enableInteractions(): void;
  50890. private get _noControllerIsActive();
  50891. private beforeRender;
  50892. private _isTeleportationFloor;
  50893. /**
  50894. * Adds a floor mesh to be used for teleportation.
  50895. * @param floorMesh the mesh to be used for teleportation.
  50896. */
  50897. addFloorMesh(floorMesh: Mesh): void;
  50898. /**
  50899. * Removes a floor mesh from being used for teleportation.
  50900. * @param floorMesh the mesh to be removed.
  50901. */
  50902. removeFloorMesh(floorMesh: Mesh): void;
  50903. /**
  50904. * Enables interactions and teleportation using the VR controllers and gaze.
  50905. * @param vrTeleportationOptions options to modify teleportation behavior.
  50906. */
  50907. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50908. private _onNewGamepadConnected;
  50909. private _tryEnableInteractionOnController;
  50910. private _onNewGamepadDisconnected;
  50911. private _enableInteractionOnController;
  50912. private _checkTeleportWithRay;
  50913. private _checkRotate;
  50914. private _checkTeleportBackwards;
  50915. private _enableTeleportationOnController;
  50916. private _createTeleportationCircles;
  50917. private _displayTeleportationTarget;
  50918. private _hideTeleportationTarget;
  50919. private _rotateCamera;
  50920. private _moveTeleportationSelectorTo;
  50921. private _workingVector;
  50922. private _workingQuaternion;
  50923. private _workingMatrix;
  50924. /**
  50925. * Time Constant Teleportation Mode
  50926. */
  50927. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50928. /**
  50929. * Speed Constant Teleportation Mode
  50930. */
  50931. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50932. /**
  50933. * Teleports the users feet to the desired location
  50934. * @param location The location where the user's feet should be placed
  50935. */
  50936. teleportCamera(location: Vector3): void;
  50937. private _convertNormalToDirectionOfRay;
  50938. private _castRayAndSelectObject;
  50939. private _notifySelectedMeshUnselected;
  50940. /**
  50941. * Permanently set new colors for the laser pointer
  50942. * @param color the new laser color
  50943. * @param pickedColor the new laser color when picked mesh detected
  50944. */
  50945. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50946. /**
  50947. * Set lighting enabled / disabled on the laser pointer of both controllers
  50948. * @param enabled should the lighting be enabled on the laser pointer
  50949. */
  50950. setLaserLightingState(enabled?: boolean): void;
  50951. /**
  50952. * Permanently set new colors for the gaze pointer
  50953. * @param color the new gaze color
  50954. * @param pickedColor the new gaze color when picked mesh detected
  50955. */
  50956. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50957. /**
  50958. * Sets the color of the laser ray from the vr controllers.
  50959. * @param color new color for the ray.
  50960. */
  50961. changeLaserColor(color: Color3): void;
  50962. /**
  50963. * Sets the color of the ray from the vr headsets gaze.
  50964. * @param color new color for the ray.
  50965. */
  50966. changeGazeColor(color: Color3): void;
  50967. /**
  50968. * Exits VR and disposes of the vr experience helper
  50969. */
  50970. dispose(): void;
  50971. /**
  50972. * Gets the name of the VRExperienceHelper class
  50973. * @returns "VRExperienceHelper"
  50974. */
  50975. getClassName(): string;
  50976. }
  50977. }
  50978. declare module "babylonjs/Cameras/VR/index" {
  50979. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50980. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50981. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50982. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50983. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50984. export * from "babylonjs/Cameras/VR/webVRCamera";
  50985. }
  50986. declare module "babylonjs/Cameras/RigModes/index" {
  50987. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50988. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50989. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50990. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50991. }
  50992. declare module "babylonjs/Cameras/index" {
  50993. export * from "babylonjs/Cameras/Inputs/index";
  50994. export * from "babylonjs/Cameras/cameraInputsManager";
  50995. export * from "babylonjs/Cameras/camera";
  50996. export * from "babylonjs/Cameras/targetCamera";
  50997. export * from "babylonjs/Cameras/freeCamera";
  50998. export * from "babylonjs/Cameras/freeCameraInputsManager";
  50999. export * from "babylonjs/Cameras/touchCamera";
  51000. export * from "babylonjs/Cameras/arcRotateCamera";
  51001. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51002. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51003. export * from "babylonjs/Cameras/flyCamera";
  51004. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51005. export * from "babylonjs/Cameras/followCamera";
  51006. export * from "babylonjs/Cameras/followCameraInputsManager";
  51007. export * from "babylonjs/Cameras/gamepadCamera";
  51008. export * from "babylonjs/Cameras/Stereoscopic/index";
  51009. export * from "babylonjs/Cameras/universalCamera";
  51010. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51011. export * from "babylonjs/Cameras/VR/index";
  51012. export * from "babylonjs/Cameras/RigModes/index";
  51013. }
  51014. declare module "babylonjs/Collisions/index" {
  51015. export * from "babylonjs/Collisions/collider";
  51016. export * from "babylonjs/Collisions/collisionCoordinator";
  51017. export * from "babylonjs/Collisions/pickingInfo";
  51018. export * from "babylonjs/Collisions/intersectionInfo";
  51019. export * from "babylonjs/Collisions/meshCollisionData";
  51020. }
  51021. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51022. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51023. import { Vector3 } from "babylonjs/Maths/math.vector";
  51024. import { Ray } from "babylonjs/Culling/ray";
  51025. import { Plane } from "babylonjs/Maths/math.plane";
  51026. /**
  51027. * Contains an array of blocks representing the octree
  51028. */
  51029. export interface IOctreeContainer<T> {
  51030. /**
  51031. * Blocks within the octree
  51032. */
  51033. blocks: Array<OctreeBlock<T>>;
  51034. }
  51035. /**
  51036. * Class used to store a cell in an octree
  51037. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51038. */
  51039. export class OctreeBlock<T> {
  51040. /**
  51041. * Gets the content of the current block
  51042. */
  51043. entries: T[];
  51044. /**
  51045. * Gets the list of block children
  51046. */
  51047. blocks: Array<OctreeBlock<T>>;
  51048. private _depth;
  51049. private _maxDepth;
  51050. private _capacity;
  51051. private _minPoint;
  51052. private _maxPoint;
  51053. private _boundingVectors;
  51054. private _creationFunc;
  51055. /**
  51056. * Creates a new block
  51057. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51058. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51059. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51060. * @param depth defines the current depth of this block in the octree
  51061. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51062. * @param creationFunc defines a callback to call when an element is added to the block
  51063. */
  51064. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51065. /**
  51066. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51067. */
  51068. get capacity(): number;
  51069. /**
  51070. * Gets the minimum vector (in world space) of the block's bounding box
  51071. */
  51072. get minPoint(): Vector3;
  51073. /**
  51074. * Gets the maximum vector (in world space) of the block's bounding box
  51075. */
  51076. get maxPoint(): Vector3;
  51077. /**
  51078. * Add a new element to this block
  51079. * @param entry defines the element to add
  51080. */
  51081. addEntry(entry: T): void;
  51082. /**
  51083. * Remove an element from this block
  51084. * @param entry defines the element to remove
  51085. */
  51086. removeEntry(entry: T): void;
  51087. /**
  51088. * Add an array of elements to this block
  51089. * @param entries defines the array of elements to add
  51090. */
  51091. addEntries(entries: T[]): void;
  51092. /**
  51093. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51094. * @param frustumPlanes defines the frustum planes to test
  51095. * @param selection defines the array to store current content if selection is positive
  51096. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51097. */
  51098. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51099. /**
  51100. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51101. * @param sphereCenter defines the bounding sphere center
  51102. * @param sphereRadius defines the bounding sphere radius
  51103. * @param selection defines the array to store current content if selection is positive
  51104. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51105. */
  51106. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51107. /**
  51108. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51109. * @param ray defines the ray to test with
  51110. * @param selection defines the array to store current content if selection is positive
  51111. */
  51112. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51113. /**
  51114. * Subdivide the content into child blocks (this block will then be empty)
  51115. */
  51116. createInnerBlocks(): void;
  51117. /**
  51118. * @hidden
  51119. */
  51120. 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;
  51121. }
  51122. }
  51123. declare module "babylonjs/Culling/Octrees/octree" {
  51124. import { SmartArray } from "babylonjs/Misc/smartArray";
  51125. import { Vector3 } from "babylonjs/Maths/math.vector";
  51126. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51128. import { Ray } from "babylonjs/Culling/ray";
  51129. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51130. import { Plane } from "babylonjs/Maths/math.plane";
  51131. /**
  51132. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51133. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51134. */
  51135. export class Octree<T> {
  51136. /** 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.) */
  51137. maxDepth: number;
  51138. /**
  51139. * Blocks within the octree containing objects
  51140. */
  51141. blocks: Array<OctreeBlock<T>>;
  51142. /**
  51143. * Content stored in the octree
  51144. */
  51145. dynamicContent: T[];
  51146. private _maxBlockCapacity;
  51147. private _selectionContent;
  51148. private _creationFunc;
  51149. /**
  51150. * Creates a octree
  51151. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51152. * @param creationFunc function to be used to instatiate the octree
  51153. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51154. * @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.)
  51155. */
  51156. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51157. /** 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.) */
  51158. maxDepth?: number);
  51159. /**
  51160. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51161. * @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);
  51162. * @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);
  51163. * @param entries meshes to be added to the octree blocks
  51164. */
  51165. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51166. /**
  51167. * Adds a mesh to the octree
  51168. * @param entry Mesh to add to the octree
  51169. */
  51170. addMesh(entry: T): void;
  51171. /**
  51172. * Remove an element from the octree
  51173. * @param entry defines the element to remove
  51174. */
  51175. removeMesh(entry: T): void;
  51176. /**
  51177. * Selects an array of meshes within the frustum
  51178. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51179. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51180. * @returns array of meshes within the frustum
  51181. */
  51182. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51183. /**
  51184. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51185. * @param sphereCenter defines the bounding sphere center
  51186. * @param sphereRadius defines the bounding sphere radius
  51187. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51188. * @returns an array of objects that intersect the sphere
  51189. */
  51190. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51191. /**
  51192. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51193. * @param ray defines the ray to test with
  51194. * @returns array of intersected objects
  51195. */
  51196. intersectsRay(ray: Ray): SmartArray<T>;
  51197. /**
  51198. * Adds a mesh into the octree block if it intersects the block
  51199. */
  51200. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51201. /**
  51202. * Adds a submesh into the octree block if it intersects the block
  51203. */
  51204. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51205. }
  51206. }
  51207. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51208. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51209. import { Scene } from "babylonjs/scene";
  51210. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51212. import { Ray } from "babylonjs/Culling/ray";
  51213. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51214. import { Collider } from "babylonjs/Collisions/collider";
  51215. module "babylonjs/scene" {
  51216. interface Scene {
  51217. /**
  51218. * @hidden
  51219. * Backing Filed
  51220. */
  51221. _selectionOctree: Octree<AbstractMesh>;
  51222. /**
  51223. * Gets the octree used to boost mesh selection (picking)
  51224. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51225. */
  51226. selectionOctree: Octree<AbstractMesh>;
  51227. /**
  51228. * Creates or updates the octree used to boost selection (picking)
  51229. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51230. * @param maxCapacity defines the maximum capacity per leaf
  51231. * @param maxDepth defines the maximum depth of the octree
  51232. * @returns an octree of AbstractMesh
  51233. */
  51234. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51235. }
  51236. }
  51237. module "babylonjs/Meshes/abstractMesh" {
  51238. interface AbstractMesh {
  51239. /**
  51240. * @hidden
  51241. * Backing Field
  51242. */
  51243. _submeshesOctree: Octree<SubMesh>;
  51244. /**
  51245. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51246. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51247. * @param maxCapacity defines the maximum size of each block (64 by default)
  51248. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51249. * @returns the new octree
  51250. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51251. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51252. */
  51253. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51254. }
  51255. }
  51256. /**
  51257. * Defines the octree scene component responsible to manage any octrees
  51258. * in a given scene.
  51259. */
  51260. export class OctreeSceneComponent {
  51261. /**
  51262. * The component name help to identify the component in the list of scene components.
  51263. */
  51264. readonly name: string;
  51265. /**
  51266. * The scene the component belongs to.
  51267. */
  51268. scene: Scene;
  51269. /**
  51270. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51271. */
  51272. readonly checksIsEnabled: boolean;
  51273. /**
  51274. * Creates a new instance of the component for the given scene
  51275. * @param scene Defines the scene to register the component in
  51276. */
  51277. constructor(scene: Scene);
  51278. /**
  51279. * Registers the component in a given scene
  51280. */
  51281. register(): void;
  51282. /**
  51283. * Return the list of active meshes
  51284. * @returns the list of active meshes
  51285. */
  51286. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51287. /**
  51288. * Return the list of active sub meshes
  51289. * @param mesh The mesh to get the candidates sub meshes from
  51290. * @returns the list of active sub meshes
  51291. */
  51292. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51293. private _tempRay;
  51294. /**
  51295. * Return the list of sub meshes intersecting with a given local ray
  51296. * @param mesh defines the mesh to find the submesh for
  51297. * @param localRay defines the ray in local space
  51298. * @returns the list of intersecting sub meshes
  51299. */
  51300. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51301. /**
  51302. * Return the list of sub meshes colliding with a collider
  51303. * @param mesh defines the mesh to find the submesh for
  51304. * @param collider defines the collider to evaluate the collision against
  51305. * @returns the list of colliding sub meshes
  51306. */
  51307. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51308. /**
  51309. * Rebuilds the elements related to this component in case of
  51310. * context lost for instance.
  51311. */
  51312. rebuild(): void;
  51313. /**
  51314. * Disposes the component and the associated ressources.
  51315. */
  51316. dispose(): void;
  51317. }
  51318. }
  51319. declare module "babylonjs/Culling/Octrees/index" {
  51320. export * from "babylonjs/Culling/Octrees/octree";
  51321. export * from "babylonjs/Culling/Octrees/octreeBlock";
  51322. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  51323. }
  51324. declare module "babylonjs/Culling/index" {
  51325. export * from "babylonjs/Culling/boundingBox";
  51326. export * from "babylonjs/Culling/boundingInfo";
  51327. export * from "babylonjs/Culling/boundingSphere";
  51328. export * from "babylonjs/Culling/Octrees/index";
  51329. export * from "babylonjs/Culling/ray";
  51330. }
  51331. declare module "babylonjs/Gizmos/gizmo" {
  51332. import { Nullable } from "babylonjs/types";
  51333. import { IDisposable } from "babylonjs/scene";
  51334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51335. import { Mesh } from "babylonjs/Meshes/mesh";
  51336. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51337. /**
  51338. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  51339. */
  51340. export class Gizmo implements IDisposable {
  51341. /** The utility layer the gizmo will be added to */
  51342. gizmoLayer: UtilityLayerRenderer;
  51343. /**
  51344. * The root mesh of the gizmo
  51345. */
  51346. _rootMesh: Mesh;
  51347. private _attachedMesh;
  51348. /**
  51349. * Ratio for the scale of the gizmo (Default: 1)
  51350. */
  51351. scaleRatio: number;
  51352. /**
  51353. * If a custom mesh has been set (Default: false)
  51354. */
  51355. protected _customMeshSet: boolean;
  51356. /**
  51357. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  51358. * * When set, interactions will be enabled
  51359. */
  51360. get attachedMesh(): Nullable<AbstractMesh>;
  51361. set attachedMesh(value: Nullable<AbstractMesh>);
  51362. /**
  51363. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51364. * @param mesh The mesh to replace the default mesh of the gizmo
  51365. */
  51366. setCustomMesh(mesh: Mesh): void;
  51367. /**
  51368. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  51369. */
  51370. updateGizmoRotationToMatchAttachedMesh: boolean;
  51371. /**
  51372. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  51373. */
  51374. updateGizmoPositionToMatchAttachedMesh: boolean;
  51375. /**
  51376. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  51377. */
  51378. updateScale: boolean;
  51379. protected _interactionsEnabled: boolean;
  51380. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51381. private _beforeRenderObserver;
  51382. private _tempVector;
  51383. /**
  51384. * Creates a gizmo
  51385. * @param gizmoLayer The utility layer the gizmo will be added to
  51386. */
  51387. constructor(
  51388. /** The utility layer the gizmo will be added to */
  51389. gizmoLayer?: UtilityLayerRenderer);
  51390. /**
  51391. * Updates the gizmo to match the attached mesh's position/rotation
  51392. */
  51393. protected _update(): void;
  51394. /**
  51395. * Disposes of the gizmo
  51396. */
  51397. dispose(): void;
  51398. }
  51399. }
  51400. declare module "babylonjs/Gizmos/planeDragGizmo" {
  51401. import { Observable } from "babylonjs/Misc/observable";
  51402. import { Nullable } from "babylonjs/types";
  51403. import { Vector3 } from "babylonjs/Maths/math.vector";
  51404. import { Color3 } from "babylonjs/Maths/math.color";
  51405. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51407. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51408. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51409. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51410. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51411. import { Scene } from "babylonjs/scene";
  51412. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51413. /**
  51414. * Single plane drag gizmo
  51415. */
  51416. export class PlaneDragGizmo extends Gizmo {
  51417. /**
  51418. * Drag behavior responsible for the gizmos dragging interactions
  51419. */
  51420. dragBehavior: PointerDragBehavior;
  51421. private _pointerObserver;
  51422. /**
  51423. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51424. */
  51425. snapDistance: number;
  51426. /**
  51427. * Event that fires each time the gizmo snaps to a new location.
  51428. * * snapDistance is the the change in distance
  51429. */
  51430. onSnapObservable: Observable<{
  51431. snapDistance: number;
  51432. }>;
  51433. private _plane;
  51434. private _coloredMaterial;
  51435. private _hoverMaterial;
  51436. private _isEnabled;
  51437. private _parent;
  51438. /** @hidden */
  51439. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  51440. /** @hidden */
  51441. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51442. /**
  51443. * Creates a PlaneDragGizmo
  51444. * @param gizmoLayer The utility layer the gizmo will be added to
  51445. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  51446. * @param color The color of the gizmo
  51447. */
  51448. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51449. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51450. /**
  51451. * If the gizmo is enabled
  51452. */
  51453. set isEnabled(value: boolean);
  51454. get isEnabled(): boolean;
  51455. /**
  51456. * Disposes of the gizmo
  51457. */
  51458. dispose(): void;
  51459. }
  51460. }
  51461. declare module "babylonjs/Gizmos/positionGizmo" {
  51462. import { Observable } from "babylonjs/Misc/observable";
  51463. import { Nullable } from "babylonjs/types";
  51464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51465. import { Mesh } from "babylonjs/Meshes/mesh";
  51466. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51467. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  51468. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  51469. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51470. /**
  51471. * Gizmo that enables dragging a mesh along 3 axis
  51472. */
  51473. export class PositionGizmo extends Gizmo {
  51474. /**
  51475. * Internal gizmo used for interactions on the x axis
  51476. */
  51477. xGizmo: AxisDragGizmo;
  51478. /**
  51479. * Internal gizmo used for interactions on the y axis
  51480. */
  51481. yGizmo: AxisDragGizmo;
  51482. /**
  51483. * Internal gizmo used for interactions on the z axis
  51484. */
  51485. zGizmo: AxisDragGizmo;
  51486. /**
  51487. * Internal gizmo used for interactions on the yz plane
  51488. */
  51489. xPlaneGizmo: PlaneDragGizmo;
  51490. /**
  51491. * Internal gizmo used for interactions on the xz plane
  51492. */
  51493. yPlaneGizmo: PlaneDragGizmo;
  51494. /**
  51495. * Internal gizmo used for interactions on the xy plane
  51496. */
  51497. zPlaneGizmo: PlaneDragGizmo;
  51498. /**
  51499. * private variables
  51500. */
  51501. private _meshAttached;
  51502. private _updateGizmoRotationToMatchAttachedMesh;
  51503. private _snapDistance;
  51504. private _scaleRatio;
  51505. /** Fires an event when any of it's sub gizmos are dragged */
  51506. onDragStartObservable: Observable<unknown>;
  51507. /** Fires an event when any of it's sub gizmos are released from dragging */
  51508. onDragEndObservable: Observable<unknown>;
  51509. /**
  51510. * If set to true, planar drag is enabled
  51511. */
  51512. private _planarGizmoEnabled;
  51513. get attachedMesh(): Nullable<AbstractMesh>;
  51514. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51515. /**
  51516. * Creates a PositionGizmo
  51517. * @param gizmoLayer The utility layer the gizmo will be added to
  51518. */
  51519. constructor(gizmoLayer?: UtilityLayerRenderer);
  51520. /**
  51521. * If the planar drag gizmo is enabled
  51522. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  51523. */
  51524. set planarGizmoEnabled(value: boolean);
  51525. get planarGizmoEnabled(): boolean;
  51526. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51527. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51528. /**
  51529. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51530. */
  51531. set snapDistance(value: number);
  51532. get snapDistance(): number;
  51533. /**
  51534. * Ratio for the scale of the gizmo (Default: 1)
  51535. */
  51536. set scaleRatio(value: number);
  51537. get scaleRatio(): number;
  51538. /**
  51539. * Disposes of the gizmo
  51540. */
  51541. dispose(): void;
  51542. /**
  51543. * CustomMeshes are not supported by this gizmo
  51544. * @param mesh The mesh to replace the default mesh of the gizmo
  51545. */
  51546. setCustomMesh(mesh: Mesh): void;
  51547. }
  51548. }
  51549. declare module "babylonjs/Gizmos/axisDragGizmo" {
  51550. import { Observable } from "babylonjs/Misc/observable";
  51551. import { Nullable } from "babylonjs/types";
  51552. import { Vector3 } from "babylonjs/Maths/math.vector";
  51553. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51555. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51556. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51557. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51558. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51559. import { Scene } from "babylonjs/scene";
  51560. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51561. import { Color3 } from "babylonjs/Maths/math.color";
  51562. /**
  51563. * Single axis drag gizmo
  51564. */
  51565. export class AxisDragGizmo extends Gizmo {
  51566. /**
  51567. * Drag behavior responsible for the gizmos dragging interactions
  51568. */
  51569. dragBehavior: PointerDragBehavior;
  51570. private _pointerObserver;
  51571. /**
  51572. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51573. */
  51574. snapDistance: number;
  51575. /**
  51576. * Event that fires each time the gizmo snaps to a new location.
  51577. * * snapDistance is the the change in distance
  51578. */
  51579. onSnapObservable: Observable<{
  51580. snapDistance: number;
  51581. }>;
  51582. private _isEnabled;
  51583. private _parent;
  51584. private _arrow;
  51585. private _coloredMaterial;
  51586. private _hoverMaterial;
  51587. /** @hidden */
  51588. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51589. /** @hidden */
  51590. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51591. /**
  51592. * Creates an AxisDragGizmo
  51593. * @param gizmoLayer The utility layer the gizmo will be added to
  51594. * @param dragAxis The axis which the gizmo will be able to drag on
  51595. * @param color The color of the gizmo
  51596. */
  51597. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51598. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51599. /**
  51600. * If the gizmo is enabled
  51601. */
  51602. set isEnabled(value: boolean);
  51603. get isEnabled(): boolean;
  51604. /**
  51605. * Disposes of the gizmo
  51606. */
  51607. dispose(): void;
  51608. }
  51609. }
  51610. declare module "babylonjs/Debug/axesViewer" {
  51611. import { Vector3 } from "babylonjs/Maths/math.vector";
  51612. import { Nullable } from "babylonjs/types";
  51613. import { Scene } from "babylonjs/scene";
  51614. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51615. /**
  51616. * The Axes viewer will show 3 axes in a specific point in space
  51617. */
  51618. export class AxesViewer {
  51619. private _xAxis;
  51620. private _yAxis;
  51621. private _zAxis;
  51622. private _scaleLinesFactor;
  51623. private _instanced;
  51624. /**
  51625. * Gets the hosting scene
  51626. */
  51627. scene: Scene;
  51628. /**
  51629. * Gets or sets a number used to scale line length
  51630. */
  51631. scaleLines: number;
  51632. /** Gets the node hierarchy used to render x-axis */
  51633. get xAxis(): TransformNode;
  51634. /** Gets the node hierarchy used to render y-axis */
  51635. get yAxis(): TransformNode;
  51636. /** Gets the node hierarchy used to render z-axis */
  51637. get zAxis(): TransformNode;
  51638. /**
  51639. * Creates a new AxesViewer
  51640. * @param scene defines the hosting scene
  51641. * @param scaleLines defines a number used to scale line length (1 by default)
  51642. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51643. * @param xAxis defines the node hierarchy used to render the x-axis
  51644. * @param yAxis defines the node hierarchy used to render the y-axis
  51645. * @param zAxis defines the node hierarchy used to render the z-axis
  51646. */
  51647. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51648. /**
  51649. * Force the viewer to update
  51650. * @param position defines the position of the viewer
  51651. * @param xaxis defines the x axis of the viewer
  51652. * @param yaxis defines the y axis of the viewer
  51653. * @param zaxis defines the z axis of the viewer
  51654. */
  51655. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51656. /**
  51657. * Creates an instance of this axes viewer.
  51658. * @returns a new axes viewer with instanced meshes
  51659. */
  51660. createInstance(): AxesViewer;
  51661. /** Releases resources */
  51662. dispose(): void;
  51663. private static _SetRenderingGroupId;
  51664. }
  51665. }
  51666. declare module "babylonjs/Debug/boneAxesViewer" {
  51667. import { Nullable } from "babylonjs/types";
  51668. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51669. import { Vector3 } from "babylonjs/Maths/math.vector";
  51670. import { Mesh } from "babylonjs/Meshes/mesh";
  51671. import { Bone } from "babylonjs/Bones/bone";
  51672. import { Scene } from "babylonjs/scene";
  51673. /**
  51674. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51675. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51676. */
  51677. export class BoneAxesViewer extends AxesViewer {
  51678. /**
  51679. * Gets or sets the target mesh where to display the axes viewer
  51680. */
  51681. mesh: Nullable<Mesh>;
  51682. /**
  51683. * Gets or sets the target bone where to display the axes viewer
  51684. */
  51685. bone: Nullable<Bone>;
  51686. /** Gets current position */
  51687. pos: Vector3;
  51688. /** Gets direction of X axis */
  51689. xaxis: Vector3;
  51690. /** Gets direction of Y axis */
  51691. yaxis: Vector3;
  51692. /** Gets direction of Z axis */
  51693. zaxis: Vector3;
  51694. /**
  51695. * Creates a new BoneAxesViewer
  51696. * @param scene defines the hosting scene
  51697. * @param bone defines the target bone
  51698. * @param mesh defines the target mesh
  51699. * @param scaleLines defines a scaling factor for line length (1 by default)
  51700. */
  51701. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51702. /**
  51703. * Force the viewer to update
  51704. */
  51705. update(): void;
  51706. /** Releases resources */
  51707. dispose(): void;
  51708. }
  51709. }
  51710. declare module "babylonjs/Debug/debugLayer" {
  51711. import { Scene } from "babylonjs/scene";
  51712. /**
  51713. * Interface used to define scene explorer extensibility option
  51714. */
  51715. export interface IExplorerExtensibilityOption {
  51716. /**
  51717. * Define the option label
  51718. */
  51719. label: string;
  51720. /**
  51721. * Defines the action to execute on click
  51722. */
  51723. action: (entity: any) => void;
  51724. }
  51725. /**
  51726. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51727. */
  51728. export interface IExplorerExtensibilityGroup {
  51729. /**
  51730. * Defines a predicate to test if a given type mut be extended
  51731. */
  51732. predicate: (entity: any) => boolean;
  51733. /**
  51734. * Gets the list of options added to a type
  51735. */
  51736. entries: IExplorerExtensibilityOption[];
  51737. }
  51738. /**
  51739. * Interface used to define the options to use to create the Inspector
  51740. */
  51741. export interface IInspectorOptions {
  51742. /**
  51743. * Display in overlay mode (default: false)
  51744. */
  51745. overlay?: boolean;
  51746. /**
  51747. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51748. */
  51749. globalRoot?: HTMLElement;
  51750. /**
  51751. * Display the Scene explorer
  51752. */
  51753. showExplorer?: boolean;
  51754. /**
  51755. * Display the property inspector
  51756. */
  51757. showInspector?: boolean;
  51758. /**
  51759. * Display in embed mode (both panes on the right)
  51760. */
  51761. embedMode?: boolean;
  51762. /**
  51763. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51764. */
  51765. handleResize?: boolean;
  51766. /**
  51767. * Allow the panes to popup (default: true)
  51768. */
  51769. enablePopup?: boolean;
  51770. /**
  51771. * Allow the panes to be closed by users (default: true)
  51772. */
  51773. enableClose?: boolean;
  51774. /**
  51775. * Optional list of extensibility entries
  51776. */
  51777. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51778. /**
  51779. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51780. */
  51781. inspectorURL?: string;
  51782. /**
  51783. * Optional initial tab (default to DebugLayerTab.Properties)
  51784. */
  51785. initialTab?: DebugLayerTab;
  51786. }
  51787. module "babylonjs/scene" {
  51788. interface Scene {
  51789. /**
  51790. * @hidden
  51791. * Backing field
  51792. */
  51793. _debugLayer: DebugLayer;
  51794. /**
  51795. * Gets the debug layer (aka Inspector) associated with the scene
  51796. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51797. */
  51798. debugLayer: DebugLayer;
  51799. }
  51800. }
  51801. /**
  51802. * Enum of inspector action tab
  51803. */
  51804. export enum DebugLayerTab {
  51805. /**
  51806. * Properties tag (default)
  51807. */
  51808. Properties = 0,
  51809. /**
  51810. * Debug tab
  51811. */
  51812. Debug = 1,
  51813. /**
  51814. * Statistics tab
  51815. */
  51816. Statistics = 2,
  51817. /**
  51818. * Tools tab
  51819. */
  51820. Tools = 3,
  51821. /**
  51822. * Settings tab
  51823. */
  51824. Settings = 4
  51825. }
  51826. /**
  51827. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51828. * what is happening in your scene
  51829. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51830. */
  51831. export class DebugLayer {
  51832. /**
  51833. * Define the url to get the inspector script from.
  51834. * By default it uses the babylonjs CDN.
  51835. * @ignoreNaming
  51836. */
  51837. static InspectorURL: string;
  51838. private _scene;
  51839. private BJSINSPECTOR;
  51840. private _onPropertyChangedObservable?;
  51841. /**
  51842. * Observable triggered when a property is changed through the inspector.
  51843. */
  51844. get onPropertyChangedObservable(): any;
  51845. /**
  51846. * Instantiates a new debug layer.
  51847. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51848. * what is happening in your scene
  51849. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51850. * @param scene Defines the scene to inspect
  51851. */
  51852. constructor(scene: Scene);
  51853. /** Creates the inspector window. */
  51854. private _createInspector;
  51855. /**
  51856. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51857. * @param entity defines the entity to select
  51858. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51859. */
  51860. select(entity: any, lineContainerTitles?: string | string[]): void;
  51861. /** Get the inspector from bundle or global */
  51862. private _getGlobalInspector;
  51863. /**
  51864. * Get if the inspector is visible or not.
  51865. * @returns true if visible otherwise, false
  51866. */
  51867. isVisible(): boolean;
  51868. /**
  51869. * Hide the inspector and close its window.
  51870. */
  51871. hide(): void;
  51872. /**
  51873. * Update the scene in the inspector
  51874. */
  51875. setAsActiveScene(): void;
  51876. /**
  51877. * Launch the debugLayer.
  51878. * @param config Define the configuration of the inspector
  51879. * @return a promise fulfilled when the debug layer is visible
  51880. */
  51881. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51882. }
  51883. }
  51884. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51885. import { Nullable } from "babylonjs/types";
  51886. import { Scene } from "babylonjs/scene";
  51887. import { Vector4 } from "babylonjs/Maths/math.vector";
  51888. import { Color4 } from "babylonjs/Maths/math.color";
  51889. import { Mesh } from "babylonjs/Meshes/mesh";
  51890. /**
  51891. * Class containing static functions to help procedurally build meshes
  51892. */
  51893. export class BoxBuilder {
  51894. /**
  51895. * Creates a box mesh
  51896. * * The parameter `size` sets the size (float) of each box side (default 1)
  51897. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51898. * * 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)
  51899. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51903. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51904. * @param name defines the name of the mesh
  51905. * @param options defines the options used to create the mesh
  51906. * @param scene defines the hosting scene
  51907. * @returns the box mesh
  51908. */
  51909. static CreateBox(name: string, options: {
  51910. size?: number;
  51911. width?: number;
  51912. height?: number;
  51913. depth?: number;
  51914. faceUV?: Vector4[];
  51915. faceColors?: Color4[];
  51916. sideOrientation?: number;
  51917. frontUVs?: Vector4;
  51918. backUVs?: Vector4;
  51919. wrap?: boolean;
  51920. topBaseAt?: number;
  51921. bottomBaseAt?: number;
  51922. updatable?: boolean;
  51923. }, scene?: Nullable<Scene>): Mesh;
  51924. }
  51925. }
  51926. declare module "babylonjs/Debug/physicsViewer" {
  51927. import { Nullable } from "babylonjs/types";
  51928. import { Scene } from "babylonjs/scene";
  51929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51930. import { Mesh } from "babylonjs/Meshes/mesh";
  51931. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51932. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51933. /**
  51934. * Used to show the physics impostor around the specific mesh
  51935. */
  51936. export class PhysicsViewer {
  51937. /** @hidden */
  51938. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51939. /** @hidden */
  51940. protected _meshes: Array<Nullable<AbstractMesh>>;
  51941. /** @hidden */
  51942. protected _scene: Nullable<Scene>;
  51943. /** @hidden */
  51944. protected _numMeshes: number;
  51945. /** @hidden */
  51946. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51947. private _renderFunction;
  51948. private _utilityLayer;
  51949. private _debugBoxMesh;
  51950. private _debugSphereMesh;
  51951. private _debugCylinderMesh;
  51952. private _debugMaterial;
  51953. private _debugMeshMeshes;
  51954. /**
  51955. * Creates a new PhysicsViewer
  51956. * @param scene defines the hosting scene
  51957. */
  51958. constructor(scene: Scene);
  51959. /** @hidden */
  51960. protected _updateDebugMeshes(): void;
  51961. /**
  51962. * Renders a specified physic impostor
  51963. * @param impostor defines the impostor to render
  51964. * @param targetMesh defines the mesh represented by the impostor
  51965. * @returns the new debug mesh used to render the impostor
  51966. */
  51967. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51968. /**
  51969. * Hides a specified physic impostor
  51970. * @param impostor defines the impostor to hide
  51971. */
  51972. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51973. private _getDebugMaterial;
  51974. private _getDebugBoxMesh;
  51975. private _getDebugSphereMesh;
  51976. private _getDebugCylinderMesh;
  51977. private _getDebugMeshMesh;
  51978. private _getDebugMesh;
  51979. /** Releases all resources */
  51980. dispose(): void;
  51981. }
  51982. }
  51983. declare module "babylonjs/Debug/rayHelper" {
  51984. import { Nullable } from "babylonjs/types";
  51985. import { Ray } from "babylonjs/Culling/ray";
  51986. import { Vector3 } from "babylonjs/Maths/math.vector";
  51987. import { Color3 } from "babylonjs/Maths/math.color";
  51988. import { Scene } from "babylonjs/scene";
  51989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51990. import "babylonjs/Meshes/Builders/linesBuilder";
  51991. /**
  51992. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51993. * in order to better appreciate the issue one might have.
  51994. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51995. */
  51996. export class RayHelper {
  51997. /**
  51998. * Defines the ray we are currently tryin to visualize.
  51999. */
  52000. ray: Nullable<Ray>;
  52001. private _renderPoints;
  52002. private _renderLine;
  52003. private _renderFunction;
  52004. private _scene;
  52005. private _updateToMeshFunction;
  52006. private _attachedToMesh;
  52007. private _meshSpaceDirection;
  52008. private _meshSpaceOrigin;
  52009. /**
  52010. * Helper function to create a colored helper in a scene in one line.
  52011. * @param ray Defines the ray we are currently tryin to visualize
  52012. * @param scene Defines the scene the ray is used in
  52013. * @param color Defines the color we want to see the ray in
  52014. * @returns The newly created ray helper.
  52015. */
  52016. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52017. /**
  52018. * Instantiate a new ray helper.
  52019. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52020. * in order to better appreciate the issue one might have.
  52021. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52022. * @param ray Defines the ray we are currently tryin to visualize
  52023. */
  52024. constructor(ray: Ray);
  52025. /**
  52026. * Shows the ray we are willing to debug.
  52027. * @param scene Defines the scene the ray needs to be rendered in
  52028. * @param color Defines the color the ray needs to be rendered in
  52029. */
  52030. show(scene: Scene, color?: Color3): void;
  52031. /**
  52032. * Hides the ray we are debugging.
  52033. */
  52034. hide(): void;
  52035. private _render;
  52036. /**
  52037. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52038. * @param mesh Defines the mesh we want the helper attached to
  52039. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52040. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52041. * @param length Defines the length of the ray
  52042. */
  52043. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52044. /**
  52045. * Detach the ray helper from the mesh it has previously been attached to.
  52046. */
  52047. detachFromMesh(): void;
  52048. private _updateToMesh;
  52049. /**
  52050. * Dispose the helper and release its associated resources.
  52051. */
  52052. dispose(): void;
  52053. }
  52054. }
  52055. declare module "babylonjs/Debug/skeletonViewer" {
  52056. import { Color3 } from "babylonjs/Maths/math.color";
  52057. import { Scene } from "babylonjs/scene";
  52058. import { Nullable } from "babylonjs/types";
  52059. import { Skeleton } from "babylonjs/Bones/skeleton";
  52060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52061. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52062. /**
  52063. * Class used to render a debug view of a given skeleton
  52064. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  52065. */
  52066. export class SkeletonViewer {
  52067. /** defines the skeleton to render */
  52068. skeleton: Skeleton;
  52069. /** defines the mesh attached to the skeleton */
  52070. mesh: AbstractMesh;
  52071. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52072. autoUpdateBonesMatrices: boolean;
  52073. /** defines the rendering group id to use with the viewer */
  52074. renderingGroupId: number;
  52075. /** Gets or sets the color used to render the skeleton */
  52076. color: Color3;
  52077. private _scene;
  52078. private _debugLines;
  52079. private _debugMesh;
  52080. private _isEnabled;
  52081. private _renderFunction;
  52082. private _utilityLayer;
  52083. /**
  52084. * Returns the mesh used to render the bones
  52085. */
  52086. get debugMesh(): Nullable<LinesMesh>;
  52087. /**
  52088. * Creates a new SkeletonViewer
  52089. * @param skeleton defines the skeleton to render
  52090. * @param mesh defines the mesh attached to the skeleton
  52091. * @param scene defines the hosting scene
  52092. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  52093. * @param renderingGroupId defines the rendering group id to use with the viewer
  52094. */
  52095. constructor(
  52096. /** defines the skeleton to render */
  52097. skeleton: Skeleton,
  52098. /** defines the mesh attached to the skeleton */
  52099. mesh: AbstractMesh, scene: Scene,
  52100. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52101. autoUpdateBonesMatrices?: boolean,
  52102. /** defines the rendering group id to use with the viewer */
  52103. renderingGroupId?: number);
  52104. /** Gets or sets a boolean indicating if the viewer is enabled */
  52105. set isEnabled(value: boolean);
  52106. get isEnabled(): boolean;
  52107. private _getBonePosition;
  52108. private _getLinesForBonesWithLength;
  52109. private _getLinesForBonesNoLength;
  52110. /** Update the viewer to sync with current skeleton state */
  52111. update(): void;
  52112. /** Release associated resources */
  52113. dispose(): void;
  52114. }
  52115. }
  52116. declare module "babylonjs/Debug/index" {
  52117. export * from "babylonjs/Debug/axesViewer";
  52118. export * from "babylonjs/Debug/boneAxesViewer";
  52119. export * from "babylonjs/Debug/debugLayer";
  52120. export * from "babylonjs/Debug/physicsViewer";
  52121. export * from "babylonjs/Debug/rayHelper";
  52122. export * from "babylonjs/Debug/skeletonViewer";
  52123. }
  52124. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  52125. /**
  52126. * Enum for Device Types
  52127. */
  52128. export enum DeviceType {
  52129. /** Generic */
  52130. Generic = 0,
  52131. /** Keyboard */
  52132. Keyboard = 1,
  52133. /** Mouse */
  52134. Mouse = 2,
  52135. /** Touch Pointers */
  52136. Touch = 3,
  52137. /** PS4 Dual Shock */
  52138. DualShock = 4,
  52139. /** Xbox */
  52140. Xbox = 5,
  52141. /** Switch Controller */
  52142. Switch = 6
  52143. }
  52144. /**
  52145. * Enum for All Pointers (Touch/Mouse)
  52146. */
  52147. export enum PointerInput {
  52148. /** Horizontal Axis */
  52149. Horizontal = 0,
  52150. /** Vertical Axis */
  52151. Vertical = 1,
  52152. /** Left Click or Touch */
  52153. LeftClick = 2,
  52154. /** Middle Click */
  52155. MiddleClick = 3,
  52156. /** Right Click */
  52157. RightClick = 4,
  52158. /** Browser Back */
  52159. BrowserBack = 5,
  52160. /** Browser Forward */
  52161. BrowserForward = 6
  52162. }
  52163. /**
  52164. * Enum for Dual Shock Gamepad
  52165. */
  52166. export enum DualShockInput {
  52167. /** Cross */
  52168. Cross = 0,
  52169. /** Circle */
  52170. Circle = 1,
  52171. /** Square */
  52172. Square = 2,
  52173. /** Triangle */
  52174. Triangle = 3,
  52175. /** L1 */
  52176. L1 = 4,
  52177. /** R1 */
  52178. R1 = 5,
  52179. /** L2 */
  52180. L2 = 6,
  52181. /** R2 */
  52182. R2 = 7,
  52183. /** Share */
  52184. Share = 8,
  52185. /** Options */
  52186. Options = 9,
  52187. /** L3 */
  52188. L3 = 10,
  52189. /** R3 */
  52190. R3 = 11,
  52191. /** DPadUp */
  52192. DPadUp = 12,
  52193. /** DPadDown */
  52194. DPadDown = 13,
  52195. /** DPadLeft */
  52196. DPadLeft = 14,
  52197. /** DRight */
  52198. DPadRight = 15,
  52199. /** Home */
  52200. Home = 16,
  52201. /** TouchPad */
  52202. TouchPad = 17,
  52203. /** LStickXAxis */
  52204. LStickXAxis = 18,
  52205. /** LStickYAxis */
  52206. LStickYAxis = 19,
  52207. /** RStickXAxis */
  52208. RStickXAxis = 20,
  52209. /** RStickYAxis */
  52210. RStickYAxis = 21
  52211. }
  52212. /**
  52213. * Enum for Xbox Gamepad
  52214. */
  52215. export enum XboxInput {
  52216. /** A */
  52217. A = 0,
  52218. /** B */
  52219. B = 1,
  52220. /** X */
  52221. X = 2,
  52222. /** Y */
  52223. Y = 3,
  52224. /** LB */
  52225. LB = 4,
  52226. /** RB */
  52227. RB = 5,
  52228. /** LT */
  52229. LT = 6,
  52230. /** RT */
  52231. RT = 7,
  52232. /** Back */
  52233. Back = 8,
  52234. /** Start */
  52235. Start = 9,
  52236. /** LS */
  52237. LS = 10,
  52238. /** RS */
  52239. RS = 11,
  52240. /** DPadUp */
  52241. DPadUp = 12,
  52242. /** DPadDown */
  52243. DPadDown = 13,
  52244. /** DPadLeft */
  52245. DPadLeft = 14,
  52246. /** DRight */
  52247. DPadRight = 15,
  52248. /** Home */
  52249. Home = 16,
  52250. /** LStickXAxis */
  52251. LStickXAxis = 17,
  52252. /** LStickYAxis */
  52253. LStickYAxis = 18,
  52254. /** RStickXAxis */
  52255. RStickXAxis = 19,
  52256. /** RStickYAxis */
  52257. RStickYAxis = 20
  52258. }
  52259. /**
  52260. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  52261. */
  52262. export enum SwitchInput {
  52263. /** B */
  52264. B = 0,
  52265. /** A */
  52266. A = 1,
  52267. /** Y */
  52268. Y = 2,
  52269. /** X */
  52270. X = 3,
  52271. /** L */
  52272. L = 4,
  52273. /** R */
  52274. R = 5,
  52275. /** ZL */
  52276. ZL = 6,
  52277. /** ZR */
  52278. ZR = 7,
  52279. /** Minus */
  52280. Minus = 8,
  52281. /** Plus */
  52282. Plus = 9,
  52283. /** LS */
  52284. LS = 10,
  52285. /** RS */
  52286. RS = 11,
  52287. /** DPadUp */
  52288. DPadUp = 12,
  52289. /** DPadDown */
  52290. DPadDown = 13,
  52291. /** DPadLeft */
  52292. DPadLeft = 14,
  52293. /** DRight */
  52294. DPadRight = 15,
  52295. /** Home */
  52296. Home = 16,
  52297. /** Capture */
  52298. Capture = 17,
  52299. /** LStickXAxis */
  52300. LStickXAxis = 18,
  52301. /** LStickYAxis */
  52302. LStickYAxis = 19,
  52303. /** RStickXAxis */
  52304. RStickXAxis = 20,
  52305. /** RStickYAxis */
  52306. RStickYAxis = 21
  52307. }
  52308. }
  52309. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  52310. import { Engine } from "babylonjs/Engines/engine";
  52311. import { IDisposable } from "babylonjs/scene";
  52312. import { Nullable } from "babylonjs/types";
  52313. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52314. /**
  52315. * This class will take all inputs from Keyboard, Pointer, and
  52316. * any Gamepads and provide a polling system that all devices
  52317. * will use. This class assumes that there will only be one
  52318. * pointer device and one keyboard.
  52319. */
  52320. export class DeviceInputSystem implements IDisposable {
  52321. /**
  52322. * Callback to be triggered when a device is connected
  52323. */
  52324. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52325. /**
  52326. * Callback to be triggered when a device is disconnected
  52327. */
  52328. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52329. /**
  52330. * Callback to be triggered when event driven input is updated
  52331. */
  52332. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  52333. private _inputs;
  52334. private _gamepads;
  52335. private _keyboardActive;
  52336. private _pointerActive;
  52337. private _elementToAttachTo;
  52338. private _keyboardDownEvent;
  52339. private _keyboardUpEvent;
  52340. private _pointerMoveEvent;
  52341. private _pointerDownEvent;
  52342. private _pointerUpEvent;
  52343. private _gamepadConnectedEvent;
  52344. private _gamepadDisconnectedEvent;
  52345. private static _MAX_KEYCODES;
  52346. private static _MAX_POINTER_INPUTS;
  52347. private constructor();
  52348. /**
  52349. * Creates a new DeviceInputSystem instance
  52350. * @param engine Engine to pull input element from
  52351. * @returns The new instance
  52352. */
  52353. static Create(engine: Engine): DeviceInputSystem;
  52354. /**
  52355. * Checks for current device input value, given an id and input index
  52356. * @param deviceName Id of connected device
  52357. * @param inputIndex Index of device input
  52358. * @returns Current value of input
  52359. */
  52360. /**
  52361. * Checks for current device input value, given an id and input index
  52362. * @param deviceType Enum specifiying device type
  52363. * @param deviceSlot "Slot" or index that device is referenced in
  52364. * @param inputIndex Id of input to be checked
  52365. * @returns Current value of input
  52366. */
  52367. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  52368. /**
  52369. * Dispose of all the eventlisteners
  52370. */
  52371. dispose(): void;
  52372. /**
  52373. * Add device and inputs to device array
  52374. * @param deviceType Enum specifiying device type
  52375. * @param deviceSlot "Slot" or index that device is referenced in
  52376. * @param numberOfInputs Number of input entries to create for given device
  52377. */
  52378. private _registerDevice;
  52379. /**
  52380. * Given a specific device name, remove that device from the device map
  52381. * @param deviceType Enum specifiying device type
  52382. * @param deviceSlot "Slot" or index that device is referenced in
  52383. */
  52384. private _unregisterDevice;
  52385. /**
  52386. * Handle all actions that come from keyboard interaction
  52387. */
  52388. private _handleKeyActions;
  52389. /**
  52390. * Handle all actions that come from pointer interaction
  52391. */
  52392. private _handlePointerActions;
  52393. /**
  52394. * Handle all actions that come from gamepad interaction
  52395. */
  52396. private _handleGamepadActions;
  52397. /**
  52398. * Update all non-event based devices with each frame
  52399. * @param deviceType Enum specifiying device type
  52400. * @param deviceSlot "Slot" or index that device is referenced in
  52401. * @param inputIndex Id of input to be checked
  52402. */
  52403. private _updateDevice;
  52404. /**
  52405. * Gets DeviceType from the device name
  52406. * @param deviceName Name of Device from DeviceInputSystem
  52407. * @returns DeviceType enum value
  52408. */
  52409. private _getGamepadDeviceType;
  52410. }
  52411. }
  52412. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  52413. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52414. /**
  52415. * Type to handle enforcement of inputs
  52416. */
  52417. 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;
  52418. }
  52419. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  52420. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  52421. import { Engine } from "babylonjs/Engines/engine";
  52422. import { IDisposable } from "babylonjs/scene";
  52423. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52424. import { Nullable } from "babylonjs/types";
  52425. import { Observable } from "babylonjs/Misc/observable";
  52426. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52427. /**
  52428. * Class that handles all input for a specific device
  52429. */
  52430. export class DeviceSource<T extends DeviceType> {
  52431. /** Type of device */
  52432. readonly deviceType: DeviceType;
  52433. /** "Slot" or index that device is referenced in */
  52434. readonly deviceSlot: number;
  52435. /**
  52436. * Observable to handle device input changes per device
  52437. */
  52438. readonly onInputChangedObservable: Observable<{
  52439. inputIndex: DeviceInput<T>;
  52440. previousState: Nullable<number>;
  52441. currentState: Nullable<number>;
  52442. }>;
  52443. private readonly _deviceInputSystem;
  52444. /**
  52445. * Default Constructor
  52446. * @param deviceInputSystem Reference to DeviceInputSystem
  52447. * @param deviceType Type of device
  52448. * @param deviceSlot "Slot" or index that device is referenced in
  52449. */
  52450. constructor(deviceInputSystem: DeviceInputSystem,
  52451. /** Type of device */
  52452. deviceType: DeviceType,
  52453. /** "Slot" or index that device is referenced in */
  52454. deviceSlot?: number);
  52455. /**
  52456. * Get input for specific input
  52457. * @param inputIndex index of specific input on device
  52458. * @returns Input value from DeviceInputSystem
  52459. */
  52460. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  52461. }
  52462. /**
  52463. * Class to keep track of devices
  52464. */
  52465. export class DeviceSourceManager implements IDisposable {
  52466. /**
  52467. * Observable to be triggered when before a device is connected
  52468. */
  52469. readonly onBeforeDeviceConnectedObservable: Observable<{
  52470. deviceType: DeviceType;
  52471. deviceSlot: number;
  52472. }>;
  52473. /**
  52474. * Observable to be triggered when before a device is disconnected
  52475. */
  52476. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  52477. deviceType: DeviceType;
  52478. deviceSlot: number;
  52479. }>;
  52480. /**
  52481. * Observable to be triggered when after a device is connected
  52482. */
  52483. readonly onAfterDeviceConnectedObservable: Observable<{
  52484. deviceType: DeviceType;
  52485. deviceSlot: number;
  52486. }>;
  52487. /**
  52488. * Observable to be triggered when after a device is disconnected
  52489. */
  52490. readonly onAfterDeviceDisconnectedObservable: Observable<{
  52491. deviceType: DeviceType;
  52492. deviceSlot: number;
  52493. }>;
  52494. private readonly _devices;
  52495. private readonly _firstDevice;
  52496. private readonly _deviceInputSystem;
  52497. /**
  52498. * Default Constructor
  52499. * @param engine engine to pull input element from
  52500. */
  52501. constructor(engine: Engine);
  52502. /**
  52503. * Gets a DeviceSource, given a type and slot
  52504. * @param deviceType Enum specifying device type
  52505. * @param deviceSlot "Slot" or index that device is referenced in
  52506. * @returns DeviceSource object
  52507. */
  52508. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  52509. /**
  52510. * Gets an array of DeviceSource objects for a given device type
  52511. * @param deviceType Enum specifying device type
  52512. * @returns Array of DeviceSource objects
  52513. */
  52514. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  52515. /**
  52516. * Dispose of DeviceInputSystem and other parts
  52517. */
  52518. dispose(): void;
  52519. /**
  52520. * Function to add device name to device list
  52521. * @param deviceType Enum specifying device type
  52522. * @param deviceSlot "Slot" or index that device is referenced in
  52523. */
  52524. private _addDevice;
  52525. /**
  52526. * Function to remove device name to device list
  52527. * @param deviceType Enum specifying device type
  52528. * @param deviceSlot "Slot" or index that device is referenced in
  52529. */
  52530. private _removeDevice;
  52531. /**
  52532. * Updates array storing first connected device of each type
  52533. * @param type Type of Device
  52534. */
  52535. private _updateFirstDevices;
  52536. }
  52537. }
  52538. declare module "babylonjs/DeviceInput/index" {
  52539. export * from "babylonjs/DeviceInput/deviceInputSystem";
  52540. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52541. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52542. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52543. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52544. }
  52545. declare module "babylonjs/Engines/nullEngine" {
  52546. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  52547. import { Engine } from "babylonjs/Engines/engine";
  52548. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  52549. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  52550. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52551. import { Effect } from "babylonjs/Materials/effect";
  52552. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  52553. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52554. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  52555. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  52556. /**
  52557. * Options to create the null engine
  52558. */
  52559. export class NullEngineOptions {
  52560. /**
  52561. * Render width (Default: 512)
  52562. */
  52563. renderWidth: number;
  52564. /**
  52565. * Render height (Default: 256)
  52566. */
  52567. renderHeight: number;
  52568. /**
  52569. * Texture size (Default: 512)
  52570. */
  52571. textureSize: number;
  52572. /**
  52573. * If delta time between frames should be constant
  52574. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52575. */
  52576. deterministicLockstep: boolean;
  52577. /**
  52578. * Maximum about of steps between frames (Default: 4)
  52579. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52580. */
  52581. lockstepMaxSteps: number;
  52582. }
  52583. /**
  52584. * The null engine class provides support for headless version of babylon.js.
  52585. * This can be used in server side scenario or for testing purposes
  52586. */
  52587. export class NullEngine extends Engine {
  52588. private _options;
  52589. /**
  52590. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52591. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52592. * @returns true if engine is in deterministic lock step mode
  52593. */
  52594. isDeterministicLockStep(): boolean;
  52595. /**
  52596. * Gets the max steps when engine is running in deterministic lock step
  52597. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52598. * @returns the max steps
  52599. */
  52600. getLockstepMaxSteps(): number;
  52601. /**
  52602. * Gets the current hardware scaling level.
  52603. * By default the hardware scaling level is computed from the window device ratio.
  52604. * 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.
  52605. * @returns a number indicating the current hardware scaling level
  52606. */
  52607. getHardwareScalingLevel(): number;
  52608. constructor(options?: NullEngineOptions);
  52609. /**
  52610. * Creates a vertex buffer
  52611. * @param vertices the data for the vertex buffer
  52612. * @returns the new WebGL static buffer
  52613. */
  52614. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52615. /**
  52616. * Creates a new index buffer
  52617. * @param indices defines the content of the index buffer
  52618. * @param updatable defines if the index buffer must be updatable
  52619. * @returns a new webGL buffer
  52620. */
  52621. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52622. /**
  52623. * Clear the current render buffer or the current render target (if any is set up)
  52624. * @param color defines the color to use
  52625. * @param backBuffer defines if the back buffer must be cleared
  52626. * @param depth defines if the depth buffer must be cleared
  52627. * @param stencil defines if the stencil buffer must be cleared
  52628. */
  52629. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52630. /**
  52631. * Gets the current render width
  52632. * @param useScreen defines if screen size must be used (or the current render target if any)
  52633. * @returns a number defining the current render width
  52634. */
  52635. getRenderWidth(useScreen?: boolean): number;
  52636. /**
  52637. * Gets the current render height
  52638. * @param useScreen defines if screen size must be used (or the current render target if any)
  52639. * @returns a number defining the current render height
  52640. */
  52641. getRenderHeight(useScreen?: boolean): number;
  52642. /**
  52643. * Set the WebGL's viewport
  52644. * @param viewport defines the viewport element to be used
  52645. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52646. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52647. */
  52648. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52649. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52650. /**
  52651. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52652. * @param pipelineContext defines the pipeline context to use
  52653. * @param uniformsNames defines the list of uniform names
  52654. * @returns an array of webGL uniform locations
  52655. */
  52656. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52657. /**
  52658. * Gets the lsit of active attributes for a given webGL program
  52659. * @param pipelineContext defines the pipeline context to use
  52660. * @param attributesNames defines the list of attribute names to get
  52661. * @returns an array of indices indicating the offset of each attribute
  52662. */
  52663. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52664. /**
  52665. * Binds an effect to the webGL context
  52666. * @param effect defines the effect to bind
  52667. */
  52668. bindSamplers(effect: Effect): void;
  52669. /**
  52670. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52671. * @param effect defines the effect to activate
  52672. */
  52673. enableEffect(effect: Effect): void;
  52674. /**
  52675. * Set various states to the webGL context
  52676. * @param culling defines backface culling state
  52677. * @param zOffset defines the value to apply to zOffset (0 by default)
  52678. * @param force defines if states must be applied even if cache is up to date
  52679. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52680. */
  52681. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52682. /**
  52683. * Set the value of an uniform to an array of int32
  52684. * @param uniform defines the webGL uniform location where to store the value
  52685. * @param array defines the array of int32 to store
  52686. */
  52687. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52688. /**
  52689. * Set the value of an uniform to an array of int32 (stored as vec2)
  52690. * @param uniform defines the webGL uniform location where to store the value
  52691. * @param array defines the array of int32 to store
  52692. */
  52693. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52694. /**
  52695. * Set the value of an uniform to an array of int32 (stored as vec3)
  52696. * @param uniform defines the webGL uniform location where to store the value
  52697. * @param array defines the array of int32 to store
  52698. */
  52699. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52700. /**
  52701. * Set the value of an uniform to an array of int32 (stored as vec4)
  52702. * @param uniform defines the webGL uniform location where to store the value
  52703. * @param array defines the array of int32 to store
  52704. */
  52705. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52706. /**
  52707. * Set the value of an uniform to an array of float32
  52708. * @param uniform defines the webGL uniform location where to store the value
  52709. * @param array defines the array of float32 to store
  52710. */
  52711. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52712. /**
  52713. * Set the value of an uniform to an array of float32 (stored as vec2)
  52714. * @param uniform defines the webGL uniform location where to store the value
  52715. * @param array defines the array of float32 to store
  52716. */
  52717. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52718. /**
  52719. * Set the value of an uniform to an array of float32 (stored as vec3)
  52720. * @param uniform defines the webGL uniform location where to store the value
  52721. * @param array defines the array of float32 to store
  52722. */
  52723. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52724. /**
  52725. * Set the value of an uniform to an array of float32 (stored as vec4)
  52726. * @param uniform defines the webGL uniform location where to store the value
  52727. * @param array defines the array of float32 to store
  52728. */
  52729. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52730. /**
  52731. * Set the value of an uniform to an array of number
  52732. * @param uniform defines the webGL uniform location where to store the value
  52733. * @param array defines the array of number to store
  52734. */
  52735. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52736. /**
  52737. * Set the value of an uniform to an array of number (stored as vec2)
  52738. * @param uniform defines the webGL uniform location where to store the value
  52739. * @param array defines the array of number to store
  52740. */
  52741. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52742. /**
  52743. * Set the value of an uniform to an array of number (stored as vec3)
  52744. * @param uniform defines the webGL uniform location where to store the value
  52745. * @param array defines the array of number to store
  52746. */
  52747. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52748. /**
  52749. * Set the value of an uniform to an array of number (stored as vec4)
  52750. * @param uniform defines the webGL uniform location where to store the value
  52751. * @param array defines the array of number to store
  52752. */
  52753. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52754. /**
  52755. * Set the value of an uniform to an array of float32 (stored as matrices)
  52756. * @param uniform defines the webGL uniform location where to store the value
  52757. * @param matrices defines the array of float32 to store
  52758. */
  52759. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52760. /**
  52761. * Set the value of an uniform to a matrix (3x3)
  52762. * @param uniform defines the webGL uniform location where to store the value
  52763. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52764. */
  52765. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52766. /**
  52767. * Set the value of an uniform to a matrix (2x2)
  52768. * @param uniform defines the webGL uniform location where to store the value
  52769. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52770. */
  52771. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52772. /**
  52773. * Set the value of an uniform to a number (float)
  52774. * @param uniform defines the webGL uniform location where to store the value
  52775. * @param value defines the float number to store
  52776. */
  52777. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52778. /**
  52779. * Set the value of an uniform to a vec2
  52780. * @param uniform defines the webGL uniform location where to store the value
  52781. * @param x defines the 1st component of the value
  52782. * @param y defines the 2nd component of the value
  52783. */
  52784. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52785. /**
  52786. * Set the value of an uniform to a vec3
  52787. * @param uniform defines the webGL uniform location where to store the value
  52788. * @param x defines the 1st component of the value
  52789. * @param y defines the 2nd component of the value
  52790. * @param z defines the 3rd component of the value
  52791. */
  52792. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52793. /**
  52794. * Set the value of an uniform to a boolean
  52795. * @param uniform defines the webGL uniform location where to store the value
  52796. * @param bool defines the boolean to store
  52797. */
  52798. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52799. /**
  52800. * Set the value of an uniform to a vec4
  52801. * @param uniform defines the webGL uniform location where to store the value
  52802. * @param x defines the 1st component of the value
  52803. * @param y defines the 2nd component of the value
  52804. * @param z defines the 3rd component of the value
  52805. * @param w defines the 4th component of the value
  52806. */
  52807. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52808. /**
  52809. * Sets the current alpha mode
  52810. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52811. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52812. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52813. */
  52814. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52815. /**
  52816. * Bind webGl buffers directly to the webGL context
  52817. * @param vertexBuffers defines the vertex buffer to bind
  52818. * @param indexBuffer defines the index buffer to bind
  52819. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52820. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52821. * @param effect defines the effect associated with the vertex buffer
  52822. */
  52823. bindBuffers(vertexBuffers: {
  52824. [key: string]: VertexBuffer;
  52825. }, indexBuffer: DataBuffer, effect: Effect): void;
  52826. /**
  52827. * Force the entire cache to be cleared
  52828. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52829. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52830. */
  52831. wipeCaches(bruteForce?: boolean): void;
  52832. /**
  52833. * Send a draw order
  52834. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52835. * @param indexStart defines the starting index
  52836. * @param indexCount defines the number of index to draw
  52837. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52838. */
  52839. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52840. /**
  52841. * Draw a list of indexed primitives
  52842. * @param fillMode defines the primitive to use
  52843. * @param indexStart defines the starting index
  52844. * @param indexCount defines the number of index to draw
  52845. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52846. */
  52847. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52848. /**
  52849. * Draw a list of unindexed primitives
  52850. * @param fillMode defines the primitive to use
  52851. * @param verticesStart defines the index of first vertex to draw
  52852. * @param verticesCount defines the count of vertices to draw
  52853. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52854. */
  52855. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52856. /** @hidden */
  52857. _createTexture(): WebGLTexture;
  52858. /** @hidden */
  52859. _releaseTexture(texture: InternalTexture): void;
  52860. /**
  52861. * Usually called from Texture.ts.
  52862. * Passed information to create a WebGLTexture
  52863. * @param urlArg defines a value which contains one of the following:
  52864. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52865. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52866. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52867. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52868. * @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)
  52869. * @param scene needed for loading to the correct scene
  52870. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52871. * @param onLoad optional callback to be called upon successful completion
  52872. * @param onError optional callback to be called upon failure
  52873. * @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
  52874. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52875. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52876. * @param forcedExtension defines the extension to use to pick the right loader
  52877. * @param mimeType defines an optional mime type
  52878. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52879. */
  52880. 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;
  52881. /**
  52882. * Creates a new render target texture
  52883. * @param size defines the size of the texture
  52884. * @param options defines the options used to create the texture
  52885. * @returns a new render target texture stored in an InternalTexture
  52886. */
  52887. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52888. /**
  52889. * Update the sampling mode of a given texture
  52890. * @param samplingMode defines the required sampling mode
  52891. * @param texture defines the texture to update
  52892. */
  52893. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52894. /**
  52895. * Binds the frame buffer to the specified texture.
  52896. * @param texture The texture to render to or null for the default canvas
  52897. * @param faceIndex The face of the texture to render to in case of cube texture
  52898. * @param requiredWidth The width of the target to render to
  52899. * @param requiredHeight The height of the target to render to
  52900. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52901. * @param lodLevel defines le lod level to bind to the frame buffer
  52902. */
  52903. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52904. /**
  52905. * Unbind the current render target texture from the webGL context
  52906. * @param texture defines the render target texture to unbind
  52907. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52908. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52909. */
  52910. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52911. /**
  52912. * Creates a dynamic vertex buffer
  52913. * @param vertices the data for the dynamic vertex buffer
  52914. * @returns the new WebGL dynamic buffer
  52915. */
  52916. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52917. /**
  52918. * Update the content of a dynamic texture
  52919. * @param texture defines the texture to update
  52920. * @param canvas defines the canvas containing the source
  52921. * @param invertY defines if data must be stored with Y axis inverted
  52922. * @param premulAlpha defines if alpha is stored as premultiplied
  52923. * @param format defines the format of the data
  52924. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52925. */
  52926. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52927. /**
  52928. * Gets a boolean indicating if all created effects are ready
  52929. * @returns true if all effects are ready
  52930. */
  52931. areAllEffectsReady(): boolean;
  52932. /**
  52933. * @hidden
  52934. * Get the current error code of the webGL context
  52935. * @returns the error code
  52936. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52937. */
  52938. getError(): number;
  52939. /** @hidden */
  52940. _getUnpackAlignement(): number;
  52941. /** @hidden */
  52942. _unpackFlipY(value: boolean): void;
  52943. /**
  52944. * Update a dynamic index buffer
  52945. * @param indexBuffer defines the target index buffer
  52946. * @param indices defines the data to update
  52947. * @param offset defines the offset in the target index buffer where update should start
  52948. */
  52949. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52950. /**
  52951. * Updates a dynamic vertex buffer.
  52952. * @param vertexBuffer the vertex buffer to update
  52953. * @param vertices the data used to update the vertex buffer
  52954. * @param byteOffset the byte offset of the data (optional)
  52955. * @param byteLength the byte length of the data (optional)
  52956. */
  52957. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52958. /** @hidden */
  52959. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52960. /** @hidden */
  52961. _bindTexture(channel: number, texture: InternalTexture): void;
  52962. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52963. /**
  52964. * 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
  52965. */
  52966. releaseEffects(): void;
  52967. displayLoadingUI(): void;
  52968. hideLoadingUI(): void;
  52969. /** @hidden */
  52970. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52971. /** @hidden */
  52972. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52973. /** @hidden */
  52974. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52975. /** @hidden */
  52976. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52977. }
  52978. }
  52979. declare module "babylonjs/Instrumentation/timeToken" {
  52980. import { Nullable } from "babylonjs/types";
  52981. /**
  52982. * @hidden
  52983. **/
  52984. export class _TimeToken {
  52985. _startTimeQuery: Nullable<WebGLQuery>;
  52986. _endTimeQuery: Nullable<WebGLQuery>;
  52987. _timeElapsedQuery: Nullable<WebGLQuery>;
  52988. _timeElapsedQueryEnded: boolean;
  52989. }
  52990. }
  52991. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52992. import { Nullable, int } from "babylonjs/types";
  52993. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52994. /** @hidden */
  52995. export class _OcclusionDataStorage {
  52996. /** @hidden */
  52997. occlusionInternalRetryCounter: number;
  52998. /** @hidden */
  52999. isOcclusionQueryInProgress: boolean;
  53000. /** @hidden */
  53001. isOccluded: boolean;
  53002. /** @hidden */
  53003. occlusionRetryCount: number;
  53004. /** @hidden */
  53005. occlusionType: number;
  53006. /** @hidden */
  53007. occlusionQueryAlgorithmType: number;
  53008. }
  53009. module "babylonjs/Engines/engine" {
  53010. interface Engine {
  53011. /**
  53012. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  53013. * @return the new query
  53014. */
  53015. createQuery(): WebGLQuery;
  53016. /**
  53017. * Delete and release a webGL query
  53018. * @param query defines the query to delete
  53019. * @return the current engine
  53020. */
  53021. deleteQuery(query: WebGLQuery): Engine;
  53022. /**
  53023. * Check if a given query has resolved and got its value
  53024. * @param query defines the query to check
  53025. * @returns true if the query got its value
  53026. */
  53027. isQueryResultAvailable(query: WebGLQuery): boolean;
  53028. /**
  53029. * Gets the value of a given query
  53030. * @param query defines the query to check
  53031. * @returns the value of the query
  53032. */
  53033. getQueryResult(query: WebGLQuery): number;
  53034. /**
  53035. * Initiates an occlusion query
  53036. * @param algorithmType defines the algorithm to use
  53037. * @param query defines the query to use
  53038. * @returns the current engine
  53039. * @see https://doc.babylonjs.com/features/occlusionquery
  53040. */
  53041. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  53042. /**
  53043. * Ends an occlusion query
  53044. * @see https://doc.babylonjs.com/features/occlusionquery
  53045. * @param algorithmType defines the algorithm to use
  53046. * @returns the current engine
  53047. */
  53048. endOcclusionQuery(algorithmType: number): Engine;
  53049. /**
  53050. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  53051. * Please note that only one query can be issued at a time
  53052. * @returns a time token used to track the time span
  53053. */
  53054. startTimeQuery(): Nullable<_TimeToken>;
  53055. /**
  53056. * Ends a time query
  53057. * @param token defines the token used to measure the time span
  53058. * @returns the time spent (in ns)
  53059. */
  53060. endTimeQuery(token: _TimeToken): int;
  53061. /** @hidden */
  53062. _currentNonTimestampToken: Nullable<_TimeToken>;
  53063. /** @hidden */
  53064. _createTimeQuery(): WebGLQuery;
  53065. /** @hidden */
  53066. _deleteTimeQuery(query: WebGLQuery): void;
  53067. /** @hidden */
  53068. _getGlAlgorithmType(algorithmType: number): number;
  53069. /** @hidden */
  53070. _getTimeQueryResult(query: WebGLQuery): any;
  53071. /** @hidden */
  53072. _getTimeQueryAvailability(query: WebGLQuery): any;
  53073. }
  53074. }
  53075. module "babylonjs/Meshes/abstractMesh" {
  53076. interface AbstractMesh {
  53077. /**
  53078. * Backing filed
  53079. * @hidden
  53080. */
  53081. __occlusionDataStorage: _OcclusionDataStorage;
  53082. /**
  53083. * Access property
  53084. * @hidden
  53085. */
  53086. _occlusionDataStorage: _OcclusionDataStorage;
  53087. /**
  53088. * 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.
  53089. * The default value is -1 which means don't break the query and wait till the result
  53090. * @see https://doc.babylonjs.com/features/occlusionquery
  53091. */
  53092. occlusionRetryCount: number;
  53093. /**
  53094. * 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:
  53095. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  53096. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  53097. * * 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.
  53098. * @see https://doc.babylonjs.com/features/occlusionquery
  53099. */
  53100. occlusionType: number;
  53101. /**
  53102. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  53103. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  53104. * * 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.
  53105. * @see https://doc.babylonjs.com/features/occlusionquery
  53106. */
  53107. occlusionQueryAlgorithmType: number;
  53108. /**
  53109. * 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
  53110. * @see https://doc.babylonjs.com/features/occlusionquery
  53111. */
  53112. isOccluded: boolean;
  53113. /**
  53114. * Flag to check the progress status of the query
  53115. * @see https://doc.babylonjs.com/features/occlusionquery
  53116. */
  53117. isOcclusionQueryInProgress: boolean;
  53118. }
  53119. }
  53120. }
  53121. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  53122. import { Nullable } from "babylonjs/types";
  53123. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53124. /** @hidden */
  53125. export var _forceTransformFeedbackToBundle: boolean;
  53126. module "babylonjs/Engines/engine" {
  53127. interface Engine {
  53128. /**
  53129. * Creates a webGL transform feedback object
  53130. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  53131. * @returns the webGL transform feedback object
  53132. */
  53133. createTransformFeedback(): WebGLTransformFeedback;
  53134. /**
  53135. * Delete a webGL transform feedback object
  53136. * @param value defines the webGL transform feedback object to delete
  53137. */
  53138. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  53139. /**
  53140. * Bind a webGL transform feedback object to the webgl context
  53141. * @param value defines the webGL transform feedback object to bind
  53142. */
  53143. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  53144. /**
  53145. * Begins a transform feedback operation
  53146. * @param usePoints defines if points or triangles must be used
  53147. */
  53148. beginTransformFeedback(usePoints: boolean): void;
  53149. /**
  53150. * Ends a transform feedback operation
  53151. */
  53152. endTransformFeedback(): void;
  53153. /**
  53154. * Specify the varyings to use with transform feedback
  53155. * @param program defines the associated webGL program
  53156. * @param value defines the list of strings representing the varying names
  53157. */
  53158. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  53159. /**
  53160. * Bind a webGL buffer for a transform feedback operation
  53161. * @param value defines the webGL buffer to bind
  53162. */
  53163. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  53164. }
  53165. }
  53166. }
  53167. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  53168. import { Scene } from "babylonjs/scene";
  53169. import { Engine } from "babylonjs/Engines/engine";
  53170. import { Texture } from "babylonjs/Materials/Textures/texture";
  53171. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53172. import "babylonjs/Engines/Extensions/engine.multiRender";
  53173. /**
  53174. * Creation options of the multi render target texture.
  53175. */
  53176. export interface IMultiRenderTargetOptions {
  53177. /**
  53178. * Define if the texture needs to create mip maps after render.
  53179. */
  53180. generateMipMaps?: boolean;
  53181. /**
  53182. * Define the types of all the draw buffers we want to create
  53183. */
  53184. types?: number[];
  53185. /**
  53186. * Define the sampling modes of all the draw buffers we want to create
  53187. */
  53188. samplingModes?: number[];
  53189. /**
  53190. * Define if a depth buffer is required
  53191. */
  53192. generateDepthBuffer?: boolean;
  53193. /**
  53194. * Define if a stencil buffer is required
  53195. */
  53196. generateStencilBuffer?: boolean;
  53197. /**
  53198. * Define if a depth texture is required instead of a depth buffer
  53199. */
  53200. generateDepthTexture?: boolean;
  53201. /**
  53202. * Define the number of desired draw buffers
  53203. */
  53204. textureCount?: number;
  53205. /**
  53206. * Define if aspect ratio should be adapted to the texture or stay the scene one
  53207. */
  53208. doNotChangeAspectRatio?: boolean;
  53209. /**
  53210. * Define the default type of the buffers we are creating
  53211. */
  53212. defaultType?: number;
  53213. }
  53214. /**
  53215. * A multi render target, like a render target provides the ability to render to a texture.
  53216. * Unlike the render target, it can render to several draw buffers in one draw.
  53217. * This is specially interesting in deferred rendering or for any effects requiring more than
  53218. * just one color from a single pass.
  53219. */
  53220. export class MultiRenderTarget extends RenderTargetTexture {
  53221. private _internalTextures;
  53222. private _textures;
  53223. private _multiRenderTargetOptions;
  53224. private _count;
  53225. /**
  53226. * Get if draw buffers are currently supported by the used hardware and browser.
  53227. */
  53228. get isSupported(): boolean;
  53229. /**
  53230. * Get the list of textures generated by the multi render target.
  53231. */
  53232. get textures(): Texture[];
  53233. /**
  53234. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  53235. */
  53236. get count(): number;
  53237. /**
  53238. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  53239. */
  53240. get depthTexture(): Texture;
  53241. /**
  53242. * Set the wrapping mode on U of all the textures we are rendering to.
  53243. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53244. */
  53245. set wrapU(wrap: number);
  53246. /**
  53247. * Set the wrapping mode on V of all the textures we are rendering to.
  53248. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53249. */
  53250. set wrapV(wrap: number);
  53251. /**
  53252. * Instantiate a new multi render target texture.
  53253. * A multi render target, like a render target provides the ability to render to a texture.
  53254. * Unlike the render target, it can render to several draw buffers in one draw.
  53255. * This is specially interesting in deferred rendering or for any effects requiring more than
  53256. * just one color from a single pass.
  53257. * @param name Define the name of the texture
  53258. * @param size Define the size of the buffers to render to
  53259. * @param count Define the number of target we are rendering into
  53260. * @param scene Define the scene the texture belongs to
  53261. * @param options Define the options used to create the multi render target
  53262. */
  53263. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  53264. /** @hidden */
  53265. _rebuild(): void;
  53266. private _createInternalTextures;
  53267. private _createTextures;
  53268. /**
  53269. * Define the number of samples used if MSAA is enabled.
  53270. */
  53271. get samples(): number;
  53272. set samples(value: number);
  53273. /**
  53274. * Resize all the textures in the multi render target.
  53275. * Be carrefull as it will recreate all the data in the new texture.
  53276. * @param size Define the new size
  53277. */
  53278. resize(size: any): void;
  53279. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  53280. /**
  53281. * Dispose the render targets and their associated resources
  53282. */
  53283. dispose(): void;
  53284. /**
  53285. * Release all the underlying texture used as draw buffers.
  53286. */
  53287. releaseInternalTextures(): void;
  53288. }
  53289. }
  53290. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  53291. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53292. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  53293. import { Nullable } from "babylonjs/types";
  53294. module "babylonjs/Engines/thinEngine" {
  53295. interface ThinEngine {
  53296. /**
  53297. * Unbind a list of render target textures from the webGL context
  53298. * This is used only when drawBuffer extension or webGL2 are active
  53299. * @param textures defines the render target textures to unbind
  53300. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53301. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53302. */
  53303. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  53304. /**
  53305. * Create a multi render target texture
  53306. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  53307. * @param size defines the size of the texture
  53308. * @param options defines the creation options
  53309. * @returns the cube texture as an InternalTexture
  53310. */
  53311. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  53312. /**
  53313. * Update the sample count for a given multiple render target texture
  53314. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  53315. * @param textures defines the textures to update
  53316. * @param samples defines the sample count to set
  53317. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  53318. */
  53319. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  53320. /**
  53321. * Select a subsets of attachments to draw to.
  53322. * @param attachments gl attachments
  53323. */
  53324. bindAttachments(attachments: number[]): void;
  53325. }
  53326. }
  53327. }
  53328. declare module "babylonjs/Engines/Extensions/engine.views" {
  53329. import { Camera } from "babylonjs/Cameras/camera";
  53330. import { Nullable } from "babylonjs/types";
  53331. /**
  53332. * Class used to define an additional view for the engine
  53333. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53334. */
  53335. export class EngineView {
  53336. /** Defines the canvas where to render the view */
  53337. target: HTMLCanvasElement;
  53338. /** Defines an optional camera used to render the view (will use active camera else) */
  53339. camera?: Camera;
  53340. }
  53341. module "babylonjs/Engines/engine" {
  53342. interface Engine {
  53343. /**
  53344. * Gets or sets the HTML element to use for attaching events
  53345. */
  53346. inputElement: Nullable<HTMLElement>;
  53347. /**
  53348. * Gets the current engine view
  53349. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53350. */
  53351. activeView: Nullable<EngineView>;
  53352. /** Gets or sets the list of views */
  53353. views: EngineView[];
  53354. /**
  53355. * Register a new child canvas
  53356. * @param canvas defines the canvas to register
  53357. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53358. * @returns the associated view
  53359. */
  53360. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53361. /**
  53362. * Remove a registered child canvas
  53363. * @param canvas defines the canvas to remove
  53364. * @returns the current engine
  53365. */
  53366. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53367. }
  53368. }
  53369. }
  53370. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53371. import { Nullable } from "babylonjs/types";
  53372. module "babylonjs/Engines/engine" {
  53373. interface Engine {
  53374. /** @hidden */
  53375. _excludedCompressedTextures: string[];
  53376. /** @hidden */
  53377. _textureFormatInUse: string;
  53378. /**
  53379. * Gets the list of texture formats supported
  53380. */
  53381. readonly texturesSupported: Array<string>;
  53382. /**
  53383. * Gets the texture format in use
  53384. */
  53385. readonly textureFormatInUse: Nullable<string>;
  53386. /**
  53387. * Set the compressed texture extensions or file names to skip.
  53388. *
  53389. * @param skippedFiles defines the list of those texture files you want to skip
  53390. * Example: [".dds", ".env", "myfile.png"]
  53391. */
  53392. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53393. /**
  53394. * Set the compressed texture format to use, based on the formats you have, and the formats
  53395. * supported by the hardware / browser.
  53396. *
  53397. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53398. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53399. * to API arguments needed to compressed textures. This puts the burden on the container
  53400. * generator to house the arcane code for determining these for current & future formats.
  53401. *
  53402. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53403. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53404. *
  53405. * Note: The result of this call is not taken into account when a texture is base64.
  53406. *
  53407. * @param formatsAvailable defines the list of those format families you have created
  53408. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53409. *
  53410. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53411. * @returns The extension selected.
  53412. */
  53413. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53414. }
  53415. }
  53416. }
  53417. declare module "babylonjs/Engines/Extensions/index" {
  53418. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53419. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53420. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53421. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53422. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53423. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53424. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53425. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53426. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53427. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53428. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53429. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53430. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53431. export * from "babylonjs/Engines/Extensions/engine.views";
  53432. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53433. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53434. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53435. }
  53436. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53437. import { Nullable } from "babylonjs/types";
  53438. /**
  53439. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53440. */
  53441. export interface CubeMapInfo {
  53442. /**
  53443. * The pixel array for the front face.
  53444. * This is stored in format, left to right, up to down format.
  53445. */
  53446. front: Nullable<ArrayBufferView>;
  53447. /**
  53448. * The pixel array for the back face.
  53449. * This is stored in format, left to right, up to down format.
  53450. */
  53451. back: Nullable<ArrayBufferView>;
  53452. /**
  53453. * The pixel array for the left face.
  53454. * This is stored in format, left to right, up to down format.
  53455. */
  53456. left: Nullable<ArrayBufferView>;
  53457. /**
  53458. * The pixel array for the right face.
  53459. * This is stored in format, left to right, up to down format.
  53460. */
  53461. right: Nullable<ArrayBufferView>;
  53462. /**
  53463. * The pixel array for the up face.
  53464. * This is stored in format, left to right, up to down format.
  53465. */
  53466. up: Nullable<ArrayBufferView>;
  53467. /**
  53468. * The pixel array for the down face.
  53469. * This is stored in format, left to right, up to down format.
  53470. */
  53471. down: Nullable<ArrayBufferView>;
  53472. /**
  53473. * The size of the cubemap stored.
  53474. *
  53475. * Each faces will be size * size pixels.
  53476. */
  53477. size: number;
  53478. /**
  53479. * The format of the texture.
  53480. *
  53481. * RGBA, RGB.
  53482. */
  53483. format: number;
  53484. /**
  53485. * The type of the texture data.
  53486. *
  53487. * UNSIGNED_INT, FLOAT.
  53488. */
  53489. type: number;
  53490. /**
  53491. * Specifies whether the texture is in gamma space.
  53492. */
  53493. gammaSpace: boolean;
  53494. }
  53495. /**
  53496. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  53497. */
  53498. export class PanoramaToCubeMapTools {
  53499. private static FACE_LEFT;
  53500. private static FACE_RIGHT;
  53501. private static FACE_FRONT;
  53502. private static FACE_BACK;
  53503. private static FACE_DOWN;
  53504. private static FACE_UP;
  53505. /**
  53506. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  53507. *
  53508. * @param float32Array The source data.
  53509. * @param inputWidth The width of the input panorama.
  53510. * @param inputHeight The height of the input panorama.
  53511. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  53512. * @return The cubemap data
  53513. */
  53514. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  53515. private static CreateCubemapTexture;
  53516. private static CalcProjectionSpherical;
  53517. }
  53518. }
  53519. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  53520. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53522. import { Nullable } from "babylonjs/types";
  53523. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53524. /**
  53525. * Helper class dealing with the extraction of spherical polynomial dataArray
  53526. * from a cube map.
  53527. */
  53528. export class CubeMapToSphericalPolynomialTools {
  53529. private static FileFaces;
  53530. /**
  53531. * Converts a texture to the according Spherical Polynomial data.
  53532. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53533. *
  53534. * @param texture The texture to extract the information from.
  53535. * @return The Spherical Polynomial data.
  53536. */
  53537. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  53538. /**
  53539. * Converts a cubemap to the according Spherical Polynomial data.
  53540. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53541. *
  53542. * @param cubeInfo The Cube map to extract the information from.
  53543. * @return The Spherical Polynomial data.
  53544. */
  53545. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  53546. }
  53547. }
  53548. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  53549. import { Nullable } from "babylonjs/types";
  53550. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53551. module "babylonjs/Materials/Textures/baseTexture" {
  53552. interface BaseTexture {
  53553. /**
  53554. * Get the polynomial representation of the texture data.
  53555. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  53556. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  53557. */
  53558. sphericalPolynomial: Nullable<SphericalPolynomial>;
  53559. }
  53560. }
  53561. }
  53562. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  53563. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53564. /** @hidden */
  53565. export var rgbdEncodePixelShader: {
  53566. name: string;
  53567. shader: string;
  53568. };
  53569. }
  53570. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  53571. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53572. /** @hidden */
  53573. export var rgbdDecodePixelShader: {
  53574. name: string;
  53575. shader: string;
  53576. };
  53577. }
  53578. declare module "babylonjs/Misc/environmentTextureTools" {
  53579. import { Nullable } from "babylonjs/types";
  53580. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53581. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53582. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53583. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53584. import "babylonjs/Engines/Extensions/engine.readTexture";
  53585. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53586. import "babylonjs/Shaders/rgbdEncode.fragment";
  53587. import "babylonjs/Shaders/rgbdDecode.fragment";
  53588. /**
  53589. * Raw texture data and descriptor sufficient for WebGL texture upload
  53590. */
  53591. export interface EnvironmentTextureInfo {
  53592. /**
  53593. * Version of the environment map
  53594. */
  53595. version: number;
  53596. /**
  53597. * Width of image
  53598. */
  53599. width: number;
  53600. /**
  53601. * Irradiance information stored in the file.
  53602. */
  53603. irradiance: any;
  53604. /**
  53605. * Specular information stored in the file.
  53606. */
  53607. specular: any;
  53608. }
  53609. /**
  53610. * Defines One Image in the file. It requires only the position in the file
  53611. * as well as the length.
  53612. */
  53613. interface BufferImageData {
  53614. /**
  53615. * Length of the image data.
  53616. */
  53617. length: number;
  53618. /**
  53619. * Position of the data from the null terminator delimiting the end of the JSON.
  53620. */
  53621. position: number;
  53622. }
  53623. /**
  53624. * Defines the specular data enclosed in the file.
  53625. * This corresponds to the version 1 of the data.
  53626. */
  53627. export interface EnvironmentTextureSpecularInfoV1 {
  53628. /**
  53629. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53630. */
  53631. specularDataPosition?: number;
  53632. /**
  53633. * This contains all the images data needed to reconstruct the cubemap.
  53634. */
  53635. mipmaps: Array<BufferImageData>;
  53636. /**
  53637. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53638. */
  53639. lodGenerationScale: number;
  53640. }
  53641. /**
  53642. * Sets of helpers addressing the serialization and deserialization of environment texture
  53643. * stored in a BabylonJS env file.
  53644. * Those files are usually stored as .env files.
  53645. */
  53646. export class EnvironmentTextureTools {
  53647. /**
  53648. * Magic number identifying the env file.
  53649. */
  53650. private static _MagicBytes;
  53651. /**
  53652. * Gets the environment info from an env file.
  53653. * @param data The array buffer containing the .env bytes.
  53654. * @returns the environment file info (the json header) if successfully parsed.
  53655. */
  53656. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53657. /**
  53658. * Creates an environment texture from a loaded cube texture.
  53659. * @param texture defines the cube texture to convert in env file
  53660. * @return a promise containing the environment data if succesfull.
  53661. */
  53662. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53663. /**
  53664. * Creates a JSON representation of the spherical data.
  53665. * @param texture defines the texture containing the polynomials
  53666. * @return the JSON representation of the spherical info
  53667. */
  53668. private static _CreateEnvTextureIrradiance;
  53669. /**
  53670. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53671. * @param data the image data
  53672. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53673. * @return the views described by info providing access to the underlying buffer
  53674. */
  53675. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53676. /**
  53677. * Uploads the texture info contained in the env file to the GPU.
  53678. * @param texture defines the internal texture to upload to
  53679. * @param data defines the data to load
  53680. * @param info defines the texture info retrieved through the GetEnvInfo method
  53681. * @returns a promise
  53682. */
  53683. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53684. private static _OnImageReadyAsync;
  53685. /**
  53686. * Uploads the levels of image data to the GPU.
  53687. * @param texture defines the internal texture to upload to
  53688. * @param imageData defines the array buffer views of image data [mipmap][face]
  53689. * @returns a promise
  53690. */
  53691. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53692. /**
  53693. * Uploads spherical polynomials information to the texture.
  53694. * @param texture defines the texture we are trying to upload the information to
  53695. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53696. */
  53697. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53698. /** @hidden */
  53699. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53700. }
  53701. }
  53702. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53703. /**
  53704. * Class used to inline functions in shader code
  53705. */
  53706. export class ShaderCodeInliner {
  53707. private static readonly _RegexpFindFunctionNameAndType;
  53708. private _sourceCode;
  53709. private _functionDescr;
  53710. private _numMaxIterations;
  53711. /** Gets or sets the token used to mark the functions to inline */
  53712. inlineToken: string;
  53713. /** Gets or sets the debug mode */
  53714. debug: boolean;
  53715. /** Gets the code after the inlining process */
  53716. get code(): string;
  53717. /**
  53718. * Initializes the inliner
  53719. * @param sourceCode shader code source to inline
  53720. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53721. */
  53722. constructor(sourceCode: string, numMaxIterations?: number);
  53723. /**
  53724. * Start the processing of the shader code
  53725. */
  53726. processCode(): void;
  53727. private _collectFunctions;
  53728. private _processInlining;
  53729. private _extractBetweenMarkers;
  53730. private _skipWhitespaces;
  53731. private _removeComments;
  53732. private _replaceFunctionCallsByCode;
  53733. private _findBackward;
  53734. private _escapeRegExp;
  53735. private _replaceNames;
  53736. }
  53737. }
  53738. declare module "babylonjs/Engines/nativeEngine" {
  53739. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53740. import { Engine } from "babylonjs/Engines/engine";
  53741. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53742. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53743. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53744. import { Effect } from "babylonjs/Materials/effect";
  53745. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53746. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53747. import { IColor4Like } from "babylonjs/Maths/math.like";
  53748. import { Scene } from "babylonjs/scene";
  53749. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53750. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53751. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53752. /**
  53753. * Container for accessors for natively-stored mesh data buffers.
  53754. */
  53755. class NativeDataBuffer extends DataBuffer {
  53756. /**
  53757. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53758. */
  53759. nativeIndexBuffer?: any;
  53760. /**
  53761. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53762. */
  53763. nativeVertexBuffer?: any;
  53764. }
  53765. /** @hidden */
  53766. class NativeTexture extends InternalTexture {
  53767. getInternalTexture(): InternalTexture;
  53768. getViewCount(): number;
  53769. }
  53770. /** @hidden */
  53771. export class NativeEngine extends Engine {
  53772. private readonly _native;
  53773. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53774. private readonly INVALID_HANDLE;
  53775. getHardwareScalingLevel(): number;
  53776. constructor();
  53777. dispose(): void;
  53778. /**
  53779. * Can be used to override the current requestAnimationFrame requester.
  53780. * @hidden
  53781. */
  53782. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53783. /**
  53784. * Override default engine behavior.
  53785. * @param color
  53786. * @param backBuffer
  53787. * @param depth
  53788. * @param stencil
  53789. */
  53790. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53791. /**
  53792. * Gets host document
  53793. * @returns the host document object
  53794. */
  53795. getHostDocument(): Nullable<Document>;
  53796. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53797. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53798. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53799. recordVertexArrayObject(vertexBuffers: {
  53800. [key: string]: VertexBuffer;
  53801. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53802. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53803. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53804. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53805. /**
  53806. * Draw a list of indexed primitives
  53807. * @param fillMode defines the primitive to use
  53808. * @param indexStart defines the starting index
  53809. * @param indexCount defines the number of index to draw
  53810. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53811. */
  53812. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53813. /**
  53814. * Draw a list of unindexed primitives
  53815. * @param fillMode defines the primitive to use
  53816. * @param verticesStart defines the index of first vertex to draw
  53817. * @param verticesCount defines the count of vertices to draw
  53818. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53819. */
  53820. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53821. createPipelineContext(): IPipelineContext;
  53822. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53823. /** @hidden */
  53824. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53825. /** @hidden */
  53826. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53827. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53828. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53829. protected _setProgram(program: WebGLProgram): void;
  53830. _releaseEffect(effect: Effect): void;
  53831. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53832. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53833. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53834. bindSamplers(effect: Effect): void;
  53835. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53836. getRenderWidth(useScreen?: boolean): number;
  53837. getRenderHeight(useScreen?: boolean): number;
  53838. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53839. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53840. /**
  53841. * Set the z offset to apply to current rendering
  53842. * @param value defines the offset to apply
  53843. */
  53844. setZOffset(value: number): void;
  53845. /**
  53846. * Gets the current value of the zOffset
  53847. * @returns the current zOffset state
  53848. */
  53849. getZOffset(): number;
  53850. /**
  53851. * Enable or disable depth buffering
  53852. * @param enable defines the state to set
  53853. */
  53854. setDepthBuffer(enable: boolean): void;
  53855. /**
  53856. * Gets a boolean indicating if depth writing is enabled
  53857. * @returns the current depth writing state
  53858. */
  53859. getDepthWrite(): boolean;
  53860. /**
  53861. * Enable or disable depth writing
  53862. * @param enable defines the state to set
  53863. */
  53864. setDepthWrite(enable: boolean): void;
  53865. /**
  53866. * Enable or disable color writing
  53867. * @param enable defines the state to set
  53868. */
  53869. setColorWrite(enable: boolean): void;
  53870. /**
  53871. * Gets a boolean indicating if color writing is enabled
  53872. * @returns the current color writing state
  53873. */
  53874. getColorWrite(): boolean;
  53875. /**
  53876. * Sets alpha constants used by some alpha blending modes
  53877. * @param r defines the red component
  53878. * @param g defines the green component
  53879. * @param b defines the blue component
  53880. * @param a defines the alpha component
  53881. */
  53882. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53883. /**
  53884. * Sets the current alpha mode
  53885. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53886. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53887. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53888. */
  53889. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53890. /**
  53891. * Gets the current alpha mode
  53892. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53893. * @returns the current alpha mode
  53894. */
  53895. getAlphaMode(): number;
  53896. setInt(uniform: WebGLUniformLocation, int: number): void;
  53897. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53898. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53899. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53900. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53901. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53902. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53903. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53904. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53905. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53906. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53907. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53908. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53909. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53910. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53911. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53912. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53913. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53914. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53915. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53916. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53917. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53918. wipeCaches(bruteForce?: boolean): void;
  53919. _createTexture(): WebGLTexture;
  53920. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53921. /**
  53922. * Usually called from Texture.ts.
  53923. * Passed information to create a WebGLTexture
  53924. * @param url defines a value which contains one of the following:
  53925. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53926. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53927. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53928. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53929. * @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)
  53930. * @param scene needed for loading to the correct scene
  53931. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53932. * @param onLoad optional callback to be called upon successful completion
  53933. * @param onError optional callback to be called upon failure
  53934. * @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
  53935. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53936. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53937. * @param forcedExtension defines the extension to use to pick the right loader
  53938. * @param mimeType defines an optional mime type
  53939. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53940. */
  53941. 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;
  53942. /**
  53943. * Creates a cube texture
  53944. * @param rootUrl defines the url where the files to load is located
  53945. * @param scene defines the current scene
  53946. * @param files defines the list of files to load (1 per face)
  53947. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53948. * @param onLoad defines an optional callback raised when the texture is loaded
  53949. * @param onError defines an optional callback raised if there is an issue to load the texture
  53950. * @param format defines the format of the data
  53951. * @param forcedExtension defines the extension to use to pick the right loader
  53952. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53953. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53954. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53955. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53956. * @returns the cube texture as an InternalTexture
  53957. */
  53958. 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;
  53959. private _getSamplingFilter;
  53960. private static _GetNativeTextureFormat;
  53961. createRenderTargetTexture(size: number | {
  53962. width: number;
  53963. height: number;
  53964. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53965. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53966. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53967. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53968. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53969. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53970. /**
  53971. * Updates a dynamic vertex buffer.
  53972. * @param vertexBuffer the vertex buffer to update
  53973. * @param data the data used to update the vertex buffer
  53974. * @param byteOffset the byte offset of the data (optional)
  53975. * @param byteLength the byte length of the data (optional)
  53976. */
  53977. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53978. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53979. private _updateAnisotropicLevel;
  53980. private _getAddressMode;
  53981. /** @hidden */
  53982. _bindTexture(channel: number, texture: InternalTexture): void;
  53983. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53984. releaseEffects(): void;
  53985. /** @hidden */
  53986. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53987. /** @hidden */
  53988. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53989. /** @hidden */
  53990. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53991. /** @hidden */
  53992. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53993. }
  53994. }
  53995. declare module "babylonjs/Engines/index" {
  53996. export * from "babylonjs/Engines/constants";
  53997. export * from "babylonjs/Engines/engineCapabilities";
  53998. export * from "babylonjs/Engines/instancingAttributeInfo";
  53999. export * from "babylonjs/Engines/thinEngine";
  54000. export * from "babylonjs/Engines/engine";
  54001. export * from "babylonjs/Engines/engineStore";
  54002. export * from "babylonjs/Engines/nullEngine";
  54003. export * from "babylonjs/Engines/Extensions/index";
  54004. export * from "babylonjs/Engines/IPipelineContext";
  54005. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54006. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54007. export * from "babylonjs/Engines/nativeEngine";
  54008. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54009. }
  54010. declare module "babylonjs/Events/clipboardEvents" {
  54011. /**
  54012. * Gather the list of clipboard event types as constants.
  54013. */
  54014. export class ClipboardEventTypes {
  54015. /**
  54016. * The clipboard event is fired when a copy command is active (pressed).
  54017. */
  54018. static readonly COPY: number;
  54019. /**
  54020. * The clipboard event is fired when a cut command is active (pressed).
  54021. */
  54022. static readonly CUT: number;
  54023. /**
  54024. * The clipboard event is fired when a paste command is active (pressed).
  54025. */
  54026. static readonly PASTE: number;
  54027. }
  54028. /**
  54029. * This class is used to store clipboard related info for the onClipboardObservable event.
  54030. */
  54031. export class ClipboardInfo {
  54032. /**
  54033. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54034. */
  54035. type: number;
  54036. /**
  54037. * Defines the related dom event
  54038. */
  54039. event: ClipboardEvent;
  54040. /**
  54041. *Creates an instance of ClipboardInfo.
  54042. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54043. * @param event Defines the related dom event
  54044. */
  54045. constructor(
  54046. /**
  54047. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54048. */
  54049. type: number,
  54050. /**
  54051. * Defines the related dom event
  54052. */
  54053. event: ClipboardEvent);
  54054. /**
  54055. * Get the clipboard event's type from the keycode.
  54056. * @param keyCode Defines the keyCode for the current keyboard event.
  54057. * @return {number}
  54058. */
  54059. static GetTypeFromCharacter(keyCode: number): number;
  54060. }
  54061. }
  54062. declare module "babylonjs/Events/index" {
  54063. export * from "babylonjs/Events/keyboardEvents";
  54064. export * from "babylonjs/Events/pointerEvents";
  54065. export * from "babylonjs/Events/clipboardEvents";
  54066. }
  54067. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54068. import { Scene } from "babylonjs/scene";
  54069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54070. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54071. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54072. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54073. /**
  54074. * Google Daydream controller
  54075. */
  54076. export class DaydreamController extends WebVRController {
  54077. /**
  54078. * Base Url for the controller model.
  54079. */
  54080. static MODEL_BASE_URL: string;
  54081. /**
  54082. * File name for the controller model.
  54083. */
  54084. static MODEL_FILENAME: string;
  54085. /**
  54086. * Gamepad Id prefix used to identify Daydream Controller.
  54087. */
  54088. static readonly GAMEPAD_ID_PREFIX: string;
  54089. /**
  54090. * Creates a new DaydreamController from a gamepad
  54091. * @param vrGamepad the gamepad that the controller should be created from
  54092. */
  54093. constructor(vrGamepad: any);
  54094. /**
  54095. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54096. * @param scene scene in which to add meshes
  54097. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54098. */
  54099. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54100. /**
  54101. * Called once for each button that changed state since the last frame
  54102. * @param buttonIdx Which button index changed
  54103. * @param state New state of the button
  54104. * @param changes Which properties on the state changed since last frame
  54105. */
  54106. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54107. }
  54108. }
  54109. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54110. import { Scene } from "babylonjs/scene";
  54111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54112. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54113. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54114. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54115. /**
  54116. * Gear VR Controller
  54117. */
  54118. export class GearVRController extends WebVRController {
  54119. /**
  54120. * Base Url for the controller model.
  54121. */
  54122. static MODEL_BASE_URL: string;
  54123. /**
  54124. * File name for the controller model.
  54125. */
  54126. static MODEL_FILENAME: string;
  54127. /**
  54128. * Gamepad Id prefix used to identify this controller.
  54129. */
  54130. static readonly GAMEPAD_ID_PREFIX: string;
  54131. private readonly _buttonIndexToObservableNameMap;
  54132. /**
  54133. * Creates a new GearVRController from a gamepad
  54134. * @param vrGamepad the gamepad that the controller should be created from
  54135. */
  54136. constructor(vrGamepad: any);
  54137. /**
  54138. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54139. * @param scene scene in which to add meshes
  54140. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54141. */
  54142. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54143. /**
  54144. * Called once for each button that changed state since the last frame
  54145. * @param buttonIdx Which button index changed
  54146. * @param state New state of the button
  54147. * @param changes Which properties on the state changed since last frame
  54148. */
  54149. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54150. }
  54151. }
  54152. declare module "babylonjs/Gamepads/Controllers/genericController" {
  54153. import { Scene } from "babylonjs/scene";
  54154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54155. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54156. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54157. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54158. /**
  54159. * Generic Controller
  54160. */
  54161. export class GenericController extends WebVRController {
  54162. /**
  54163. * Base Url for the controller model.
  54164. */
  54165. static readonly MODEL_BASE_URL: string;
  54166. /**
  54167. * File name for the controller model.
  54168. */
  54169. static readonly MODEL_FILENAME: string;
  54170. /**
  54171. * Creates a new GenericController from a gamepad
  54172. * @param vrGamepad the gamepad that the controller should be created from
  54173. */
  54174. constructor(vrGamepad: any);
  54175. /**
  54176. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54177. * @param scene scene in which to add meshes
  54178. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54179. */
  54180. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54181. /**
  54182. * Called once for each button that changed state since the last frame
  54183. * @param buttonIdx Which button index changed
  54184. * @param state New state of the button
  54185. * @param changes Which properties on the state changed since last frame
  54186. */
  54187. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54188. }
  54189. }
  54190. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54191. import { Observable } from "babylonjs/Misc/observable";
  54192. import { Scene } from "babylonjs/scene";
  54193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54194. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54195. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54196. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54197. /**
  54198. * Oculus Touch Controller
  54199. */
  54200. export class OculusTouchController extends WebVRController {
  54201. /**
  54202. * Base Url for the controller model.
  54203. */
  54204. static MODEL_BASE_URL: string;
  54205. /**
  54206. * File name for the left controller model.
  54207. */
  54208. static MODEL_LEFT_FILENAME: string;
  54209. /**
  54210. * File name for the right controller model.
  54211. */
  54212. static MODEL_RIGHT_FILENAME: string;
  54213. /**
  54214. * Base Url for the Quest controller model.
  54215. */
  54216. static QUEST_MODEL_BASE_URL: string;
  54217. /**
  54218. * @hidden
  54219. * If the controllers are running on a device that needs the updated Quest controller models
  54220. */
  54221. static _IsQuest: boolean;
  54222. /**
  54223. * Fired when the secondary trigger on this controller is modified
  54224. */
  54225. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54226. /**
  54227. * Fired when the thumb rest on this controller is modified
  54228. */
  54229. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54230. /**
  54231. * Creates a new OculusTouchController from a gamepad
  54232. * @param vrGamepad the gamepad that the controller should be created from
  54233. */
  54234. constructor(vrGamepad: any);
  54235. /**
  54236. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54237. * @param scene scene in which to add meshes
  54238. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54239. */
  54240. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54241. /**
  54242. * Fired when the A button on this controller is modified
  54243. */
  54244. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54245. /**
  54246. * Fired when the B button on this controller is modified
  54247. */
  54248. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54249. /**
  54250. * Fired when the X button on this controller is modified
  54251. */
  54252. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54253. /**
  54254. * Fired when the Y button on this controller is modified
  54255. */
  54256. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54257. /**
  54258. * Called once for each button that changed state since the last frame
  54259. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  54260. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  54261. * 2) secondary trigger (same)
  54262. * 3) A (right) X (left), touch, pressed = value
  54263. * 4) B / Y
  54264. * 5) thumb rest
  54265. * @param buttonIdx Which button index changed
  54266. * @param state New state of the button
  54267. * @param changes Which properties on the state changed since last frame
  54268. */
  54269. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54270. }
  54271. }
  54272. declare module "babylonjs/Gamepads/Controllers/viveController" {
  54273. import { Scene } from "babylonjs/scene";
  54274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54275. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54276. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54277. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54278. import { Observable } from "babylonjs/Misc/observable";
  54279. /**
  54280. * Vive Controller
  54281. */
  54282. export class ViveController extends WebVRController {
  54283. /**
  54284. * Base Url for the controller model.
  54285. */
  54286. static MODEL_BASE_URL: string;
  54287. /**
  54288. * File name for the controller model.
  54289. */
  54290. static MODEL_FILENAME: string;
  54291. /**
  54292. * Creates a new ViveController from a gamepad
  54293. * @param vrGamepad the gamepad that the controller should be created from
  54294. */
  54295. constructor(vrGamepad: any);
  54296. /**
  54297. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54298. * @param scene scene in which to add meshes
  54299. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54300. */
  54301. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54302. /**
  54303. * Fired when the left button on this controller is modified
  54304. */
  54305. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54306. /**
  54307. * Fired when the right button on this controller is modified
  54308. */
  54309. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54310. /**
  54311. * Fired when the menu button on this controller is modified
  54312. */
  54313. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54314. /**
  54315. * Called once for each button that changed state since the last frame
  54316. * Vive mapping:
  54317. * 0: touchpad
  54318. * 1: trigger
  54319. * 2: left AND right buttons
  54320. * 3: menu button
  54321. * @param buttonIdx Which button index changed
  54322. * @param state New state of the button
  54323. * @param changes Which properties on the state changed since last frame
  54324. */
  54325. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54326. }
  54327. }
  54328. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  54329. import { Observable } from "babylonjs/Misc/observable";
  54330. import { Scene } from "babylonjs/scene";
  54331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54332. import { Ray } from "babylonjs/Culling/ray";
  54333. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54334. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54335. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54336. /**
  54337. * Defines the WindowsMotionController object that the state of the windows motion controller
  54338. */
  54339. export class WindowsMotionController extends WebVRController {
  54340. /**
  54341. * The base url used to load the left and right controller models
  54342. */
  54343. static MODEL_BASE_URL: string;
  54344. /**
  54345. * The name of the left controller model file
  54346. */
  54347. static MODEL_LEFT_FILENAME: string;
  54348. /**
  54349. * The name of the right controller model file
  54350. */
  54351. static MODEL_RIGHT_FILENAME: string;
  54352. /**
  54353. * The controller name prefix for this controller type
  54354. */
  54355. static readonly GAMEPAD_ID_PREFIX: string;
  54356. /**
  54357. * The controller id pattern for this controller type
  54358. */
  54359. private static readonly GAMEPAD_ID_PATTERN;
  54360. private _loadedMeshInfo;
  54361. protected readonly _mapping: {
  54362. buttons: string[];
  54363. buttonMeshNames: {
  54364. trigger: string;
  54365. menu: string;
  54366. grip: string;
  54367. thumbstick: string;
  54368. trackpad: string;
  54369. };
  54370. buttonObservableNames: {
  54371. trigger: string;
  54372. menu: string;
  54373. grip: string;
  54374. thumbstick: string;
  54375. trackpad: string;
  54376. };
  54377. axisMeshNames: string[];
  54378. pointingPoseMeshName: string;
  54379. };
  54380. /**
  54381. * Fired when the trackpad on this controller is clicked
  54382. */
  54383. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54384. /**
  54385. * Fired when the trackpad on this controller is modified
  54386. */
  54387. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54388. /**
  54389. * The current x and y values of this controller's trackpad
  54390. */
  54391. trackpad: StickValues;
  54392. /**
  54393. * Creates a new WindowsMotionController from a gamepad
  54394. * @param vrGamepad the gamepad that the controller should be created from
  54395. */
  54396. constructor(vrGamepad: any);
  54397. /**
  54398. * Fired when the trigger on this controller is modified
  54399. */
  54400. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54401. /**
  54402. * Fired when the menu button on this controller is modified
  54403. */
  54404. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54405. /**
  54406. * Fired when the grip button on this controller is modified
  54407. */
  54408. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54409. /**
  54410. * Fired when the thumbstick button on this controller is modified
  54411. */
  54412. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54413. /**
  54414. * Fired when the touchpad button on this controller is modified
  54415. */
  54416. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54417. /**
  54418. * Fired when the touchpad values on this controller are modified
  54419. */
  54420. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54421. protected _updateTrackpad(): void;
  54422. /**
  54423. * Called once per frame by the engine.
  54424. */
  54425. update(): void;
  54426. /**
  54427. * Called once for each button that changed state since the last frame
  54428. * @param buttonIdx Which button index changed
  54429. * @param state New state of the button
  54430. * @param changes Which properties on the state changed since last frame
  54431. */
  54432. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54433. /**
  54434. * Moves the buttons on the controller mesh based on their current state
  54435. * @param buttonName the name of the button to move
  54436. * @param buttonValue the value of the button which determines the buttons new position
  54437. */
  54438. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54439. /**
  54440. * Moves the axis on the controller mesh based on its current state
  54441. * @param axis the index of the axis
  54442. * @param axisValue the value of the axis which determines the meshes new position
  54443. * @hidden
  54444. */
  54445. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54446. /**
  54447. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54448. * @param scene scene in which to add meshes
  54449. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54450. */
  54451. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54452. /**
  54453. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  54454. * can be transformed by button presses and axes values, based on this._mapping.
  54455. *
  54456. * @param scene scene in which the meshes exist
  54457. * @param meshes list of meshes that make up the controller model to process
  54458. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  54459. */
  54460. private processModel;
  54461. private createMeshInfo;
  54462. /**
  54463. * Gets the ray of the controller in the direction the controller is pointing
  54464. * @param length the length the resulting ray should be
  54465. * @returns a ray in the direction the controller is pointing
  54466. */
  54467. getForwardRay(length?: number): Ray;
  54468. /**
  54469. * Disposes of the controller
  54470. */
  54471. dispose(): void;
  54472. }
  54473. /**
  54474. * This class represents a new windows motion controller in XR.
  54475. */
  54476. export class XRWindowsMotionController extends WindowsMotionController {
  54477. /**
  54478. * Changing the original WIndowsMotionController mapping to fir the new mapping
  54479. */
  54480. protected readonly _mapping: {
  54481. buttons: string[];
  54482. buttonMeshNames: {
  54483. trigger: string;
  54484. menu: string;
  54485. grip: string;
  54486. thumbstick: string;
  54487. trackpad: string;
  54488. };
  54489. buttonObservableNames: {
  54490. trigger: string;
  54491. menu: string;
  54492. grip: string;
  54493. thumbstick: string;
  54494. trackpad: string;
  54495. };
  54496. axisMeshNames: string[];
  54497. pointingPoseMeshName: string;
  54498. };
  54499. /**
  54500. * Construct a new XR-Based windows motion controller
  54501. *
  54502. * @param gamepadInfo the gamepad object from the browser
  54503. */
  54504. constructor(gamepadInfo: any);
  54505. /**
  54506. * holds the thumbstick values (X,Y)
  54507. */
  54508. thumbstickValues: StickValues;
  54509. /**
  54510. * Fired when the thumbstick on this controller is clicked
  54511. */
  54512. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  54513. /**
  54514. * Fired when the thumbstick on this controller is modified
  54515. */
  54516. onThumbstickValuesChangedObservable: Observable<StickValues>;
  54517. /**
  54518. * Fired when the touchpad button on this controller is modified
  54519. */
  54520. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54521. /**
  54522. * Fired when the touchpad values on this controller are modified
  54523. */
  54524. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54525. /**
  54526. * Fired when the thumbstick button on this controller is modified
  54527. * here to prevent breaking changes
  54528. */
  54529. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54530. /**
  54531. * updating the thumbstick(!) and not the trackpad.
  54532. * This is named this way due to the difference between WebVR and XR and to avoid
  54533. * changing the parent class.
  54534. */
  54535. protected _updateTrackpad(): void;
  54536. /**
  54537. * Disposes the class with joy
  54538. */
  54539. dispose(): void;
  54540. }
  54541. }
  54542. declare module "babylonjs/Gamepads/Controllers/index" {
  54543. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  54544. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  54545. export * from "babylonjs/Gamepads/Controllers/genericController";
  54546. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  54547. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54548. export * from "babylonjs/Gamepads/Controllers/viveController";
  54549. export * from "babylonjs/Gamepads/Controllers/webVRController";
  54550. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  54551. }
  54552. declare module "babylonjs/Gamepads/index" {
  54553. export * from "babylonjs/Gamepads/Controllers/index";
  54554. export * from "babylonjs/Gamepads/gamepad";
  54555. export * from "babylonjs/Gamepads/gamepadManager";
  54556. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  54557. export * from "babylonjs/Gamepads/xboxGamepad";
  54558. export * from "babylonjs/Gamepads/dualShockGamepad";
  54559. }
  54560. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  54561. import { Scene } from "babylonjs/scene";
  54562. import { Vector4 } from "babylonjs/Maths/math.vector";
  54563. import { Color4 } from "babylonjs/Maths/math.color";
  54564. import { Mesh } from "babylonjs/Meshes/mesh";
  54565. import { Nullable } from "babylonjs/types";
  54566. /**
  54567. * Class containing static functions to help procedurally build meshes
  54568. */
  54569. export class PolyhedronBuilder {
  54570. /**
  54571. * Creates a polyhedron mesh
  54572. * * 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
  54573. * * The parameter `size` (positive float, default 1) sets the polygon size
  54574. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54575. * * 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`
  54576. * * 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
  54577. * * 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)`)
  54578. * * 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
  54579. * * 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
  54580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54581. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54583. * @param name defines the name of the mesh
  54584. * @param options defines the options used to create the mesh
  54585. * @param scene defines the hosting scene
  54586. * @returns the polyhedron mesh
  54587. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54588. */
  54589. static CreatePolyhedron(name: string, options: {
  54590. type?: number;
  54591. size?: number;
  54592. sizeX?: number;
  54593. sizeY?: number;
  54594. sizeZ?: number;
  54595. custom?: any;
  54596. faceUV?: Vector4[];
  54597. faceColors?: Color4[];
  54598. flat?: boolean;
  54599. updatable?: boolean;
  54600. sideOrientation?: number;
  54601. frontUVs?: Vector4;
  54602. backUVs?: Vector4;
  54603. }, scene?: Nullable<Scene>): Mesh;
  54604. }
  54605. }
  54606. declare module "babylonjs/Gizmos/scaleGizmo" {
  54607. import { Observable } from "babylonjs/Misc/observable";
  54608. import { Nullable } from "babylonjs/types";
  54609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54610. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54611. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54612. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54613. /**
  54614. * Gizmo that enables scaling a mesh along 3 axis
  54615. */
  54616. export class ScaleGizmo extends Gizmo {
  54617. /**
  54618. * Internal gizmo used for interactions on the x axis
  54619. */
  54620. xGizmo: AxisScaleGizmo;
  54621. /**
  54622. * Internal gizmo used for interactions on the y axis
  54623. */
  54624. yGizmo: AxisScaleGizmo;
  54625. /**
  54626. * Internal gizmo used for interactions on the z axis
  54627. */
  54628. zGizmo: AxisScaleGizmo;
  54629. /**
  54630. * Internal gizmo used to scale all axis equally
  54631. */
  54632. uniformScaleGizmo: AxisScaleGizmo;
  54633. private _meshAttached;
  54634. private _updateGizmoRotationToMatchAttachedMesh;
  54635. private _snapDistance;
  54636. private _scaleRatio;
  54637. private _uniformScalingMesh;
  54638. private _octahedron;
  54639. private _sensitivity;
  54640. /** Fires an event when any of it's sub gizmos are dragged */
  54641. onDragStartObservable: Observable<unknown>;
  54642. /** Fires an event when any of it's sub gizmos are released from dragging */
  54643. onDragEndObservable: Observable<unknown>;
  54644. get attachedMesh(): Nullable<AbstractMesh>;
  54645. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54646. /**
  54647. * Creates a ScaleGizmo
  54648. * @param gizmoLayer The utility layer the gizmo will be added to
  54649. */
  54650. constructor(gizmoLayer?: UtilityLayerRenderer);
  54651. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54652. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54653. /**
  54654. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54655. */
  54656. set snapDistance(value: number);
  54657. get snapDistance(): number;
  54658. /**
  54659. * Ratio for the scale of the gizmo (Default: 1)
  54660. */
  54661. set scaleRatio(value: number);
  54662. get scaleRatio(): number;
  54663. /**
  54664. * Sensitivity factor for dragging (Default: 1)
  54665. */
  54666. set sensitivity(value: number);
  54667. get sensitivity(): number;
  54668. /**
  54669. * Disposes of the gizmo
  54670. */
  54671. dispose(): void;
  54672. }
  54673. }
  54674. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54675. import { Observable } from "babylonjs/Misc/observable";
  54676. import { Nullable } from "babylonjs/types";
  54677. import { Vector3 } from "babylonjs/Maths/math.vector";
  54678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54679. import { Mesh } from "babylonjs/Meshes/mesh";
  54680. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54681. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54682. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54683. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54684. import { Color3 } from "babylonjs/Maths/math.color";
  54685. /**
  54686. * Single axis scale gizmo
  54687. */
  54688. export class AxisScaleGizmo extends Gizmo {
  54689. /**
  54690. * Drag behavior responsible for the gizmos dragging interactions
  54691. */
  54692. dragBehavior: PointerDragBehavior;
  54693. private _pointerObserver;
  54694. /**
  54695. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54696. */
  54697. snapDistance: number;
  54698. /**
  54699. * Event that fires each time the gizmo snaps to a new location.
  54700. * * snapDistance is the the change in distance
  54701. */
  54702. onSnapObservable: Observable<{
  54703. snapDistance: number;
  54704. }>;
  54705. /**
  54706. * If the scaling operation should be done on all axis (default: false)
  54707. */
  54708. uniformScaling: boolean;
  54709. /**
  54710. * Custom sensitivity value for the drag strength
  54711. */
  54712. sensitivity: number;
  54713. private _isEnabled;
  54714. private _parent;
  54715. private _arrow;
  54716. private _coloredMaterial;
  54717. private _hoverMaterial;
  54718. /**
  54719. * Creates an AxisScaleGizmo
  54720. * @param gizmoLayer The utility layer the gizmo will be added to
  54721. * @param dragAxis The axis which the gizmo will be able to scale on
  54722. * @param color The color of the gizmo
  54723. */
  54724. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54725. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54726. /**
  54727. * If the gizmo is enabled
  54728. */
  54729. set isEnabled(value: boolean);
  54730. get isEnabled(): boolean;
  54731. /**
  54732. * Disposes of the gizmo
  54733. */
  54734. dispose(): void;
  54735. /**
  54736. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54737. * @param mesh The mesh to replace the default mesh of the gizmo
  54738. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54739. */
  54740. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54741. }
  54742. }
  54743. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54744. import { Observable } from "babylonjs/Misc/observable";
  54745. import { Nullable } from "babylonjs/types";
  54746. import { Vector3 } from "babylonjs/Maths/math.vector";
  54747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54748. import { Mesh } from "babylonjs/Meshes/mesh";
  54749. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54750. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54751. import { Color3 } from "babylonjs/Maths/math.color";
  54752. import "babylonjs/Meshes/Builders/boxBuilder";
  54753. /**
  54754. * Bounding box gizmo
  54755. */
  54756. export class BoundingBoxGizmo extends Gizmo {
  54757. private _lineBoundingBox;
  54758. private _rotateSpheresParent;
  54759. private _scaleBoxesParent;
  54760. private _boundingDimensions;
  54761. private _renderObserver;
  54762. private _pointerObserver;
  54763. private _scaleDragSpeed;
  54764. private _tmpQuaternion;
  54765. private _tmpVector;
  54766. private _tmpRotationMatrix;
  54767. /**
  54768. * 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)
  54769. */
  54770. ignoreChildren: boolean;
  54771. /**
  54772. * 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)
  54773. */
  54774. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54775. /**
  54776. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54777. */
  54778. rotationSphereSize: number;
  54779. /**
  54780. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54781. */
  54782. scaleBoxSize: number;
  54783. /**
  54784. * 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)
  54785. */
  54786. fixedDragMeshScreenSize: boolean;
  54787. /**
  54788. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54789. */
  54790. fixedDragMeshScreenSizeDistanceFactor: number;
  54791. /**
  54792. * Fired when a rotation sphere or scale box is dragged
  54793. */
  54794. onDragStartObservable: Observable<{}>;
  54795. /**
  54796. * Fired when a scale box is dragged
  54797. */
  54798. onScaleBoxDragObservable: Observable<{}>;
  54799. /**
  54800. * Fired when a scale box drag is ended
  54801. */
  54802. onScaleBoxDragEndObservable: Observable<{}>;
  54803. /**
  54804. * Fired when a rotation sphere is dragged
  54805. */
  54806. onRotationSphereDragObservable: Observable<{}>;
  54807. /**
  54808. * Fired when a rotation sphere drag is ended
  54809. */
  54810. onRotationSphereDragEndObservable: Observable<{}>;
  54811. /**
  54812. * Relative bounding box pivot used when scaling the attached mesh. 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)
  54813. */
  54814. scalePivot: Nullable<Vector3>;
  54815. /**
  54816. * Mesh used as a pivot to rotate the attached mesh
  54817. */
  54818. private _anchorMesh;
  54819. private _existingMeshScale;
  54820. private _dragMesh;
  54821. private pointerDragBehavior;
  54822. private coloredMaterial;
  54823. private hoverColoredMaterial;
  54824. /**
  54825. * Sets the color of the bounding box gizmo
  54826. * @param color the color to set
  54827. */
  54828. setColor(color: Color3): void;
  54829. /**
  54830. * Creates an BoundingBoxGizmo
  54831. * @param gizmoLayer The utility layer the gizmo will be added to
  54832. * @param color The color of the gizmo
  54833. */
  54834. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54835. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54836. private _selectNode;
  54837. /**
  54838. * Updates the bounding box information for the Gizmo
  54839. */
  54840. updateBoundingBox(): void;
  54841. private _updateRotationSpheres;
  54842. private _updateScaleBoxes;
  54843. /**
  54844. * Enables rotation on the specified axis and disables rotation on the others
  54845. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54846. */
  54847. setEnabledRotationAxis(axis: string): void;
  54848. /**
  54849. * Enables/disables scaling
  54850. * @param enable if scaling should be enabled
  54851. * @param homogeneousScaling defines if scaling should only be homogeneous
  54852. */
  54853. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54854. private _updateDummy;
  54855. /**
  54856. * Enables a pointer drag behavior on the bounding box of the gizmo
  54857. */
  54858. enableDragBehavior(): void;
  54859. /**
  54860. * Disposes of the gizmo
  54861. */
  54862. dispose(): void;
  54863. /**
  54864. * 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)
  54865. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54866. * @returns the bounding box mesh with the passed in mesh as a child
  54867. */
  54868. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54869. /**
  54870. * CustomMeshes are not supported by this gizmo
  54871. * @param mesh The mesh to replace the default mesh of the gizmo
  54872. */
  54873. setCustomMesh(mesh: Mesh): void;
  54874. }
  54875. }
  54876. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54877. import { Observable } from "babylonjs/Misc/observable";
  54878. import { Nullable } from "babylonjs/types";
  54879. import { Vector3 } from "babylonjs/Maths/math.vector";
  54880. import { Color3 } from "babylonjs/Maths/math.color";
  54881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54882. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54883. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54884. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54885. import "babylonjs/Meshes/Builders/linesBuilder";
  54886. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54887. /**
  54888. * Single plane rotation gizmo
  54889. */
  54890. export class PlaneRotationGizmo extends Gizmo {
  54891. /**
  54892. * Drag behavior responsible for the gizmos dragging interactions
  54893. */
  54894. dragBehavior: PointerDragBehavior;
  54895. private _pointerObserver;
  54896. /**
  54897. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54898. */
  54899. snapDistance: number;
  54900. /**
  54901. * Event that fires each time the gizmo snaps to a new location.
  54902. * * snapDistance is the the change in distance
  54903. */
  54904. onSnapObservable: Observable<{
  54905. snapDistance: number;
  54906. }>;
  54907. private _isEnabled;
  54908. private _parent;
  54909. /**
  54910. * Creates a PlaneRotationGizmo
  54911. * @param gizmoLayer The utility layer the gizmo will be added to
  54912. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54913. * @param color The color of the gizmo
  54914. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54915. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54916. */
  54917. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54918. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54919. /**
  54920. * If the gizmo is enabled
  54921. */
  54922. set isEnabled(value: boolean);
  54923. get isEnabled(): boolean;
  54924. /**
  54925. * Disposes of the gizmo
  54926. */
  54927. dispose(): void;
  54928. }
  54929. }
  54930. declare module "babylonjs/Gizmos/rotationGizmo" {
  54931. import { Observable } from "babylonjs/Misc/observable";
  54932. import { Nullable } from "babylonjs/types";
  54933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54934. import { Mesh } from "babylonjs/Meshes/mesh";
  54935. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54936. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54937. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54938. /**
  54939. * Gizmo that enables rotating a mesh along 3 axis
  54940. */
  54941. export class RotationGizmo extends Gizmo {
  54942. /**
  54943. * Internal gizmo used for interactions on the x axis
  54944. */
  54945. xGizmo: PlaneRotationGizmo;
  54946. /**
  54947. * Internal gizmo used for interactions on the y axis
  54948. */
  54949. yGizmo: PlaneRotationGizmo;
  54950. /**
  54951. * Internal gizmo used for interactions on the z axis
  54952. */
  54953. zGizmo: PlaneRotationGizmo;
  54954. /** Fires an event when any of it's sub gizmos are dragged */
  54955. onDragStartObservable: Observable<unknown>;
  54956. /** Fires an event when any of it's sub gizmos are released from dragging */
  54957. onDragEndObservable: Observable<unknown>;
  54958. private _meshAttached;
  54959. get attachedMesh(): Nullable<AbstractMesh>;
  54960. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54961. /**
  54962. * Creates a RotationGizmo
  54963. * @param gizmoLayer The utility layer the gizmo will be added to
  54964. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54965. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54966. */
  54967. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54968. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54969. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54970. /**
  54971. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54972. */
  54973. set snapDistance(value: number);
  54974. get snapDistance(): number;
  54975. /**
  54976. * Ratio for the scale of the gizmo (Default: 1)
  54977. */
  54978. set scaleRatio(value: number);
  54979. get scaleRatio(): number;
  54980. /**
  54981. * Disposes of the gizmo
  54982. */
  54983. dispose(): void;
  54984. /**
  54985. * CustomMeshes are not supported by this gizmo
  54986. * @param mesh The mesh to replace the default mesh of the gizmo
  54987. */
  54988. setCustomMesh(mesh: Mesh): void;
  54989. }
  54990. }
  54991. declare module "babylonjs/Gizmos/gizmoManager" {
  54992. import { Observable } from "babylonjs/Misc/observable";
  54993. import { Nullable } from "babylonjs/types";
  54994. import { Scene, IDisposable } from "babylonjs/scene";
  54995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54996. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54997. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54998. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54999. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55000. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55001. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55002. /**
  55003. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  55004. */
  55005. export class GizmoManager implements IDisposable {
  55006. private scene;
  55007. /**
  55008. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55009. */
  55010. gizmos: {
  55011. positionGizmo: Nullable<PositionGizmo>;
  55012. rotationGizmo: Nullable<RotationGizmo>;
  55013. scaleGizmo: Nullable<ScaleGizmo>;
  55014. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55015. };
  55016. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55017. clearGizmoOnEmptyPointerEvent: boolean;
  55018. /** Fires an event when the manager is attached to a mesh */
  55019. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55020. private _gizmosEnabled;
  55021. private _pointerObserver;
  55022. private _attachedMesh;
  55023. private _boundingBoxColor;
  55024. private _defaultUtilityLayer;
  55025. private _defaultKeepDepthUtilityLayer;
  55026. /**
  55027. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55028. */
  55029. boundingBoxDragBehavior: SixDofDragBehavior;
  55030. /**
  55031. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55032. */
  55033. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55034. /**
  55035. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  55036. */
  55037. usePointerToAttachGizmos: boolean;
  55038. /**
  55039. * Utility layer that the bounding box gizmo belongs to
  55040. */
  55041. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55042. /**
  55043. * Utility layer that all gizmos besides bounding box belong to
  55044. */
  55045. get utilityLayer(): UtilityLayerRenderer;
  55046. /**
  55047. * Instatiates a gizmo manager
  55048. * @param scene the scene to overlay the gizmos on top of
  55049. */
  55050. constructor(scene: Scene);
  55051. /**
  55052. * Attaches a set of gizmos to the specified mesh
  55053. * @param mesh The mesh the gizmo's should be attached to
  55054. */
  55055. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55056. /**
  55057. * If the position gizmo is enabled
  55058. */
  55059. set positionGizmoEnabled(value: boolean);
  55060. get positionGizmoEnabled(): boolean;
  55061. /**
  55062. * If the rotation gizmo is enabled
  55063. */
  55064. set rotationGizmoEnabled(value: boolean);
  55065. get rotationGizmoEnabled(): boolean;
  55066. /**
  55067. * If the scale gizmo is enabled
  55068. */
  55069. set scaleGizmoEnabled(value: boolean);
  55070. get scaleGizmoEnabled(): boolean;
  55071. /**
  55072. * If the boundingBox gizmo is enabled
  55073. */
  55074. set boundingBoxGizmoEnabled(value: boolean);
  55075. get boundingBoxGizmoEnabled(): boolean;
  55076. /**
  55077. * Disposes of the gizmo manager
  55078. */
  55079. dispose(): void;
  55080. }
  55081. }
  55082. declare module "babylonjs/Lights/directionalLight" {
  55083. import { Camera } from "babylonjs/Cameras/camera";
  55084. import { Scene } from "babylonjs/scene";
  55085. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55087. import { Light } from "babylonjs/Lights/light";
  55088. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55089. import { Effect } from "babylonjs/Materials/effect";
  55090. /**
  55091. * A directional light is defined by a direction (what a surprise!).
  55092. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55093. * 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.
  55094. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55095. */
  55096. export class DirectionalLight extends ShadowLight {
  55097. private _shadowFrustumSize;
  55098. /**
  55099. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  55100. */
  55101. get shadowFrustumSize(): number;
  55102. /**
  55103. * Specifies a fix frustum size for the shadow generation.
  55104. */
  55105. set shadowFrustumSize(value: number);
  55106. private _shadowOrthoScale;
  55107. /**
  55108. * Gets the shadow projection scale against the optimal computed one.
  55109. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55110. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55111. */
  55112. get shadowOrthoScale(): number;
  55113. /**
  55114. * Sets the shadow projection scale against the optimal computed one.
  55115. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55116. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55117. */
  55118. set shadowOrthoScale(value: number);
  55119. /**
  55120. * Automatically compute the projection matrix to best fit (including all the casters)
  55121. * on each frame.
  55122. */
  55123. autoUpdateExtends: boolean;
  55124. /**
  55125. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  55126. * on each frame. autoUpdateExtends must be set to true for this to work
  55127. */
  55128. autoCalcShadowZBounds: boolean;
  55129. private _orthoLeft;
  55130. private _orthoRight;
  55131. private _orthoTop;
  55132. private _orthoBottom;
  55133. /**
  55134. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  55135. * The directional light is emitted from everywhere in the given direction.
  55136. * It can cast shadows.
  55137. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55138. * @param name The friendly name of the light
  55139. * @param direction The direction of the light
  55140. * @param scene The scene the light belongs to
  55141. */
  55142. constructor(name: string, direction: Vector3, scene: Scene);
  55143. /**
  55144. * Returns the string "DirectionalLight".
  55145. * @return The class name
  55146. */
  55147. getClassName(): string;
  55148. /**
  55149. * Returns the integer 1.
  55150. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55151. */
  55152. getTypeID(): number;
  55153. /**
  55154. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  55155. * Returns the DirectionalLight Shadow projection matrix.
  55156. */
  55157. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55158. /**
  55159. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  55160. * Returns the DirectionalLight Shadow projection matrix.
  55161. */
  55162. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55163. /**
  55164. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55165. * Returns the DirectionalLight Shadow projection matrix.
  55166. */
  55167. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55168. protected _buildUniformLayout(): void;
  55169. /**
  55170. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55171. * @param effect The effect to update
  55172. * @param lightIndex The index of the light in the effect to update
  55173. * @returns The directional light
  55174. */
  55175. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55176. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55177. /**
  55178. * Gets the minZ used for shadow according to both the scene and the light.
  55179. *
  55180. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55181. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55182. * @param activeCamera The camera we are returning the min for
  55183. * @returns the depth min z
  55184. */
  55185. getDepthMinZ(activeCamera: Camera): number;
  55186. /**
  55187. * Gets the maxZ used for shadow according to both the scene and the light.
  55188. *
  55189. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55190. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55191. * @param activeCamera The camera we are returning the max for
  55192. * @returns the depth max z
  55193. */
  55194. getDepthMaxZ(activeCamera: Camera): number;
  55195. /**
  55196. * Prepares the list of defines specific to the light type.
  55197. * @param defines the list of defines
  55198. * @param lightIndex defines the index of the light for the effect
  55199. */
  55200. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55201. }
  55202. }
  55203. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55204. import { Mesh } from "babylonjs/Meshes/mesh";
  55205. /**
  55206. * Class containing static functions to help procedurally build meshes
  55207. */
  55208. export class HemisphereBuilder {
  55209. /**
  55210. * Creates a hemisphere mesh
  55211. * @param name defines the name of the mesh
  55212. * @param options defines the options used to create the mesh
  55213. * @param scene defines the hosting scene
  55214. * @returns the hemisphere mesh
  55215. */
  55216. static CreateHemisphere(name: string, options: {
  55217. segments?: number;
  55218. diameter?: number;
  55219. sideOrientation?: number;
  55220. }, scene: any): Mesh;
  55221. }
  55222. }
  55223. declare module "babylonjs/Lights/spotLight" {
  55224. import { Nullable } from "babylonjs/types";
  55225. import { Scene } from "babylonjs/scene";
  55226. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55228. import { Effect } from "babylonjs/Materials/effect";
  55229. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55230. import { Light } from "babylonjs/Lights/light";
  55231. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55232. /**
  55233. * A spot light is defined by a position, a direction, an angle, and an exponent.
  55234. * These values define a cone of light starting from the position, emitting toward the direction.
  55235. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  55236. * and the exponent defines the speed of the decay of the light with distance (reach).
  55237. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55238. */
  55239. export class SpotLight extends ShadowLight {
  55240. private _angle;
  55241. private _innerAngle;
  55242. private _cosHalfAngle;
  55243. private _lightAngleScale;
  55244. private _lightAngleOffset;
  55245. /**
  55246. * Gets the cone angle of the spot light in Radians.
  55247. */
  55248. get angle(): number;
  55249. /**
  55250. * Sets the cone angle of the spot light in Radians.
  55251. */
  55252. set angle(value: number);
  55253. /**
  55254. * Only used in gltf falloff mode, this defines the angle where
  55255. * the directional falloff will start before cutting at angle which could be seen
  55256. * as outer angle.
  55257. */
  55258. get innerAngle(): number;
  55259. /**
  55260. * Only used in gltf falloff mode, this defines the angle where
  55261. * the directional falloff will start before cutting at angle which could be seen
  55262. * as outer angle.
  55263. */
  55264. set innerAngle(value: number);
  55265. private _shadowAngleScale;
  55266. /**
  55267. * Allows scaling the angle of the light for shadow generation only.
  55268. */
  55269. get shadowAngleScale(): number;
  55270. /**
  55271. * Allows scaling the angle of the light for shadow generation only.
  55272. */
  55273. set shadowAngleScale(value: number);
  55274. /**
  55275. * The light decay speed with the distance from the emission spot.
  55276. */
  55277. exponent: number;
  55278. private _projectionTextureMatrix;
  55279. /**
  55280. * Allows reading the projecton texture
  55281. */
  55282. get projectionTextureMatrix(): Matrix;
  55283. protected _projectionTextureLightNear: number;
  55284. /**
  55285. * Gets the near clip of the Spotlight for texture projection.
  55286. */
  55287. get projectionTextureLightNear(): number;
  55288. /**
  55289. * Sets the near clip of the Spotlight for texture projection.
  55290. */
  55291. set projectionTextureLightNear(value: number);
  55292. protected _projectionTextureLightFar: number;
  55293. /**
  55294. * Gets the far clip of the Spotlight for texture projection.
  55295. */
  55296. get projectionTextureLightFar(): number;
  55297. /**
  55298. * Sets the far clip of the Spotlight for texture projection.
  55299. */
  55300. set projectionTextureLightFar(value: number);
  55301. protected _projectionTextureUpDirection: Vector3;
  55302. /**
  55303. * Gets the Up vector of the Spotlight for texture projection.
  55304. */
  55305. get projectionTextureUpDirection(): Vector3;
  55306. /**
  55307. * Sets the Up vector of the Spotlight for texture projection.
  55308. */
  55309. set projectionTextureUpDirection(value: Vector3);
  55310. private _projectionTexture;
  55311. /**
  55312. * Gets the projection texture of the light.
  55313. */
  55314. get projectionTexture(): Nullable<BaseTexture>;
  55315. /**
  55316. * Sets the projection texture of the light.
  55317. */
  55318. set projectionTexture(value: Nullable<BaseTexture>);
  55319. private _projectionTextureViewLightDirty;
  55320. private _projectionTextureProjectionLightDirty;
  55321. private _projectionTextureDirty;
  55322. private _projectionTextureViewTargetVector;
  55323. private _projectionTextureViewLightMatrix;
  55324. private _projectionTextureProjectionLightMatrix;
  55325. private _projectionTextureScalingMatrix;
  55326. /**
  55327. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  55328. * It can cast shadows.
  55329. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55330. * @param name The light friendly name
  55331. * @param position The position of the spot light in the scene
  55332. * @param direction The direction of the light in the scene
  55333. * @param angle The cone angle of the light in Radians
  55334. * @param exponent The light decay speed with the distance from the emission spot
  55335. * @param scene The scene the lights belongs to
  55336. */
  55337. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55338. /**
  55339. * Returns the string "SpotLight".
  55340. * @returns the class name
  55341. */
  55342. getClassName(): string;
  55343. /**
  55344. * Returns the integer 2.
  55345. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55346. */
  55347. getTypeID(): number;
  55348. /**
  55349. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55350. */
  55351. protected _setDirection(value: Vector3): void;
  55352. /**
  55353. * Overrides the position setter to recompute the projection texture view light Matrix.
  55354. */
  55355. protected _setPosition(value: Vector3): void;
  55356. /**
  55357. * 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.
  55358. * Returns the SpotLight.
  55359. */
  55360. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55361. protected _computeProjectionTextureViewLightMatrix(): void;
  55362. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55363. /**
  55364. * Main function for light texture projection matrix computing.
  55365. */
  55366. protected _computeProjectionTextureMatrix(): void;
  55367. protected _buildUniformLayout(): void;
  55368. private _computeAngleValues;
  55369. /**
  55370. * Sets the passed Effect "effect" with the Light textures.
  55371. * @param effect The effect to update
  55372. * @param lightIndex The index of the light in the effect to update
  55373. * @returns The light
  55374. */
  55375. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55376. /**
  55377. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55378. * @param effect The effect to update
  55379. * @param lightIndex The index of the light in the effect to update
  55380. * @returns The spot light
  55381. */
  55382. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55383. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55384. /**
  55385. * Disposes the light and the associated resources.
  55386. */
  55387. dispose(): void;
  55388. /**
  55389. * Prepares the list of defines specific to the light type.
  55390. * @param defines the list of defines
  55391. * @param lightIndex defines the index of the light for the effect
  55392. */
  55393. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55394. }
  55395. }
  55396. declare module "babylonjs/Gizmos/lightGizmo" {
  55397. import { Nullable } from "babylonjs/types";
  55398. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55399. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55400. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55401. import { Light } from "babylonjs/Lights/light";
  55402. /**
  55403. * Gizmo that enables viewing a light
  55404. */
  55405. export class LightGizmo extends Gizmo {
  55406. private _lightMesh;
  55407. private _material;
  55408. private _cachedPosition;
  55409. private _cachedForward;
  55410. private _attachedMeshParent;
  55411. /**
  55412. * Creates a LightGizmo
  55413. * @param gizmoLayer The utility layer the gizmo will be added to
  55414. */
  55415. constructor(gizmoLayer?: UtilityLayerRenderer);
  55416. private _light;
  55417. /**
  55418. * The light that the gizmo is attached to
  55419. */
  55420. set light(light: Nullable<Light>);
  55421. get light(): Nullable<Light>;
  55422. /**
  55423. * Gets the material used to render the light gizmo
  55424. */
  55425. get material(): StandardMaterial;
  55426. /**
  55427. * @hidden
  55428. * Updates the gizmo to match the attached mesh's position/rotation
  55429. */
  55430. protected _update(): void;
  55431. private static _Scale;
  55432. /**
  55433. * Creates the lines for a light mesh
  55434. */
  55435. private static _CreateLightLines;
  55436. /**
  55437. * Disposes of the light gizmo
  55438. */
  55439. dispose(): void;
  55440. private static _CreateHemisphericLightMesh;
  55441. private static _CreatePointLightMesh;
  55442. private static _CreateSpotLightMesh;
  55443. private static _CreateDirectionalLightMesh;
  55444. }
  55445. }
  55446. declare module "babylonjs/Gizmos/index" {
  55447. export * from "babylonjs/Gizmos/axisDragGizmo";
  55448. export * from "babylonjs/Gizmos/axisScaleGizmo";
  55449. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  55450. export * from "babylonjs/Gizmos/gizmo";
  55451. export * from "babylonjs/Gizmos/gizmoManager";
  55452. export * from "babylonjs/Gizmos/planeRotationGizmo";
  55453. export * from "babylonjs/Gizmos/positionGizmo";
  55454. export * from "babylonjs/Gizmos/rotationGizmo";
  55455. export * from "babylonjs/Gizmos/scaleGizmo";
  55456. export * from "babylonjs/Gizmos/lightGizmo";
  55457. export * from "babylonjs/Gizmos/planeDragGizmo";
  55458. }
  55459. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  55460. /** @hidden */
  55461. export var backgroundFragmentDeclaration: {
  55462. name: string;
  55463. shader: string;
  55464. };
  55465. }
  55466. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  55467. /** @hidden */
  55468. export var backgroundUboDeclaration: {
  55469. name: string;
  55470. shader: string;
  55471. };
  55472. }
  55473. declare module "babylonjs/Shaders/background.fragment" {
  55474. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  55475. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55476. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55477. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55478. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55479. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55480. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55481. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  55482. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  55483. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55484. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  55485. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  55486. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55487. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  55488. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  55489. /** @hidden */
  55490. export var backgroundPixelShader: {
  55491. name: string;
  55492. shader: string;
  55493. };
  55494. }
  55495. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  55496. /** @hidden */
  55497. export var backgroundVertexDeclaration: {
  55498. name: string;
  55499. shader: string;
  55500. };
  55501. }
  55502. declare module "babylonjs/Shaders/background.vertex" {
  55503. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  55504. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55505. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55506. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55507. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55508. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  55509. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  55510. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55511. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55512. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55513. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55514. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55515. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  55516. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  55517. /** @hidden */
  55518. export var backgroundVertexShader: {
  55519. name: string;
  55520. shader: string;
  55521. };
  55522. }
  55523. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  55524. import { Nullable, int, float } from "babylonjs/types";
  55525. import { Scene } from "babylonjs/scene";
  55526. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55527. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55529. import { Mesh } from "babylonjs/Meshes/mesh";
  55530. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55531. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  55532. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  55533. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55534. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  55535. import { Color3 } from "babylonjs/Maths/math.color";
  55536. import "babylonjs/Shaders/background.fragment";
  55537. import "babylonjs/Shaders/background.vertex";
  55538. /**
  55539. * Background material used to create an efficient environement around your scene.
  55540. */
  55541. export class BackgroundMaterial extends PushMaterial {
  55542. /**
  55543. * Standard reflectance value at parallel view angle.
  55544. */
  55545. static StandardReflectance0: number;
  55546. /**
  55547. * Standard reflectance value at grazing angle.
  55548. */
  55549. static StandardReflectance90: number;
  55550. protected _primaryColor: Color3;
  55551. /**
  55552. * Key light Color (multiply against the environement texture)
  55553. */
  55554. primaryColor: Color3;
  55555. protected __perceptualColor: Nullable<Color3>;
  55556. /**
  55557. * Experimental Internal Use Only.
  55558. *
  55559. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  55560. * This acts as a helper to set the primary color to a more "human friendly" value.
  55561. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  55562. * output color as close as possible from the chosen value.
  55563. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55564. * part of lighting setup.)
  55565. */
  55566. get _perceptualColor(): Nullable<Color3>;
  55567. set _perceptualColor(value: Nullable<Color3>);
  55568. protected _primaryColorShadowLevel: float;
  55569. /**
  55570. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55571. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55572. */
  55573. get primaryColorShadowLevel(): float;
  55574. set primaryColorShadowLevel(value: float);
  55575. protected _primaryColorHighlightLevel: float;
  55576. /**
  55577. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55578. * The primary color is used at the level chosen to define what the white area would look.
  55579. */
  55580. get primaryColorHighlightLevel(): float;
  55581. set primaryColorHighlightLevel(value: float);
  55582. protected _reflectionTexture: Nullable<BaseTexture>;
  55583. /**
  55584. * Reflection Texture used in the material.
  55585. * Should be author in a specific way for the best result (refer to the documentation).
  55586. */
  55587. reflectionTexture: Nullable<BaseTexture>;
  55588. protected _reflectionBlur: float;
  55589. /**
  55590. * Reflection Texture level of blur.
  55591. *
  55592. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55593. * texture twice.
  55594. */
  55595. reflectionBlur: float;
  55596. protected _diffuseTexture: Nullable<BaseTexture>;
  55597. /**
  55598. * Diffuse Texture used in the material.
  55599. * Should be author in a specific way for the best result (refer to the documentation).
  55600. */
  55601. diffuseTexture: Nullable<BaseTexture>;
  55602. protected _shadowLights: Nullable<IShadowLight[]>;
  55603. /**
  55604. * Specify the list of lights casting shadow on the material.
  55605. * All scene shadow lights will be included if null.
  55606. */
  55607. shadowLights: Nullable<IShadowLight[]>;
  55608. protected _shadowLevel: float;
  55609. /**
  55610. * Helps adjusting the shadow to a softer level if required.
  55611. * 0 means black shadows and 1 means no shadows.
  55612. */
  55613. shadowLevel: float;
  55614. protected _sceneCenter: Vector3;
  55615. /**
  55616. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55617. * It is usually zero but might be interesting to modify according to your setup.
  55618. */
  55619. sceneCenter: Vector3;
  55620. protected _opacityFresnel: boolean;
  55621. /**
  55622. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55623. * This helps ensuring a nice transition when the camera goes under the ground.
  55624. */
  55625. opacityFresnel: boolean;
  55626. protected _reflectionFresnel: boolean;
  55627. /**
  55628. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55629. * This helps adding a mirror texture on the ground.
  55630. */
  55631. reflectionFresnel: boolean;
  55632. protected _reflectionFalloffDistance: number;
  55633. /**
  55634. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55635. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55636. */
  55637. reflectionFalloffDistance: number;
  55638. protected _reflectionAmount: number;
  55639. /**
  55640. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55641. */
  55642. reflectionAmount: number;
  55643. protected _reflectionReflectance0: number;
  55644. /**
  55645. * This specifies the weight of the reflection at grazing angle.
  55646. */
  55647. reflectionReflectance0: number;
  55648. protected _reflectionReflectance90: number;
  55649. /**
  55650. * This specifies the weight of the reflection at a perpendicular point of view.
  55651. */
  55652. reflectionReflectance90: number;
  55653. /**
  55654. * Sets the reflection reflectance fresnel values according to the default standard
  55655. * empirically know to work well :-)
  55656. */
  55657. set reflectionStandardFresnelWeight(value: number);
  55658. protected _useRGBColor: boolean;
  55659. /**
  55660. * Helps to directly use the maps channels instead of their level.
  55661. */
  55662. useRGBColor: boolean;
  55663. protected _enableNoise: boolean;
  55664. /**
  55665. * This helps reducing the banding effect that could occur on the background.
  55666. */
  55667. enableNoise: boolean;
  55668. /**
  55669. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55670. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55671. * Recommended to be keep at 1.0 except for special cases.
  55672. */
  55673. get fovMultiplier(): number;
  55674. set fovMultiplier(value: number);
  55675. private _fovMultiplier;
  55676. /**
  55677. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55678. */
  55679. useEquirectangularFOV: boolean;
  55680. private _maxSimultaneousLights;
  55681. /**
  55682. * Number of Simultaneous lights allowed on the material.
  55683. */
  55684. maxSimultaneousLights: int;
  55685. private _shadowOnly;
  55686. /**
  55687. * Make the material only render shadows
  55688. */
  55689. shadowOnly: boolean;
  55690. /**
  55691. * Default configuration related to image processing available in the Background Material.
  55692. */
  55693. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55694. /**
  55695. * Keep track of the image processing observer to allow dispose and replace.
  55696. */
  55697. private _imageProcessingObserver;
  55698. /**
  55699. * Attaches a new image processing configuration to the PBR Material.
  55700. * @param configuration (if null the scene configuration will be use)
  55701. */
  55702. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55703. /**
  55704. * Gets the image processing configuration used either in this material.
  55705. */
  55706. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55707. /**
  55708. * Sets the Default image processing configuration used either in the this material.
  55709. *
  55710. * If sets to null, the scene one is in use.
  55711. */
  55712. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55713. /**
  55714. * Gets wether the color curves effect is enabled.
  55715. */
  55716. get cameraColorCurvesEnabled(): boolean;
  55717. /**
  55718. * Sets wether the color curves effect is enabled.
  55719. */
  55720. set cameraColorCurvesEnabled(value: boolean);
  55721. /**
  55722. * Gets wether the color grading effect is enabled.
  55723. */
  55724. get cameraColorGradingEnabled(): boolean;
  55725. /**
  55726. * Gets wether the color grading effect is enabled.
  55727. */
  55728. set cameraColorGradingEnabled(value: boolean);
  55729. /**
  55730. * Gets wether tonemapping is enabled or not.
  55731. */
  55732. get cameraToneMappingEnabled(): boolean;
  55733. /**
  55734. * Sets wether tonemapping is enabled or not
  55735. */
  55736. set cameraToneMappingEnabled(value: boolean);
  55737. /**
  55738. * The camera exposure used on this material.
  55739. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55740. * This corresponds to a photographic exposure.
  55741. */
  55742. get cameraExposure(): float;
  55743. /**
  55744. * The camera exposure used on this material.
  55745. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55746. * This corresponds to a photographic exposure.
  55747. */
  55748. set cameraExposure(value: float);
  55749. /**
  55750. * Gets The camera contrast used on this material.
  55751. */
  55752. get cameraContrast(): float;
  55753. /**
  55754. * Sets The camera contrast used on this material.
  55755. */
  55756. set cameraContrast(value: float);
  55757. /**
  55758. * Gets the Color Grading 2D Lookup Texture.
  55759. */
  55760. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55761. /**
  55762. * Sets the Color Grading 2D Lookup Texture.
  55763. */
  55764. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55765. /**
  55766. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55767. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55768. * 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;
  55769. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55770. */
  55771. get cameraColorCurves(): Nullable<ColorCurves>;
  55772. /**
  55773. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55774. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55775. * 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;
  55776. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55777. */
  55778. set cameraColorCurves(value: Nullable<ColorCurves>);
  55779. /**
  55780. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55781. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55782. */
  55783. switchToBGR: boolean;
  55784. private _renderTargets;
  55785. private _reflectionControls;
  55786. private _white;
  55787. private _primaryShadowColor;
  55788. private _primaryHighlightColor;
  55789. /**
  55790. * Instantiates a Background Material in the given scene
  55791. * @param name The friendly name of the material
  55792. * @param scene The scene to add the material to
  55793. */
  55794. constructor(name: string, scene: Scene);
  55795. /**
  55796. * Gets a boolean indicating that current material needs to register RTT
  55797. */
  55798. get hasRenderTargetTextures(): boolean;
  55799. /**
  55800. * The entire material has been created in order to prevent overdraw.
  55801. * @returns false
  55802. */
  55803. needAlphaTesting(): boolean;
  55804. /**
  55805. * The entire material has been created in order to prevent overdraw.
  55806. * @returns true if blending is enable
  55807. */
  55808. needAlphaBlending(): boolean;
  55809. /**
  55810. * Checks wether the material is ready to be rendered for a given mesh.
  55811. * @param mesh The mesh to render
  55812. * @param subMesh The submesh to check against
  55813. * @param useInstances Specify wether or not the material is used with instances
  55814. * @returns true if all the dependencies are ready (Textures, Effects...)
  55815. */
  55816. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55817. /**
  55818. * Compute the primary color according to the chosen perceptual color.
  55819. */
  55820. private _computePrimaryColorFromPerceptualColor;
  55821. /**
  55822. * Compute the highlights and shadow colors according to their chosen levels.
  55823. */
  55824. private _computePrimaryColors;
  55825. /**
  55826. * Build the uniform buffer used in the material.
  55827. */
  55828. buildUniformLayout(): void;
  55829. /**
  55830. * Unbind the material.
  55831. */
  55832. unbind(): void;
  55833. /**
  55834. * Bind only the world matrix to the material.
  55835. * @param world The world matrix to bind.
  55836. */
  55837. bindOnlyWorldMatrix(world: Matrix): void;
  55838. /**
  55839. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55840. * @param world The world matrix to bind.
  55841. * @param subMesh The submesh to bind for.
  55842. */
  55843. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55844. /**
  55845. * Checks to see if a texture is used in the material.
  55846. * @param texture - Base texture to use.
  55847. * @returns - Boolean specifying if a texture is used in the material.
  55848. */
  55849. hasTexture(texture: BaseTexture): boolean;
  55850. /**
  55851. * Dispose the material.
  55852. * @param forceDisposeEffect Force disposal of the associated effect.
  55853. * @param forceDisposeTextures Force disposal of the associated textures.
  55854. */
  55855. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55856. /**
  55857. * Clones the material.
  55858. * @param name The cloned name.
  55859. * @returns The cloned material.
  55860. */
  55861. clone(name: string): BackgroundMaterial;
  55862. /**
  55863. * Serializes the current material to its JSON representation.
  55864. * @returns The JSON representation.
  55865. */
  55866. serialize(): any;
  55867. /**
  55868. * Gets the class name of the material
  55869. * @returns "BackgroundMaterial"
  55870. */
  55871. getClassName(): string;
  55872. /**
  55873. * Parse a JSON input to create back a background material.
  55874. * @param source The JSON data to parse
  55875. * @param scene The scene to create the parsed material in
  55876. * @param rootUrl The root url of the assets the material depends upon
  55877. * @returns the instantiated BackgroundMaterial.
  55878. */
  55879. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55880. }
  55881. }
  55882. declare module "babylonjs/Helpers/environmentHelper" {
  55883. import { Observable } from "babylonjs/Misc/observable";
  55884. import { Nullable } from "babylonjs/types";
  55885. import { Scene } from "babylonjs/scene";
  55886. import { Vector3 } from "babylonjs/Maths/math.vector";
  55887. import { Color3 } from "babylonjs/Maths/math.color";
  55888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55889. import { Mesh } from "babylonjs/Meshes/mesh";
  55890. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55891. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55892. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55893. import "babylonjs/Meshes/Builders/planeBuilder";
  55894. import "babylonjs/Meshes/Builders/boxBuilder";
  55895. /**
  55896. * Represents the different options available during the creation of
  55897. * a Environment helper.
  55898. *
  55899. * This can control the default ground, skybox and image processing setup of your scene.
  55900. */
  55901. export interface IEnvironmentHelperOptions {
  55902. /**
  55903. * Specifies whether or not to create a ground.
  55904. * True by default.
  55905. */
  55906. createGround: boolean;
  55907. /**
  55908. * Specifies the ground size.
  55909. * 15 by default.
  55910. */
  55911. groundSize: number;
  55912. /**
  55913. * The texture used on the ground for the main color.
  55914. * Comes from the BabylonJS CDN by default.
  55915. *
  55916. * Remarks: Can be either a texture or a url.
  55917. */
  55918. groundTexture: string | BaseTexture;
  55919. /**
  55920. * The color mixed in the ground texture by default.
  55921. * BabylonJS clearColor by default.
  55922. */
  55923. groundColor: Color3;
  55924. /**
  55925. * Specifies the ground opacity.
  55926. * 1 by default.
  55927. */
  55928. groundOpacity: number;
  55929. /**
  55930. * Enables the ground to receive shadows.
  55931. * True by default.
  55932. */
  55933. enableGroundShadow: boolean;
  55934. /**
  55935. * Helps preventing the shadow to be fully black on the ground.
  55936. * 0.5 by default.
  55937. */
  55938. groundShadowLevel: number;
  55939. /**
  55940. * Creates a mirror texture attach to the ground.
  55941. * false by default.
  55942. */
  55943. enableGroundMirror: boolean;
  55944. /**
  55945. * Specifies the ground mirror size ratio.
  55946. * 0.3 by default as the default kernel is 64.
  55947. */
  55948. groundMirrorSizeRatio: number;
  55949. /**
  55950. * Specifies the ground mirror blur kernel size.
  55951. * 64 by default.
  55952. */
  55953. groundMirrorBlurKernel: number;
  55954. /**
  55955. * Specifies the ground mirror visibility amount.
  55956. * 1 by default
  55957. */
  55958. groundMirrorAmount: number;
  55959. /**
  55960. * Specifies the ground mirror reflectance weight.
  55961. * This uses the standard weight of the background material to setup the fresnel effect
  55962. * of the mirror.
  55963. * 1 by default.
  55964. */
  55965. groundMirrorFresnelWeight: number;
  55966. /**
  55967. * Specifies the ground mirror Falloff distance.
  55968. * This can helps reducing the size of the reflection.
  55969. * 0 by Default.
  55970. */
  55971. groundMirrorFallOffDistance: number;
  55972. /**
  55973. * Specifies the ground mirror texture type.
  55974. * Unsigned Int by Default.
  55975. */
  55976. groundMirrorTextureType: number;
  55977. /**
  55978. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55979. * the shown objects.
  55980. */
  55981. groundYBias: number;
  55982. /**
  55983. * Specifies whether or not to create a skybox.
  55984. * True by default.
  55985. */
  55986. createSkybox: boolean;
  55987. /**
  55988. * Specifies the skybox size.
  55989. * 20 by default.
  55990. */
  55991. skyboxSize: number;
  55992. /**
  55993. * The texture used on the skybox for the main color.
  55994. * Comes from the BabylonJS CDN by default.
  55995. *
  55996. * Remarks: Can be either a texture or a url.
  55997. */
  55998. skyboxTexture: string | BaseTexture;
  55999. /**
  56000. * The color mixed in the skybox texture by default.
  56001. * BabylonJS clearColor by default.
  56002. */
  56003. skyboxColor: Color3;
  56004. /**
  56005. * The background rotation around the Y axis of the scene.
  56006. * This helps aligning the key lights of your scene with the background.
  56007. * 0 by default.
  56008. */
  56009. backgroundYRotation: number;
  56010. /**
  56011. * Compute automatically the size of the elements to best fit with the scene.
  56012. */
  56013. sizeAuto: boolean;
  56014. /**
  56015. * Default position of the rootMesh if autoSize is not true.
  56016. */
  56017. rootPosition: Vector3;
  56018. /**
  56019. * Sets up the image processing in the scene.
  56020. * true by default.
  56021. */
  56022. setupImageProcessing: boolean;
  56023. /**
  56024. * The texture used as your environment texture in the scene.
  56025. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56026. *
  56027. * Remarks: Can be either a texture or a url.
  56028. */
  56029. environmentTexture: string | BaseTexture;
  56030. /**
  56031. * The value of the exposure to apply to the scene.
  56032. * 0.6 by default if setupImageProcessing is true.
  56033. */
  56034. cameraExposure: number;
  56035. /**
  56036. * The value of the contrast to apply to the scene.
  56037. * 1.6 by default if setupImageProcessing is true.
  56038. */
  56039. cameraContrast: number;
  56040. /**
  56041. * Specifies whether or not tonemapping should be enabled in the scene.
  56042. * true by default if setupImageProcessing is true.
  56043. */
  56044. toneMappingEnabled: boolean;
  56045. }
  56046. /**
  56047. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  56048. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  56049. * It also helps with the default setup of your imageProcessing configuration.
  56050. */
  56051. export class EnvironmentHelper {
  56052. /**
  56053. * Default ground texture URL.
  56054. */
  56055. private static _groundTextureCDNUrl;
  56056. /**
  56057. * Default skybox texture URL.
  56058. */
  56059. private static _skyboxTextureCDNUrl;
  56060. /**
  56061. * Default environment texture URL.
  56062. */
  56063. private static _environmentTextureCDNUrl;
  56064. /**
  56065. * Creates the default options for the helper.
  56066. */
  56067. private static _getDefaultOptions;
  56068. private _rootMesh;
  56069. /**
  56070. * Gets the root mesh created by the helper.
  56071. */
  56072. get rootMesh(): Mesh;
  56073. private _skybox;
  56074. /**
  56075. * Gets the skybox created by the helper.
  56076. */
  56077. get skybox(): Nullable<Mesh>;
  56078. private _skyboxTexture;
  56079. /**
  56080. * Gets the skybox texture created by the helper.
  56081. */
  56082. get skyboxTexture(): Nullable<BaseTexture>;
  56083. private _skyboxMaterial;
  56084. /**
  56085. * Gets the skybox material created by the helper.
  56086. */
  56087. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56088. private _ground;
  56089. /**
  56090. * Gets the ground mesh created by the helper.
  56091. */
  56092. get ground(): Nullable<Mesh>;
  56093. private _groundTexture;
  56094. /**
  56095. * Gets the ground texture created by the helper.
  56096. */
  56097. get groundTexture(): Nullable<BaseTexture>;
  56098. private _groundMirror;
  56099. /**
  56100. * Gets the ground mirror created by the helper.
  56101. */
  56102. get groundMirror(): Nullable<MirrorTexture>;
  56103. /**
  56104. * Gets the ground mirror render list to helps pushing the meshes
  56105. * you wish in the ground reflection.
  56106. */
  56107. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  56108. private _groundMaterial;
  56109. /**
  56110. * Gets the ground material created by the helper.
  56111. */
  56112. get groundMaterial(): Nullable<BackgroundMaterial>;
  56113. /**
  56114. * Stores the creation options.
  56115. */
  56116. private readonly _scene;
  56117. private _options;
  56118. /**
  56119. * This observable will be notified with any error during the creation of the environment,
  56120. * mainly texture creation errors.
  56121. */
  56122. onErrorObservable: Observable<{
  56123. message?: string;
  56124. exception?: any;
  56125. }>;
  56126. /**
  56127. * constructor
  56128. * @param options Defines the options we want to customize the helper
  56129. * @param scene The scene to add the material to
  56130. */
  56131. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  56132. /**
  56133. * Updates the background according to the new options
  56134. * @param options
  56135. */
  56136. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  56137. /**
  56138. * Sets the primary color of all the available elements.
  56139. * @param color the main color to affect to the ground and the background
  56140. */
  56141. setMainColor(color: Color3): void;
  56142. /**
  56143. * Setup the image processing according to the specified options.
  56144. */
  56145. private _setupImageProcessing;
  56146. /**
  56147. * Setup the environment texture according to the specified options.
  56148. */
  56149. private _setupEnvironmentTexture;
  56150. /**
  56151. * Setup the background according to the specified options.
  56152. */
  56153. private _setupBackground;
  56154. /**
  56155. * Get the scene sizes according to the setup.
  56156. */
  56157. private _getSceneSize;
  56158. /**
  56159. * Setup the ground according to the specified options.
  56160. */
  56161. private _setupGround;
  56162. /**
  56163. * Setup the ground material according to the specified options.
  56164. */
  56165. private _setupGroundMaterial;
  56166. /**
  56167. * Setup the ground diffuse texture according to the specified options.
  56168. */
  56169. private _setupGroundDiffuseTexture;
  56170. /**
  56171. * Setup the ground mirror texture according to the specified options.
  56172. */
  56173. private _setupGroundMirrorTexture;
  56174. /**
  56175. * Setup the ground to receive the mirror texture.
  56176. */
  56177. private _setupMirrorInGroundMaterial;
  56178. /**
  56179. * Setup the skybox according to the specified options.
  56180. */
  56181. private _setupSkybox;
  56182. /**
  56183. * Setup the skybox material according to the specified options.
  56184. */
  56185. private _setupSkyboxMaterial;
  56186. /**
  56187. * Setup the skybox reflection texture according to the specified options.
  56188. */
  56189. private _setupSkyboxReflectionTexture;
  56190. private _errorHandler;
  56191. /**
  56192. * Dispose all the elements created by the Helper.
  56193. */
  56194. dispose(): void;
  56195. }
  56196. }
  56197. declare module "babylonjs/Helpers/photoDome" {
  56198. import { Observable } from "babylonjs/Misc/observable";
  56199. import { Nullable } from "babylonjs/types";
  56200. import { Scene } from "babylonjs/scene";
  56201. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56202. import { Mesh } from "babylonjs/Meshes/mesh";
  56203. import { Texture } from "babylonjs/Materials/Textures/texture";
  56204. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56205. import "babylonjs/Meshes/Builders/sphereBuilder";
  56206. /**
  56207. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56208. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56209. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56210. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56211. */
  56212. export class PhotoDome extends TransformNode {
  56213. /**
  56214. * Define the image as a Monoscopic panoramic 360 image.
  56215. */
  56216. static readonly MODE_MONOSCOPIC: number;
  56217. /**
  56218. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56219. */
  56220. static readonly MODE_TOPBOTTOM: number;
  56221. /**
  56222. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56223. */
  56224. static readonly MODE_SIDEBYSIDE: number;
  56225. private _useDirectMapping;
  56226. /**
  56227. * The texture being displayed on the sphere
  56228. */
  56229. protected _photoTexture: Texture;
  56230. /**
  56231. * Gets or sets the texture being displayed on the sphere
  56232. */
  56233. get photoTexture(): Texture;
  56234. set photoTexture(value: Texture);
  56235. /**
  56236. * Observable raised when an error occured while loading the 360 image
  56237. */
  56238. onLoadErrorObservable: Observable<string>;
  56239. /**
  56240. * The skybox material
  56241. */
  56242. protected _material: BackgroundMaterial;
  56243. /**
  56244. * The surface used for the skybox
  56245. */
  56246. protected _mesh: Mesh;
  56247. /**
  56248. * Gets the mesh used for the skybox.
  56249. */
  56250. get mesh(): Mesh;
  56251. /**
  56252. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56253. * Also see the options.resolution property.
  56254. */
  56255. get fovMultiplier(): number;
  56256. set fovMultiplier(value: number);
  56257. private _imageMode;
  56258. /**
  56259. * Gets or set the current video mode for the video. It can be:
  56260. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  56261. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56262. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56263. */
  56264. get imageMode(): number;
  56265. set imageMode(value: number);
  56266. /**
  56267. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  56268. * @param name Element's name, child elements will append suffixes for their own names.
  56269. * @param urlsOfPhoto defines the url of the photo to display
  56270. * @param options defines an object containing optional or exposed sub element properties
  56271. * @param onError defines a callback called when an error occured while loading the texture
  56272. */
  56273. constructor(name: string, urlOfPhoto: string, options: {
  56274. resolution?: number;
  56275. size?: number;
  56276. useDirectMapping?: boolean;
  56277. faceForward?: boolean;
  56278. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  56279. private _onBeforeCameraRenderObserver;
  56280. private _changeImageMode;
  56281. /**
  56282. * Releases resources associated with this node.
  56283. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56284. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56285. */
  56286. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56287. }
  56288. }
  56289. declare module "babylonjs/Misc/rgbdTextureTools" {
  56290. import "babylonjs/Shaders/rgbdDecode.fragment";
  56291. import "babylonjs/Engines/Extensions/engine.renderTarget";
  56292. import { Texture } from "babylonjs/Materials/Textures/texture";
  56293. /**
  56294. * Class used to host RGBD texture specific utilities
  56295. */
  56296. export class RGBDTextureTools {
  56297. /**
  56298. * Expand the RGBD Texture from RGBD to Half Float if possible.
  56299. * @param texture the texture to expand.
  56300. */
  56301. static ExpandRGBDTexture(texture: Texture): void;
  56302. }
  56303. }
  56304. declare module "babylonjs/Misc/brdfTextureTools" {
  56305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56306. import { Scene } from "babylonjs/scene";
  56307. /**
  56308. * Class used to host texture specific utilities
  56309. */
  56310. export class BRDFTextureTools {
  56311. /**
  56312. * Prevents texture cache collision
  56313. */
  56314. private static _instanceNumber;
  56315. /**
  56316. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  56317. * @param scene defines the hosting scene
  56318. * @returns the environment BRDF texture
  56319. */
  56320. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  56321. private static _environmentBRDFBase64Texture;
  56322. }
  56323. }
  56324. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  56325. import { Nullable } from "babylonjs/types";
  56326. import { Color3 } from "babylonjs/Maths/math.color";
  56327. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56328. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56329. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56330. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56331. import { Engine } from "babylonjs/Engines/engine";
  56332. import { Scene } from "babylonjs/scene";
  56333. /**
  56334. * @hidden
  56335. */
  56336. export interface IMaterialClearCoatDefines {
  56337. CLEARCOAT: boolean;
  56338. CLEARCOAT_DEFAULTIOR: boolean;
  56339. CLEARCOAT_TEXTURE: boolean;
  56340. CLEARCOAT_TEXTUREDIRECTUV: number;
  56341. CLEARCOAT_BUMP: boolean;
  56342. CLEARCOAT_BUMPDIRECTUV: number;
  56343. CLEARCOAT_TINT: boolean;
  56344. CLEARCOAT_TINT_TEXTURE: boolean;
  56345. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56346. /** @hidden */
  56347. _areTexturesDirty: boolean;
  56348. }
  56349. /**
  56350. * Define the code related to the clear coat parameters of the pbr material.
  56351. */
  56352. export class PBRClearCoatConfiguration {
  56353. /**
  56354. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56355. * The default fits with a polyurethane material.
  56356. */
  56357. private static readonly _DefaultIndexOfRefraction;
  56358. private _isEnabled;
  56359. /**
  56360. * Defines if the clear coat is enabled in the material.
  56361. */
  56362. isEnabled: boolean;
  56363. /**
  56364. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56365. */
  56366. intensity: number;
  56367. /**
  56368. * Defines the clear coat layer roughness.
  56369. */
  56370. roughness: number;
  56371. private _indexOfRefraction;
  56372. /**
  56373. * Defines the index of refraction of the clear coat.
  56374. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56375. * The default fits with a polyurethane material.
  56376. * Changing the default value is more performance intensive.
  56377. */
  56378. indexOfRefraction: number;
  56379. private _texture;
  56380. /**
  56381. * Stores the clear coat values in a texture.
  56382. */
  56383. texture: Nullable<BaseTexture>;
  56384. private _bumpTexture;
  56385. /**
  56386. * Define the clear coat specific bump texture.
  56387. */
  56388. bumpTexture: Nullable<BaseTexture>;
  56389. private _isTintEnabled;
  56390. /**
  56391. * Defines if the clear coat tint is enabled in the material.
  56392. */
  56393. isTintEnabled: boolean;
  56394. /**
  56395. * Defines the clear coat tint of the material.
  56396. * This is only use if tint is enabled
  56397. */
  56398. tintColor: Color3;
  56399. /**
  56400. * Defines the distance at which the tint color should be found in the
  56401. * clear coat media.
  56402. * This is only use if tint is enabled
  56403. */
  56404. tintColorAtDistance: number;
  56405. /**
  56406. * Defines the clear coat layer thickness.
  56407. * This is only use if tint is enabled
  56408. */
  56409. tintThickness: number;
  56410. private _tintTexture;
  56411. /**
  56412. * Stores the clear tint values in a texture.
  56413. * rgb is tint
  56414. * a is a thickness factor
  56415. */
  56416. tintTexture: Nullable<BaseTexture>;
  56417. /** @hidden */
  56418. private _internalMarkAllSubMeshesAsTexturesDirty;
  56419. /** @hidden */
  56420. _markAllSubMeshesAsTexturesDirty(): void;
  56421. /**
  56422. * Instantiate a new istance of clear coat configuration.
  56423. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56424. */
  56425. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56426. /**
  56427. * Gets wehter the submesh is ready to be used or not.
  56428. * @param defines the list of "defines" to update.
  56429. * @param scene defines the scene the material belongs to.
  56430. * @param engine defines the engine the material belongs to.
  56431. * @param disableBumpMap defines wether the material disables bump or not.
  56432. * @returns - boolean indicating that the submesh is ready or not.
  56433. */
  56434. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56435. /**
  56436. * Checks to see if a texture is used in the material.
  56437. * @param defines the list of "defines" to update.
  56438. * @param scene defines the scene to the material belongs to.
  56439. */
  56440. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  56441. /**
  56442. * Binds the material data.
  56443. * @param uniformBuffer defines the Uniform buffer to fill in.
  56444. * @param scene defines the scene the material belongs to.
  56445. * @param engine defines the engine the material belongs to.
  56446. * @param disableBumpMap defines wether the material disables bump or not.
  56447. * @param isFrozen defines wether the material is frozen or not.
  56448. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56449. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56450. */
  56451. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  56452. /**
  56453. * Checks to see if a texture is used in the material.
  56454. * @param texture - Base texture to use.
  56455. * @returns - Boolean specifying if a texture is used in the material.
  56456. */
  56457. hasTexture(texture: BaseTexture): boolean;
  56458. /**
  56459. * Returns an array of the actively used textures.
  56460. * @param activeTextures Array of BaseTextures
  56461. */
  56462. getActiveTextures(activeTextures: BaseTexture[]): void;
  56463. /**
  56464. * Returns the animatable textures.
  56465. * @param animatables Array of animatable textures.
  56466. */
  56467. getAnimatables(animatables: IAnimatable[]): void;
  56468. /**
  56469. * Disposes the resources of the material.
  56470. * @param forceDisposeTextures - Forces the disposal of all textures.
  56471. */
  56472. dispose(forceDisposeTextures?: boolean): void;
  56473. /**
  56474. * Get the current class name of the texture useful for serialization or dynamic coding.
  56475. * @returns "PBRClearCoatConfiguration"
  56476. */
  56477. getClassName(): string;
  56478. /**
  56479. * Add fallbacks to the effect fallbacks list.
  56480. * @param defines defines the Base texture to use.
  56481. * @param fallbacks defines the current fallback list.
  56482. * @param currentRank defines the current fallback rank.
  56483. * @returns the new fallback rank.
  56484. */
  56485. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56486. /**
  56487. * Add the required uniforms to the current list.
  56488. * @param uniforms defines the current uniform list.
  56489. */
  56490. static AddUniforms(uniforms: string[]): void;
  56491. /**
  56492. * Add the required samplers to the current list.
  56493. * @param samplers defines the current sampler list.
  56494. */
  56495. static AddSamplers(samplers: string[]): void;
  56496. /**
  56497. * Add the required uniforms to the current buffer.
  56498. * @param uniformBuffer defines the current uniform buffer.
  56499. */
  56500. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56501. /**
  56502. * Makes a duplicate of the current configuration into another one.
  56503. * @param clearCoatConfiguration define the config where to copy the info
  56504. */
  56505. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  56506. /**
  56507. * Serializes this clear coat configuration.
  56508. * @returns - An object with the serialized config.
  56509. */
  56510. serialize(): any;
  56511. /**
  56512. * Parses a anisotropy Configuration from a serialized object.
  56513. * @param source - Serialized object.
  56514. * @param scene Defines the scene we are parsing for
  56515. * @param rootUrl Defines the rootUrl to load from
  56516. */
  56517. parse(source: any, scene: Scene, rootUrl: string): void;
  56518. }
  56519. }
  56520. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  56521. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56523. import { Vector2 } from "babylonjs/Maths/math.vector";
  56524. import { Scene } from "babylonjs/scene";
  56525. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56526. import { Nullable } from "babylonjs/types";
  56527. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56528. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56529. /**
  56530. * @hidden
  56531. */
  56532. export interface IMaterialAnisotropicDefines {
  56533. ANISOTROPIC: boolean;
  56534. ANISOTROPIC_TEXTURE: boolean;
  56535. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56536. MAINUV1: boolean;
  56537. _areTexturesDirty: boolean;
  56538. _needUVs: boolean;
  56539. }
  56540. /**
  56541. * Define the code related to the anisotropic parameters of the pbr material.
  56542. */
  56543. export class PBRAnisotropicConfiguration {
  56544. private _isEnabled;
  56545. /**
  56546. * Defines if the anisotropy is enabled in the material.
  56547. */
  56548. isEnabled: boolean;
  56549. /**
  56550. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  56551. */
  56552. intensity: number;
  56553. /**
  56554. * Defines if the effect is along the tangents, bitangents or in between.
  56555. * By default, the effect is "strectching" the highlights along the tangents.
  56556. */
  56557. direction: Vector2;
  56558. private _texture;
  56559. /**
  56560. * Stores the anisotropy values in a texture.
  56561. * rg is direction (like normal from -1 to 1)
  56562. * b is a intensity
  56563. */
  56564. texture: Nullable<BaseTexture>;
  56565. /** @hidden */
  56566. private _internalMarkAllSubMeshesAsTexturesDirty;
  56567. /** @hidden */
  56568. _markAllSubMeshesAsTexturesDirty(): void;
  56569. /**
  56570. * Instantiate a new istance of anisotropy configuration.
  56571. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56572. */
  56573. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56574. /**
  56575. * Specifies that the submesh is ready to be used.
  56576. * @param defines the list of "defines" to update.
  56577. * @param scene defines the scene the material belongs to.
  56578. * @returns - boolean indicating that the submesh is ready or not.
  56579. */
  56580. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56581. /**
  56582. * Checks to see if a texture is used in the material.
  56583. * @param defines the list of "defines" to update.
  56584. * @param mesh the mesh we are preparing the defines for.
  56585. * @param scene defines the scene the material belongs to.
  56586. */
  56587. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56588. /**
  56589. * Binds the material data.
  56590. * @param uniformBuffer defines the Uniform buffer to fill in.
  56591. * @param scene defines the scene the material belongs to.
  56592. * @param isFrozen defines wether the material is frozen or not.
  56593. */
  56594. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56595. /**
  56596. * Checks to see if a texture is used in the material.
  56597. * @param texture - Base texture to use.
  56598. * @returns - Boolean specifying if a texture is used in the material.
  56599. */
  56600. hasTexture(texture: BaseTexture): boolean;
  56601. /**
  56602. * Returns an array of the actively used textures.
  56603. * @param activeTextures Array of BaseTextures
  56604. */
  56605. getActiveTextures(activeTextures: BaseTexture[]): void;
  56606. /**
  56607. * Returns the animatable textures.
  56608. * @param animatables Array of animatable textures.
  56609. */
  56610. getAnimatables(animatables: IAnimatable[]): void;
  56611. /**
  56612. * Disposes the resources of the material.
  56613. * @param forceDisposeTextures - Forces the disposal of all textures.
  56614. */
  56615. dispose(forceDisposeTextures?: boolean): void;
  56616. /**
  56617. * Get the current class name of the texture useful for serialization or dynamic coding.
  56618. * @returns "PBRAnisotropicConfiguration"
  56619. */
  56620. getClassName(): string;
  56621. /**
  56622. * Add fallbacks to the effect fallbacks list.
  56623. * @param defines defines the Base texture to use.
  56624. * @param fallbacks defines the current fallback list.
  56625. * @param currentRank defines the current fallback rank.
  56626. * @returns the new fallback rank.
  56627. */
  56628. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56629. /**
  56630. * Add the required uniforms to the current list.
  56631. * @param uniforms defines the current uniform list.
  56632. */
  56633. static AddUniforms(uniforms: string[]): void;
  56634. /**
  56635. * Add the required uniforms to the current buffer.
  56636. * @param uniformBuffer defines the current uniform buffer.
  56637. */
  56638. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56639. /**
  56640. * Add the required samplers to the current list.
  56641. * @param samplers defines the current sampler list.
  56642. */
  56643. static AddSamplers(samplers: string[]): void;
  56644. /**
  56645. * Makes a duplicate of the current configuration into another one.
  56646. * @param anisotropicConfiguration define the config where to copy the info
  56647. */
  56648. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56649. /**
  56650. * Serializes this anisotropy configuration.
  56651. * @returns - An object with the serialized config.
  56652. */
  56653. serialize(): any;
  56654. /**
  56655. * Parses a anisotropy Configuration from a serialized object.
  56656. * @param source - Serialized object.
  56657. * @param scene Defines the scene we are parsing for
  56658. * @param rootUrl Defines the rootUrl to load from
  56659. */
  56660. parse(source: any, scene: Scene, rootUrl: string): void;
  56661. }
  56662. }
  56663. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56664. import { Scene } from "babylonjs/scene";
  56665. /**
  56666. * @hidden
  56667. */
  56668. export interface IMaterialBRDFDefines {
  56669. BRDF_V_HEIGHT_CORRELATED: boolean;
  56670. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56671. SPHERICAL_HARMONICS: boolean;
  56672. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56673. /** @hidden */
  56674. _areMiscDirty: boolean;
  56675. }
  56676. /**
  56677. * Define the code related to the BRDF parameters of the pbr material.
  56678. */
  56679. export class PBRBRDFConfiguration {
  56680. /**
  56681. * Default value used for the energy conservation.
  56682. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56683. */
  56684. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56685. /**
  56686. * Default value used for the Smith Visibility Height Correlated mode.
  56687. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56688. */
  56689. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56690. /**
  56691. * Default value used for the IBL diffuse part.
  56692. * This can help switching back to the polynomials mode globally which is a tiny bit
  56693. * less GPU intensive at the drawback of a lower quality.
  56694. */
  56695. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56696. /**
  56697. * Default value used for activating energy conservation for the specular workflow.
  56698. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56699. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56700. */
  56701. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56702. private _useEnergyConservation;
  56703. /**
  56704. * Defines if the material uses energy conservation.
  56705. */
  56706. useEnergyConservation: boolean;
  56707. private _useSmithVisibilityHeightCorrelated;
  56708. /**
  56709. * LEGACY Mode set to false
  56710. * Defines if the material uses height smith correlated visibility term.
  56711. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56712. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56713. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56714. * Not relying on height correlated will also disable energy conservation.
  56715. */
  56716. useSmithVisibilityHeightCorrelated: boolean;
  56717. private _useSphericalHarmonics;
  56718. /**
  56719. * LEGACY Mode set to false
  56720. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56721. * diffuse part of the IBL.
  56722. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56723. * to the ground truth.
  56724. */
  56725. useSphericalHarmonics: boolean;
  56726. private _useSpecularGlossinessInputEnergyConservation;
  56727. /**
  56728. * Defines if the material uses energy conservation, when the specular workflow is active.
  56729. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56730. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56731. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56732. */
  56733. useSpecularGlossinessInputEnergyConservation: boolean;
  56734. /** @hidden */
  56735. private _internalMarkAllSubMeshesAsMiscDirty;
  56736. /** @hidden */
  56737. _markAllSubMeshesAsMiscDirty(): void;
  56738. /**
  56739. * Instantiate a new istance of clear coat configuration.
  56740. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56741. */
  56742. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56743. /**
  56744. * Checks to see if a texture is used in the material.
  56745. * @param defines the list of "defines" to update.
  56746. */
  56747. prepareDefines(defines: IMaterialBRDFDefines): void;
  56748. /**
  56749. * Get the current class name of the texture useful for serialization or dynamic coding.
  56750. * @returns "PBRClearCoatConfiguration"
  56751. */
  56752. getClassName(): string;
  56753. /**
  56754. * Makes a duplicate of the current configuration into another one.
  56755. * @param brdfConfiguration define the config where to copy the info
  56756. */
  56757. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56758. /**
  56759. * Serializes this BRDF configuration.
  56760. * @returns - An object with the serialized config.
  56761. */
  56762. serialize(): any;
  56763. /**
  56764. * Parses a anisotropy Configuration from a serialized object.
  56765. * @param source - Serialized object.
  56766. * @param scene Defines the scene we are parsing for
  56767. * @param rootUrl Defines the rootUrl to load from
  56768. */
  56769. parse(source: any, scene: Scene, rootUrl: string): void;
  56770. }
  56771. }
  56772. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56773. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56774. import { Color3 } from "babylonjs/Maths/math.color";
  56775. import { Scene } from "babylonjs/scene";
  56776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56777. import { Nullable } from "babylonjs/types";
  56778. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56779. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56780. /**
  56781. * @hidden
  56782. */
  56783. export interface IMaterialSheenDefines {
  56784. SHEEN: boolean;
  56785. SHEEN_TEXTURE: boolean;
  56786. SHEEN_TEXTUREDIRECTUV: number;
  56787. SHEEN_LINKWITHALBEDO: boolean;
  56788. SHEEN_ROUGHNESS: boolean;
  56789. SHEEN_ALBEDOSCALING: boolean;
  56790. /** @hidden */
  56791. _areTexturesDirty: boolean;
  56792. }
  56793. /**
  56794. * Define the code related to the Sheen parameters of the pbr material.
  56795. */
  56796. export class PBRSheenConfiguration {
  56797. private _isEnabled;
  56798. /**
  56799. * Defines if the material uses sheen.
  56800. */
  56801. isEnabled: boolean;
  56802. private _linkSheenWithAlbedo;
  56803. /**
  56804. * Defines if the sheen is linked to the sheen color.
  56805. */
  56806. linkSheenWithAlbedo: boolean;
  56807. /**
  56808. * Defines the sheen intensity.
  56809. */
  56810. intensity: number;
  56811. /**
  56812. * Defines the sheen color.
  56813. */
  56814. color: Color3;
  56815. private _texture;
  56816. /**
  56817. * Stores the sheen tint values in a texture.
  56818. * rgb is tint
  56819. * a is a intensity or roughness if roughness has been defined
  56820. */
  56821. texture: Nullable<BaseTexture>;
  56822. private _roughness;
  56823. /**
  56824. * Defines the sheen roughness.
  56825. * It is not taken into account if linkSheenWithAlbedo is true.
  56826. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56827. */
  56828. roughness: Nullable<number>;
  56829. private _albedoScaling;
  56830. /**
  56831. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56832. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56833. * making it easier to setup and tweak the effect
  56834. */
  56835. albedoScaling: boolean;
  56836. /** @hidden */
  56837. private _internalMarkAllSubMeshesAsTexturesDirty;
  56838. /** @hidden */
  56839. _markAllSubMeshesAsTexturesDirty(): void;
  56840. /**
  56841. * Instantiate a new istance of clear coat configuration.
  56842. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56843. */
  56844. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56845. /**
  56846. * Specifies that the submesh is ready to be used.
  56847. * @param defines the list of "defines" to update.
  56848. * @param scene defines the scene the material belongs to.
  56849. * @returns - boolean indicating that the submesh is ready or not.
  56850. */
  56851. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56852. /**
  56853. * Checks to see if a texture is used in the material.
  56854. * @param defines the list of "defines" to update.
  56855. * @param scene defines the scene the material belongs to.
  56856. */
  56857. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56858. /**
  56859. * Binds the material data.
  56860. * @param uniformBuffer defines the Uniform buffer to fill in.
  56861. * @param scene defines the scene the material belongs to.
  56862. * @param isFrozen defines wether the material is frozen or not.
  56863. */
  56864. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56865. /**
  56866. * Checks to see if a texture is used in the material.
  56867. * @param texture - Base texture to use.
  56868. * @returns - Boolean specifying if a texture is used in the material.
  56869. */
  56870. hasTexture(texture: BaseTexture): boolean;
  56871. /**
  56872. * Returns an array of the actively used textures.
  56873. * @param activeTextures Array of BaseTextures
  56874. */
  56875. getActiveTextures(activeTextures: BaseTexture[]): void;
  56876. /**
  56877. * Returns the animatable textures.
  56878. * @param animatables Array of animatable textures.
  56879. */
  56880. getAnimatables(animatables: IAnimatable[]): void;
  56881. /**
  56882. * Disposes the resources of the material.
  56883. * @param forceDisposeTextures - Forces the disposal of all textures.
  56884. */
  56885. dispose(forceDisposeTextures?: boolean): void;
  56886. /**
  56887. * Get the current class name of the texture useful for serialization or dynamic coding.
  56888. * @returns "PBRSheenConfiguration"
  56889. */
  56890. getClassName(): string;
  56891. /**
  56892. * Add fallbacks to the effect fallbacks list.
  56893. * @param defines defines the Base texture to use.
  56894. * @param fallbacks defines the current fallback list.
  56895. * @param currentRank defines the current fallback rank.
  56896. * @returns the new fallback rank.
  56897. */
  56898. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56899. /**
  56900. * Add the required uniforms to the current list.
  56901. * @param uniforms defines the current uniform list.
  56902. */
  56903. static AddUniforms(uniforms: string[]): void;
  56904. /**
  56905. * Add the required uniforms to the current buffer.
  56906. * @param uniformBuffer defines the current uniform buffer.
  56907. */
  56908. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56909. /**
  56910. * Add the required samplers to the current list.
  56911. * @param samplers defines the current sampler list.
  56912. */
  56913. static AddSamplers(samplers: string[]): void;
  56914. /**
  56915. * Makes a duplicate of the current configuration into another one.
  56916. * @param sheenConfiguration define the config where to copy the info
  56917. */
  56918. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56919. /**
  56920. * Serializes this BRDF configuration.
  56921. * @returns - An object with the serialized config.
  56922. */
  56923. serialize(): any;
  56924. /**
  56925. * Parses a anisotropy Configuration from a serialized object.
  56926. * @param source - Serialized object.
  56927. * @param scene Defines the scene we are parsing for
  56928. * @param rootUrl Defines the rootUrl to load from
  56929. */
  56930. parse(source: any, scene: Scene, rootUrl: string): void;
  56931. }
  56932. }
  56933. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56934. import { Nullable } from "babylonjs/types";
  56935. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56936. import { Color3 } from "babylonjs/Maths/math.color";
  56937. import { SmartArray } from "babylonjs/Misc/smartArray";
  56938. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56939. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56940. import { Effect } from "babylonjs/Materials/effect";
  56941. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56942. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56943. import { Engine } from "babylonjs/Engines/engine";
  56944. import { Scene } from "babylonjs/scene";
  56945. /**
  56946. * @hidden
  56947. */
  56948. export interface IMaterialSubSurfaceDefines {
  56949. SUBSURFACE: boolean;
  56950. SS_REFRACTION: boolean;
  56951. SS_TRANSLUCENCY: boolean;
  56952. SS_SCATTERING: boolean;
  56953. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56954. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56955. SS_REFRACTIONMAP_3D: boolean;
  56956. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56957. SS_LODINREFRACTIONALPHA: boolean;
  56958. SS_GAMMAREFRACTION: boolean;
  56959. SS_RGBDREFRACTION: boolean;
  56960. SS_LINEARSPECULARREFRACTION: boolean;
  56961. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56962. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56963. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56964. /** @hidden */
  56965. _areTexturesDirty: boolean;
  56966. }
  56967. /**
  56968. * Define the code related to the sub surface parameters of the pbr material.
  56969. */
  56970. export class PBRSubSurfaceConfiguration {
  56971. private _isRefractionEnabled;
  56972. /**
  56973. * Defines if the refraction is enabled in the material.
  56974. */
  56975. isRefractionEnabled: boolean;
  56976. private _isTranslucencyEnabled;
  56977. /**
  56978. * Defines if the translucency is enabled in the material.
  56979. */
  56980. isTranslucencyEnabled: boolean;
  56981. private _isScatteringEnabled;
  56982. /**
  56983. * Defines if the sub surface scattering is enabled in the material.
  56984. */
  56985. isScatteringEnabled: boolean;
  56986. private _scatteringDiffusionProfileIndex;
  56987. /**
  56988. * Diffusion profile for subsurface scattering.
  56989. * Useful for better scattering in the skins or foliages.
  56990. */
  56991. get scatteringDiffusionProfile(): Nullable<Color3>;
  56992. set scatteringDiffusionProfile(c: Nullable<Color3>);
  56993. /**
  56994. * Defines the refraction intensity of the material.
  56995. * The refraction when enabled replaces the Diffuse part of the material.
  56996. * The intensity helps transitionning between diffuse and refraction.
  56997. */
  56998. refractionIntensity: number;
  56999. /**
  57000. * Defines the translucency intensity of the material.
  57001. * When translucency has been enabled, this defines how much of the "translucency"
  57002. * is addded to the diffuse part of the material.
  57003. */
  57004. translucencyIntensity: number;
  57005. /**
  57006. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57007. */
  57008. useAlbedoToTintRefraction: boolean;
  57009. private _thicknessTexture;
  57010. /**
  57011. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57012. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57013. * 0 would mean minimumThickness
  57014. * 1 would mean maximumThickness
  57015. * The other channels might be use as a mask to vary the different effects intensity.
  57016. */
  57017. thicknessTexture: Nullable<BaseTexture>;
  57018. private _refractionTexture;
  57019. /**
  57020. * Defines the texture to use for refraction.
  57021. */
  57022. refractionTexture: Nullable<BaseTexture>;
  57023. private _indexOfRefraction;
  57024. /**
  57025. * Index of refraction of the material base layer.
  57026. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57027. *
  57028. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57029. *
  57030. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57031. */
  57032. indexOfRefraction: number;
  57033. private _volumeIndexOfRefraction;
  57034. /**
  57035. * Index of refraction of the material's volume.
  57036. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57037. *
  57038. * This ONLY impacts refraction. If not provided or given a non-valid value,
  57039. * the volume will use the same IOR as the surface.
  57040. */
  57041. get volumeIndexOfRefraction(): number;
  57042. set volumeIndexOfRefraction(value: number);
  57043. private _invertRefractionY;
  57044. /**
  57045. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57046. */
  57047. invertRefractionY: boolean;
  57048. private _linkRefractionWithTransparency;
  57049. /**
  57050. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57051. * Materials half opaque for instance using refraction could benefit from this control.
  57052. */
  57053. linkRefractionWithTransparency: boolean;
  57054. /**
  57055. * Defines the minimum thickness stored in the thickness map.
  57056. * If no thickness map is defined, this value will be used to simulate thickness.
  57057. */
  57058. minimumThickness: number;
  57059. /**
  57060. * Defines the maximum thickness stored in the thickness map.
  57061. */
  57062. maximumThickness: number;
  57063. /**
  57064. * Defines the volume tint of the material.
  57065. * This is used for both translucency and scattering.
  57066. */
  57067. tintColor: Color3;
  57068. /**
  57069. * Defines the distance at which the tint color should be found in the media.
  57070. * This is used for refraction only.
  57071. */
  57072. tintColorAtDistance: number;
  57073. /**
  57074. * Defines how far each channel transmit through the media.
  57075. * It is defined as a color to simplify it selection.
  57076. */
  57077. diffusionDistance: Color3;
  57078. private _useMaskFromThicknessTexture;
  57079. /**
  57080. * Stores the intensity of the different subsurface effects in the thickness texture.
  57081. * * the green channel is the translucency intensity.
  57082. * * the blue channel is the scattering intensity.
  57083. * * the alpha channel is the refraction intensity.
  57084. */
  57085. useMaskFromThicknessTexture: boolean;
  57086. private _scene;
  57087. /** @hidden */
  57088. private _internalMarkAllSubMeshesAsTexturesDirty;
  57089. private _internalMarkScenePrePassDirty;
  57090. /** @hidden */
  57091. _markAllSubMeshesAsTexturesDirty(): void;
  57092. /** @hidden */
  57093. _markScenePrePassDirty(): void;
  57094. /**
  57095. * Instantiate a new istance of sub surface configuration.
  57096. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57097. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  57098. * @param scene The scene
  57099. */
  57100. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  57101. /**
  57102. * Gets wehter the submesh is ready to be used or not.
  57103. * @param defines the list of "defines" to update.
  57104. * @param scene defines the scene the material belongs to.
  57105. * @returns - boolean indicating that the submesh is ready or not.
  57106. */
  57107. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  57108. /**
  57109. * Checks to see if a texture is used in the material.
  57110. * @param defines the list of "defines" to update.
  57111. * @param scene defines the scene to the material belongs to.
  57112. */
  57113. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  57114. /**
  57115. * Binds the material data.
  57116. * @param uniformBuffer defines the Uniform buffer to fill in.
  57117. * @param scene defines the scene the material belongs to.
  57118. * @param engine defines the engine the material belongs to.
  57119. * @param isFrozen defines whether the material is frozen or not.
  57120. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  57121. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  57122. */
  57123. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  57124. /**
  57125. * Unbinds the material from the mesh.
  57126. * @param activeEffect defines the effect that should be unbound from.
  57127. * @returns true if unbound, otherwise false
  57128. */
  57129. unbind(activeEffect: Effect): boolean;
  57130. /**
  57131. * Returns the texture used for refraction or null if none is used.
  57132. * @param scene defines the scene the material belongs to.
  57133. * @returns - Refraction texture if present. If no refraction texture and refraction
  57134. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57135. */
  57136. private _getRefractionTexture;
  57137. /**
  57138. * Returns true if alpha blending should be disabled.
  57139. */
  57140. get disableAlphaBlending(): boolean;
  57141. /**
  57142. * Fills the list of render target textures.
  57143. * @param renderTargets the list of render targets to update
  57144. */
  57145. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  57146. /**
  57147. * Checks to see if a texture is used in the material.
  57148. * @param texture - Base texture to use.
  57149. * @returns - Boolean specifying if a texture is used in the material.
  57150. */
  57151. hasTexture(texture: BaseTexture): boolean;
  57152. /**
  57153. * Gets a boolean indicating that current material needs to register RTT
  57154. * @returns true if this uses a render target otherwise false.
  57155. */
  57156. hasRenderTargetTextures(): boolean;
  57157. /**
  57158. * Returns an array of the actively used textures.
  57159. * @param activeTextures Array of BaseTextures
  57160. */
  57161. getActiveTextures(activeTextures: BaseTexture[]): void;
  57162. /**
  57163. * Returns the animatable textures.
  57164. * @param animatables Array of animatable textures.
  57165. */
  57166. getAnimatables(animatables: IAnimatable[]): void;
  57167. /**
  57168. * Disposes the resources of the material.
  57169. * @param forceDisposeTextures - Forces the disposal of all textures.
  57170. */
  57171. dispose(forceDisposeTextures?: boolean): void;
  57172. /**
  57173. * Get the current class name of the texture useful for serialization or dynamic coding.
  57174. * @returns "PBRSubSurfaceConfiguration"
  57175. */
  57176. getClassName(): string;
  57177. /**
  57178. * Add fallbacks to the effect fallbacks list.
  57179. * @param defines defines the Base texture to use.
  57180. * @param fallbacks defines the current fallback list.
  57181. * @param currentRank defines the current fallback rank.
  57182. * @returns the new fallback rank.
  57183. */
  57184. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57185. /**
  57186. * Add the required uniforms to the current list.
  57187. * @param uniforms defines the current uniform list.
  57188. */
  57189. static AddUniforms(uniforms: string[]): void;
  57190. /**
  57191. * Add the required samplers to the current list.
  57192. * @param samplers defines the current sampler list.
  57193. */
  57194. static AddSamplers(samplers: string[]): void;
  57195. /**
  57196. * Add the required uniforms to the current buffer.
  57197. * @param uniformBuffer defines the current uniform buffer.
  57198. */
  57199. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57200. /**
  57201. * Makes a duplicate of the current configuration into another one.
  57202. * @param configuration define the config where to copy the info
  57203. */
  57204. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57205. /**
  57206. * Serializes this Sub Surface configuration.
  57207. * @returns - An object with the serialized config.
  57208. */
  57209. serialize(): any;
  57210. /**
  57211. * Parses a anisotropy Configuration from a serialized object.
  57212. * @param source - Serialized object.
  57213. * @param scene Defines the scene we are parsing for
  57214. * @param rootUrl Defines the rootUrl to load from
  57215. */
  57216. parse(source: any, scene: Scene, rootUrl: string): void;
  57217. }
  57218. }
  57219. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  57220. /** @hidden */
  57221. export var prePassDeclaration: {
  57222. name: string;
  57223. shader: string;
  57224. };
  57225. }
  57226. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57227. /** @hidden */
  57228. export var pbrFragmentDeclaration: {
  57229. name: string;
  57230. shader: string;
  57231. };
  57232. }
  57233. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  57234. /** @hidden */
  57235. export var pbrUboDeclaration: {
  57236. name: string;
  57237. shader: string;
  57238. };
  57239. }
  57240. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  57241. /** @hidden */
  57242. export var pbrFragmentExtraDeclaration: {
  57243. name: string;
  57244. shader: string;
  57245. };
  57246. }
  57247. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  57248. /** @hidden */
  57249. export var pbrFragmentSamplersDeclaration: {
  57250. name: string;
  57251. shader: string;
  57252. };
  57253. }
  57254. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  57255. /** @hidden */
  57256. export var subSurfaceScatteringFunctions: {
  57257. name: string;
  57258. shader: string;
  57259. };
  57260. }
  57261. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  57262. /** @hidden */
  57263. export var importanceSampling: {
  57264. name: string;
  57265. shader: string;
  57266. };
  57267. }
  57268. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  57269. /** @hidden */
  57270. export var pbrHelperFunctions: {
  57271. name: string;
  57272. shader: string;
  57273. };
  57274. }
  57275. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  57276. /** @hidden */
  57277. export var harmonicsFunctions: {
  57278. name: string;
  57279. shader: string;
  57280. };
  57281. }
  57282. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  57283. /** @hidden */
  57284. export var pbrDirectLightingSetupFunctions: {
  57285. name: string;
  57286. shader: string;
  57287. };
  57288. }
  57289. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  57290. /** @hidden */
  57291. export var pbrDirectLightingFalloffFunctions: {
  57292. name: string;
  57293. shader: string;
  57294. };
  57295. }
  57296. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  57297. /** @hidden */
  57298. export var pbrBRDFFunctions: {
  57299. name: string;
  57300. shader: string;
  57301. };
  57302. }
  57303. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  57304. /** @hidden */
  57305. export var hdrFilteringFunctions: {
  57306. name: string;
  57307. shader: string;
  57308. };
  57309. }
  57310. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  57311. /** @hidden */
  57312. export var pbrDirectLightingFunctions: {
  57313. name: string;
  57314. shader: string;
  57315. };
  57316. }
  57317. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  57318. /** @hidden */
  57319. export var pbrIBLFunctions: {
  57320. name: string;
  57321. shader: string;
  57322. };
  57323. }
  57324. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  57325. /** @hidden */
  57326. export var pbrBlockAlbedoOpacity: {
  57327. name: string;
  57328. shader: string;
  57329. };
  57330. }
  57331. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  57332. /** @hidden */
  57333. export var pbrBlockReflectivity: {
  57334. name: string;
  57335. shader: string;
  57336. };
  57337. }
  57338. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  57339. /** @hidden */
  57340. export var pbrBlockAmbientOcclusion: {
  57341. name: string;
  57342. shader: string;
  57343. };
  57344. }
  57345. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  57346. /** @hidden */
  57347. export var pbrBlockAlphaFresnel: {
  57348. name: string;
  57349. shader: string;
  57350. };
  57351. }
  57352. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  57353. /** @hidden */
  57354. export var pbrBlockAnisotropic: {
  57355. name: string;
  57356. shader: string;
  57357. };
  57358. }
  57359. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  57360. /** @hidden */
  57361. export var pbrBlockReflection: {
  57362. name: string;
  57363. shader: string;
  57364. };
  57365. }
  57366. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57367. /** @hidden */
  57368. export var pbrBlockSheen: {
  57369. name: string;
  57370. shader: string;
  57371. };
  57372. }
  57373. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57374. /** @hidden */
  57375. export var pbrBlockClearcoat: {
  57376. name: string;
  57377. shader: string;
  57378. };
  57379. }
  57380. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57381. /** @hidden */
  57382. export var pbrBlockSubSurface: {
  57383. name: string;
  57384. shader: string;
  57385. };
  57386. }
  57387. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57388. /** @hidden */
  57389. export var pbrBlockNormalGeometric: {
  57390. name: string;
  57391. shader: string;
  57392. };
  57393. }
  57394. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57395. /** @hidden */
  57396. export var pbrBlockNormalFinal: {
  57397. name: string;
  57398. shader: string;
  57399. };
  57400. }
  57401. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57402. /** @hidden */
  57403. export var pbrBlockGeometryInfo: {
  57404. name: string;
  57405. shader: string;
  57406. };
  57407. }
  57408. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57409. /** @hidden */
  57410. export var pbrBlockReflectance0: {
  57411. name: string;
  57412. shader: string;
  57413. };
  57414. }
  57415. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57416. /** @hidden */
  57417. export var pbrBlockReflectance: {
  57418. name: string;
  57419. shader: string;
  57420. };
  57421. }
  57422. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57423. /** @hidden */
  57424. export var pbrBlockDirectLighting: {
  57425. name: string;
  57426. shader: string;
  57427. };
  57428. }
  57429. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57430. /** @hidden */
  57431. export var pbrBlockFinalLitComponents: {
  57432. name: string;
  57433. shader: string;
  57434. };
  57435. }
  57436. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57437. /** @hidden */
  57438. export var pbrBlockFinalUnlitComponents: {
  57439. name: string;
  57440. shader: string;
  57441. };
  57442. }
  57443. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57444. /** @hidden */
  57445. export var pbrBlockFinalColorComposition: {
  57446. name: string;
  57447. shader: string;
  57448. };
  57449. }
  57450. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  57451. /** @hidden */
  57452. export var pbrBlockImageProcessing: {
  57453. name: string;
  57454. shader: string;
  57455. };
  57456. }
  57457. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  57458. /** @hidden */
  57459. export var pbrDebug: {
  57460. name: string;
  57461. shader: string;
  57462. };
  57463. }
  57464. declare module "babylonjs/Shaders/pbr.fragment" {
  57465. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  57466. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  57467. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57468. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  57469. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57470. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57471. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  57472. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57473. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57474. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57475. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57476. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57477. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  57478. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  57479. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  57480. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57481. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57482. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57483. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  57484. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  57485. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  57486. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  57487. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  57488. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  57489. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  57490. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57491. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57492. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  57493. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  57494. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  57495. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  57496. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  57497. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  57498. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  57499. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  57500. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  57501. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57502. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  57503. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57504. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  57505. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  57506. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  57507. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  57508. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  57509. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  57510. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57511. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  57512. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  57513. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  57514. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57515. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57516. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  57517. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  57518. /** @hidden */
  57519. export var pbrPixelShader: {
  57520. name: string;
  57521. shader: string;
  57522. };
  57523. }
  57524. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  57525. /** @hidden */
  57526. export var pbrVertexDeclaration: {
  57527. name: string;
  57528. shader: string;
  57529. };
  57530. }
  57531. declare module "babylonjs/Shaders/pbr.vertex" {
  57532. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  57533. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57534. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57535. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57536. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57537. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57538. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  57539. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57540. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57541. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57542. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57543. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57544. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57545. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57547. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57548. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57549. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  57550. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57551. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57552. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57553. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57554. /** @hidden */
  57555. export var pbrVertexShader: {
  57556. name: string;
  57557. shader: string;
  57558. };
  57559. }
  57560. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  57561. import { Nullable } from "babylonjs/types";
  57562. import { Scene } from "babylonjs/scene";
  57563. import { Matrix } from "babylonjs/Maths/math.vector";
  57564. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57566. import { Mesh } from "babylonjs/Meshes/mesh";
  57567. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  57568. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  57569. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  57570. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  57571. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  57572. import { Color3 } from "babylonjs/Maths/math.color";
  57573. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57574. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  57575. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57576. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57577. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57578. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57579. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57580. import "babylonjs/Shaders/pbr.fragment";
  57581. import "babylonjs/Shaders/pbr.vertex";
  57582. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  57583. /**
  57584. * Manages the defines for the PBR Material.
  57585. * @hidden
  57586. */
  57587. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  57588. PBR: boolean;
  57589. NUM_SAMPLES: string;
  57590. REALTIME_FILTERING: boolean;
  57591. MAINUV1: boolean;
  57592. MAINUV2: boolean;
  57593. UV1: boolean;
  57594. UV2: boolean;
  57595. ALBEDO: boolean;
  57596. GAMMAALBEDO: boolean;
  57597. ALBEDODIRECTUV: number;
  57598. VERTEXCOLOR: boolean;
  57599. DETAIL: boolean;
  57600. DETAILDIRECTUV: number;
  57601. DETAIL_NORMALBLENDMETHOD: number;
  57602. AMBIENT: boolean;
  57603. AMBIENTDIRECTUV: number;
  57604. AMBIENTINGRAYSCALE: boolean;
  57605. OPACITY: boolean;
  57606. VERTEXALPHA: boolean;
  57607. OPACITYDIRECTUV: number;
  57608. OPACITYRGB: boolean;
  57609. ALPHATEST: boolean;
  57610. DEPTHPREPASS: boolean;
  57611. ALPHABLEND: boolean;
  57612. ALPHAFROMALBEDO: boolean;
  57613. ALPHATESTVALUE: string;
  57614. SPECULAROVERALPHA: boolean;
  57615. RADIANCEOVERALPHA: boolean;
  57616. ALPHAFRESNEL: boolean;
  57617. LINEARALPHAFRESNEL: boolean;
  57618. PREMULTIPLYALPHA: boolean;
  57619. EMISSIVE: boolean;
  57620. EMISSIVEDIRECTUV: number;
  57621. REFLECTIVITY: boolean;
  57622. REFLECTIVITYDIRECTUV: number;
  57623. SPECULARTERM: boolean;
  57624. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57625. MICROSURFACEAUTOMATIC: boolean;
  57626. LODBASEDMICROSFURACE: boolean;
  57627. MICROSURFACEMAP: boolean;
  57628. MICROSURFACEMAPDIRECTUV: number;
  57629. METALLICWORKFLOW: boolean;
  57630. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57631. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57632. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57633. AOSTOREINMETALMAPRED: boolean;
  57634. METALLIC_REFLECTANCE: boolean;
  57635. METALLIC_REFLECTANCEDIRECTUV: number;
  57636. ENVIRONMENTBRDF: boolean;
  57637. ENVIRONMENTBRDF_RGBD: boolean;
  57638. NORMAL: boolean;
  57639. TANGENT: boolean;
  57640. BUMP: boolean;
  57641. BUMPDIRECTUV: number;
  57642. OBJECTSPACE_NORMALMAP: boolean;
  57643. PARALLAX: boolean;
  57644. PARALLAXOCCLUSION: boolean;
  57645. NORMALXYSCALE: boolean;
  57646. LIGHTMAP: boolean;
  57647. LIGHTMAPDIRECTUV: number;
  57648. USELIGHTMAPASSHADOWMAP: boolean;
  57649. GAMMALIGHTMAP: boolean;
  57650. RGBDLIGHTMAP: boolean;
  57651. REFLECTION: boolean;
  57652. REFLECTIONMAP_3D: boolean;
  57653. REFLECTIONMAP_SPHERICAL: boolean;
  57654. REFLECTIONMAP_PLANAR: boolean;
  57655. REFLECTIONMAP_CUBIC: boolean;
  57656. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57657. REFLECTIONMAP_PROJECTION: boolean;
  57658. REFLECTIONMAP_SKYBOX: boolean;
  57659. REFLECTIONMAP_EXPLICIT: boolean;
  57660. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57661. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57662. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57663. INVERTCUBICMAP: boolean;
  57664. USESPHERICALFROMREFLECTIONMAP: boolean;
  57665. USEIRRADIANCEMAP: boolean;
  57666. SPHERICAL_HARMONICS: boolean;
  57667. USESPHERICALINVERTEX: boolean;
  57668. REFLECTIONMAP_OPPOSITEZ: boolean;
  57669. LODINREFLECTIONALPHA: boolean;
  57670. GAMMAREFLECTION: boolean;
  57671. RGBDREFLECTION: boolean;
  57672. LINEARSPECULARREFLECTION: boolean;
  57673. RADIANCEOCCLUSION: boolean;
  57674. HORIZONOCCLUSION: boolean;
  57675. INSTANCES: boolean;
  57676. THIN_INSTANCES: boolean;
  57677. PREPASS: boolean;
  57678. SCENE_MRT_COUNT: number;
  57679. NUM_BONE_INFLUENCERS: number;
  57680. BonesPerMesh: number;
  57681. BONETEXTURE: boolean;
  57682. NONUNIFORMSCALING: boolean;
  57683. MORPHTARGETS: boolean;
  57684. MORPHTARGETS_NORMAL: boolean;
  57685. MORPHTARGETS_TANGENT: boolean;
  57686. MORPHTARGETS_UV: boolean;
  57687. NUM_MORPH_INFLUENCERS: number;
  57688. IMAGEPROCESSING: boolean;
  57689. VIGNETTE: boolean;
  57690. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57691. VIGNETTEBLENDMODEOPAQUE: boolean;
  57692. TONEMAPPING: boolean;
  57693. TONEMAPPING_ACES: boolean;
  57694. CONTRAST: boolean;
  57695. COLORCURVES: boolean;
  57696. COLORGRADING: boolean;
  57697. COLORGRADING3D: boolean;
  57698. SAMPLER3DGREENDEPTH: boolean;
  57699. SAMPLER3DBGRMAP: boolean;
  57700. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57701. EXPOSURE: boolean;
  57702. MULTIVIEW: boolean;
  57703. USEPHYSICALLIGHTFALLOFF: boolean;
  57704. USEGLTFLIGHTFALLOFF: boolean;
  57705. TWOSIDEDLIGHTING: boolean;
  57706. SHADOWFLOAT: boolean;
  57707. CLIPPLANE: boolean;
  57708. CLIPPLANE2: boolean;
  57709. CLIPPLANE3: boolean;
  57710. CLIPPLANE4: boolean;
  57711. CLIPPLANE5: boolean;
  57712. CLIPPLANE6: boolean;
  57713. POINTSIZE: boolean;
  57714. FOG: boolean;
  57715. LOGARITHMICDEPTH: boolean;
  57716. FORCENORMALFORWARD: boolean;
  57717. SPECULARAA: boolean;
  57718. CLEARCOAT: boolean;
  57719. CLEARCOAT_DEFAULTIOR: boolean;
  57720. CLEARCOAT_TEXTURE: boolean;
  57721. CLEARCOAT_TEXTUREDIRECTUV: number;
  57722. CLEARCOAT_BUMP: boolean;
  57723. CLEARCOAT_BUMPDIRECTUV: number;
  57724. CLEARCOAT_TINT: boolean;
  57725. CLEARCOAT_TINT_TEXTURE: boolean;
  57726. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57727. ANISOTROPIC: boolean;
  57728. ANISOTROPIC_TEXTURE: boolean;
  57729. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57730. BRDF_V_HEIGHT_CORRELATED: boolean;
  57731. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57732. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57733. SHEEN: boolean;
  57734. SHEEN_TEXTURE: boolean;
  57735. SHEEN_TEXTUREDIRECTUV: number;
  57736. SHEEN_LINKWITHALBEDO: boolean;
  57737. SHEEN_ROUGHNESS: boolean;
  57738. SHEEN_ALBEDOSCALING: boolean;
  57739. SUBSURFACE: boolean;
  57740. SS_REFRACTION: boolean;
  57741. SS_TRANSLUCENCY: boolean;
  57742. SS_SCATTERING: boolean;
  57743. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57744. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57745. SS_REFRACTIONMAP_3D: boolean;
  57746. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57747. SS_LODINREFRACTIONALPHA: boolean;
  57748. SS_GAMMAREFRACTION: boolean;
  57749. SS_RGBDREFRACTION: boolean;
  57750. SS_LINEARSPECULARREFRACTION: boolean;
  57751. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57752. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57753. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57754. UNLIT: boolean;
  57755. DEBUGMODE: number;
  57756. /**
  57757. * Initializes the PBR Material defines.
  57758. */
  57759. constructor();
  57760. /**
  57761. * Resets the PBR Material defines.
  57762. */
  57763. reset(): void;
  57764. }
  57765. /**
  57766. * The Physically based material base class of BJS.
  57767. *
  57768. * This offers the main features of a standard PBR material.
  57769. * For more information, please refer to the documentation :
  57770. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57771. */
  57772. export abstract class PBRBaseMaterial extends PushMaterial {
  57773. /**
  57774. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57775. */
  57776. static readonly PBRMATERIAL_OPAQUE: number;
  57777. /**
  57778. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57779. */
  57780. static readonly PBRMATERIAL_ALPHATEST: number;
  57781. /**
  57782. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57783. */
  57784. static readonly PBRMATERIAL_ALPHABLEND: number;
  57785. /**
  57786. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57787. * They are also discarded below the alpha cutoff threshold to improve performances.
  57788. */
  57789. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57790. /**
  57791. * Defines the default value of how much AO map is occluding the analytical lights
  57792. * (point spot...).
  57793. */
  57794. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57795. /**
  57796. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57797. */
  57798. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57799. /**
  57800. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57801. * to enhance interoperability with other engines.
  57802. */
  57803. static readonly LIGHTFALLOFF_GLTF: number;
  57804. /**
  57805. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57806. * to enhance interoperability with other materials.
  57807. */
  57808. static readonly LIGHTFALLOFF_STANDARD: number;
  57809. /**
  57810. * Intensity of the direct lights e.g. the four lights available in your scene.
  57811. * This impacts both the direct diffuse and specular highlights.
  57812. */
  57813. protected _directIntensity: number;
  57814. /**
  57815. * Intensity of the emissive part of the material.
  57816. * This helps controlling the emissive effect without modifying the emissive color.
  57817. */
  57818. protected _emissiveIntensity: number;
  57819. /**
  57820. * Intensity of the environment e.g. how much the environment will light the object
  57821. * either through harmonics for rough material or through the refelction for shiny ones.
  57822. */
  57823. protected _environmentIntensity: number;
  57824. /**
  57825. * This is a special control allowing the reduction of the specular highlights coming from the
  57826. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57827. */
  57828. protected _specularIntensity: number;
  57829. /**
  57830. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57831. */
  57832. private _lightingInfos;
  57833. /**
  57834. * Debug Control allowing disabling the bump map on this material.
  57835. */
  57836. protected _disableBumpMap: boolean;
  57837. /**
  57838. * AKA Diffuse Texture in standard nomenclature.
  57839. */
  57840. protected _albedoTexture: Nullable<BaseTexture>;
  57841. /**
  57842. * AKA Occlusion Texture in other nomenclature.
  57843. */
  57844. protected _ambientTexture: Nullable<BaseTexture>;
  57845. /**
  57846. * AKA Occlusion Texture Intensity in other nomenclature.
  57847. */
  57848. protected _ambientTextureStrength: number;
  57849. /**
  57850. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57851. * 1 means it completely occludes it
  57852. * 0 mean it has no impact
  57853. */
  57854. protected _ambientTextureImpactOnAnalyticalLights: number;
  57855. /**
  57856. * Stores the alpha values in a texture.
  57857. */
  57858. protected _opacityTexture: Nullable<BaseTexture>;
  57859. /**
  57860. * Stores the reflection values in a texture.
  57861. */
  57862. protected _reflectionTexture: Nullable<BaseTexture>;
  57863. /**
  57864. * Stores the emissive values in a texture.
  57865. */
  57866. protected _emissiveTexture: Nullable<BaseTexture>;
  57867. /**
  57868. * AKA Specular texture in other nomenclature.
  57869. */
  57870. protected _reflectivityTexture: Nullable<BaseTexture>;
  57871. /**
  57872. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57873. */
  57874. protected _metallicTexture: Nullable<BaseTexture>;
  57875. /**
  57876. * Specifies the metallic scalar of the metallic/roughness workflow.
  57877. * Can also be used to scale the metalness values of the metallic texture.
  57878. */
  57879. protected _metallic: Nullable<number>;
  57880. /**
  57881. * Specifies the roughness scalar of the metallic/roughness workflow.
  57882. * Can also be used to scale the roughness values of the metallic texture.
  57883. */
  57884. protected _roughness: Nullable<number>;
  57885. /**
  57886. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57887. * By default the indexOfrefraction is used to compute F0;
  57888. *
  57889. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57890. *
  57891. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57892. * F90 = metallicReflectanceColor;
  57893. */
  57894. protected _metallicF0Factor: number;
  57895. /**
  57896. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57897. * By default the F90 is always 1;
  57898. *
  57899. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57900. *
  57901. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57902. * F90 = metallicReflectanceColor;
  57903. */
  57904. protected _metallicReflectanceColor: Color3;
  57905. /**
  57906. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57907. * This is multiply against the scalar values defined in the material.
  57908. */
  57909. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57910. /**
  57911. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57912. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57913. */
  57914. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57915. /**
  57916. * Stores surface normal data used to displace a mesh in a texture.
  57917. */
  57918. protected _bumpTexture: Nullable<BaseTexture>;
  57919. /**
  57920. * Stores the pre-calculated light information of a mesh in a texture.
  57921. */
  57922. protected _lightmapTexture: Nullable<BaseTexture>;
  57923. /**
  57924. * The color of a material in ambient lighting.
  57925. */
  57926. protected _ambientColor: Color3;
  57927. /**
  57928. * AKA Diffuse Color in other nomenclature.
  57929. */
  57930. protected _albedoColor: Color3;
  57931. /**
  57932. * AKA Specular Color in other nomenclature.
  57933. */
  57934. protected _reflectivityColor: Color3;
  57935. /**
  57936. * The color applied when light is reflected from a material.
  57937. */
  57938. protected _reflectionColor: Color3;
  57939. /**
  57940. * The color applied when light is emitted from a material.
  57941. */
  57942. protected _emissiveColor: Color3;
  57943. /**
  57944. * AKA Glossiness in other nomenclature.
  57945. */
  57946. protected _microSurface: number;
  57947. /**
  57948. * Specifies that the material will use the light map as a show map.
  57949. */
  57950. protected _useLightmapAsShadowmap: boolean;
  57951. /**
  57952. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57953. * makes the reflect vector face the model (under horizon).
  57954. */
  57955. protected _useHorizonOcclusion: boolean;
  57956. /**
  57957. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57958. * too much the area relying on ambient texture to define their ambient occlusion.
  57959. */
  57960. protected _useRadianceOcclusion: boolean;
  57961. /**
  57962. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57963. */
  57964. protected _useAlphaFromAlbedoTexture: boolean;
  57965. /**
  57966. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57967. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57968. */
  57969. protected _useSpecularOverAlpha: boolean;
  57970. /**
  57971. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57972. */
  57973. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57974. /**
  57975. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57976. */
  57977. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57978. /**
  57979. * Specifies if the metallic texture contains the roughness information in its green channel.
  57980. */
  57981. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57982. /**
  57983. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57984. */
  57985. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57986. /**
  57987. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57988. */
  57989. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57990. /**
  57991. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57992. */
  57993. protected _useAmbientInGrayScale: boolean;
  57994. /**
  57995. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57996. * The material will try to infer what glossiness each pixel should be.
  57997. */
  57998. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57999. /**
  58000. * Defines the falloff type used in this material.
  58001. * It by default is Physical.
  58002. */
  58003. protected _lightFalloff: number;
  58004. /**
  58005. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58006. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58007. */
  58008. protected _useRadianceOverAlpha: boolean;
  58009. /**
  58010. * Allows using an object space normal map (instead of tangent space).
  58011. */
  58012. protected _useObjectSpaceNormalMap: boolean;
  58013. /**
  58014. * Allows using the bump map in parallax mode.
  58015. */
  58016. protected _useParallax: boolean;
  58017. /**
  58018. * Allows using the bump map in parallax occlusion mode.
  58019. */
  58020. protected _useParallaxOcclusion: boolean;
  58021. /**
  58022. * Controls the scale bias of the parallax mode.
  58023. */
  58024. protected _parallaxScaleBias: number;
  58025. /**
  58026. * If sets to true, disables all the lights affecting the material.
  58027. */
  58028. protected _disableLighting: boolean;
  58029. /**
  58030. * Number of Simultaneous lights allowed on the material.
  58031. */
  58032. protected _maxSimultaneousLights: number;
  58033. /**
  58034. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58035. */
  58036. protected _invertNormalMapX: boolean;
  58037. /**
  58038. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58039. */
  58040. protected _invertNormalMapY: boolean;
  58041. /**
  58042. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58043. */
  58044. protected _twoSidedLighting: boolean;
  58045. /**
  58046. * Defines the alpha limits in alpha test mode.
  58047. */
  58048. protected _alphaCutOff: number;
  58049. /**
  58050. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58051. */
  58052. protected _forceAlphaTest: boolean;
  58053. /**
  58054. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58055. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58056. */
  58057. protected _useAlphaFresnel: boolean;
  58058. /**
  58059. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58060. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58061. */
  58062. protected _useLinearAlphaFresnel: boolean;
  58063. /**
  58064. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  58065. * from cos thetav and roughness:
  58066. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  58067. */
  58068. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  58069. /**
  58070. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58071. */
  58072. protected _forceIrradianceInFragment: boolean;
  58073. private _realTimeFiltering;
  58074. /**
  58075. * Enables realtime filtering on the texture.
  58076. */
  58077. get realTimeFiltering(): boolean;
  58078. set realTimeFiltering(b: boolean);
  58079. private _realTimeFilteringQuality;
  58080. /**
  58081. * Quality switch for realtime filtering
  58082. */
  58083. get realTimeFilteringQuality(): number;
  58084. set realTimeFilteringQuality(n: number);
  58085. /**
  58086. * Should this material render to several textures at once
  58087. */
  58088. get shouldRenderToMRT(): boolean;
  58089. /**
  58090. * Force normal to face away from face.
  58091. */
  58092. protected _forceNormalForward: boolean;
  58093. /**
  58094. * Enables specular anti aliasing in the PBR shader.
  58095. * It will both interacts on the Geometry for analytical and IBL lighting.
  58096. * It also prefilter the roughness map based on the bump values.
  58097. */
  58098. protected _enableSpecularAntiAliasing: boolean;
  58099. /**
  58100. * Default configuration related to image processing available in the PBR Material.
  58101. */
  58102. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58103. /**
  58104. * Keep track of the image processing observer to allow dispose and replace.
  58105. */
  58106. private _imageProcessingObserver;
  58107. /**
  58108. * Attaches a new image processing configuration to the PBR Material.
  58109. * @param configuration
  58110. */
  58111. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58112. /**
  58113. * Stores the available render targets.
  58114. */
  58115. private _renderTargets;
  58116. /**
  58117. * Sets the global ambient color for the material used in lighting calculations.
  58118. */
  58119. private _globalAmbientColor;
  58120. /**
  58121. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  58122. */
  58123. private _useLogarithmicDepth;
  58124. /**
  58125. * If set to true, no lighting calculations will be applied.
  58126. */
  58127. private _unlit;
  58128. private _debugMode;
  58129. /**
  58130. * @hidden
  58131. * This is reserved for the inspector.
  58132. * Defines the material debug mode.
  58133. * It helps seeing only some components of the material while troubleshooting.
  58134. */
  58135. debugMode: number;
  58136. /**
  58137. * @hidden
  58138. * This is reserved for the inspector.
  58139. * Specify from where on screen the debug mode should start.
  58140. * The value goes from -1 (full screen) to 1 (not visible)
  58141. * It helps with side by side comparison against the final render
  58142. * This defaults to -1
  58143. */
  58144. private debugLimit;
  58145. /**
  58146. * @hidden
  58147. * This is reserved for the inspector.
  58148. * As the default viewing range might not be enough (if the ambient is really small for instance)
  58149. * You can use the factor to better multiply the final value.
  58150. */
  58151. private debugFactor;
  58152. /**
  58153. * Defines the clear coat layer parameters for the material.
  58154. */
  58155. readonly clearCoat: PBRClearCoatConfiguration;
  58156. /**
  58157. * Defines the anisotropic parameters for the material.
  58158. */
  58159. readonly anisotropy: PBRAnisotropicConfiguration;
  58160. /**
  58161. * Defines the BRDF parameters for the material.
  58162. */
  58163. readonly brdf: PBRBRDFConfiguration;
  58164. /**
  58165. * Defines the Sheen parameters for the material.
  58166. */
  58167. readonly sheen: PBRSheenConfiguration;
  58168. /**
  58169. * Defines the SubSurface parameters for the material.
  58170. */
  58171. readonly subSurface: PBRSubSurfaceConfiguration;
  58172. /**
  58173. * Defines the detail map parameters for the material.
  58174. */
  58175. readonly detailMap: DetailMapConfiguration;
  58176. protected _rebuildInParallel: boolean;
  58177. /**
  58178. * Instantiates a new PBRMaterial instance.
  58179. *
  58180. * @param name The material name
  58181. * @param scene The scene the material will be use in.
  58182. */
  58183. constructor(name: string, scene: Scene);
  58184. /**
  58185. * Gets a boolean indicating that current material needs to register RTT
  58186. */
  58187. get hasRenderTargetTextures(): boolean;
  58188. /**
  58189. * Gets the name of the material class.
  58190. */
  58191. getClassName(): string;
  58192. /**
  58193. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58194. */
  58195. get useLogarithmicDepth(): boolean;
  58196. /**
  58197. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58198. */
  58199. set useLogarithmicDepth(value: boolean);
  58200. /**
  58201. * Returns true if alpha blending should be disabled.
  58202. */
  58203. protected get _disableAlphaBlending(): boolean;
  58204. /**
  58205. * Specifies whether or not this material should be rendered in alpha blend mode.
  58206. */
  58207. needAlphaBlending(): boolean;
  58208. /**
  58209. * Specifies whether or not this material should be rendered in alpha test mode.
  58210. */
  58211. needAlphaTesting(): boolean;
  58212. /**
  58213. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58214. */
  58215. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58216. /**
  58217. * Gets the texture used for the alpha test.
  58218. */
  58219. getAlphaTestTexture(): Nullable<BaseTexture>;
  58220. /**
  58221. * Specifies that the submesh is ready to be used.
  58222. * @param mesh - BJS mesh.
  58223. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58224. * @param useInstances - Specifies that instances should be used.
  58225. * @returns - boolean indicating that the submesh is ready or not.
  58226. */
  58227. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58228. /**
  58229. * Specifies if the material uses metallic roughness workflow.
  58230. * @returns boolean specifiying if the material uses metallic roughness workflow.
  58231. */
  58232. isMetallicWorkflow(): boolean;
  58233. private _prepareEffect;
  58234. private _prepareDefines;
  58235. /**
  58236. * Force shader compilation
  58237. */
  58238. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  58239. /**
  58240. * Initializes the uniform buffer layout for the shader.
  58241. */
  58242. buildUniformLayout(): void;
  58243. /**
  58244. * Unbinds the material from the mesh
  58245. */
  58246. unbind(): void;
  58247. /**
  58248. * Binds the submesh data.
  58249. * @param world - The world matrix.
  58250. * @param mesh - The BJS mesh.
  58251. * @param subMesh - A submesh of the BJS mesh.
  58252. */
  58253. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58254. /**
  58255. * Returns the animatable textures.
  58256. * @returns - Array of animatable textures.
  58257. */
  58258. getAnimatables(): IAnimatable[];
  58259. /**
  58260. * Returns the texture used for reflections.
  58261. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  58262. */
  58263. private _getReflectionTexture;
  58264. /**
  58265. * Returns an array of the actively used textures.
  58266. * @returns - Array of BaseTextures
  58267. */
  58268. getActiveTextures(): BaseTexture[];
  58269. /**
  58270. * Checks to see if a texture is used in the material.
  58271. * @param texture - Base texture to use.
  58272. * @returns - Boolean specifying if a texture is used in the material.
  58273. */
  58274. hasTexture(texture: BaseTexture): boolean;
  58275. /**
  58276. * Disposes the resources of the material.
  58277. * @param forceDisposeEffect - Forces the disposal of effects.
  58278. * @param forceDisposeTextures - Forces the disposal of all textures.
  58279. */
  58280. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58281. }
  58282. }
  58283. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  58284. import { Nullable } from "babylonjs/types";
  58285. import { Scene } from "babylonjs/scene";
  58286. import { Color3 } from "babylonjs/Maths/math.color";
  58287. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  58288. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  58289. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58290. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58291. /**
  58292. * The Physically based material of BJS.
  58293. *
  58294. * This offers the main features of a standard PBR material.
  58295. * For more information, please refer to the documentation :
  58296. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58297. */
  58298. export class PBRMaterial extends PBRBaseMaterial {
  58299. /**
  58300. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58301. */
  58302. static readonly PBRMATERIAL_OPAQUE: number;
  58303. /**
  58304. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58305. */
  58306. static readonly PBRMATERIAL_ALPHATEST: number;
  58307. /**
  58308. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58309. */
  58310. static readonly PBRMATERIAL_ALPHABLEND: number;
  58311. /**
  58312. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58313. * They are also discarded below the alpha cutoff threshold to improve performances.
  58314. */
  58315. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58316. /**
  58317. * Defines the default value of how much AO map is occluding the analytical lights
  58318. * (point spot...).
  58319. */
  58320. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58321. /**
  58322. * Intensity of the direct lights e.g. the four lights available in your scene.
  58323. * This impacts both the direct diffuse and specular highlights.
  58324. */
  58325. directIntensity: number;
  58326. /**
  58327. * Intensity of the emissive part of the material.
  58328. * This helps controlling the emissive effect without modifying the emissive color.
  58329. */
  58330. emissiveIntensity: number;
  58331. /**
  58332. * Intensity of the environment e.g. how much the environment will light the object
  58333. * either through harmonics for rough material or through the refelction for shiny ones.
  58334. */
  58335. environmentIntensity: number;
  58336. /**
  58337. * This is a special control allowing the reduction of the specular highlights coming from the
  58338. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58339. */
  58340. specularIntensity: number;
  58341. /**
  58342. * Debug Control allowing disabling the bump map on this material.
  58343. */
  58344. disableBumpMap: boolean;
  58345. /**
  58346. * AKA Diffuse Texture in standard nomenclature.
  58347. */
  58348. albedoTexture: BaseTexture;
  58349. /**
  58350. * AKA Occlusion Texture in other nomenclature.
  58351. */
  58352. ambientTexture: BaseTexture;
  58353. /**
  58354. * AKA Occlusion Texture Intensity in other nomenclature.
  58355. */
  58356. ambientTextureStrength: number;
  58357. /**
  58358. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58359. * 1 means it completely occludes it
  58360. * 0 mean it has no impact
  58361. */
  58362. ambientTextureImpactOnAnalyticalLights: number;
  58363. /**
  58364. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  58365. */
  58366. opacityTexture: BaseTexture;
  58367. /**
  58368. * Stores the reflection values in a texture.
  58369. */
  58370. reflectionTexture: Nullable<BaseTexture>;
  58371. /**
  58372. * Stores the emissive values in a texture.
  58373. */
  58374. emissiveTexture: BaseTexture;
  58375. /**
  58376. * AKA Specular texture in other nomenclature.
  58377. */
  58378. reflectivityTexture: BaseTexture;
  58379. /**
  58380. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58381. */
  58382. metallicTexture: BaseTexture;
  58383. /**
  58384. * Specifies the metallic scalar of the metallic/roughness workflow.
  58385. * Can also be used to scale the metalness values of the metallic texture.
  58386. */
  58387. metallic: Nullable<number>;
  58388. /**
  58389. * Specifies the roughness scalar of the metallic/roughness workflow.
  58390. * Can also be used to scale the roughness values of the metallic texture.
  58391. */
  58392. roughness: Nullable<number>;
  58393. /**
  58394. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58395. * By default the indexOfrefraction is used to compute F0;
  58396. *
  58397. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58398. *
  58399. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58400. * F90 = metallicReflectanceColor;
  58401. */
  58402. metallicF0Factor: number;
  58403. /**
  58404. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58405. * By default the F90 is always 1;
  58406. *
  58407. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58408. *
  58409. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58410. * F90 = metallicReflectanceColor;
  58411. */
  58412. metallicReflectanceColor: Color3;
  58413. /**
  58414. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58415. * This is multiply against the scalar values defined in the material.
  58416. */
  58417. metallicReflectanceTexture: Nullable<BaseTexture>;
  58418. /**
  58419. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58420. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58421. */
  58422. microSurfaceTexture: BaseTexture;
  58423. /**
  58424. * Stores surface normal data used to displace a mesh in a texture.
  58425. */
  58426. bumpTexture: BaseTexture;
  58427. /**
  58428. * Stores the pre-calculated light information of a mesh in a texture.
  58429. */
  58430. lightmapTexture: BaseTexture;
  58431. /**
  58432. * Stores the refracted light information in a texture.
  58433. */
  58434. get refractionTexture(): Nullable<BaseTexture>;
  58435. set refractionTexture(value: Nullable<BaseTexture>);
  58436. /**
  58437. * The color of a material in ambient lighting.
  58438. */
  58439. ambientColor: Color3;
  58440. /**
  58441. * AKA Diffuse Color in other nomenclature.
  58442. */
  58443. albedoColor: Color3;
  58444. /**
  58445. * AKA Specular Color in other nomenclature.
  58446. */
  58447. reflectivityColor: Color3;
  58448. /**
  58449. * The color reflected from the material.
  58450. */
  58451. reflectionColor: Color3;
  58452. /**
  58453. * The color emitted from the material.
  58454. */
  58455. emissiveColor: Color3;
  58456. /**
  58457. * AKA Glossiness in other nomenclature.
  58458. */
  58459. microSurface: number;
  58460. /**
  58461. * Index of refraction of the material base layer.
  58462. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58463. *
  58464. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58465. *
  58466. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58467. */
  58468. get indexOfRefraction(): number;
  58469. set indexOfRefraction(value: number);
  58470. /**
  58471. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58472. */
  58473. get invertRefractionY(): boolean;
  58474. set invertRefractionY(value: boolean);
  58475. /**
  58476. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58477. * Materials half opaque for instance using refraction could benefit from this control.
  58478. */
  58479. get linkRefractionWithTransparency(): boolean;
  58480. set linkRefractionWithTransparency(value: boolean);
  58481. /**
  58482. * If true, the light map contains occlusion information instead of lighting info.
  58483. */
  58484. useLightmapAsShadowmap: boolean;
  58485. /**
  58486. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58487. */
  58488. useAlphaFromAlbedoTexture: boolean;
  58489. /**
  58490. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58491. */
  58492. forceAlphaTest: boolean;
  58493. /**
  58494. * Defines the alpha limits in alpha test mode.
  58495. */
  58496. alphaCutOff: number;
  58497. /**
  58498. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  58499. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58500. */
  58501. useSpecularOverAlpha: boolean;
  58502. /**
  58503. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58504. */
  58505. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58506. /**
  58507. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58508. */
  58509. useRoughnessFromMetallicTextureAlpha: boolean;
  58510. /**
  58511. * Specifies if the metallic texture contains the roughness information in its green channel.
  58512. */
  58513. useRoughnessFromMetallicTextureGreen: boolean;
  58514. /**
  58515. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58516. */
  58517. useMetallnessFromMetallicTextureBlue: boolean;
  58518. /**
  58519. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58520. */
  58521. useAmbientOcclusionFromMetallicTextureRed: boolean;
  58522. /**
  58523. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58524. */
  58525. useAmbientInGrayScale: boolean;
  58526. /**
  58527. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58528. * The material will try to infer what glossiness each pixel should be.
  58529. */
  58530. useAutoMicroSurfaceFromReflectivityMap: boolean;
  58531. /**
  58532. * BJS is using an harcoded light falloff based on a manually sets up range.
  58533. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58534. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58535. */
  58536. get usePhysicalLightFalloff(): boolean;
  58537. /**
  58538. * BJS is using an harcoded light falloff based on a manually sets up range.
  58539. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58540. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58541. */
  58542. set usePhysicalLightFalloff(value: boolean);
  58543. /**
  58544. * In order to support the falloff compatibility with gltf, a special mode has been added
  58545. * to reproduce the gltf light falloff.
  58546. */
  58547. get useGLTFLightFalloff(): boolean;
  58548. /**
  58549. * In order to support the falloff compatibility with gltf, a special mode has been added
  58550. * to reproduce the gltf light falloff.
  58551. */
  58552. set useGLTFLightFalloff(value: boolean);
  58553. /**
  58554. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58555. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58556. */
  58557. useRadianceOverAlpha: boolean;
  58558. /**
  58559. * Allows using an object space normal map (instead of tangent space).
  58560. */
  58561. useObjectSpaceNormalMap: boolean;
  58562. /**
  58563. * Allows using the bump map in parallax mode.
  58564. */
  58565. useParallax: boolean;
  58566. /**
  58567. * Allows using the bump map in parallax occlusion mode.
  58568. */
  58569. useParallaxOcclusion: boolean;
  58570. /**
  58571. * Controls the scale bias of the parallax mode.
  58572. */
  58573. parallaxScaleBias: number;
  58574. /**
  58575. * If sets to true, disables all the lights affecting the material.
  58576. */
  58577. disableLighting: boolean;
  58578. /**
  58579. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58580. */
  58581. forceIrradianceInFragment: boolean;
  58582. /**
  58583. * Number of Simultaneous lights allowed on the material.
  58584. */
  58585. maxSimultaneousLights: number;
  58586. /**
  58587. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58588. */
  58589. invertNormalMapX: boolean;
  58590. /**
  58591. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58592. */
  58593. invertNormalMapY: boolean;
  58594. /**
  58595. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58596. */
  58597. twoSidedLighting: boolean;
  58598. /**
  58599. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58600. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58601. */
  58602. useAlphaFresnel: boolean;
  58603. /**
  58604. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58605. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58606. */
  58607. useLinearAlphaFresnel: boolean;
  58608. /**
  58609. * Let user defines the brdf lookup texture used for IBL.
  58610. * A default 8bit version is embedded but you could point at :
  58611. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  58612. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  58613. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  58614. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  58615. */
  58616. environmentBRDFTexture: Nullable<BaseTexture>;
  58617. /**
  58618. * Force normal to face away from face.
  58619. */
  58620. forceNormalForward: boolean;
  58621. /**
  58622. * Enables specular anti aliasing in the PBR shader.
  58623. * It will both interacts on the Geometry for analytical and IBL lighting.
  58624. * It also prefilter the roughness map based on the bump values.
  58625. */
  58626. enableSpecularAntiAliasing: boolean;
  58627. /**
  58628. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58629. * makes the reflect vector face the model (under horizon).
  58630. */
  58631. useHorizonOcclusion: boolean;
  58632. /**
  58633. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58634. * too much the area relying on ambient texture to define their ambient occlusion.
  58635. */
  58636. useRadianceOcclusion: boolean;
  58637. /**
  58638. * If set to true, no lighting calculations will be applied.
  58639. */
  58640. unlit: boolean;
  58641. /**
  58642. * Gets the image processing configuration used either in this material.
  58643. */
  58644. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58645. /**
  58646. * Sets the Default image processing configuration used either in the this material.
  58647. *
  58648. * If sets to null, the scene one is in use.
  58649. */
  58650. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58651. /**
  58652. * Gets wether the color curves effect is enabled.
  58653. */
  58654. get cameraColorCurvesEnabled(): boolean;
  58655. /**
  58656. * Sets wether the color curves effect is enabled.
  58657. */
  58658. set cameraColorCurvesEnabled(value: boolean);
  58659. /**
  58660. * Gets wether the color grading effect is enabled.
  58661. */
  58662. get cameraColorGradingEnabled(): boolean;
  58663. /**
  58664. * Gets wether the color grading effect is enabled.
  58665. */
  58666. set cameraColorGradingEnabled(value: boolean);
  58667. /**
  58668. * Gets wether tonemapping is enabled or not.
  58669. */
  58670. get cameraToneMappingEnabled(): boolean;
  58671. /**
  58672. * Sets wether tonemapping is enabled or not
  58673. */
  58674. set cameraToneMappingEnabled(value: boolean);
  58675. /**
  58676. * The camera exposure used on this material.
  58677. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58678. * This corresponds to a photographic exposure.
  58679. */
  58680. get cameraExposure(): number;
  58681. /**
  58682. * The camera exposure used on this material.
  58683. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58684. * This corresponds to a photographic exposure.
  58685. */
  58686. set cameraExposure(value: number);
  58687. /**
  58688. * Gets The camera contrast used on this material.
  58689. */
  58690. get cameraContrast(): number;
  58691. /**
  58692. * Sets The camera contrast used on this material.
  58693. */
  58694. set cameraContrast(value: number);
  58695. /**
  58696. * Gets the Color Grading 2D Lookup Texture.
  58697. */
  58698. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58699. /**
  58700. * Sets the Color Grading 2D Lookup Texture.
  58701. */
  58702. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58703. /**
  58704. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58705. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58706. * 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;
  58707. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58708. */
  58709. get cameraColorCurves(): Nullable<ColorCurves>;
  58710. /**
  58711. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58712. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58713. * 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;
  58714. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58715. */
  58716. set cameraColorCurves(value: Nullable<ColorCurves>);
  58717. /**
  58718. * Instantiates a new PBRMaterial instance.
  58719. *
  58720. * @param name The material name
  58721. * @param scene The scene the material will be use in.
  58722. */
  58723. constructor(name: string, scene: Scene);
  58724. /**
  58725. * Returns the name of this material class.
  58726. */
  58727. getClassName(): string;
  58728. /**
  58729. * Makes a duplicate of the current material.
  58730. * @param name - name to use for the new material.
  58731. */
  58732. clone(name: string): PBRMaterial;
  58733. /**
  58734. * Serializes this PBR Material.
  58735. * @returns - An object with the serialized material.
  58736. */
  58737. serialize(): any;
  58738. /**
  58739. * Parses a PBR Material from a serialized object.
  58740. * @param source - Serialized object.
  58741. * @param scene - BJS scene instance.
  58742. * @param rootUrl - url for the scene object
  58743. * @returns - PBRMaterial
  58744. */
  58745. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58746. }
  58747. }
  58748. declare module "babylonjs/Misc/dds" {
  58749. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58750. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58751. import { Nullable } from "babylonjs/types";
  58752. import { Scene } from "babylonjs/scene";
  58753. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58754. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58755. /**
  58756. * Direct draw surface info
  58757. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58758. */
  58759. export interface DDSInfo {
  58760. /**
  58761. * Width of the texture
  58762. */
  58763. width: number;
  58764. /**
  58765. * Width of the texture
  58766. */
  58767. height: number;
  58768. /**
  58769. * Number of Mipmaps for the texture
  58770. * @see https://en.wikipedia.org/wiki/Mipmap
  58771. */
  58772. mipmapCount: number;
  58773. /**
  58774. * If the textures format is a known fourCC format
  58775. * @see https://www.fourcc.org/
  58776. */
  58777. isFourCC: boolean;
  58778. /**
  58779. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58780. */
  58781. isRGB: boolean;
  58782. /**
  58783. * If the texture is a lumincance format
  58784. */
  58785. isLuminance: boolean;
  58786. /**
  58787. * If this is a cube texture
  58788. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58789. */
  58790. isCube: boolean;
  58791. /**
  58792. * If the texture is a compressed format eg. FOURCC_DXT1
  58793. */
  58794. isCompressed: boolean;
  58795. /**
  58796. * The dxgiFormat of the texture
  58797. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58798. */
  58799. dxgiFormat: number;
  58800. /**
  58801. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58802. */
  58803. textureType: number;
  58804. /**
  58805. * Sphericle polynomial created for the dds texture
  58806. */
  58807. sphericalPolynomial?: SphericalPolynomial;
  58808. }
  58809. /**
  58810. * Class used to provide DDS decompression tools
  58811. */
  58812. export class DDSTools {
  58813. /**
  58814. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58815. */
  58816. static StoreLODInAlphaChannel: boolean;
  58817. /**
  58818. * Gets DDS information from an array buffer
  58819. * @param data defines the array buffer view to read data from
  58820. * @returns the DDS information
  58821. */
  58822. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58823. private static _FloatView;
  58824. private static _Int32View;
  58825. private static _ToHalfFloat;
  58826. private static _FromHalfFloat;
  58827. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58828. private static _GetHalfFloatRGBAArrayBuffer;
  58829. private static _GetFloatRGBAArrayBuffer;
  58830. private static _GetFloatAsUIntRGBAArrayBuffer;
  58831. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58832. private static _GetRGBAArrayBuffer;
  58833. private static _ExtractLongWordOrder;
  58834. private static _GetRGBArrayBuffer;
  58835. private static _GetLuminanceArrayBuffer;
  58836. /**
  58837. * Uploads DDS Levels to a Babylon Texture
  58838. * @hidden
  58839. */
  58840. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58841. }
  58842. module "babylonjs/Engines/thinEngine" {
  58843. interface ThinEngine {
  58844. /**
  58845. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58846. * @param rootUrl defines the url where the file to load is located
  58847. * @param scene defines the current scene
  58848. * @param lodScale defines scale to apply to the mip map selection
  58849. * @param lodOffset defines offset to apply to the mip map selection
  58850. * @param onLoad defines an optional callback raised when the texture is loaded
  58851. * @param onError defines an optional callback raised if there is an issue to load the texture
  58852. * @param format defines the format of the data
  58853. * @param forcedExtension defines the extension to use to pick the right loader
  58854. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58855. * @returns the cube texture as an InternalTexture
  58856. */
  58857. 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;
  58858. }
  58859. }
  58860. }
  58861. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58862. import { Nullable } from "babylonjs/types";
  58863. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58864. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58865. /**
  58866. * Implementation of the DDS Texture Loader.
  58867. * @hidden
  58868. */
  58869. export class _DDSTextureLoader implements IInternalTextureLoader {
  58870. /**
  58871. * Defines wether the loader supports cascade loading the different faces.
  58872. */
  58873. readonly supportCascades: boolean;
  58874. /**
  58875. * This returns if the loader support the current file information.
  58876. * @param extension defines the file extension of the file being loaded
  58877. * @returns true if the loader can load the specified file
  58878. */
  58879. canLoad(extension: string): boolean;
  58880. /**
  58881. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58882. * @param data contains the texture data
  58883. * @param texture defines the BabylonJS internal texture
  58884. * @param createPolynomials will be true if polynomials have been requested
  58885. * @param onLoad defines the callback to trigger once the texture is ready
  58886. * @param onError defines the callback to trigger in case of error
  58887. */
  58888. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58889. /**
  58890. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58891. * @param data contains the texture data
  58892. * @param texture defines the BabylonJS internal texture
  58893. * @param callback defines the method to call once ready to upload
  58894. */
  58895. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58896. }
  58897. }
  58898. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58899. import { Nullable } from "babylonjs/types";
  58900. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58901. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58902. /**
  58903. * Implementation of the ENV Texture Loader.
  58904. * @hidden
  58905. */
  58906. export class _ENVTextureLoader implements IInternalTextureLoader {
  58907. /**
  58908. * Defines wether the loader supports cascade loading the different faces.
  58909. */
  58910. readonly supportCascades: boolean;
  58911. /**
  58912. * This returns if the loader support the current file information.
  58913. * @param extension defines the file extension of the file being loaded
  58914. * @returns true if the loader can load the specified file
  58915. */
  58916. canLoad(extension: string): boolean;
  58917. /**
  58918. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58919. * @param data contains the texture data
  58920. * @param texture defines the BabylonJS internal texture
  58921. * @param createPolynomials will be true if polynomials have been requested
  58922. * @param onLoad defines the callback to trigger once the texture is ready
  58923. * @param onError defines the callback to trigger in case of error
  58924. */
  58925. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58926. /**
  58927. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58928. * @param data contains the texture data
  58929. * @param texture defines the BabylonJS internal texture
  58930. * @param callback defines the method to call once ready to upload
  58931. */
  58932. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58933. }
  58934. }
  58935. declare module "babylonjs/Misc/khronosTextureContainer" {
  58936. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58937. /**
  58938. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58939. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58940. */
  58941. export class KhronosTextureContainer {
  58942. /** contents of the KTX container file */
  58943. data: ArrayBufferView;
  58944. private static HEADER_LEN;
  58945. private static COMPRESSED_2D;
  58946. private static COMPRESSED_3D;
  58947. private static TEX_2D;
  58948. private static TEX_3D;
  58949. /**
  58950. * Gets the openGL type
  58951. */
  58952. glType: number;
  58953. /**
  58954. * Gets the openGL type size
  58955. */
  58956. glTypeSize: number;
  58957. /**
  58958. * Gets the openGL format
  58959. */
  58960. glFormat: number;
  58961. /**
  58962. * Gets the openGL internal format
  58963. */
  58964. glInternalFormat: number;
  58965. /**
  58966. * Gets the base internal format
  58967. */
  58968. glBaseInternalFormat: number;
  58969. /**
  58970. * Gets image width in pixel
  58971. */
  58972. pixelWidth: number;
  58973. /**
  58974. * Gets image height in pixel
  58975. */
  58976. pixelHeight: number;
  58977. /**
  58978. * Gets image depth in pixels
  58979. */
  58980. pixelDepth: number;
  58981. /**
  58982. * Gets the number of array elements
  58983. */
  58984. numberOfArrayElements: number;
  58985. /**
  58986. * Gets the number of faces
  58987. */
  58988. numberOfFaces: number;
  58989. /**
  58990. * Gets the number of mipmap levels
  58991. */
  58992. numberOfMipmapLevels: number;
  58993. /**
  58994. * Gets the bytes of key value data
  58995. */
  58996. bytesOfKeyValueData: number;
  58997. /**
  58998. * Gets the load type
  58999. */
  59000. loadType: number;
  59001. /**
  59002. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59003. */
  59004. isInvalid: boolean;
  59005. /**
  59006. * Creates a new KhronosTextureContainer
  59007. * @param data contents of the KTX container file
  59008. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59009. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59010. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59011. */
  59012. constructor(
  59013. /** contents of the KTX container file */
  59014. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59015. /**
  59016. * Uploads KTX content to a Babylon Texture.
  59017. * It is assumed that the texture has already been created & is currently bound
  59018. * @hidden
  59019. */
  59020. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59021. private _upload2DCompressedLevels;
  59022. /**
  59023. * Checks if the given data starts with a KTX file identifier.
  59024. * @param data the data to check
  59025. * @returns true if the data is a KTX file or false otherwise
  59026. */
  59027. static IsValid(data: ArrayBufferView): boolean;
  59028. }
  59029. }
  59030. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59031. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59032. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59033. /**
  59034. * Class for loading KTX2 files
  59035. * !!! Experimental Extension Subject to Changes !!!
  59036. * @hidden
  59037. */
  59038. export class KhronosTextureContainer2 {
  59039. private static _ModulePromise;
  59040. private static _TranscodeFormat;
  59041. constructor(engine: ThinEngine);
  59042. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  59043. private _determineTranscodeFormat;
  59044. /**
  59045. * Checks if the given data starts with a KTX2 file identifier.
  59046. * @param data the data to check
  59047. * @returns true if the data is a KTX2 file or false otherwise
  59048. */
  59049. static IsValid(data: ArrayBufferView): boolean;
  59050. }
  59051. }
  59052. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  59053. import { Nullable } from "babylonjs/types";
  59054. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59055. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59056. /**
  59057. * Implementation of the KTX Texture Loader.
  59058. * @hidden
  59059. */
  59060. export class _KTXTextureLoader implements IInternalTextureLoader {
  59061. /**
  59062. * Defines wether the loader supports cascade loading the different faces.
  59063. */
  59064. readonly supportCascades: boolean;
  59065. /**
  59066. * This returns if the loader support the current file information.
  59067. * @param extension defines the file extension of the file being loaded
  59068. * @param mimeType defines the optional mime type of the file being loaded
  59069. * @returns true if the loader can load the specified file
  59070. */
  59071. canLoad(extension: string, mimeType?: string): boolean;
  59072. /**
  59073. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59074. * @param data contains the texture data
  59075. * @param texture defines the BabylonJS internal texture
  59076. * @param createPolynomials will be true if polynomials have been requested
  59077. * @param onLoad defines the callback to trigger once the texture is ready
  59078. * @param onError defines the callback to trigger in case of error
  59079. */
  59080. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59081. /**
  59082. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59083. * @param data contains the texture data
  59084. * @param texture defines the BabylonJS internal texture
  59085. * @param callback defines the method to call once ready to upload
  59086. */
  59087. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59088. }
  59089. }
  59090. declare module "babylonjs/Helpers/sceneHelpers" {
  59091. import { Nullable } from "babylonjs/types";
  59092. import { Mesh } from "babylonjs/Meshes/mesh";
  59093. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59094. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59095. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59096. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59097. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59098. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59099. import "babylonjs/Meshes/Builders/boxBuilder";
  59100. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  59101. /** @hidden */
  59102. export var _forceSceneHelpersToBundle: boolean;
  59103. module "babylonjs/scene" {
  59104. interface Scene {
  59105. /**
  59106. * Creates a default light for the scene.
  59107. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59108. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59109. */
  59110. createDefaultLight(replace?: boolean): void;
  59111. /**
  59112. * Creates a default camera for the scene.
  59113. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59114. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59115. * @param replace has default false, when true replaces the active camera in the scene
  59116. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59117. */
  59118. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59119. /**
  59120. * Creates a default camera and a default light.
  59121. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59122. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59123. * @param replace has the default false, when true replaces the active camera/light in the scene
  59124. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59125. */
  59126. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59127. /**
  59128. * Creates a new sky box
  59129. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59130. * @param environmentTexture defines the texture to use as environment texture
  59131. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59132. * @param scale defines the overall scale of the skybox
  59133. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59134. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59135. * @returns a new mesh holding the sky box
  59136. */
  59137. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59138. /**
  59139. * Creates a new environment
  59140. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59141. * @param options defines the options you can use to configure the environment
  59142. * @returns the new EnvironmentHelper
  59143. */
  59144. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59145. /**
  59146. * Creates a new VREXperienceHelper
  59147. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59148. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59149. * @returns a new VREXperienceHelper
  59150. */
  59151. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59152. /**
  59153. * Creates a new WebXRDefaultExperience
  59154. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59155. * @param options experience options
  59156. * @returns a promise for a new WebXRDefaultExperience
  59157. */
  59158. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59159. }
  59160. }
  59161. }
  59162. declare module "babylonjs/Helpers/videoDome" {
  59163. import { Scene } from "babylonjs/scene";
  59164. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59165. import { Mesh } from "babylonjs/Meshes/mesh";
  59166. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  59167. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  59168. import "babylonjs/Meshes/Builders/sphereBuilder";
  59169. /**
  59170. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59171. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59172. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59173. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59174. */
  59175. export class VideoDome extends TransformNode {
  59176. /**
  59177. * Define the video source as a Monoscopic panoramic 360 video.
  59178. */
  59179. static readonly MODE_MONOSCOPIC: number;
  59180. /**
  59181. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59182. */
  59183. static readonly MODE_TOPBOTTOM: number;
  59184. /**
  59185. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59186. */
  59187. static readonly MODE_SIDEBYSIDE: number;
  59188. private _halfDome;
  59189. private _useDirectMapping;
  59190. /**
  59191. * The video texture being displayed on the sphere
  59192. */
  59193. protected _videoTexture: VideoTexture;
  59194. /**
  59195. * Gets the video texture being displayed on the sphere
  59196. */
  59197. get videoTexture(): VideoTexture;
  59198. /**
  59199. * The skybox material
  59200. */
  59201. protected _material: BackgroundMaterial;
  59202. /**
  59203. * The surface used for the skybox
  59204. */
  59205. protected _mesh: Mesh;
  59206. /**
  59207. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59208. */
  59209. private _halfDomeMask;
  59210. /**
  59211. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59212. * Also see the options.resolution property.
  59213. */
  59214. get fovMultiplier(): number;
  59215. set fovMultiplier(value: number);
  59216. private _videoMode;
  59217. /**
  59218. * Gets or set the current video mode for the video. It can be:
  59219. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  59220. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59221. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59222. */
  59223. get videoMode(): number;
  59224. set videoMode(value: number);
  59225. /**
  59226. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  59227. *
  59228. */
  59229. get halfDome(): boolean;
  59230. /**
  59231. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  59232. */
  59233. set halfDome(enabled: boolean);
  59234. /**
  59235. * Oberserver used in Stereoscopic VR Mode.
  59236. */
  59237. private _onBeforeCameraRenderObserver;
  59238. /**
  59239. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  59240. * @param name Element's name, child elements will append suffixes for their own names.
  59241. * @param urlsOrVideo defines the url(s) or the video element to use
  59242. * @param options An object containing optional or exposed sub element properties
  59243. */
  59244. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  59245. resolution?: number;
  59246. clickToPlay?: boolean;
  59247. autoPlay?: boolean;
  59248. loop?: boolean;
  59249. size?: number;
  59250. poster?: string;
  59251. faceForward?: boolean;
  59252. useDirectMapping?: boolean;
  59253. halfDomeMode?: boolean;
  59254. }, scene: Scene);
  59255. private _changeVideoMode;
  59256. /**
  59257. * Releases resources associated with this node.
  59258. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59259. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59260. */
  59261. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59262. }
  59263. }
  59264. declare module "babylonjs/Helpers/index" {
  59265. export * from "babylonjs/Helpers/environmentHelper";
  59266. export * from "babylonjs/Helpers/photoDome";
  59267. export * from "babylonjs/Helpers/sceneHelpers";
  59268. export * from "babylonjs/Helpers/videoDome";
  59269. }
  59270. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  59271. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59272. import { IDisposable } from "babylonjs/scene";
  59273. import { Engine } from "babylonjs/Engines/engine";
  59274. /**
  59275. * This class can be used to get instrumentation data from a Babylon engine
  59276. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59277. */
  59278. export class EngineInstrumentation implements IDisposable {
  59279. /**
  59280. * Define the instrumented engine.
  59281. */
  59282. engine: Engine;
  59283. private _captureGPUFrameTime;
  59284. private _gpuFrameTimeToken;
  59285. private _gpuFrameTime;
  59286. private _captureShaderCompilationTime;
  59287. private _shaderCompilationTime;
  59288. private _onBeginFrameObserver;
  59289. private _onEndFrameObserver;
  59290. private _onBeforeShaderCompilationObserver;
  59291. private _onAfterShaderCompilationObserver;
  59292. /**
  59293. * Gets the perf counter used for GPU frame time
  59294. */
  59295. get gpuFrameTimeCounter(): PerfCounter;
  59296. /**
  59297. * Gets the GPU frame time capture status
  59298. */
  59299. get captureGPUFrameTime(): boolean;
  59300. /**
  59301. * Enable or disable the GPU frame time capture
  59302. */
  59303. set captureGPUFrameTime(value: boolean);
  59304. /**
  59305. * Gets the perf counter used for shader compilation time
  59306. */
  59307. get shaderCompilationTimeCounter(): PerfCounter;
  59308. /**
  59309. * Gets the shader compilation time capture status
  59310. */
  59311. get captureShaderCompilationTime(): boolean;
  59312. /**
  59313. * Enable or disable the shader compilation time capture
  59314. */
  59315. set captureShaderCompilationTime(value: boolean);
  59316. /**
  59317. * Instantiates a new engine instrumentation.
  59318. * This class can be used to get instrumentation data from a Babylon engine
  59319. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59320. * @param engine Defines the engine to instrument
  59321. */
  59322. constructor(
  59323. /**
  59324. * Define the instrumented engine.
  59325. */
  59326. engine: Engine);
  59327. /**
  59328. * Dispose and release associated resources.
  59329. */
  59330. dispose(): void;
  59331. }
  59332. }
  59333. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  59334. import { Scene, IDisposable } from "babylonjs/scene";
  59335. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59336. /**
  59337. * This class can be used to get instrumentation data from a Babylon engine
  59338. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59339. */
  59340. export class SceneInstrumentation implements IDisposable {
  59341. /**
  59342. * Defines the scene to instrument
  59343. */
  59344. scene: Scene;
  59345. private _captureActiveMeshesEvaluationTime;
  59346. private _activeMeshesEvaluationTime;
  59347. private _captureRenderTargetsRenderTime;
  59348. private _renderTargetsRenderTime;
  59349. private _captureFrameTime;
  59350. private _frameTime;
  59351. private _captureRenderTime;
  59352. private _renderTime;
  59353. private _captureInterFrameTime;
  59354. private _interFrameTime;
  59355. private _captureParticlesRenderTime;
  59356. private _particlesRenderTime;
  59357. private _captureSpritesRenderTime;
  59358. private _spritesRenderTime;
  59359. private _capturePhysicsTime;
  59360. private _physicsTime;
  59361. private _captureAnimationsTime;
  59362. private _animationsTime;
  59363. private _captureCameraRenderTime;
  59364. private _cameraRenderTime;
  59365. private _onBeforeActiveMeshesEvaluationObserver;
  59366. private _onAfterActiveMeshesEvaluationObserver;
  59367. private _onBeforeRenderTargetsRenderObserver;
  59368. private _onAfterRenderTargetsRenderObserver;
  59369. private _onAfterRenderObserver;
  59370. private _onBeforeDrawPhaseObserver;
  59371. private _onAfterDrawPhaseObserver;
  59372. private _onBeforeAnimationsObserver;
  59373. private _onBeforeParticlesRenderingObserver;
  59374. private _onAfterParticlesRenderingObserver;
  59375. private _onBeforeSpritesRenderingObserver;
  59376. private _onAfterSpritesRenderingObserver;
  59377. private _onBeforePhysicsObserver;
  59378. private _onAfterPhysicsObserver;
  59379. private _onAfterAnimationsObserver;
  59380. private _onBeforeCameraRenderObserver;
  59381. private _onAfterCameraRenderObserver;
  59382. /**
  59383. * Gets the perf counter used for active meshes evaluation time
  59384. */
  59385. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59386. /**
  59387. * Gets the active meshes evaluation time capture status
  59388. */
  59389. get captureActiveMeshesEvaluationTime(): boolean;
  59390. /**
  59391. * Enable or disable the active meshes evaluation time capture
  59392. */
  59393. set captureActiveMeshesEvaluationTime(value: boolean);
  59394. /**
  59395. * Gets the perf counter used for render targets render time
  59396. */
  59397. get renderTargetsRenderTimeCounter(): PerfCounter;
  59398. /**
  59399. * Gets the render targets render time capture status
  59400. */
  59401. get captureRenderTargetsRenderTime(): boolean;
  59402. /**
  59403. * Enable or disable the render targets render time capture
  59404. */
  59405. set captureRenderTargetsRenderTime(value: boolean);
  59406. /**
  59407. * Gets the perf counter used for particles render time
  59408. */
  59409. get particlesRenderTimeCounter(): PerfCounter;
  59410. /**
  59411. * Gets the particles render time capture status
  59412. */
  59413. get captureParticlesRenderTime(): boolean;
  59414. /**
  59415. * Enable or disable the particles render time capture
  59416. */
  59417. set captureParticlesRenderTime(value: boolean);
  59418. /**
  59419. * Gets the perf counter used for sprites render time
  59420. */
  59421. get spritesRenderTimeCounter(): PerfCounter;
  59422. /**
  59423. * Gets the sprites render time capture status
  59424. */
  59425. get captureSpritesRenderTime(): boolean;
  59426. /**
  59427. * Enable or disable the sprites render time capture
  59428. */
  59429. set captureSpritesRenderTime(value: boolean);
  59430. /**
  59431. * Gets the perf counter used for physics time
  59432. */
  59433. get physicsTimeCounter(): PerfCounter;
  59434. /**
  59435. * Gets the physics time capture status
  59436. */
  59437. get capturePhysicsTime(): boolean;
  59438. /**
  59439. * Enable or disable the physics time capture
  59440. */
  59441. set capturePhysicsTime(value: boolean);
  59442. /**
  59443. * Gets the perf counter used for animations time
  59444. */
  59445. get animationsTimeCounter(): PerfCounter;
  59446. /**
  59447. * Gets the animations time capture status
  59448. */
  59449. get captureAnimationsTime(): boolean;
  59450. /**
  59451. * Enable or disable the animations time capture
  59452. */
  59453. set captureAnimationsTime(value: boolean);
  59454. /**
  59455. * Gets the perf counter used for frame time capture
  59456. */
  59457. get frameTimeCounter(): PerfCounter;
  59458. /**
  59459. * Gets the frame time capture status
  59460. */
  59461. get captureFrameTime(): boolean;
  59462. /**
  59463. * Enable or disable the frame time capture
  59464. */
  59465. set captureFrameTime(value: boolean);
  59466. /**
  59467. * Gets the perf counter used for inter-frames time capture
  59468. */
  59469. get interFrameTimeCounter(): PerfCounter;
  59470. /**
  59471. * Gets the inter-frames time capture status
  59472. */
  59473. get captureInterFrameTime(): boolean;
  59474. /**
  59475. * Enable or disable the inter-frames time capture
  59476. */
  59477. set captureInterFrameTime(value: boolean);
  59478. /**
  59479. * Gets the perf counter used for render time capture
  59480. */
  59481. get renderTimeCounter(): PerfCounter;
  59482. /**
  59483. * Gets the render time capture status
  59484. */
  59485. get captureRenderTime(): boolean;
  59486. /**
  59487. * Enable or disable the render time capture
  59488. */
  59489. set captureRenderTime(value: boolean);
  59490. /**
  59491. * Gets the perf counter used for camera render time capture
  59492. */
  59493. get cameraRenderTimeCounter(): PerfCounter;
  59494. /**
  59495. * Gets the camera render time capture status
  59496. */
  59497. get captureCameraRenderTime(): boolean;
  59498. /**
  59499. * Enable or disable the camera render time capture
  59500. */
  59501. set captureCameraRenderTime(value: boolean);
  59502. /**
  59503. * Gets the perf counter used for draw calls
  59504. */
  59505. get drawCallsCounter(): PerfCounter;
  59506. /**
  59507. * Instantiates a new scene instrumentation.
  59508. * This class can be used to get instrumentation data from a Babylon engine
  59509. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59510. * @param scene Defines the scene to instrument
  59511. */
  59512. constructor(
  59513. /**
  59514. * Defines the scene to instrument
  59515. */
  59516. scene: Scene);
  59517. /**
  59518. * Dispose and release associated resources.
  59519. */
  59520. dispose(): void;
  59521. }
  59522. }
  59523. declare module "babylonjs/Instrumentation/index" {
  59524. export * from "babylonjs/Instrumentation/engineInstrumentation";
  59525. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  59526. export * from "babylonjs/Instrumentation/timeToken";
  59527. }
  59528. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  59529. /** @hidden */
  59530. export var glowMapGenerationPixelShader: {
  59531. name: string;
  59532. shader: string;
  59533. };
  59534. }
  59535. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  59536. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59537. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59538. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59539. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59540. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59541. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59542. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59543. /** @hidden */
  59544. export var glowMapGenerationVertexShader: {
  59545. name: string;
  59546. shader: string;
  59547. };
  59548. }
  59549. declare module "babylonjs/Layers/effectLayer" {
  59550. import { Observable } from "babylonjs/Misc/observable";
  59551. import { Nullable } from "babylonjs/types";
  59552. import { Camera } from "babylonjs/Cameras/camera";
  59553. import { Scene } from "babylonjs/scene";
  59554. import { ISize } from "babylonjs/Maths/math.size";
  59555. import { Color4 } from "babylonjs/Maths/math.color";
  59556. import { Engine } from "babylonjs/Engines/engine";
  59557. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59559. import { Mesh } from "babylonjs/Meshes/mesh";
  59560. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59561. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59562. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59563. import { Effect } from "babylonjs/Materials/effect";
  59564. import { Material } from "babylonjs/Materials/material";
  59565. import "babylonjs/Shaders/glowMapGeneration.fragment";
  59566. import "babylonjs/Shaders/glowMapGeneration.vertex";
  59567. /**
  59568. * Effect layer options. This helps customizing the behaviour
  59569. * of the effect layer.
  59570. */
  59571. export interface IEffectLayerOptions {
  59572. /**
  59573. * Multiplication factor apply to the canvas size to compute the render target size
  59574. * used to generated the objects (the smaller the faster).
  59575. */
  59576. mainTextureRatio: number;
  59577. /**
  59578. * Enforces a fixed size texture to ensure effect stability across devices.
  59579. */
  59580. mainTextureFixedSize?: number;
  59581. /**
  59582. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59583. */
  59584. alphaBlendingMode: number;
  59585. /**
  59586. * The camera attached to the layer.
  59587. */
  59588. camera: Nullable<Camera>;
  59589. /**
  59590. * The rendering group to draw the layer in.
  59591. */
  59592. renderingGroupId: number;
  59593. }
  59594. /**
  59595. * The effect layer Helps adding post process effect blended with the main pass.
  59596. *
  59597. * This can be for instance use to generate glow or higlight effects on the scene.
  59598. *
  59599. * The effect layer class can not be used directly and is intented to inherited from to be
  59600. * customized per effects.
  59601. */
  59602. export abstract class EffectLayer {
  59603. private _vertexBuffers;
  59604. private _indexBuffer;
  59605. private _cachedDefines;
  59606. private _effectLayerMapGenerationEffect;
  59607. private _effectLayerOptions;
  59608. private _mergeEffect;
  59609. protected _scene: Scene;
  59610. protected _engine: Engine;
  59611. protected _maxSize: number;
  59612. protected _mainTextureDesiredSize: ISize;
  59613. protected _mainTexture: RenderTargetTexture;
  59614. protected _shouldRender: boolean;
  59615. protected _postProcesses: PostProcess[];
  59616. protected _textures: BaseTexture[];
  59617. protected _emissiveTextureAndColor: {
  59618. texture: Nullable<BaseTexture>;
  59619. color: Color4;
  59620. };
  59621. /**
  59622. * The name of the layer
  59623. */
  59624. name: string;
  59625. /**
  59626. * The clear color of the texture used to generate the glow map.
  59627. */
  59628. neutralColor: Color4;
  59629. /**
  59630. * Specifies whether the highlight layer is enabled or not.
  59631. */
  59632. isEnabled: boolean;
  59633. /**
  59634. * Gets the camera attached to the layer.
  59635. */
  59636. get camera(): Nullable<Camera>;
  59637. /**
  59638. * Gets the rendering group id the layer should render in.
  59639. */
  59640. get renderingGroupId(): number;
  59641. set renderingGroupId(renderingGroupId: number);
  59642. /**
  59643. * An event triggered when the effect layer has been disposed.
  59644. */
  59645. onDisposeObservable: Observable<EffectLayer>;
  59646. /**
  59647. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59648. */
  59649. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59650. /**
  59651. * An event triggered when the generated texture is being merged in the scene.
  59652. */
  59653. onBeforeComposeObservable: Observable<EffectLayer>;
  59654. /**
  59655. * An event triggered when the mesh is rendered into the effect render target.
  59656. */
  59657. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59658. /**
  59659. * An event triggered after the mesh has been rendered into the effect render target.
  59660. */
  59661. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59662. /**
  59663. * An event triggered when the generated texture has been merged in the scene.
  59664. */
  59665. onAfterComposeObservable: Observable<EffectLayer>;
  59666. /**
  59667. * An event triggered when the efffect layer changes its size.
  59668. */
  59669. onSizeChangedObservable: Observable<EffectLayer>;
  59670. /** @hidden */
  59671. static _SceneComponentInitialization: (scene: Scene) => void;
  59672. /**
  59673. * Instantiates a new effect Layer and references it in the scene.
  59674. * @param name The name of the layer
  59675. * @param scene The scene to use the layer in
  59676. */
  59677. constructor(
  59678. /** The Friendly of the effect in the scene */
  59679. name: string, scene: Scene);
  59680. /**
  59681. * Get the effect name of the layer.
  59682. * @return The effect name
  59683. */
  59684. abstract getEffectName(): string;
  59685. /**
  59686. * Checks for the readiness of the element composing the layer.
  59687. * @param subMesh the mesh to check for
  59688. * @param useInstances specify whether or not to use instances to render the mesh
  59689. * @return true if ready otherwise, false
  59690. */
  59691. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59692. /**
  59693. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59694. * @returns true if the effect requires stencil during the main canvas render pass.
  59695. */
  59696. abstract needStencil(): boolean;
  59697. /**
  59698. * Create the merge effect. This is the shader use to blit the information back
  59699. * to the main canvas at the end of the scene rendering.
  59700. * @returns The effect containing the shader used to merge the effect on the main canvas
  59701. */
  59702. protected abstract _createMergeEffect(): Effect;
  59703. /**
  59704. * Creates the render target textures and post processes used in the effect layer.
  59705. */
  59706. protected abstract _createTextureAndPostProcesses(): void;
  59707. /**
  59708. * Implementation specific of rendering the generating effect on the main canvas.
  59709. * @param effect The effect used to render through
  59710. */
  59711. protected abstract _internalRender(effect: Effect): void;
  59712. /**
  59713. * Sets the required values for both the emissive texture and and the main color.
  59714. */
  59715. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59716. /**
  59717. * Free any resources and references associated to a mesh.
  59718. * Internal use
  59719. * @param mesh The mesh to free.
  59720. */
  59721. abstract _disposeMesh(mesh: Mesh): void;
  59722. /**
  59723. * Serializes this layer (Glow or Highlight for example)
  59724. * @returns a serialized layer object
  59725. */
  59726. abstract serialize?(): any;
  59727. /**
  59728. * Initializes the effect layer with the required options.
  59729. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59730. */
  59731. protected _init(options: Partial<IEffectLayerOptions>): void;
  59732. /**
  59733. * Generates the index buffer of the full screen quad blending to the main canvas.
  59734. */
  59735. private _generateIndexBuffer;
  59736. /**
  59737. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59738. */
  59739. private _generateVertexBuffer;
  59740. /**
  59741. * Sets the main texture desired size which is the closest power of two
  59742. * of the engine canvas size.
  59743. */
  59744. private _setMainTextureSize;
  59745. /**
  59746. * Creates the main texture for the effect layer.
  59747. */
  59748. protected _createMainTexture(): void;
  59749. /**
  59750. * Adds specific effects defines.
  59751. * @param defines The defines to add specifics to.
  59752. */
  59753. protected _addCustomEffectDefines(defines: string[]): void;
  59754. /**
  59755. * Checks for the readiness of the element composing the layer.
  59756. * @param subMesh the mesh to check for
  59757. * @param useInstances specify whether or not to use instances to render the mesh
  59758. * @param emissiveTexture the associated emissive texture used to generate the glow
  59759. * @return true if ready otherwise, false
  59760. */
  59761. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59762. /**
  59763. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59764. */
  59765. render(): void;
  59766. /**
  59767. * Determine if a given mesh will be used in the current effect.
  59768. * @param mesh mesh to test
  59769. * @returns true if the mesh will be used
  59770. */
  59771. hasMesh(mesh: AbstractMesh): boolean;
  59772. /**
  59773. * Returns true if the layer contains information to display, otherwise false.
  59774. * @returns true if the glow layer should be rendered
  59775. */
  59776. shouldRender(): boolean;
  59777. /**
  59778. * Returns true if the mesh should render, otherwise false.
  59779. * @param mesh The mesh to render
  59780. * @returns true if it should render otherwise false
  59781. */
  59782. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59783. /**
  59784. * Returns true if the mesh can be rendered, otherwise false.
  59785. * @param mesh The mesh to render
  59786. * @param material The material used on the mesh
  59787. * @returns true if it can be rendered otherwise false
  59788. */
  59789. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59790. /**
  59791. * Returns true if the mesh should render, otherwise false.
  59792. * @param mesh The mesh to render
  59793. * @returns true if it should render otherwise false
  59794. */
  59795. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59796. /**
  59797. * Renders the submesh passed in parameter to the generation map.
  59798. */
  59799. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59800. /**
  59801. * Defines whether the current material of the mesh should be use to render the effect.
  59802. * @param mesh defines the current mesh to render
  59803. */
  59804. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59805. /**
  59806. * Rebuild the required buffers.
  59807. * @hidden Internal use only.
  59808. */
  59809. _rebuild(): void;
  59810. /**
  59811. * Dispose only the render target textures and post process.
  59812. */
  59813. private _disposeTextureAndPostProcesses;
  59814. /**
  59815. * Dispose the highlight layer and free resources.
  59816. */
  59817. dispose(): void;
  59818. /**
  59819. * Gets the class name of the effect layer
  59820. * @returns the string with the class name of the effect layer
  59821. */
  59822. getClassName(): string;
  59823. /**
  59824. * Creates an effect layer from parsed effect layer data
  59825. * @param parsedEffectLayer defines effect layer data
  59826. * @param scene defines the current scene
  59827. * @param rootUrl defines the root URL containing the effect layer information
  59828. * @returns a parsed effect Layer
  59829. */
  59830. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59831. }
  59832. }
  59833. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59834. import { Scene } from "babylonjs/scene";
  59835. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59836. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59837. import { AbstractScene } from "babylonjs/abstractScene";
  59838. module "babylonjs/abstractScene" {
  59839. interface AbstractScene {
  59840. /**
  59841. * The list of effect layers (highlights/glow) added to the scene
  59842. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59843. * @see https://doc.babylonjs.com/how_to/glow_layer
  59844. */
  59845. effectLayers: Array<EffectLayer>;
  59846. /**
  59847. * Removes the given effect layer from this scene.
  59848. * @param toRemove defines the effect layer to remove
  59849. * @returns the index of the removed effect layer
  59850. */
  59851. removeEffectLayer(toRemove: EffectLayer): number;
  59852. /**
  59853. * Adds the given effect layer to this scene
  59854. * @param newEffectLayer defines the effect layer to add
  59855. */
  59856. addEffectLayer(newEffectLayer: EffectLayer): void;
  59857. }
  59858. }
  59859. /**
  59860. * Defines the layer scene component responsible to manage any effect layers
  59861. * in a given scene.
  59862. */
  59863. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59864. /**
  59865. * The component name helpfull to identify the component in the list of scene components.
  59866. */
  59867. readonly name: string;
  59868. /**
  59869. * The scene the component belongs to.
  59870. */
  59871. scene: Scene;
  59872. private _engine;
  59873. private _renderEffects;
  59874. private _needStencil;
  59875. private _previousStencilState;
  59876. /**
  59877. * Creates a new instance of the component for the given scene
  59878. * @param scene Defines the scene to register the component in
  59879. */
  59880. constructor(scene: Scene);
  59881. /**
  59882. * Registers the component in a given scene
  59883. */
  59884. register(): void;
  59885. /**
  59886. * Rebuilds the elements related to this component in case of
  59887. * context lost for instance.
  59888. */
  59889. rebuild(): void;
  59890. /**
  59891. * Serializes the component data to the specified json object
  59892. * @param serializationObject The object to serialize to
  59893. */
  59894. serialize(serializationObject: any): void;
  59895. /**
  59896. * Adds all the elements from the container to the scene
  59897. * @param container the container holding the elements
  59898. */
  59899. addFromContainer(container: AbstractScene): void;
  59900. /**
  59901. * Removes all the elements in the container from the scene
  59902. * @param container contains the elements to remove
  59903. * @param dispose if the removed element should be disposed (default: false)
  59904. */
  59905. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59906. /**
  59907. * Disposes the component and the associated ressources.
  59908. */
  59909. dispose(): void;
  59910. private _isReadyForMesh;
  59911. private _renderMainTexture;
  59912. private _setStencil;
  59913. private _setStencilBack;
  59914. private _draw;
  59915. private _drawCamera;
  59916. private _drawRenderingGroup;
  59917. }
  59918. }
  59919. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59920. /** @hidden */
  59921. export var glowMapMergePixelShader: {
  59922. name: string;
  59923. shader: string;
  59924. };
  59925. }
  59926. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59927. /** @hidden */
  59928. export var glowMapMergeVertexShader: {
  59929. name: string;
  59930. shader: string;
  59931. };
  59932. }
  59933. declare module "babylonjs/Layers/glowLayer" {
  59934. import { Nullable } from "babylonjs/types";
  59935. import { Camera } from "babylonjs/Cameras/camera";
  59936. import { Scene } from "babylonjs/scene";
  59937. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59939. import { Mesh } from "babylonjs/Meshes/mesh";
  59940. import { Texture } from "babylonjs/Materials/Textures/texture";
  59941. import { Effect } from "babylonjs/Materials/effect";
  59942. import { Material } from "babylonjs/Materials/material";
  59943. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59944. import { Color4 } from "babylonjs/Maths/math.color";
  59945. import "babylonjs/Shaders/glowMapMerge.fragment";
  59946. import "babylonjs/Shaders/glowMapMerge.vertex";
  59947. import "babylonjs/Layers/effectLayerSceneComponent";
  59948. module "babylonjs/abstractScene" {
  59949. interface AbstractScene {
  59950. /**
  59951. * Return a the first highlight layer of the scene with a given name.
  59952. * @param name The name of the highlight layer to look for.
  59953. * @return The highlight layer if found otherwise null.
  59954. */
  59955. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59956. }
  59957. }
  59958. /**
  59959. * Glow layer options. This helps customizing the behaviour
  59960. * of the glow layer.
  59961. */
  59962. export interface IGlowLayerOptions {
  59963. /**
  59964. * Multiplication factor apply to the canvas size to compute the render target size
  59965. * used to generated the glowing objects (the smaller the faster).
  59966. */
  59967. mainTextureRatio: number;
  59968. /**
  59969. * Enforces a fixed size texture to ensure resize independant blur.
  59970. */
  59971. mainTextureFixedSize?: number;
  59972. /**
  59973. * How big is the kernel of the blur texture.
  59974. */
  59975. blurKernelSize: number;
  59976. /**
  59977. * The camera attached to the layer.
  59978. */
  59979. camera: Nullable<Camera>;
  59980. /**
  59981. * Enable MSAA by chosing the number of samples.
  59982. */
  59983. mainTextureSamples?: number;
  59984. /**
  59985. * The rendering group to draw the layer in.
  59986. */
  59987. renderingGroupId: number;
  59988. }
  59989. /**
  59990. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59991. *
  59992. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59993. *
  59994. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59995. */
  59996. export class GlowLayer extends EffectLayer {
  59997. /**
  59998. * Effect Name of the layer.
  59999. */
  60000. static readonly EffectName: string;
  60001. /**
  60002. * The default blur kernel size used for the glow.
  60003. */
  60004. static DefaultBlurKernelSize: number;
  60005. /**
  60006. * The default texture size ratio used for the glow.
  60007. */
  60008. static DefaultTextureRatio: number;
  60009. /**
  60010. * Sets the kernel size of the blur.
  60011. */
  60012. set blurKernelSize(value: number);
  60013. /**
  60014. * Gets the kernel size of the blur.
  60015. */
  60016. get blurKernelSize(): number;
  60017. /**
  60018. * Sets the glow intensity.
  60019. */
  60020. set intensity(value: number);
  60021. /**
  60022. * Gets the glow intensity.
  60023. */
  60024. get intensity(): number;
  60025. private _options;
  60026. private _intensity;
  60027. private _horizontalBlurPostprocess1;
  60028. private _verticalBlurPostprocess1;
  60029. private _horizontalBlurPostprocess2;
  60030. private _verticalBlurPostprocess2;
  60031. private _blurTexture1;
  60032. private _blurTexture2;
  60033. private _postProcesses1;
  60034. private _postProcesses2;
  60035. private _includedOnlyMeshes;
  60036. private _excludedMeshes;
  60037. private _meshesUsingTheirOwnMaterials;
  60038. /**
  60039. * Callback used to let the user override the color selection on a per mesh basis
  60040. */
  60041. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60042. /**
  60043. * Callback used to let the user override the texture selection on a per mesh basis
  60044. */
  60045. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60046. /**
  60047. * Instantiates a new glow Layer and references it to the scene.
  60048. * @param name The name of the layer
  60049. * @param scene The scene to use the layer in
  60050. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60051. */
  60052. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60053. /**
  60054. * Get the effect name of the layer.
  60055. * @return The effect name
  60056. */
  60057. getEffectName(): string;
  60058. /**
  60059. * Create the merge effect. This is the shader use to blit the information back
  60060. * to the main canvas at the end of the scene rendering.
  60061. */
  60062. protected _createMergeEffect(): Effect;
  60063. /**
  60064. * Creates the render target textures and post processes used in the glow layer.
  60065. */
  60066. protected _createTextureAndPostProcesses(): void;
  60067. /**
  60068. * Checks for the readiness of the element composing the layer.
  60069. * @param subMesh the mesh to check for
  60070. * @param useInstances specify wether or not to use instances to render the mesh
  60071. * @param emissiveTexture the associated emissive texture used to generate the glow
  60072. * @return true if ready otherwise, false
  60073. */
  60074. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60075. /**
  60076. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60077. */
  60078. needStencil(): boolean;
  60079. /**
  60080. * Returns true if the mesh can be rendered, otherwise false.
  60081. * @param mesh The mesh to render
  60082. * @param material The material used on the mesh
  60083. * @returns true if it can be rendered otherwise false
  60084. */
  60085. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60086. /**
  60087. * Implementation specific of rendering the generating effect on the main canvas.
  60088. * @param effect The effect used to render through
  60089. */
  60090. protected _internalRender(effect: Effect): void;
  60091. /**
  60092. * Sets the required values for both the emissive texture and and the main color.
  60093. */
  60094. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60095. /**
  60096. * Returns true if the mesh should render, otherwise false.
  60097. * @param mesh The mesh to render
  60098. * @returns true if it should render otherwise false
  60099. */
  60100. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60101. /**
  60102. * Adds specific effects defines.
  60103. * @param defines The defines to add specifics to.
  60104. */
  60105. protected _addCustomEffectDefines(defines: string[]): void;
  60106. /**
  60107. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60108. * @param mesh The mesh to exclude from the glow layer
  60109. */
  60110. addExcludedMesh(mesh: Mesh): void;
  60111. /**
  60112. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60113. * @param mesh The mesh to remove
  60114. */
  60115. removeExcludedMesh(mesh: Mesh): void;
  60116. /**
  60117. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60118. * @param mesh The mesh to include in the glow layer
  60119. */
  60120. addIncludedOnlyMesh(mesh: Mesh): void;
  60121. /**
  60122. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60123. * @param mesh The mesh to remove
  60124. */
  60125. removeIncludedOnlyMesh(mesh: Mesh): void;
  60126. /**
  60127. * Determine if a given mesh will be used in the glow layer
  60128. * @param mesh The mesh to test
  60129. * @returns true if the mesh will be highlighted by the current glow layer
  60130. */
  60131. hasMesh(mesh: AbstractMesh): boolean;
  60132. /**
  60133. * Defines whether the current material of the mesh should be use to render the effect.
  60134. * @param mesh defines the current mesh to render
  60135. */
  60136. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60137. /**
  60138. * Add a mesh to be rendered through its own material and not with emissive only.
  60139. * @param mesh The mesh for which we need to use its material
  60140. */
  60141. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60142. /**
  60143. * Remove a mesh from being rendered through its own material and not with emissive only.
  60144. * @param mesh The mesh for which we need to not use its material
  60145. */
  60146. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60147. /**
  60148. * Free any resources and references associated to a mesh.
  60149. * Internal use
  60150. * @param mesh The mesh to free.
  60151. * @hidden
  60152. */
  60153. _disposeMesh(mesh: Mesh): void;
  60154. /**
  60155. * Gets the class name of the effect layer
  60156. * @returns the string with the class name of the effect layer
  60157. */
  60158. getClassName(): string;
  60159. /**
  60160. * Serializes this glow layer
  60161. * @returns a serialized glow layer object
  60162. */
  60163. serialize(): any;
  60164. /**
  60165. * Creates a Glow Layer from parsed glow layer data
  60166. * @param parsedGlowLayer defines glow layer data
  60167. * @param scene defines the current scene
  60168. * @param rootUrl defines the root URL containing the glow layer information
  60169. * @returns a parsed Glow Layer
  60170. */
  60171. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60172. }
  60173. }
  60174. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  60175. /** @hidden */
  60176. export var glowBlurPostProcessPixelShader: {
  60177. name: string;
  60178. shader: string;
  60179. };
  60180. }
  60181. declare module "babylonjs/Layers/highlightLayer" {
  60182. import { Observable } from "babylonjs/Misc/observable";
  60183. import { Nullable } from "babylonjs/types";
  60184. import { Camera } from "babylonjs/Cameras/camera";
  60185. import { Scene } from "babylonjs/scene";
  60186. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60188. import { Mesh } from "babylonjs/Meshes/mesh";
  60189. import { Effect } from "babylonjs/Materials/effect";
  60190. import { Material } from "babylonjs/Materials/material";
  60191. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60192. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60193. import "babylonjs/Shaders/glowMapMerge.fragment";
  60194. import "babylonjs/Shaders/glowMapMerge.vertex";
  60195. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  60196. module "babylonjs/abstractScene" {
  60197. interface AbstractScene {
  60198. /**
  60199. * Return a the first highlight layer of the scene with a given name.
  60200. * @param name The name of the highlight layer to look for.
  60201. * @return The highlight layer if found otherwise null.
  60202. */
  60203. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60204. }
  60205. }
  60206. /**
  60207. * Highlight layer options. This helps customizing the behaviour
  60208. * of the highlight layer.
  60209. */
  60210. export interface IHighlightLayerOptions {
  60211. /**
  60212. * Multiplication factor apply to the canvas size to compute the render target size
  60213. * used to generated the glowing objects (the smaller the faster).
  60214. */
  60215. mainTextureRatio: number;
  60216. /**
  60217. * Enforces a fixed size texture to ensure resize independant blur.
  60218. */
  60219. mainTextureFixedSize?: number;
  60220. /**
  60221. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60222. * of the picture to blur (the smaller the faster).
  60223. */
  60224. blurTextureSizeRatio: number;
  60225. /**
  60226. * How big in texel of the blur texture is the vertical blur.
  60227. */
  60228. blurVerticalSize: number;
  60229. /**
  60230. * How big in texel of the blur texture is the horizontal blur.
  60231. */
  60232. blurHorizontalSize: number;
  60233. /**
  60234. * Alpha blending mode used to apply the blur. Default is combine.
  60235. */
  60236. alphaBlendingMode: number;
  60237. /**
  60238. * The camera attached to the layer.
  60239. */
  60240. camera: Nullable<Camera>;
  60241. /**
  60242. * Should we display highlight as a solid stroke?
  60243. */
  60244. isStroke?: boolean;
  60245. /**
  60246. * The rendering group to draw the layer in.
  60247. */
  60248. renderingGroupId: number;
  60249. }
  60250. /**
  60251. * The highlight layer Helps adding a glow effect around a mesh.
  60252. *
  60253. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60254. * glowy meshes to your scene.
  60255. *
  60256. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60257. */
  60258. export class HighlightLayer extends EffectLayer {
  60259. name: string;
  60260. /**
  60261. * Effect Name of the highlight layer.
  60262. */
  60263. static readonly EffectName: string;
  60264. /**
  60265. * The neutral color used during the preparation of the glow effect.
  60266. * This is black by default as the blend operation is a blend operation.
  60267. */
  60268. static NeutralColor: Color4;
  60269. /**
  60270. * Stencil value used for glowing meshes.
  60271. */
  60272. static GlowingMeshStencilReference: number;
  60273. /**
  60274. * Stencil value used for the other meshes in the scene.
  60275. */
  60276. static NormalMeshStencilReference: number;
  60277. /**
  60278. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60279. */
  60280. innerGlow: boolean;
  60281. /**
  60282. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60283. */
  60284. outerGlow: boolean;
  60285. /**
  60286. * Specifies the horizontal size of the blur.
  60287. */
  60288. set blurHorizontalSize(value: number);
  60289. /**
  60290. * Specifies the vertical size of the blur.
  60291. */
  60292. set blurVerticalSize(value: number);
  60293. /**
  60294. * Gets the horizontal size of the blur.
  60295. */
  60296. get blurHorizontalSize(): number;
  60297. /**
  60298. * Gets the vertical size of the blur.
  60299. */
  60300. get blurVerticalSize(): number;
  60301. /**
  60302. * An event triggered when the highlight layer is being blurred.
  60303. */
  60304. onBeforeBlurObservable: Observable<HighlightLayer>;
  60305. /**
  60306. * An event triggered when the highlight layer has been blurred.
  60307. */
  60308. onAfterBlurObservable: Observable<HighlightLayer>;
  60309. private _instanceGlowingMeshStencilReference;
  60310. private _options;
  60311. private _downSamplePostprocess;
  60312. private _horizontalBlurPostprocess;
  60313. private _verticalBlurPostprocess;
  60314. private _blurTexture;
  60315. private _meshes;
  60316. private _excludedMeshes;
  60317. /**
  60318. * Instantiates a new highlight Layer and references it to the scene..
  60319. * @param name The name of the layer
  60320. * @param scene The scene to use the layer in
  60321. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60322. */
  60323. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60324. /**
  60325. * Get the effect name of the layer.
  60326. * @return The effect name
  60327. */
  60328. getEffectName(): string;
  60329. /**
  60330. * Create the merge effect. This is the shader use to blit the information back
  60331. * to the main canvas at the end of the scene rendering.
  60332. */
  60333. protected _createMergeEffect(): Effect;
  60334. /**
  60335. * Creates the render target textures and post processes used in the highlight layer.
  60336. */
  60337. protected _createTextureAndPostProcesses(): void;
  60338. /**
  60339. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60340. */
  60341. needStencil(): boolean;
  60342. /**
  60343. * Checks for the readiness of the element composing the layer.
  60344. * @param subMesh the mesh to check for
  60345. * @param useInstances specify wether or not to use instances to render the mesh
  60346. * @param emissiveTexture the associated emissive texture used to generate the glow
  60347. * @return true if ready otherwise, false
  60348. */
  60349. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60350. /**
  60351. * Implementation specific of rendering the generating effect on the main canvas.
  60352. * @param effect The effect used to render through
  60353. */
  60354. protected _internalRender(effect: Effect): void;
  60355. /**
  60356. * Returns true if the layer contains information to display, otherwise false.
  60357. */
  60358. shouldRender(): boolean;
  60359. /**
  60360. * Returns true if the mesh should render, otherwise false.
  60361. * @param mesh The mesh to render
  60362. * @returns true if it should render otherwise false
  60363. */
  60364. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60365. /**
  60366. * Returns true if the mesh can be rendered, otherwise false.
  60367. * @param mesh The mesh to render
  60368. * @param material The material used on the mesh
  60369. * @returns true if it can be rendered otherwise false
  60370. */
  60371. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60372. /**
  60373. * Adds specific effects defines.
  60374. * @param defines The defines to add specifics to.
  60375. */
  60376. protected _addCustomEffectDefines(defines: string[]): void;
  60377. /**
  60378. * Sets the required values for both the emissive texture and and the main color.
  60379. */
  60380. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60381. /**
  60382. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60383. * @param mesh The mesh to exclude from the highlight layer
  60384. */
  60385. addExcludedMesh(mesh: Mesh): void;
  60386. /**
  60387. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60388. * @param mesh The mesh to highlight
  60389. */
  60390. removeExcludedMesh(mesh: Mesh): void;
  60391. /**
  60392. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60393. * @param mesh mesh to test
  60394. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60395. */
  60396. hasMesh(mesh: AbstractMesh): boolean;
  60397. /**
  60398. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60399. * @param mesh The mesh to highlight
  60400. * @param color The color of the highlight
  60401. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60402. */
  60403. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60404. /**
  60405. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60406. * @param mesh The mesh to highlight
  60407. */
  60408. removeMesh(mesh: Mesh): void;
  60409. /**
  60410. * Remove all the meshes currently referenced in the highlight layer
  60411. */
  60412. removeAllMeshes(): void;
  60413. /**
  60414. * Force the stencil to the normal expected value for none glowing parts
  60415. */
  60416. private _defaultStencilReference;
  60417. /**
  60418. * Free any resources and references associated to a mesh.
  60419. * Internal use
  60420. * @param mesh The mesh to free.
  60421. * @hidden
  60422. */
  60423. _disposeMesh(mesh: Mesh): void;
  60424. /**
  60425. * Dispose the highlight layer and free resources.
  60426. */
  60427. dispose(): void;
  60428. /**
  60429. * Gets the class name of the effect layer
  60430. * @returns the string with the class name of the effect layer
  60431. */
  60432. getClassName(): string;
  60433. /**
  60434. * Serializes this Highlight layer
  60435. * @returns a serialized Highlight layer object
  60436. */
  60437. serialize(): any;
  60438. /**
  60439. * Creates a Highlight layer from parsed Highlight layer data
  60440. * @param parsedHightlightLayer defines the Highlight layer data
  60441. * @param scene defines the current scene
  60442. * @param rootUrl defines the root URL containing the Highlight layer information
  60443. * @returns a parsed Highlight layer
  60444. */
  60445. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60446. }
  60447. }
  60448. declare module "babylonjs/Layers/layerSceneComponent" {
  60449. import { Scene } from "babylonjs/scene";
  60450. import { ISceneComponent } from "babylonjs/sceneComponent";
  60451. import { Layer } from "babylonjs/Layers/layer";
  60452. import { AbstractScene } from "babylonjs/abstractScene";
  60453. module "babylonjs/abstractScene" {
  60454. interface AbstractScene {
  60455. /**
  60456. * The list of layers (background and foreground) of the scene
  60457. */
  60458. layers: Array<Layer>;
  60459. }
  60460. }
  60461. /**
  60462. * Defines the layer scene component responsible to manage any layers
  60463. * in a given scene.
  60464. */
  60465. export class LayerSceneComponent implements ISceneComponent {
  60466. /**
  60467. * The component name helpfull to identify the component in the list of scene components.
  60468. */
  60469. readonly name: string;
  60470. /**
  60471. * The scene the component belongs to.
  60472. */
  60473. scene: Scene;
  60474. private _engine;
  60475. /**
  60476. * Creates a new instance of the component for the given scene
  60477. * @param scene Defines the scene to register the component in
  60478. */
  60479. constructor(scene: Scene);
  60480. /**
  60481. * Registers the component in a given scene
  60482. */
  60483. register(): void;
  60484. /**
  60485. * Rebuilds the elements related to this component in case of
  60486. * context lost for instance.
  60487. */
  60488. rebuild(): void;
  60489. /**
  60490. * Disposes the component and the associated ressources.
  60491. */
  60492. dispose(): void;
  60493. private _draw;
  60494. private _drawCameraPredicate;
  60495. private _drawCameraBackground;
  60496. private _drawCameraForeground;
  60497. private _drawRenderTargetPredicate;
  60498. private _drawRenderTargetBackground;
  60499. private _drawRenderTargetForeground;
  60500. /**
  60501. * Adds all the elements from the container to the scene
  60502. * @param container the container holding the elements
  60503. */
  60504. addFromContainer(container: AbstractScene): void;
  60505. /**
  60506. * Removes all the elements in the container from the scene
  60507. * @param container contains the elements to remove
  60508. * @param dispose if the removed element should be disposed (default: false)
  60509. */
  60510. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60511. }
  60512. }
  60513. declare module "babylonjs/Shaders/layer.fragment" {
  60514. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60515. /** @hidden */
  60516. export var layerPixelShader: {
  60517. name: string;
  60518. shader: string;
  60519. };
  60520. }
  60521. declare module "babylonjs/Shaders/layer.vertex" {
  60522. /** @hidden */
  60523. export var layerVertexShader: {
  60524. name: string;
  60525. shader: string;
  60526. };
  60527. }
  60528. declare module "babylonjs/Layers/layer" {
  60529. import { Observable } from "babylonjs/Misc/observable";
  60530. import { Nullable } from "babylonjs/types";
  60531. import { Scene } from "babylonjs/scene";
  60532. import { Vector2 } from "babylonjs/Maths/math.vector";
  60533. import { Color4 } from "babylonjs/Maths/math.color";
  60534. import { Texture } from "babylonjs/Materials/Textures/texture";
  60535. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60536. import "babylonjs/Shaders/layer.fragment";
  60537. import "babylonjs/Shaders/layer.vertex";
  60538. /**
  60539. * This represents a full screen 2d layer.
  60540. * This can be useful to display a picture in the background of your scene for instance.
  60541. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60542. */
  60543. export class Layer {
  60544. /**
  60545. * Define the name of the layer.
  60546. */
  60547. name: string;
  60548. /**
  60549. * Define the texture the layer should display.
  60550. */
  60551. texture: Nullable<Texture>;
  60552. /**
  60553. * Is the layer in background or foreground.
  60554. */
  60555. isBackground: boolean;
  60556. /**
  60557. * Define the color of the layer (instead of texture).
  60558. */
  60559. color: Color4;
  60560. /**
  60561. * Define the scale of the layer in order to zoom in out of the texture.
  60562. */
  60563. scale: Vector2;
  60564. /**
  60565. * Define an offset for the layer in order to shift the texture.
  60566. */
  60567. offset: Vector2;
  60568. /**
  60569. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60570. */
  60571. alphaBlendingMode: number;
  60572. /**
  60573. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60574. * Alpha test will not mix with the background color in case of transparency.
  60575. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60576. */
  60577. alphaTest: boolean;
  60578. /**
  60579. * Define a mask to restrict the layer to only some of the scene cameras.
  60580. */
  60581. layerMask: number;
  60582. /**
  60583. * Define the list of render target the layer is visible into.
  60584. */
  60585. renderTargetTextures: RenderTargetTexture[];
  60586. /**
  60587. * Define if the layer is only used in renderTarget or if it also
  60588. * renders in the main frame buffer of the canvas.
  60589. */
  60590. renderOnlyInRenderTargetTextures: boolean;
  60591. private _scene;
  60592. private _vertexBuffers;
  60593. private _indexBuffer;
  60594. private _effect;
  60595. private _previousDefines;
  60596. /**
  60597. * An event triggered when the layer is disposed.
  60598. */
  60599. onDisposeObservable: Observable<Layer>;
  60600. private _onDisposeObserver;
  60601. /**
  60602. * Back compatibility with callback before the onDisposeObservable existed.
  60603. * The set callback will be triggered when the layer has been disposed.
  60604. */
  60605. set onDispose(callback: () => void);
  60606. /**
  60607. * An event triggered before rendering the scene
  60608. */
  60609. onBeforeRenderObservable: Observable<Layer>;
  60610. private _onBeforeRenderObserver;
  60611. /**
  60612. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60613. * The set callback will be triggered just before rendering the layer.
  60614. */
  60615. set onBeforeRender(callback: () => void);
  60616. /**
  60617. * An event triggered after rendering the scene
  60618. */
  60619. onAfterRenderObservable: Observable<Layer>;
  60620. private _onAfterRenderObserver;
  60621. /**
  60622. * Back compatibility with callback before the onAfterRenderObservable existed.
  60623. * The set callback will be triggered just after rendering the layer.
  60624. */
  60625. set onAfterRender(callback: () => void);
  60626. /**
  60627. * Instantiates a new layer.
  60628. * This represents a full screen 2d layer.
  60629. * This can be useful to display a picture in the background of your scene for instance.
  60630. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60631. * @param name Define the name of the layer in the scene
  60632. * @param imgUrl Define the url of the texture to display in the layer
  60633. * @param scene Define the scene the layer belongs to
  60634. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60635. * @param color Defines a color for the layer
  60636. */
  60637. constructor(
  60638. /**
  60639. * Define the name of the layer.
  60640. */
  60641. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60642. private _createIndexBuffer;
  60643. /** @hidden */
  60644. _rebuild(): void;
  60645. /**
  60646. * Renders the layer in the scene.
  60647. */
  60648. render(): void;
  60649. /**
  60650. * Disposes and releases the associated ressources.
  60651. */
  60652. dispose(): void;
  60653. }
  60654. }
  60655. declare module "babylonjs/Layers/index" {
  60656. export * from "babylonjs/Layers/effectLayer";
  60657. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60658. export * from "babylonjs/Layers/glowLayer";
  60659. export * from "babylonjs/Layers/highlightLayer";
  60660. export * from "babylonjs/Layers/layer";
  60661. export * from "babylonjs/Layers/layerSceneComponent";
  60662. }
  60663. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60664. /** @hidden */
  60665. export var lensFlarePixelShader: {
  60666. name: string;
  60667. shader: string;
  60668. };
  60669. }
  60670. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60671. /** @hidden */
  60672. export var lensFlareVertexShader: {
  60673. name: string;
  60674. shader: string;
  60675. };
  60676. }
  60677. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60678. import { Scene } from "babylonjs/scene";
  60679. import { Vector3 } from "babylonjs/Maths/math.vector";
  60680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60681. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60682. import "babylonjs/Shaders/lensFlare.fragment";
  60683. import "babylonjs/Shaders/lensFlare.vertex";
  60684. import { Viewport } from "babylonjs/Maths/math.viewport";
  60685. /**
  60686. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60687. * It is usually composed of several `lensFlare`.
  60688. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60689. */
  60690. export class LensFlareSystem {
  60691. /**
  60692. * Define the name of the lens flare system
  60693. */
  60694. name: string;
  60695. /**
  60696. * List of lens flares used in this system.
  60697. */
  60698. lensFlares: LensFlare[];
  60699. /**
  60700. * Define a limit from the border the lens flare can be visible.
  60701. */
  60702. borderLimit: number;
  60703. /**
  60704. * Define a viewport border we do not want to see the lens flare in.
  60705. */
  60706. viewportBorder: number;
  60707. /**
  60708. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60709. */
  60710. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60711. /**
  60712. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60713. */
  60714. layerMask: number;
  60715. /**
  60716. * Define the id of the lens flare system in the scene.
  60717. * (equal to name by default)
  60718. */
  60719. id: string;
  60720. private _scene;
  60721. private _emitter;
  60722. private _vertexBuffers;
  60723. private _indexBuffer;
  60724. private _effect;
  60725. private _positionX;
  60726. private _positionY;
  60727. private _isEnabled;
  60728. /** @hidden */
  60729. static _SceneComponentInitialization: (scene: Scene) => void;
  60730. /**
  60731. * Instantiates a lens flare system.
  60732. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60733. * It is usually composed of several `lensFlare`.
  60734. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60735. * @param name Define the name of the lens flare system in the scene
  60736. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60737. * @param scene Define the scene the lens flare system belongs to
  60738. */
  60739. constructor(
  60740. /**
  60741. * Define the name of the lens flare system
  60742. */
  60743. name: string, emitter: any, scene: Scene);
  60744. /**
  60745. * Define if the lens flare system is enabled.
  60746. */
  60747. get isEnabled(): boolean;
  60748. set isEnabled(value: boolean);
  60749. /**
  60750. * Get the scene the effects belongs to.
  60751. * @returns the scene holding the lens flare system
  60752. */
  60753. getScene(): Scene;
  60754. /**
  60755. * Get the emitter of the lens flare system.
  60756. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60757. * @returns the emitter of the lens flare system
  60758. */
  60759. getEmitter(): any;
  60760. /**
  60761. * Set the emitter of the lens flare system.
  60762. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60763. * @param newEmitter Define the new emitter of the system
  60764. */
  60765. setEmitter(newEmitter: any): void;
  60766. /**
  60767. * Get the lens flare system emitter position.
  60768. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60769. * @returns the position
  60770. */
  60771. getEmitterPosition(): Vector3;
  60772. /**
  60773. * @hidden
  60774. */
  60775. computeEffectivePosition(globalViewport: Viewport): boolean;
  60776. /** @hidden */
  60777. _isVisible(): boolean;
  60778. /**
  60779. * @hidden
  60780. */
  60781. render(): boolean;
  60782. /**
  60783. * Dispose and release the lens flare with its associated resources.
  60784. */
  60785. dispose(): void;
  60786. /**
  60787. * Parse a lens flare system from a JSON repressentation
  60788. * @param parsedLensFlareSystem Define the JSON to parse
  60789. * @param scene Define the scene the parsed system should be instantiated in
  60790. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60791. * @returns the parsed system
  60792. */
  60793. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60794. /**
  60795. * Serialize the current Lens Flare System into a JSON representation.
  60796. * @returns the serialized JSON
  60797. */
  60798. serialize(): any;
  60799. }
  60800. }
  60801. declare module "babylonjs/LensFlares/lensFlare" {
  60802. import { Nullable } from "babylonjs/types";
  60803. import { Color3 } from "babylonjs/Maths/math.color";
  60804. import { Texture } from "babylonjs/Materials/Textures/texture";
  60805. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60806. /**
  60807. * This represents one of the lens effect in a `lensFlareSystem`.
  60808. * It controls one of the indiviual texture used in the effect.
  60809. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60810. */
  60811. export class LensFlare {
  60812. /**
  60813. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60814. */
  60815. size: number;
  60816. /**
  60817. * 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.
  60818. */
  60819. position: number;
  60820. /**
  60821. * Define the lens color.
  60822. */
  60823. color: Color3;
  60824. /**
  60825. * Define the lens texture.
  60826. */
  60827. texture: Nullable<Texture>;
  60828. /**
  60829. * Define the alpha mode to render this particular lens.
  60830. */
  60831. alphaMode: number;
  60832. private _system;
  60833. /**
  60834. * Creates a new Lens Flare.
  60835. * This represents one of the lens effect in a `lensFlareSystem`.
  60836. * It controls one of the indiviual texture used in the effect.
  60837. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60838. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60839. * @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.
  60840. * @param color Define the lens color
  60841. * @param imgUrl Define the lens texture url
  60842. * @param system Define the `lensFlareSystem` this flare is part of
  60843. * @returns The newly created Lens Flare
  60844. */
  60845. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60846. /**
  60847. * Instantiates a new Lens Flare.
  60848. * This represents one of the lens effect in a `lensFlareSystem`.
  60849. * It controls one of the indiviual texture used in the effect.
  60850. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60851. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60852. * @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.
  60853. * @param color Define the lens color
  60854. * @param imgUrl Define the lens texture url
  60855. * @param system Define the `lensFlareSystem` this flare is part of
  60856. */
  60857. constructor(
  60858. /**
  60859. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60860. */
  60861. size: number,
  60862. /**
  60863. * 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.
  60864. */
  60865. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60866. /**
  60867. * Dispose and release the lens flare with its associated resources.
  60868. */
  60869. dispose(): void;
  60870. }
  60871. }
  60872. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60873. import { Nullable } from "babylonjs/types";
  60874. import { Scene } from "babylonjs/scene";
  60875. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60876. import { AbstractScene } from "babylonjs/abstractScene";
  60877. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60878. module "babylonjs/abstractScene" {
  60879. interface AbstractScene {
  60880. /**
  60881. * The list of lens flare system added to the scene
  60882. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60883. */
  60884. lensFlareSystems: Array<LensFlareSystem>;
  60885. /**
  60886. * Removes the given lens flare system from this scene.
  60887. * @param toRemove The lens flare system to remove
  60888. * @returns The index of the removed lens flare system
  60889. */
  60890. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60891. /**
  60892. * Adds the given lens flare system to this scene
  60893. * @param newLensFlareSystem The lens flare system to add
  60894. */
  60895. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60896. /**
  60897. * Gets a lens flare system using its name
  60898. * @param name defines the name to look for
  60899. * @returns the lens flare system or null if not found
  60900. */
  60901. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60902. /**
  60903. * Gets a lens flare system using its id
  60904. * @param id defines the id to look for
  60905. * @returns the lens flare system or null if not found
  60906. */
  60907. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60908. }
  60909. }
  60910. /**
  60911. * Defines the lens flare scene component responsible to manage any lens flares
  60912. * in a given scene.
  60913. */
  60914. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60915. /**
  60916. * The component name helpfull to identify the component in the list of scene components.
  60917. */
  60918. readonly name: string;
  60919. /**
  60920. * The scene the component belongs to.
  60921. */
  60922. scene: Scene;
  60923. /**
  60924. * Creates a new instance of the component for the given scene
  60925. * @param scene Defines the scene to register the component in
  60926. */
  60927. constructor(scene: Scene);
  60928. /**
  60929. * Registers the component in a given scene
  60930. */
  60931. register(): void;
  60932. /**
  60933. * Rebuilds the elements related to this component in case of
  60934. * context lost for instance.
  60935. */
  60936. rebuild(): void;
  60937. /**
  60938. * Adds all the elements from the container to the scene
  60939. * @param container the container holding the elements
  60940. */
  60941. addFromContainer(container: AbstractScene): void;
  60942. /**
  60943. * Removes all the elements in the container from the scene
  60944. * @param container contains the elements to remove
  60945. * @param dispose if the removed element should be disposed (default: false)
  60946. */
  60947. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60948. /**
  60949. * Serializes the component data to the specified json object
  60950. * @param serializationObject The object to serialize to
  60951. */
  60952. serialize(serializationObject: any): void;
  60953. /**
  60954. * Disposes the component and the associated ressources.
  60955. */
  60956. dispose(): void;
  60957. private _draw;
  60958. }
  60959. }
  60960. declare module "babylonjs/LensFlares/index" {
  60961. export * from "babylonjs/LensFlares/lensFlare";
  60962. export * from "babylonjs/LensFlares/lensFlareSystem";
  60963. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60964. }
  60965. declare module "babylonjs/Shaders/depth.fragment" {
  60966. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60967. /** @hidden */
  60968. export var depthPixelShader: {
  60969. name: string;
  60970. shader: string;
  60971. };
  60972. }
  60973. declare module "babylonjs/Shaders/depth.vertex" {
  60974. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60975. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60976. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60977. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60978. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60979. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60980. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60981. /** @hidden */
  60982. export var depthVertexShader: {
  60983. name: string;
  60984. shader: string;
  60985. };
  60986. }
  60987. declare module "babylonjs/Rendering/depthRenderer" {
  60988. import { Nullable } from "babylonjs/types";
  60989. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60990. import { Scene } from "babylonjs/scene";
  60991. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60992. import { Camera } from "babylonjs/Cameras/camera";
  60993. import "babylonjs/Shaders/depth.fragment";
  60994. import "babylonjs/Shaders/depth.vertex";
  60995. /**
  60996. * This represents a depth renderer in Babylon.
  60997. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60998. */
  60999. export class DepthRenderer {
  61000. private _scene;
  61001. private _depthMap;
  61002. private _effect;
  61003. private readonly _storeNonLinearDepth;
  61004. private readonly _clearColor;
  61005. /** Get if the depth renderer is using packed depth or not */
  61006. readonly isPacked: boolean;
  61007. private _cachedDefines;
  61008. private _camera;
  61009. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61010. enabled: boolean;
  61011. /**
  61012. * Specifiess that the depth renderer will only be used within
  61013. * the camera it is created for.
  61014. * This can help forcing its rendering during the camera processing.
  61015. */
  61016. useOnlyInActiveCamera: boolean;
  61017. /** @hidden */
  61018. static _SceneComponentInitialization: (scene: Scene) => void;
  61019. /**
  61020. * Instantiates a depth renderer
  61021. * @param scene The scene the renderer belongs to
  61022. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61023. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61024. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61025. */
  61026. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61027. /**
  61028. * Creates the depth rendering effect and checks if the effect is ready.
  61029. * @param subMesh The submesh to be used to render the depth map of
  61030. * @param useInstances If multiple world instances should be used
  61031. * @returns if the depth renderer is ready to render the depth map
  61032. */
  61033. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61034. /**
  61035. * Gets the texture which the depth map will be written to.
  61036. * @returns The depth map texture
  61037. */
  61038. getDepthMap(): RenderTargetTexture;
  61039. /**
  61040. * Disposes of the depth renderer.
  61041. */
  61042. dispose(): void;
  61043. }
  61044. }
  61045. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  61046. /** @hidden */
  61047. export var minmaxReduxPixelShader: {
  61048. name: string;
  61049. shader: string;
  61050. };
  61051. }
  61052. declare module "babylonjs/Misc/minMaxReducer" {
  61053. import { Nullable } from "babylonjs/types";
  61054. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61055. import { Camera } from "babylonjs/Cameras/camera";
  61056. import { Observer } from "babylonjs/Misc/observable";
  61057. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61058. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  61059. import { Observable } from "babylonjs/Misc/observable";
  61060. import "babylonjs/Shaders/minmaxRedux.fragment";
  61061. /**
  61062. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61063. * and maximum values from all values of the texture.
  61064. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61065. * The source values are read from the red channel of the texture.
  61066. */
  61067. export class MinMaxReducer {
  61068. /**
  61069. * Observable triggered when the computation has been performed
  61070. */
  61071. onAfterReductionPerformed: Observable<{
  61072. min: number;
  61073. max: number;
  61074. }>;
  61075. protected _camera: Camera;
  61076. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61077. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61078. protected _postProcessManager: PostProcessManager;
  61079. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61080. protected _forceFullscreenViewport: boolean;
  61081. /**
  61082. * Creates a min/max reducer
  61083. * @param camera The camera to use for the post processes
  61084. */
  61085. constructor(camera: Camera);
  61086. /**
  61087. * Gets the texture used to read the values from.
  61088. */
  61089. get sourceTexture(): Nullable<RenderTargetTexture>;
  61090. /**
  61091. * Sets the source texture to read the values from.
  61092. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61093. * because in such textures '1' value must not be taken into account to compute the maximum
  61094. * as this value is used to clear the texture.
  61095. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61096. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61097. * @param depthRedux Indicates if the texture is a depth texture or not
  61098. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61099. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61100. */
  61101. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61102. /**
  61103. * Defines the refresh rate of the computation.
  61104. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61105. */
  61106. get refreshRate(): number;
  61107. set refreshRate(value: number);
  61108. protected _activated: boolean;
  61109. /**
  61110. * Gets the activation status of the reducer
  61111. */
  61112. get activated(): boolean;
  61113. /**
  61114. * Activates the reduction computation.
  61115. * When activated, the observers registered in onAfterReductionPerformed are
  61116. * called after the compuation is performed
  61117. */
  61118. activate(): void;
  61119. /**
  61120. * Deactivates the reduction computation.
  61121. */
  61122. deactivate(): void;
  61123. /**
  61124. * Disposes the min/max reducer
  61125. * @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.
  61126. */
  61127. dispose(disposeAll?: boolean): void;
  61128. }
  61129. }
  61130. declare module "babylonjs/Misc/depthReducer" {
  61131. import { Nullable } from "babylonjs/types";
  61132. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61133. import { Camera } from "babylonjs/Cameras/camera";
  61134. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61135. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  61136. /**
  61137. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61138. */
  61139. export class DepthReducer extends MinMaxReducer {
  61140. private _depthRenderer;
  61141. private _depthRendererId;
  61142. /**
  61143. * Gets the depth renderer used for the computation.
  61144. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61145. */
  61146. get depthRenderer(): Nullable<DepthRenderer>;
  61147. /**
  61148. * Creates a depth reducer
  61149. * @param camera The camera used to render the depth texture
  61150. */
  61151. constructor(camera: Camera);
  61152. /**
  61153. * Sets the depth renderer to use to generate the depth map
  61154. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61155. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61156. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61157. */
  61158. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61159. /** @hidden */
  61160. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61161. /**
  61162. * Activates the reduction computation.
  61163. * When activated, the observers registered in onAfterReductionPerformed are
  61164. * called after the compuation is performed
  61165. */
  61166. activate(): void;
  61167. /**
  61168. * Deactivates the reduction computation.
  61169. */
  61170. deactivate(): void;
  61171. /**
  61172. * Disposes the depth reducer
  61173. * @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.
  61174. */
  61175. dispose(disposeAll?: boolean): void;
  61176. }
  61177. }
  61178. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  61179. import { Nullable } from "babylonjs/types";
  61180. import { Scene } from "babylonjs/scene";
  61181. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61182. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61184. import { Effect } from "babylonjs/Materials/effect";
  61185. import "babylonjs/Shaders/shadowMap.fragment";
  61186. import "babylonjs/Shaders/shadowMap.vertex";
  61187. import "babylonjs/Shaders/depthBoxBlur.fragment";
  61188. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  61189. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61190. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61191. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61192. /**
  61193. * A CSM implementation allowing casting shadows on large scenes.
  61194. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61195. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61196. */
  61197. export class CascadedShadowGenerator extends ShadowGenerator {
  61198. private static readonly frustumCornersNDCSpace;
  61199. /**
  61200. * Name of the CSM class
  61201. */
  61202. static CLASSNAME: string;
  61203. /**
  61204. * Defines the default number of cascades used by the CSM.
  61205. */
  61206. static readonly DEFAULT_CASCADES_COUNT: number;
  61207. /**
  61208. * Defines the minimum number of cascades used by the CSM.
  61209. */
  61210. static readonly MIN_CASCADES_COUNT: number;
  61211. /**
  61212. * Defines the maximum number of cascades used by the CSM.
  61213. */
  61214. static readonly MAX_CASCADES_COUNT: number;
  61215. protected _validateFilter(filter: number): number;
  61216. /**
  61217. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61218. */
  61219. penumbraDarkness: number;
  61220. private _numCascades;
  61221. /**
  61222. * Gets or set the number of cascades used by the CSM.
  61223. */
  61224. get numCascades(): number;
  61225. set numCascades(value: number);
  61226. /**
  61227. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61228. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61229. */
  61230. stabilizeCascades: boolean;
  61231. private _freezeShadowCastersBoundingInfo;
  61232. private _freezeShadowCastersBoundingInfoObservable;
  61233. /**
  61234. * Enables or disables the shadow casters bounding info computation.
  61235. * If your shadow casters don't move, you can disable this feature.
  61236. * If it is enabled, the bounding box computation is done every frame.
  61237. */
  61238. get freezeShadowCastersBoundingInfo(): boolean;
  61239. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61240. private _scbiMin;
  61241. private _scbiMax;
  61242. protected _computeShadowCastersBoundingInfo(): void;
  61243. protected _shadowCastersBoundingInfo: BoundingInfo;
  61244. /**
  61245. * Gets or sets the shadow casters bounding info.
  61246. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61247. * so that the system won't overwrite the bounds you provide
  61248. */
  61249. get shadowCastersBoundingInfo(): BoundingInfo;
  61250. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61251. protected _breaksAreDirty: boolean;
  61252. protected _minDistance: number;
  61253. protected _maxDistance: number;
  61254. /**
  61255. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61256. *
  61257. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61258. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61259. * @param min minimal distance for the breaks (default to 0.)
  61260. * @param max maximal distance for the breaks (default to 1.)
  61261. */
  61262. setMinMaxDistance(min: number, max: number): void;
  61263. /** Gets the minimal distance used in the cascade break computation */
  61264. get minDistance(): number;
  61265. /** Gets the maximal distance used in the cascade break computation */
  61266. get maxDistance(): number;
  61267. /**
  61268. * Gets the class name of that object
  61269. * @returns "CascadedShadowGenerator"
  61270. */
  61271. getClassName(): string;
  61272. private _cascadeMinExtents;
  61273. private _cascadeMaxExtents;
  61274. /**
  61275. * Gets a cascade minimum extents
  61276. * @param cascadeIndex index of the cascade
  61277. * @returns the minimum cascade extents
  61278. */
  61279. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61280. /**
  61281. * Gets a cascade maximum extents
  61282. * @param cascadeIndex index of the cascade
  61283. * @returns the maximum cascade extents
  61284. */
  61285. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61286. private _cascades;
  61287. private _currentLayer;
  61288. private _viewSpaceFrustumsZ;
  61289. private _viewMatrices;
  61290. private _projectionMatrices;
  61291. private _transformMatrices;
  61292. private _transformMatricesAsArray;
  61293. private _frustumLengths;
  61294. private _lightSizeUVCorrection;
  61295. private _depthCorrection;
  61296. private _frustumCornersWorldSpace;
  61297. private _frustumCenter;
  61298. private _shadowCameraPos;
  61299. private _shadowMaxZ;
  61300. /**
  61301. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61302. * It defaults to camera.maxZ
  61303. */
  61304. get shadowMaxZ(): number;
  61305. /**
  61306. * Sets the shadow max z distance.
  61307. */
  61308. set shadowMaxZ(value: number);
  61309. protected _debug: boolean;
  61310. /**
  61311. * Gets or sets the debug flag.
  61312. * When enabled, the cascades are materialized by different colors on the screen.
  61313. */
  61314. get debug(): boolean;
  61315. set debug(dbg: boolean);
  61316. private _depthClamp;
  61317. /**
  61318. * Gets or sets the depth clamping value.
  61319. *
  61320. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61321. * to account for the shadow casters far away.
  61322. *
  61323. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61324. */
  61325. get depthClamp(): boolean;
  61326. set depthClamp(value: boolean);
  61327. private _cascadeBlendPercentage;
  61328. /**
  61329. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61330. * It defaults to 0.1 (10% blending).
  61331. */
  61332. get cascadeBlendPercentage(): number;
  61333. set cascadeBlendPercentage(value: number);
  61334. private _lambda;
  61335. /**
  61336. * Gets or set the lambda parameter.
  61337. * This parameter is used to split the camera frustum and create the cascades.
  61338. * 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.
  61339. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61340. */
  61341. get lambda(): number;
  61342. set lambda(value: number);
  61343. /**
  61344. * Gets the view matrix corresponding to a given cascade
  61345. * @param cascadeNum cascade to retrieve the view matrix from
  61346. * @returns the cascade view matrix
  61347. */
  61348. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61349. /**
  61350. * Gets the projection matrix corresponding to a given cascade
  61351. * @param cascadeNum cascade to retrieve the projection matrix from
  61352. * @returns the cascade projection matrix
  61353. */
  61354. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61355. /**
  61356. * Gets the transformation matrix corresponding to a given cascade
  61357. * @param cascadeNum cascade to retrieve the transformation matrix from
  61358. * @returns the cascade transformation matrix
  61359. */
  61360. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61361. private _depthRenderer;
  61362. /**
  61363. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61364. *
  61365. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61366. *
  61367. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61368. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61369. * @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
  61370. */
  61371. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61372. private _depthReducer;
  61373. private _autoCalcDepthBounds;
  61374. /**
  61375. * Gets or sets the autoCalcDepthBounds property.
  61376. *
  61377. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61378. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61379. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61380. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61381. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61382. */
  61383. get autoCalcDepthBounds(): boolean;
  61384. set autoCalcDepthBounds(value: boolean);
  61385. /**
  61386. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61387. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61388. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61389. * for setting the refresh rate on the renderer yourself!
  61390. */
  61391. get autoCalcDepthBoundsRefreshRate(): number;
  61392. set autoCalcDepthBoundsRefreshRate(value: number);
  61393. /**
  61394. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61395. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61396. * you change the camera near/far planes!
  61397. */
  61398. splitFrustum(): void;
  61399. private _splitFrustum;
  61400. private _computeMatrices;
  61401. private _computeFrustumInWorldSpace;
  61402. private _computeCascadeFrustum;
  61403. /**
  61404. * Support test.
  61405. */
  61406. static get IsSupported(): boolean;
  61407. /** @hidden */
  61408. static _SceneComponentInitialization: (scene: Scene) => void;
  61409. /**
  61410. * Creates a Cascaded Shadow Generator object.
  61411. * A ShadowGenerator is the required tool to use the shadows.
  61412. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61413. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61414. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61415. * @param light The directional light object generating the shadows.
  61416. * @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.
  61417. */
  61418. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61419. protected _initializeGenerator(): void;
  61420. protected _createTargetRenderTexture(): void;
  61421. protected _initializeShadowMap(): void;
  61422. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61423. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61424. /**
  61425. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61426. * @param defines Defines of the material we want to update
  61427. * @param lightIndex Index of the light in the enabled light list of the material
  61428. */
  61429. prepareDefines(defines: any, lightIndex: number): void;
  61430. /**
  61431. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61432. * defined in the generator but impacting the effect).
  61433. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61434. * @param effect The effect we are binfing the information for
  61435. */
  61436. bindShadowLight(lightIndex: string, effect: Effect): void;
  61437. /**
  61438. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61439. * (eq to view projection * shadow projection matrices)
  61440. * @returns The transform matrix used to create the shadow map
  61441. */
  61442. getTransformMatrix(): Matrix;
  61443. /**
  61444. * Disposes the ShadowGenerator.
  61445. * Returns nothing.
  61446. */
  61447. dispose(): void;
  61448. /**
  61449. * Serializes the shadow generator setup to a json object.
  61450. * @returns The serialized JSON object
  61451. */
  61452. serialize(): any;
  61453. /**
  61454. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61455. * @param parsedShadowGenerator The JSON object to parse
  61456. * @param scene The scene to create the shadow map for
  61457. * @returns The parsed shadow generator
  61458. */
  61459. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61460. }
  61461. }
  61462. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  61463. import { Scene } from "babylonjs/scene";
  61464. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61465. import { AbstractScene } from "babylonjs/abstractScene";
  61466. /**
  61467. * Defines the shadow generator component responsible to manage any shadow generators
  61468. * in a given scene.
  61469. */
  61470. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61471. /**
  61472. * The component name helpfull to identify the component in the list of scene components.
  61473. */
  61474. readonly name: string;
  61475. /**
  61476. * The scene the component belongs to.
  61477. */
  61478. scene: Scene;
  61479. /**
  61480. * Creates a new instance of the component for the given scene
  61481. * @param scene Defines the scene to register the component in
  61482. */
  61483. constructor(scene: Scene);
  61484. /**
  61485. * Registers the component in a given scene
  61486. */
  61487. register(): void;
  61488. /**
  61489. * Rebuilds the elements related to this component in case of
  61490. * context lost for instance.
  61491. */
  61492. rebuild(): void;
  61493. /**
  61494. * Serializes the component data to the specified json object
  61495. * @param serializationObject The object to serialize to
  61496. */
  61497. serialize(serializationObject: any): void;
  61498. /**
  61499. * Adds all the elements from the container to the scene
  61500. * @param container the container holding the elements
  61501. */
  61502. addFromContainer(container: AbstractScene): void;
  61503. /**
  61504. * Removes all the elements in the container from the scene
  61505. * @param container contains the elements to remove
  61506. * @param dispose if the removed element should be disposed (default: false)
  61507. */
  61508. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61509. /**
  61510. * Rebuilds the elements related to this component in case of
  61511. * context lost for instance.
  61512. */
  61513. dispose(): void;
  61514. private _gatherRenderTargets;
  61515. }
  61516. }
  61517. declare module "babylonjs/Lights/Shadows/index" {
  61518. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  61519. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  61520. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  61521. }
  61522. declare module "babylonjs/Lights/pointLight" {
  61523. import { Scene } from "babylonjs/scene";
  61524. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61526. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  61527. import { Effect } from "babylonjs/Materials/effect";
  61528. /**
  61529. * A point light is a light defined by an unique point in world space.
  61530. * The light is emitted in every direction from this point.
  61531. * A good example of a point light is a standard light bulb.
  61532. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61533. */
  61534. export class PointLight extends ShadowLight {
  61535. private _shadowAngle;
  61536. /**
  61537. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61538. * This specifies what angle the shadow will use to be created.
  61539. *
  61540. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61541. */
  61542. get shadowAngle(): number;
  61543. /**
  61544. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61545. * This specifies what angle the shadow will use to be created.
  61546. *
  61547. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61548. */
  61549. set shadowAngle(value: number);
  61550. /**
  61551. * Gets the direction if it has been set.
  61552. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61553. */
  61554. get direction(): Vector3;
  61555. /**
  61556. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61557. */
  61558. set direction(value: Vector3);
  61559. /**
  61560. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61561. * A PointLight emits the light in every direction.
  61562. * It can cast shadows.
  61563. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61564. * ```javascript
  61565. * var pointLight = new PointLight("pl", camera.position, scene);
  61566. * ```
  61567. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61568. * @param name The light friendly name
  61569. * @param position The position of the point light in the scene
  61570. * @param scene The scene the lights belongs to
  61571. */
  61572. constructor(name: string, position: Vector3, scene: Scene);
  61573. /**
  61574. * Returns the string "PointLight"
  61575. * @returns the class name
  61576. */
  61577. getClassName(): string;
  61578. /**
  61579. * Returns the integer 0.
  61580. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61581. */
  61582. getTypeID(): number;
  61583. /**
  61584. * Specifies wether or not the shadowmap should be a cube texture.
  61585. * @returns true if the shadowmap needs to be a cube texture.
  61586. */
  61587. needCube(): boolean;
  61588. /**
  61589. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61590. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61591. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61592. */
  61593. getShadowDirection(faceIndex?: number): Vector3;
  61594. /**
  61595. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61596. * - fov = PI / 2
  61597. * - aspect ratio : 1.0
  61598. * - z-near and far equal to the active camera minZ and maxZ.
  61599. * Returns the PointLight.
  61600. */
  61601. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61602. protected _buildUniformLayout(): void;
  61603. /**
  61604. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61605. * @param effect The effect to update
  61606. * @param lightIndex The index of the light in the effect to update
  61607. * @returns The point light
  61608. */
  61609. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61610. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61611. /**
  61612. * Prepares the list of defines specific to the light type.
  61613. * @param defines the list of defines
  61614. * @param lightIndex defines the index of the light for the effect
  61615. */
  61616. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61617. }
  61618. }
  61619. declare module "babylonjs/Lights/index" {
  61620. export * from "babylonjs/Lights/light";
  61621. export * from "babylonjs/Lights/shadowLight";
  61622. export * from "babylonjs/Lights/Shadows/index";
  61623. export * from "babylonjs/Lights/directionalLight";
  61624. export * from "babylonjs/Lights/hemisphericLight";
  61625. export * from "babylonjs/Lights/pointLight";
  61626. export * from "babylonjs/Lights/spotLight";
  61627. }
  61628. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  61629. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61630. /**
  61631. * Header information of HDR texture files.
  61632. */
  61633. export interface HDRInfo {
  61634. /**
  61635. * The height of the texture in pixels.
  61636. */
  61637. height: number;
  61638. /**
  61639. * The width of the texture in pixels.
  61640. */
  61641. width: number;
  61642. /**
  61643. * The index of the beginning of the data in the binary file.
  61644. */
  61645. dataPosition: number;
  61646. }
  61647. /**
  61648. * This groups tools to convert HDR texture to native colors array.
  61649. */
  61650. export class HDRTools {
  61651. private static Ldexp;
  61652. private static Rgbe2float;
  61653. private static readStringLine;
  61654. /**
  61655. * Reads header information from an RGBE texture stored in a native array.
  61656. * More information on this format are available here:
  61657. * https://en.wikipedia.org/wiki/RGBE_image_format
  61658. *
  61659. * @param uint8array The binary file stored in native array.
  61660. * @return The header information.
  61661. */
  61662. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61663. /**
  61664. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61665. * This RGBE texture needs to store the information as a panorama.
  61666. *
  61667. * More information on this format are available here:
  61668. * https://en.wikipedia.org/wiki/RGBE_image_format
  61669. *
  61670. * @param buffer The binary file stored in an array buffer.
  61671. * @param size The expected size of the extracted cubemap.
  61672. * @return The Cube Map information.
  61673. */
  61674. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61675. /**
  61676. * Returns the pixels data extracted from an RGBE texture.
  61677. * This pixels will be stored left to right up to down in the R G B order in one array.
  61678. *
  61679. * More information on this format are available here:
  61680. * https://en.wikipedia.org/wiki/RGBE_image_format
  61681. *
  61682. * @param uint8array The binary file stored in an array buffer.
  61683. * @param hdrInfo The header information of the file.
  61684. * @return The pixels data in RGB right to left up to down order.
  61685. */
  61686. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61687. private static RGBE_ReadPixels_RLE;
  61688. }
  61689. }
  61690. declare module "babylonjs/Materials/effectRenderer" {
  61691. import { Nullable } from "babylonjs/types";
  61692. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61693. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61694. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61695. import { Viewport } from "babylonjs/Maths/math.viewport";
  61696. import { Observable } from "babylonjs/Misc/observable";
  61697. import { Effect } from "babylonjs/Materials/effect";
  61698. import "babylonjs/Shaders/postprocess.vertex";
  61699. /**
  61700. * Effect Render Options
  61701. */
  61702. export interface IEffectRendererOptions {
  61703. /**
  61704. * Defines the vertices positions.
  61705. */
  61706. positions?: number[];
  61707. /**
  61708. * Defines the indices.
  61709. */
  61710. indices?: number[];
  61711. }
  61712. /**
  61713. * Helper class to render one or more effects.
  61714. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61715. */
  61716. export class EffectRenderer {
  61717. private engine;
  61718. private static _DefaultOptions;
  61719. private _vertexBuffers;
  61720. private _indexBuffer;
  61721. private _fullscreenViewport;
  61722. /**
  61723. * Creates an effect renderer
  61724. * @param engine the engine to use for rendering
  61725. * @param options defines the options of the effect renderer
  61726. */
  61727. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61728. /**
  61729. * Sets the current viewport in normalized coordinates 0-1
  61730. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61731. */
  61732. setViewport(viewport?: Viewport): void;
  61733. /**
  61734. * Binds the embedded attributes buffer to the effect.
  61735. * @param effect Defines the effect to bind the attributes for
  61736. */
  61737. bindBuffers(effect: Effect): void;
  61738. /**
  61739. * Sets the current effect wrapper to use during draw.
  61740. * The effect needs to be ready before calling this api.
  61741. * This also sets the default full screen position attribute.
  61742. * @param effectWrapper Defines the effect to draw with
  61743. */
  61744. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61745. /**
  61746. * Restores engine states
  61747. */
  61748. restoreStates(): void;
  61749. /**
  61750. * Draws a full screen quad.
  61751. */
  61752. draw(): void;
  61753. private isRenderTargetTexture;
  61754. /**
  61755. * renders one or more effects to a specified texture
  61756. * @param effectWrapper the effect to renderer
  61757. * @param outputTexture texture to draw to, if null it will render to the screen.
  61758. */
  61759. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61760. /**
  61761. * Disposes of the effect renderer
  61762. */
  61763. dispose(): void;
  61764. }
  61765. /**
  61766. * Options to create an EffectWrapper
  61767. */
  61768. interface EffectWrapperCreationOptions {
  61769. /**
  61770. * Engine to use to create the effect
  61771. */
  61772. engine: ThinEngine;
  61773. /**
  61774. * Fragment shader for the effect
  61775. */
  61776. fragmentShader: string;
  61777. /**
  61778. * Use the shader store instead of direct source code
  61779. */
  61780. useShaderStore?: boolean;
  61781. /**
  61782. * Vertex shader for the effect
  61783. */
  61784. vertexShader?: string;
  61785. /**
  61786. * Attributes to use in the shader
  61787. */
  61788. attributeNames?: Array<string>;
  61789. /**
  61790. * Uniforms to use in the shader
  61791. */
  61792. uniformNames?: Array<string>;
  61793. /**
  61794. * Texture sampler names to use in the shader
  61795. */
  61796. samplerNames?: Array<string>;
  61797. /**
  61798. * Defines to use in the shader
  61799. */
  61800. defines?: Array<string>;
  61801. /**
  61802. * Callback when effect is compiled
  61803. */
  61804. onCompiled?: Nullable<(effect: Effect) => void>;
  61805. /**
  61806. * The friendly name of the effect displayed in Spector.
  61807. */
  61808. name?: string;
  61809. }
  61810. /**
  61811. * Wraps an effect to be used for rendering
  61812. */
  61813. export class EffectWrapper {
  61814. /**
  61815. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61816. */
  61817. onApplyObservable: Observable<{}>;
  61818. /**
  61819. * The underlying effect
  61820. */
  61821. effect: Effect;
  61822. /**
  61823. * Creates an effect to be renderer
  61824. * @param creationOptions options to create the effect
  61825. */
  61826. constructor(creationOptions: EffectWrapperCreationOptions);
  61827. /**
  61828. * Disposes of the effect wrapper
  61829. */
  61830. dispose(): void;
  61831. }
  61832. }
  61833. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61834. /** @hidden */
  61835. export var hdrFilteringVertexShader: {
  61836. name: string;
  61837. shader: string;
  61838. };
  61839. }
  61840. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61841. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61842. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61843. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61844. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61845. /** @hidden */
  61846. export var hdrFilteringPixelShader: {
  61847. name: string;
  61848. shader: string;
  61849. };
  61850. }
  61851. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61852. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61853. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61854. import { Nullable } from "babylonjs/types";
  61855. import "babylonjs/Shaders/hdrFiltering.vertex";
  61856. import "babylonjs/Shaders/hdrFiltering.fragment";
  61857. /**
  61858. * Options for texture filtering
  61859. */
  61860. interface IHDRFilteringOptions {
  61861. /**
  61862. * Scales pixel intensity for the input HDR map.
  61863. */
  61864. hdrScale?: number;
  61865. /**
  61866. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61867. */
  61868. quality?: number;
  61869. }
  61870. /**
  61871. * Filters HDR maps to get correct renderings of PBR reflections
  61872. */
  61873. export class HDRFiltering {
  61874. private _engine;
  61875. private _effectRenderer;
  61876. private _effectWrapper;
  61877. private _lodGenerationOffset;
  61878. private _lodGenerationScale;
  61879. /**
  61880. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61881. * you care about baking speed.
  61882. */
  61883. quality: number;
  61884. /**
  61885. * Scales pixel intensity for the input HDR map.
  61886. */
  61887. hdrScale: number;
  61888. /**
  61889. * Instantiates HDR filter for reflection maps
  61890. *
  61891. * @param engine Thin engine
  61892. * @param options Options
  61893. */
  61894. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61895. private _createRenderTarget;
  61896. private _prefilterInternal;
  61897. private _createEffect;
  61898. /**
  61899. * Get a value indicating if the filter is ready to be used
  61900. * @param texture Texture to filter
  61901. * @returns true if the filter is ready
  61902. */
  61903. isReady(texture: BaseTexture): boolean;
  61904. /**
  61905. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61906. * Prefiltering will be invoked at the end of next rendering pass.
  61907. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61908. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61909. * @param texture Texture to filter
  61910. * @param onFinished Callback when filtering is done
  61911. * @return Promise called when prefiltering is done
  61912. */
  61913. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61914. }
  61915. }
  61916. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61917. import { Nullable } from "babylonjs/types";
  61918. import { Scene } from "babylonjs/scene";
  61919. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61920. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61921. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61922. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61923. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61924. /**
  61925. * This represents a texture coming from an HDR input.
  61926. *
  61927. * The only supported format is currently panorama picture stored in RGBE format.
  61928. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61929. */
  61930. export class HDRCubeTexture extends BaseTexture {
  61931. private static _facesMapping;
  61932. private _generateHarmonics;
  61933. private _noMipmap;
  61934. private _prefilterOnLoad;
  61935. private _textureMatrix;
  61936. private _size;
  61937. private _onLoad;
  61938. private _onError;
  61939. /**
  61940. * The texture URL.
  61941. */
  61942. url: string;
  61943. /**
  61944. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61945. */
  61946. coordinatesMode: number;
  61947. protected _isBlocking: boolean;
  61948. /**
  61949. * Sets wether or not the texture is blocking during loading.
  61950. */
  61951. set isBlocking(value: boolean);
  61952. /**
  61953. * Gets wether or not the texture is blocking during loading.
  61954. */
  61955. get isBlocking(): boolean;
  61956. protected _rotationY: number;
  61957. /**
  61958. * Sets texture matrix rotation angle around Y axis in radians.
  61959. */
  61960. set rotationY(value: number);
  61961. /**
  61962. * Gets texture matrix rotation angle around Y axis radians.
  61963. */
  61964. get rotationY(): number;
  61965. /**
  61966. * Gets or sets the center of the bounding box associated with the cube texture
  61967. * It must define where the camera used to render the texture was set
  61968. */
  61969. boundingBoxPosition: Vector3;
  61970. private _boundingBoxSize;
  61971. /**
  61972. * Gets or sets the size of the bounding box associated with the cube texture
  61973. * When defined, the cubemap will switch to local mode
  61974. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61975. * @example https://www.babylonjs-playground.com/#RNASML
  61976. */
  61977. set boundingBoxSize(value: Vector3);
  61978. get boundingBoxSize(): Vector3;
  61979. /**
  61980. * Instantiates an HDRTexture from the following parameters.
  61981. *
  61982. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61983. * @param sceneOrEngine The scene or engine the texture will be used in
  61984. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61985. * @param noMipmap Forces to not generate the mipmap if true
  61986. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61987. * @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)
  61988. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61989. */
  61990. 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>);
  61991. /**
  61992. * Get the current class name of the texture useful for serialization or dynamic coding.
  61993. * @returns "HDRCubeTexture"
  61994. */
  61995. getClassName(): string;
  61996. /**
  61997. * Occurs when the file is raw .hdr file.
  61998. */
  61999. private loadTexture;
  62000. clone(): HDRCubeTexture;
  62001. delayLoad(): void;
  62002. /**
  62003. * Get the texture reflection matrix used to rotate/transform the reflection.
  62004. * @returns the reflection matrix
  62005. */
  62006. getReflectionTextureMatrix(): Matrix;
  62007. /**
  62008. * Set the texture reflection matrix used to rotate/transform the reflection.
  62009. * @param value Define the reflection matrix to set
  62010. */
  62011. setReflectionTextureMatrix(value: Matrix): void;
  62012. /**
  62013. * Parses a JSON representation of an HDR Texture in order to create the texture
  62014. * @param parsedTexture Define the JSON representation
  62015. * @param scene Define the scene the texture should be created in
  62016. * @param rootUrl Define the root url in case we need to load relative dependencies
  62017. * @returns the newly created texture after parsing
  62018. */
  62019. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62020. serialize(): any;
  62021. }
  62022. }
  62023. declare module "babylonjs/Physics/physicsEngine" {
  62024. import { Nullable } from "babylonjs/types";
  62025. import { Vector3 } from "babylonjs/Maths/math.vector";
  62026. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62027. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62028. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62029. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62030. /**
  62031. * Class used to control physics engine
  62032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62033. */
  62034. export class PhysicsEngine implements IPhysicsEngine {
  62035. private _physicsPlugin;
  62036. /**
  62037. * Global value used to control the smallest number supported by the simulation
  62038. */
  62039. static Epsilon: number;
  62040. private _impostors;
  62041. private _joints;
  62042. private _subTimeStep;
  62043. /**
  62044. * Gets the gravity vector used by the simulation
  62045. */
  62046. gravity: Vector3;
  62047. /**
  62048. * Factory used to create the default physics plugin.
  62049. * @returns The default physics plugin
  62050. */
  62051. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62052. /**
  62053. * Creates a new Physics Engine
  62054. * @param gravity defines the gravity vector used by the simulation
  62055. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62056. */
  62057. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62058. /**
  62059. * Sets the gravity vector used by the simulation
  62060. * @param gravity defines the gravity vector to use
  62061. */
  62062. setGravity(gravity: Vector3): void;
  62063. /**
  62064. * Set the time step of the physics engine.
  62065. * Default is 1/60.
  62066. * To slow it down, enter 1/600 for example.
  62067. * To speed it up, 1/30
  62068. * @param newTimeStep defines the new timestep to apply to this world.
  62069. */
  62070. setTimeStep(newTimeStep?: number): void;
  62071. /**
  62072. * Get the time step of the physics engine.
  62073. * @returns the current time step
  62074. */
  62075. getTimeStep(): number;
  62076. /**
  62077. * Set the sub time step of the physics engine.
  62078. * Default is 0 meaning there is no sub steps
  62079. * To increase physics resolution precision, set a small value (like 1 ms)
  62080. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62081. */
  62082. setSubTimeStep(subTimeStep?: number): void;
  62083. /**
  62084. * Get the sub time step of the physics engine.
  62085. * @returns the current sub time step
  62086. */
  62087. getSubTimeStep(): number;
  62088. /**
  62089. * Release all resources
  62090. */
  62091. dispose(): void;
  62092. /**
  62093. * Gets the name of the current physics plugin
  62094. * @returns the name of the plugin
  62095. */
  62096. getPhysicsPluginName(): string;
  62097. /**
  62098. * Adding a new impostor for the impostor tracking.
  62099. * This will be done by the impostor itself.
  62100. * @param impostor the impostor to add
  62101. */
  62102. addImpostor(impostor: PhysicsImpostor): void;
  62103. /**
  62104. * Remove an impostor from the engine.
  62105. * This impostor and its mesh will not longer be updated by the physics engine.
  62106. * @param impostor the impostor to remove
  62107. */
  62108. removeImpostor(impostor: PhysicsImpostor): void;
  62109. /**
  62110. * Add a joint to the physics engine
  62111. * @param mainImpostor defines the main impostor to which the joint is added.
  62112. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62113. * @param joint defines the joint that will connect both impostors.
  62114. */
  62115. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62116. /**
  62117. * Removes a joint from the simulation
  62118. * @param mainImpostor defines the impostor used with the joint
  62119. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62120. * @param joint defines the joint to remove
  62121. */
  62122. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62123. /**
  62124. * Called by the scene. No need to call it.
  62125. * @param delta defines the timespam between frames
  62126. */
  62127. _step(delta: number): void;
  62128. /**
  62129. * Gets the current plugin used to run the simulation
  62130. * @returns current plugin
  62131. */
  62132. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62133. /**
  62134. * Gets the list of physic impostors
  62135. * @returns an array of PhysicsImpostor
  62136. */
  62137. getImpostors(): Array<PhysicsImpostor>;
  62138. /**
  62139. * Gets the impostor for a physics enabled object
  62140. * @param object defines the object impersonated by the impostor
  62141. * @returns the PhysicsImpostor or null if not found
  62142. */
  62143. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62144. /**
  62145. * Gets the impostor for a physics body object
  62146. * @param body defines physics body used by the impostor
  62147. * @returns the PhysicsImpostor or null if not found
  62148. */
  62149. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62150. /**
  62151. * Does a raycast in the physics world
  62152. * @param from when should the ray start?
  62153. * @param to when should the ray end?
  62154. * @returns PhysicsRaycastResult
  62155. */
  62156. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62157. }
  62158. }
  62159. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  62160. import { Nullable } from "babylonjs/types";
  62161. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62163. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62164. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62165. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62166. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62167. /** @hidden */
  62168. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62169. private _useDeltaForWorldStep;
  62170. world: any;
  62171. name: string;
  62172. private _physicsMaterials;
  62173. private _fixedTimeStep;
  62174. private _cannonRaycastResult;
  62175. private _raycastResult;
  62176. private _physicsBodysToRemoveAfterStep;
  62177. private _firstFrame;
  62178. BJSCANNON: any;
  62179. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62180. setGravity(gravity: Vector3): void;
  62181. setTimeStep(timeStep: number): void;
  62182. getTimeStep(): number;
  62183. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62184. private _removeMarkedPhysicsBodiesFromWorld;
  62185. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62186. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62187. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62188. private _processChildMeshes;
  62189. removePhysicsBody(impostor: PhysicsImpostor): void;
  62190. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62191. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62192. private _addMaterial;
  62193. private _checkWithEpsilon;
  62194. private _createShape;
  62195. private _createHeightmap;
  62196. private _minus90X;
  62197. private _plus90X;
  62198. private _tmpPosition;
  62199. private _tmpDeltaPosition;
  62200. private _tmpUnityRotation;
  62201. private _updatePhysicsBodyTransformation;
  62202. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62203. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62204. isSupported(): boolean;
  62205. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62206. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62207. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62208. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62209. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62210. getBodyMass(impostor: PhysicsImpostor): number;
  62211. getBodyFriction(impostor: PhysicsImpostor): number;
  62212. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62213. getBodyRestitution(impostor: PhysicsImpostor): number;
  62214. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62215. sleepBody(impostor: PhysicsImpostor): void;
  62216. wakeUpBody(impostor: PhysicsImpostor): void;
  62217. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62218. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62219. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62220. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62221. getRadius(impostor: PhysicsImpostor): number;
  62222. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62223. dispose(): void;
  62224. private _extendNamespace;
  62225. /**
  62226. * Does a raycast in the physics world
  62227. * @param from when should the ray start?
  62228. * @param to when should the ray end?
  62229. * @returns PhysicsRaycastResult
  62230. */
  62231. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62232. }
  62233. }
  62234. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  62235. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62236. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62237. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62239. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62240. import { Nullable } from "babylonjs/types";
  62241. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62242. /** @hidden */
  62243. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62244. private _useDeltaForWorldStep;
  62245. world: any;
  62246. name: string;
  62247. BJSOIMO: any;
  62248. private _raycastResult;
  62249. private _fixedTimeStep;
  62250. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62251. setGravity(gravity: Vector3): void;
  62252. setTimeStep(timeStep: number): void;
  62253. getTimeStep(): number;
  62254. private _tmpImpostorsArray;
  62255. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62256. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62257. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62258. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62259. private _tmpPositionVector;
  62260. removePhysicsBody(impostor: PhysicsImpostor): void;
  62261. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62262. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62263. isSupported(): boolean;
  62264. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62265. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62266. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62267. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62268. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62269. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62270. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62271. getBodyMass(impostor: PhysicsImpostor): number;
  62272. getBodyFriction(impostor: PhysicsImpostor): number;
  62273. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62274. getBodyRestitution(impostor: PhysicsImpostor): number;
  62275. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62276. sleepBody(impostor: PhysicsImpostor): void;
  62277. wakeUpBody(impostor: PhysicsImpostor): void;
  62278. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62279. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62280. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62281. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62282. getRadius(impostor: PhysicsImpostor): number;
  62283. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62284. dispose(): void;
  62285. /**
  62286. * Does a raycast in the physics world
  62287. * @param from when should the ray start?
  62288. * @param to when should the ray end?
  62289. * @returns PhysicsRaycastResult
  62290. */
  62291. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62292. }
  62293. }
  62294. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  62295. import { Nullable } from "babylonjs/types";
  62296. import { Scene } from "babylonjs/scene";
  62297. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  62298. import { Color4 } from "babylonjs/Maths/math.color";
  62299. import { Mesh } from "babylonjs/Meshes/mesh";
  62300. /**
  62301. * Class containing static functions to help procedurally build meshes
  62302. */
  62303. export class RibbonBuilder {
  62304. /**
  62305. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62306. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62307. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62308. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62309. * * 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
  62310. * * 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
  62311. * * 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
  62312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62314. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62315. * * 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
  62316. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62317. * * 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
  62318. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62320. * @param name defines the name of the mesh
  62321. * @param options defines the options used to create the mesh
  62322. * @param scene defines the hosting scene
  62323. * @returns the ribbon mesh
  62324. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62325. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62326. */
  62327. static CreateRibbon(name: string, options: {
  62328. pathArray: Vector3[][];
  62329. closeArray?: boolean;
  62330. closePath?: boolean;
  62331. offset?: number;
  62332. updatable?: boolean;
  62333. sideOrientation?: number;
  62334. frontUVs?: Vector4;
  62335. backUVs?: Vector4;
  62336. instance?: Mesh;
  62337. invertUV?: boolean;
  62338. uvs?: Vector2[];
  62339. colors?: Color4[];
  62340. }, scene?: Nullable<Scene>): Mesh;
  62341. }
  62342. }
  62343. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  62344. import { Nullable } from "babylonjs/types";
  62345. import { Scene } from "babylonjs/scene";
  62346. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62347. import { Mesh } from "babylonjs/Meshes/mesh";
  62348. /**
  62349. * Class containing static functions to help procedurally build meshes
  62350. */
  62351. export class ShapeBuilder {
  62352. /**
  62353. * 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.
  62354. * * 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.
  62355. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62356. * * 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.
  62357. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62358. * * 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
  62359. * * 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
  62360. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62362. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62363. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62365. * @param name defines the name of the mesh
  62366. * @param options defines the options used to create the mesh
  62367. * @param scene defines the hosting scene
  62368. * @returns the extruded shape mesh
  62369. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62371. */
  62372. static ExtrudeShape(name: string, options: {
  62373. shape: Vector3[];
  62374. path: Vector3[];
  62375. scale?: number;
  62376. rotation?: number;
  62377. cap?: number;
  62378. updatable?: boolean;
  62379. sideOrientation?: number;
  62380. frontUVs?: Vector4;
  62381. backUVs?: Vector4;
  62382. instance?: Mesh;
  62383. invertUV?: boolean;
  62384. }, scene?: Nullable<Scene>): Mesh;
  62385. /**
  62386. * Creates an custom extruded shape mesh.
  62387. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62388. * * 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.
  62389. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62390. * * 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
  62391. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62392. * * 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
  62393. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62394. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62395. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62396. * * 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
  62397. * * 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
  62398. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62401. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62403. * @param name defines the name of the mesh
  62404. * @param options defines the options used to create the mesh
  62405. * @param scene defines the hosting scene
  62406. * @returns the custom extruded shape mesh
  62407. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62408. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62409. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62410. */
  62411. static ExtrudeShapeCustom(name: string, options: {
  62412. shape: Vector3[];
  62413. path: Vector3[];
  62414. scaleFunction?: any;
  62415. rotationFunction?: any;
  62416. ribbonCloseArray?: boolean;
  62417. ribbonClosePath?: boolean;
  62418. cap?: number;
  62419. updatable?: boolean;
  62420. sideOrientation?: number;
  62421. frontUVs?: Vector4;
  62422. backUVs?: Vector4;
  62423. instance?: Mesh;
  62424. invertUV?: boolean;
  62425. }, scene?: Nullable<Scene>): Mesh;
  62426. private static _ExtrudeShapeGeneric;
  62427. }
  62428. }
  62429. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62430. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62431. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62432. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62433. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62434. import { Nullable } from "babylonjs/types";
  62435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62436. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62437. /**
  62438. * AmmoJS Physics plugin
  62439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62440. * @see https://github.com/kripken/ammo.js/
  62441. */
  62442. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62443. private _useDeltaForWorldStep;
  62444. /**
  62445. * Reference to the Ammo library
  62446. */
  62447. bjsAMMO: any;
  62448. /**
  62449. * Created ammoJS world which physics bodies are added to
  62450. */
  62451. world: any;
  62452. /**
  62453. * Name of the plugin
  62454. */
  62455. name: string;
  62456. private _timeStep;
  62457. private _fixedTimeStep;
  62458. private _maxSteps;
  62459. private _tmpQuaternion;
  62460. private _tmpAmmoTransform;
  62461. private _tmpAmmoQuaternion;
  62462. private _tmpAmmoConcreteContactResultCallback;
  62463. private _collisionConfiguration;
  62464. private _dispatcher;
  62465. private _overlappingPairCache;
  62466. private _solver;
  62467. private _softBodySolver;
  62468. private _tmpAmmoVectorA;
  62469. private _tmpAmmoVectorB;
  62470. private _tmpAmmoVectorC;
  62471. private _tmpAmmoVectorD;
  62472. private _tmpContactCallbackResult;
  62473. private _tmpAmmoVectorRCA;
  62474. private _tmpAmmoVectorRCB;
  62475. private _raycastResult;
  62476. private static readonly DISABLE_COLLISION_FLAG;
  62477. private static readonly KINEMATIC_FLAG;
  62478. private static readonly DISABLE_DEACTIVATION_FLAG;
  62479. /**
  62480. * Initializes the ammoJS plugin
  62481. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62482. * @param ammoInjection can be used to inject your own ammo reference
  62483. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62484. */
  62485. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62486. /**
  62487. * Sets the gravity of the physics world (m/(s^2))
  62488. * @param gravity Gravity to set
  62489. */
  62490. setGravity(gravity: Vector3): void;
  62491. /**
  62492. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62493. * @param timeStep timestep to use in seconds
  62494. */
  62495. setTimeStep(timeStep: number): void;
  62496. /**
  62497. * 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)
  62498. * @param fixedTimeStep fixedTimeStep to use in seconds
  62499. */
  62500. setFixedTimeStep(fixedTimeStep: number): void;
  62501. /**
  62502. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62503. * @param maxSteps the maximum number of steps by the physics engine per frame
  62504. */
  62505. setMaxSteps(maxSteps: number): void;
  62506. /**
  62507. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62508. * @returns the current timestep in seconds
  62509. */
  62510. getTimeStep(): number;
  62511. /**
  62512. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62513. */
  62514. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62515. private _isImpostorInContact;
  62516. private _isImpostorPairInContact;
  62517. private _stepSimulation;
  62518. /**
  62519. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62520. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62521. * After the step the babylon meshes are set to the position of the physics imposters
  62522. * @param delta amount of time to step forward
  62523. * @param impostors array of imposters to update before/after the step
  62524. */
  62525. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62526. /**
  62527. * Update babylon mesh to match physics world object
  62528. * @param impostor imposter to match
  62529. */
  62530. private _afterSoftStep;
  62531. /**
  62532. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62533. * @param impostor imposter to match
  62534. */
  62535. private _ropeStep;
  62536. /**
  62537. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62538. * @param impostor imposter to match
  62539. */
  62540. private _softbodyOrClothStep;
  62541. private _tmpMatrix;
  62542. /**
  62543. * Applies an impulse on the imposter
  62544. * @param impostor imposter to apply impulse to
  62545. * @param force amount of force to be applied to the imposter
  62546. * @param contactPoint the location to apply the impulse on the imposter
  62547. */
  62548. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62549. /**
  62550. * Applies a force on the imposter
  62551. * @param impostor imposter to apply force
  62552. * @param force amount of force to be applied to the imposter
  62553. * @param contactPoint the location to apply the force on the imposter
  62554. */
  62555. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62556. /**
  62557. * Creates a physics body using the plugin
  62558. * @param impostor the imposter to create the physics body on
  62559. */
  62560. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62561. /**
  62562. * Removes the physics body from the imposter and disposes of the body's memory
  62563. * @param impostor imposter to remove the physics body from
  62564. */
  62565. removePhysicsBody(impostor: PhysicsImpostor): void;
  62566. /**
  62567. * Generates a joint
  62568. * @param impostorJoint the imposter joint to create the joint with
  62569. */
  62570. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62571. /**
  62572. * Removes a joint
  62573. * @param impostorJoint the imposter joint to remove the joint from
  62574. */
  62575. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62576. private _addMeshVerts;
  62577. /**
  62578. * Initialise the soft body vertices to match its object's (mesh) vertices
  62579. * Softbody vertices (nodes) are in world space and to match this
  62580. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62581. * @param impostor to create the softbody for
  62582. */
  62583. private _softVertexData;
  62584. /**
  62585. * Create an impostor's soft body
  62586. * @param impostor to create the softbody for
  62587. */
  62588. private _createSoftbody;
  62589. /**
  62590. * Create cloth for an impostor
  62591. * @param impostor to create the softbody for
  62592. */
  62593. private _createCloth;
  62594. /**
  62595. * Create rope for an impostor
  62596. * @param impostor to create the softbody for
  62597. */
  62598. private _createRope;
  62599. /**
  62600. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62601. * @param impostor to create the custom physics shape for
  62602. */
  62603. private _createCustom;
  62604. private _addHullVerts;
  62605. private _createShape;
  62606. /**
  62607. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62608. * @param impostor imposter containing the physics body and babylon object
  62609. */
  62610. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62611. /**
  62612. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62613. * @param impostor imposter containing the physics body and babylon object
  62614. * @param newPosition new position
  62615. * @param newRotation new rotation
  62616. */
  62617. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62618. /**
  62619. * If this plugin is supported
  62620. * @returns true if its supported
  62621. */
  62622. isSupported(): boolean;
  62623. /**
  62624. * Sets the linear velocity of the physics body
  62625. * @param impostor imposter to set the velocity on
  62626. * @param velocity velocity to set
  62627. */
  62628. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62629. /**
  62630. * Sets the angular velocity of the physics body
  62631. * @param impostor imposter to set the velocity on
  62632. * @param velocity velocity to set
  62633. */
  62634. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62635. /**
  62636. * gets the linear velocity
  62637. * @param impostor imposter to get linear velocity from
  62638. * @returns linear velocity
  62639. */
  62640. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62641. /**
  62642. * gets the angular velocity
  62643. * @param impostor imposter to get angular velocity from
  62644. * @returns angular velocity
  62645. */
  62646. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62647. /**
  62648. * Sets the mass of physics body
  62649. * @param impostor imposter to set the mass on
  62650. * @param mass mass to set
  62651. */
  62652. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62653. /**
  62654. * Gets the mass of the physics body
  62655. * @param impostor imposter to get the mass from
  62656. * @returns mass
  62657. */
  62658. getBodyMass(impostor: PhysicsImpostor): number;
  62659. /**
  62660. * Gets friction of the impostor
  62661. * @param impostor impostor to get friction from
  62662. * @returns friction value
  62663. */
  62664. getBodyFriction(impostor: PhysicsImpostor): number;
  62665. /**
  62666. * Sets friction of the impostor
  62667. * @param impostor impostor to set friction on
  62668. * @param friction friction value
  62669. */
  62670. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62671. /**
  62672. * Gets restitution of the impostor
  62673. * @param impostor impostor to get restitution from
  62674. * @returns restitution value
  62675. */
  62676. getBodyRestitution(impostor: PhysicsImpostor): number;
  62677. /**
  62678. * Sets resitution of the impostor
  62679. * @param impostor impostor to set resitution on
  62680. * @param restitution resitution value
  62681. */
  62682. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62683. /**
  62684. * Gets pressure inside the impostor
  62685. * @param impostor impostor to get pressure from
  62686. * @returns pressure value
  62687. */
  62688. getBodyPressure(impostor: PhysicsImpostor): number;
  62689. /**
  62690. * Sets pressure inside a soft body impostor
  62691. * Cloth and rope must remain 0 pressure
  62692. * @param impostor impostor to set pressure on
  62693. * @param pressure pressure value
  62694. */
  62695. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62696. /**
  62697. * Gets stiffness of the impostor
  62698. * @param impostor impostor to get stiffness from
  62699. * @returns pressure value
  62700. */
  62701. getBodyStiffness(impostor: PhysicsImpostor): number;
  62702. /**
  62703. * Sets stiffness of the impostor
  62704. * @param impostor impostor to set stiffness on
  62705. * @param stiffness stiffness value from 0 to 1
  62706. */
  62707. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62708. /**
  62709. * Gets velocityIterations of the impostor
  62710. * @param impostor impostor to get velocity iterations from
  62711. * @returns velocityIterations value
  62712. */
  62713. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62714. /**
  62715. * Sets velocityIterations of the impostor
  62716. * @param impostor impostor to set velocity iterations on
  62717. * @param velocityIterations velocityIterations value
  62718. */
  62719. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62720. /**
  62721. * Gets positionIterations of the impostor
  62722. * @param impostor impostor to get position iterations from
  62723. * @returns positionIterations value
  62724. */
  62725. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62726. /**
  62727. * Sets positionIterations of the impostor
  62728. * @param impostor impostor to set position on
  62729. * @param positionIterations positionIterations value
  62730. */
  62731. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62732. /**
  62733. * Append an anchor to a cloth object
  62734. * @param impostor is the cloth impostor to add anchor to
  62735. * @param otherImpostor is the rigid impostor to anchor to
  62736. * @param width ratio across width from 0 to 1
  62737. * @param height ratio up height from 0 to 1
  62738. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62739. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62740. */
  62741. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62742. /**
  62743. * Append an hook to a rope object
  62744. * @param impostor is the rope impostor to add hook to
  62745. * @param otherImpostor is the rigid impostor to hook to
  62746. * @param length ratio along the rope from 0 to 1
  62747. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62748. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62749. */
  62750. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62751. /**
  62752. * Sleeps the physics body and stops it from being active
  62753. * @param impostor impostor to sleep
  62754. */
  62755. sleepBody(impostor: PhysicsImpostor): void;
  62756. /**
  62757. * Activates the physics body
  62758. * @param impostor impostor to activate
  62759. */
  62760. wakeUpBody(impostor: PhysicsImpostor): void;
  62761. /**
  62762. * Updates the distance parameters of the joint
  62763. * @param joint joint to update
  62764. * @param maxDistance maximum distance of the joint
  62765. * @param minDistance minimum distance of the joint
  62766. */
  62767. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62768. /**
  62769. * Sets a motor on the joint
  62770. * @param joint joint to set motor on
  62771. * @param speed speed of the motor
  62772. * @param maxForce maximum force of the motor
  62773. * @param motorIndex index of the motor
  62774. */
  62775. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62776. /**
  62777. * Sets the motors limit
  62778. * @param joint joint to set limit on
  62779. * @param upperLimit upper limit
  62780. * @param lowerLimit lower limit
  62781. */
  62782. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62783. /**
  62784. * Syncs the position and rotation of a mesh with the impostor
  62785. * @param mesh mesh to sync
  62786. * @param impostor impostor to update the mesh with
  62787. */
  62788. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62789. /**
  62790. * Gets the radius of the impostor
  62791. * @param impostor impostor to get radius from
  62792. * @returns the radius
  62793. */
  62794. getRadius(impostor: PhysicsImpostor): number;
  62795. /**
  62796. * Gets the box size of the impostor
  62797. * @param impostor impostor to get box size from
  62798. * @param result the resulting box size
  62799. */
  62800. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62801. /**
  62802. * Disposes of the impostor
  62803. */
  62804. dispose(): void;
  62805. /**
  62806. * Does a raycast in the physics world
  62807. * @param from when should the ray start?
  62808. * @param to when should the ray end?
  62809. * @returns PhysicsRaycastResult
  62810. */
  62811. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62812. }
  62813. }
  62814. declare module "babylonjs/Probes/reflectionProbe" {
  62815. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62816. import { Vector3 } from "babylonjs/Maths/math.vector";
  62817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62818. import { Nullable } from "babylonjs/types";
  62819. import { Scene } from "babylonjs/scene";
  62820. module "babylonjs/abstractScene" {
  62821. interface AbstractScene {
  62822. /**
  62823. * The list of reflection probes added to the scene
  62824. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62825. */
  62826. reflectionProbes: Array<ReflectionProbe>;
  62827. /**
  62828. * Removes the given reflection probe from this scene.
  62829. * @param toRemove The reflection probe to remove
  62830. * @returns The index of the removed reflection probe
  62831. */
  62832. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62833. /**
  62834. * Adds the given reflection probe to this scene.
  62835. * @param newReflectionProbe The reflection probe to add
  62836. */
  62837. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62838. }
  62839. }
  62840. /**
  62841. * Class used to generate realtime reflection / refraction cube textures
  62842. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62843. */
  62844. export class ReflectionProbe {
  62845. /** defines the name of the probe */
  62846. name: string;
  62847. private _scene;
  62848. private _renderTargetTexture;
  62849. private _projectionMatrix;
  62850. private _viewMatrix;
  62851. private _target;
  62852. private _add;
  62853. private _attachedMesh;
  62854. private _invertYAxis;
  62855. /** Gets or sets probe position (center of the cube map) */
  62856. position: Vector3;
  62857. /**
  62858. * Creates a new reflection probe
  62859. * @param name defines the name of the probe
  62860. * @param size defines the texture resolution (for each face)
  62861. * @param scene defines the hosting scene
  62862. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62863. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62864. */
  62865. constructor(
  62866. /** defines the name of the probe */
  62867. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62868. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62869. get samples(): number;
  62870. set samples(value: number);
  62871. /** Gets or sets the refresh rate to use (on every frame by default) */
  62872. get refreshRate(): number;
  62873. set refreshRate(value: number);
  62874. /**
  62875. * Gets the hosting scene
  62876. * @returns a Scene
  62877. */
  62878. getScene(): Scene;
  62879. /** Gets the internal CubeTexture used to render to */
  62880. get cubeTexture(): RenderTargetTexture;
  62881. /** Gets the list of meshes to render */
  62882. get renderList(): Nullable<AbstractMesh[]>;
  62883. /**
  62884. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62885. * @param mesh defines the mesh to attach to
  62886. */
  62887. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62888. /**
  62889. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62890. * @param renderingGroupId The rendering group id corresponding to its index
  62891. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62892. */
  62893. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62894. /**
  62895. * Clean all associated resources
  62896. */
  62897. dispose(): void;
  62898. /**
  62899. * Converts the reflection probe information to a readable string for debug purpose.
  62900. * @param fullDetails Supports for multiple levels of logging within scene loading
  62901. * @returns the human readable reflection probe info
  62902. */
  62903. toString(fullDetails?: boolean): string;
  62904. /**
  62905. * Get the class name of the relfection probe.
  62906. * @returns "ReflectionProbe"
  62907. */
  62908. getClassName(): string;
  62909. /**
  62910. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62911. * @returns The JSON representation of the texture
  62912. */
  62913. serialize(): any;
  62914. /**
  62915. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62916. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62917. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62918. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62919. * @returns The parsed reflection probe if successful
  62920. */
  62921. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62922. }
  62923. }
  62924. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62925. /** @hidden */
  62926. export var _BabylonLoaderRegistered: boolean;
  62927. /**
  62928. * Helps setting up some configuration for the babylon file loader.
  62929. */
  62930. export class BabylonFileLoaderConfiguration {
  62931. /**
  62932. * The loader does not allow injecting custom physix engine into the plugins.
  62933. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62934. * So you could set this variable to your engine import to make it work.
  62935. */
  62936. static LoaderInjectedPhysicsEngine: any;
  62937. }
  62938. }
  62939. declare module "babylonjs/Loading/Plugins/index" {
  62940. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62941. }
  62942. declare module "babylonjs/Loading/index" {
  62943. export * from "babylonjs/Loading/loadingScreen";
  62944. export * from "babylonjs/Loading/Plugins/index";
  62945. export * from "babylonjs/Loading/sceneLoader";
  62946. export * from "babylonjs/Loading/sceneLoaderFlags";
  62947. }
  62948. declare module "babylonjs/Materials/Background/index" {
  62949. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62950. }
  62951. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62952. import { Scene } from "babylonjs/scene";
  62953. import { Color3 } from "babylonjs/Maths/math.color";
  62954. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62956. /**
  62957. * The Physically based simple base material of BJS.
  62958. *
  62959. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62960. * It is used as the base class for both the specGloss and metalRough conventions.
  62961. */
  62962. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62963. /**
  62964. * Number of Simultaneous lights allowed on the material.
  62965. */
  62966. maxSimultaneousLights: number;
  62967. /**
  62968. * If sets to true, disables all the lights affecting the material.
  62969. */
  62970. disableLighting: boolean;
  62971. /**
  62972. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62973. */
  62974. environmentTexture: BaseTexture;
  62975. /**
  62976. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62977. */
  62978. invertNormalMapX: boolean;
  62979. /**
  62980. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62981. */
  62982. invertNormalMapY: boolean;
  62983. /**
  62984. * Normal map used in the model.
  62985. */
  62986. normalTexture: BaseTexture;
  62987. /**
  62988. * Emissivie color used to self-illuminate the model.
  62989. */
  62990. emissiveColor: Color3;
  62991. /**
  62992. * Emissivie texture used to self-illuminate the model.
  62993. */
  62994. emissiveTexture: BaseTexture;
  62995. /**
  62996. * Occlusion Channel Strenght.
  62997. */
  62998. occlusionStrength: number;
  62999. /**
  63000. * Occlusion Texture of the material (adding extra occlusion effects).
  63001. */
  63002. occlusionTexture: BaseTexture;
  63003. /**
  63004. * Defines the alpha limits in alpha test mode.
  63005. */
  63006. alphaCutOff: number;
  63007. /**
  63008. * Gets the current double sided mode.
  63009. */
  63010. get doubleSided(): boolean;
  63011. /**
  63012. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63013. */
  63014. set doubleSided(value: boolean);
  63015. /**
  63016. * Stores the pre-calculated light information of a mesh in a texture.
  63017. */
  63018. lightmapTexture: BaseTexture;
  63019. /**
  63020. * If true, the light map contains occlusion information instead of lighting info.
  63021. */
  63022. useLightmapAsShadowmap: boolean;
  63023. /**
  63024. * Instantiates a new PBRMaterial instance.
  63025. *
  63026. * @param name The material name
  63027. * @param scene The scene the material will be use in.
  63028. */
  63029. constructor(name: string, scene: Scene);
  63030. getClassName(): string;
  63031. }
  63032. }
  63033. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63034. import { Scene } from "babylonjs/scene";
  63035. import { Color3 } from "babylonjs/Maths/math.color";
  63036. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63037. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63038. /**
  63039. * The PBR material of BJS following the metal roughness convention.
  63040. *
  63041. * This fits to the PBR convention in the GLTF definition:
  63042. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63043. */
  63044. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63045. /**
  63046. * The base color has two different interpretations depending on the value of metalness.
  63047. * When the material is a metal, the base color is the specific measured reflectance value
  63048. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63049. * of the material.
  63050. */
  63051. baseColor: Color3;
  63052. /**
  63053. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63054. * well as opacity information in the alpha channel.
  63055. */
  63056. baseTexture: BaseTexture;
  63057. /**
  63058. * Specifies the metallic scalar value of the material.
  63059. * Can also be used to scale the metalness values of the metallic texture.
  63060. */
  63061. metallic: number;
  63062. /**
  63063. * Specifies the roughness scalar value of the material.
  63064. * Can also be used to scale the roughness values of the metallic texture.
  63065. */
  63066. roughness: number;
  63067. /**
  63068. * Texture containing both the metallic value in the B channel and the
  63069. * roughness value in the G channel to keep better precision.
  63070. */
  63071. metallicRoughnessTexture: BaseTexture;
  63072. /**
  63073. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63074. *
  63075. * @param name The material name
  63076. * @param scene The scene the material will be use in.
  63077. */
  63078. constructor(name: string, scene: Scene);
  63079. /**
  63080. * Return the currrent class name of the material.
  63081. */
  63082. getClassName(): string;
  63083. /**
  63084. * Makes a duplicate of the current material.
  63085. * @param name - name to use for the new material.
  63086. */
  63087. clone(name: string): PBRMetallicRoughnessMaterial;
  63088. /**
  63089. * Serialize the material to a parsable JSON object.
  63090. */
  63091. serialize(): any;
  63092. /**
  63093. * Parses a JSON object correponding to the serialize function.
  63094. */
  63095. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63096. }
  63097. }
  63098. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63099. import { Scene } from "babylonjs/scene";
  63100. import { Color3 } from "babylonjs/Maths/math.color";
  63101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63102. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63103. /**
  63104. * The PBR material of BJS following the specular glossiness convention.
  63105. *
  63106. * This fits to the PBR convention in the GLTF definition:
  63107. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63108. */
  63109. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63110. /**
  63111. * Specifies the diffuse color of the material.
  63112. */
  63113. diffuseColor: Color3;
  63114. /**
  63115. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63116. * channel.
  63117. */
  63118. diffuseTexture: BaseTexture;
  63119. /**
  63120. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63121. */
  63122. specularColor: Color3;
  63123. /**
  63124. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63125. */
  63126. glossiness: number;
  63127. /**
  63128. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63129. */
  63130. specularGlossinessTexture: BaseTexture;
  63131. /**
  63132. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63133. *
  63134. * @param name The material name
  63135. * @param scene The scene the material will be use in.
  63136. */
  63137. constructor(name: string, scene: Scene);
  63138. /**
  63139. * Return the currrent class name of the material.
  63140. */
  63141. getClassName(): string;
  63142. /**
  63143. * Makes a duplicate of the current material.
  63144. * @param name - name to use for the new material.
  63145. */
  63146. clone(name: string): PBRSpecularGlossinessMaterial;
  63147. /**
  63148. * Serialize the material to a parsable JSON object.
  63149. */
  63150. serialize(): any;
  63151. /**
  63152. * Parses a JSON object correponding to the serialize function.
  63153. */
  63154. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63155. }
  63156. }
  63157. declare module "babylonjs/Materials/PBR/index" {
  63158. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63159. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63160. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63161. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63162. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63163. }
  63164. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63165. import { Nullable } from "babylonjs/types";
  63166. import { Scene } from "babylonjs/scene";
  63167. import { Matrix } from "babylonjs/Maths/math.vector";
  63168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63169. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63170. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63171. /**
  63172. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63173. * It can help converting any input color in a desired output one. This can then be used to create effects
  63174. * from sepia, black and white to sixties or futuristic rendering...
  63175. *
  63176. * The only supported format is currently 3dl.
  63177. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63178. */
  63179. export class ColorGradingTexture extends BaseTexture {
  63180. /**
  63181. * The texture URL.
  63182. */
  63183. url: string;
  63184. /**
  63185. * Empty line regex stored for GC.
  63186. */
  63187. private static _noneEmptyLineRegex;
  63188. private _textureMatrix;
  63189. private _onLoad;
  63190. /**
  63191. * Instantiates a ColorGradingTexture from the following parameters.
  63192. *
  63193. * @param url The location of the color gradind data (currently only supporting 3dl)
  63194. * @param sceneOrEngine The scene or engine the texture will be used in
  63195. * @param onLoad defines a callback triggered when the texture has been loaded
  63196. */
  63197. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63198. /**
  63199. * Fires the onload event from the constructor if requested.
  63200. */
  63201. private _triggerOnLoad;
  63202. /**
  63203. * Returns the texture matrix used in most of the material.
  63204. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63205. */
  63206. getTextureMatrix(): Matrix;
  63207. /**
  63208. * Occurs when the file being loaded is a .3dl LUT file.
  63209. */
  63210. private load3dlTexture;
  63211. /**
  63212. * Starts the loading process of the texture.
  63213. */
  63214. private loadTexture;
  63215. /**
  63216. * Clones the color gradind texture.
  63217. */
  63218. clone(): ColorGradingTexture;
  63219. /**
  63220. * Called during delayed load for textures.
  63221. */
  63222. delayLoad(): void;
  63223. /**
  63224. * Parses a color grading texture serialized by Babylon.
  63225. * @param parsedTexture The texture information being parsedTexture
  63226. * @param scene The scene to load the texture in
  63227. * @param rootUrl The root url of the data assets to load
  63228. * @return A color gradind texture
  63229. */
  63230. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63231. /**
  63232. * Serializes the LUT texture to json format.
  63233. */
  63234. serialize(): any;
  63235. }
  63236. }
  63237. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63239. import { Scene } from "babylonjs/scene";
  63240. import { Nullable } from "babylonjs/types";
  63241. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63242. /**
  63243. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63244. */
  63245. export class EquiRectangularCubeTexture extends BaseTexture {
  63246. /** The six faces of the cube. */
  63247. private static _FacesMapping;
  63248. private _noMipmap;
  63249. private _onLoad;
  63250. private _onError;
  63251. /** The size of the cubemap. */
  63252. private _size;
  63253. /** The buffer of the image. */
  63254. private _buffer;
  63255. /** The width of the input image. */
  63256. private _width;
  63257. /** The height of the input image. */
  63258. private _height;
  63259. /** The URL to the image. */
  63260. url: string;
  63261. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63262. coordinatesMode: number;
  63263. /**
  63264. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63265. * @param url The location of the image
  63266. * @param scene The scene the texture will be used in
  63267. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63268. * @param noMipmap Forces to not generate the mipmap if true
  63269. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63270. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63271. * @param onLoad — defines a callback called when texture is loaded
  63272. * @param onError — defines a callback called if there is an error
  63273. */
  63274. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63275. /**
  63276. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63277. */
  63278. private loadImage;
  63279. /**
  63280. * Convert the image buffer into a cubemap and create a CubeTexture.
  63281. */
  63282. private loadTexture;
  63283. /**
  63284. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63285. * @param buffer The ArrayBuffer that should be converted.
  63286. * @returns The buffer as Float32Array.
  63287. */
  63288. private getFloat32ArrayFromArrayBuffer;
  63289. /**
  63290. * Get the current class name of the texture useful for serialization or dynamic coding.
  63291. * @returns "EquiRectangularCubeTexture"
  63292. */
  63293. getClassName(): string;
  63294. /**
  63295. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63296. * @returns A clone of the current EquiRectangularCubeTexture.
  63297. */
  63298. clone(): EquiRectangularCubeTexture;
  63299. }
  63300. }
  63301. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63302. import { Nullable } from "babylonjs/types";
  63303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63304. import { Matrix } from "babylonjs/Maths/math.vector";
  63305. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63306. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63307. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63308. import { Scene } from "babylonjs/scene";
  63309. /**
  63310. * Defines the options related to the creation of an HtmlElementTexture
  63311. */
  63312. export interface IHtmlElementTextureOptions {
  63313. /**
  63314. * Defines wether mip maps should be created or not.
  63315. */
  63316. generateMipMaps?: boolean;
  63317. /**
  63318. * Defines the sampling mode of the texture.
  63319. */
  63320. samplingMode?: number;
  63321. /**
  63322. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63323. */
  63324. engine: Nullable<ThinEngine>;
  63325. /**
  63326. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63327. */
  63328. scene: Nullable<Scene>;
  63329. }
  63330. /**
  63331. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63332. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63333. * is automatically managed.
  63334. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63335. * in your application.
  63336. *
  63337. * As the update is not automatic, you need to call them manually.
  63338. */
  63339. export class HtmlElementTexture extends BaseTexture {
  63340. /**
  63341. * The texture URL.
  63342. */
  63343. element: HTMLVideoElement | HTMLCanvasElement;
  63344. private static readonly DefaultOptions;
  63345. private _textureMatrix;
  63346. private _isVideo;
  63347. private _generateMipMaps;
  63348. private _samplingMode;
  63349. /**
  63350. * Instantiates a HtmlElementTexture from the following parameters.
  63351. *
  63352. * @param name Defines the name of the texture
  63353. * @param element Defines the video or canvas the texture is filled with
  63354. * @param options Defines the other none mandatory texture creation options
  63355. */
  63356. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63357. private _createInternalTexture;
  63358. /**
  63359. * Returns the texture matrix used in most of the material.
  63360. */
  63361. getTextureMatrix(): Matrix;
  63362. /**
  63363. * Updates the content of the texture.
  63364. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63365. */
  63366. update(invertY?: Nullable<boolean>): void;
  63367. }
  63368. }
  63369. declare module "babylonjs/Misc/tga" {
  63370. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63371. /**
  63372. * Based on jsTGALoader - Javascript loader for TGA file
  63373. * By Vincent Thibault
  63374. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63375. */
  63376. export class TGATools {
  63377. private static _TYPE_INDEXED;
  63378. private static _TYPE_RGB;
  63379. private static _TYPE_GREY;
  63380. private static _TYPE_RLE_INDEXED;
  63381. private static _TYPE_RLE_RGB;
  63382. private static _TYPE_RLE_GREY;
  63383. private static _ORIGIN_MASK;
  63384. private static _ORIGIN_SHIFT;
  63385. private static _ORIGIN_BL;
  63386. private static _ORIGIN_BR;
  63387. private static _ORIGIN_UL;
  63388. private static _ORIGIN_UR;
  63389. /**
  63390. * Gets the header of a TGA file
  63391. * @param data defines the TGA data
  63392. * @returns the header
  63393. */
  63394. static GetTGAHeader(data: Uint8Array): any;
  63395. /**
  63396. * Uploads TGA content to a Babylon Texture
  63397. * @hidden
  63398. */
  63399. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63400. /** @hidden */
  63401. 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;
  63402. /** @hidden */
  63403. 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;
  63404. /** @hidden */
  63405. 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;
  63406. /** @hidden */
  63407. 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;
  63408. /** @hidden */
  63409. 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;
  63410. /** @hidden */
  63411. 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;
  63412. }
  63413. }
  63414. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63415. import { Nullable } from "babylonjs/types";
  63416. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63417. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63418. /**
  63419. * Implementation of the TGA Texture Loader.
  63420. * @hidden
  63421. */
  63422. export class _TGATextureLoader implements IInternalTextureLoader {
  63423. /**
  63424. * Defines wether the loader supports cascade loading the different faces.
  63425. */
  63426. readonly supportCascades: boolean;
  63427. /**
  63428. * This returns if the loader support the current file information.
  63429. * @param extension defines the file extension of the file being loaded
  63430. * @returns true if the loader can load the specified file
  63431. */
  63432. canLoad(extension: string): boolean;
  63433. /**
  63434. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63435. * @param data contains the texture data
  63436. * @param texture defines the BabylonJS internal texture
  63437. * @param createPolynomials will be true if polynomials have been requested
  63438. * @param onLoad defines the callback to trigger once the texture is ready
  63439. * @param onError defines the callback to trigger in case of error
  63440. */
  63441. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63442. /**
  63443. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63444. * @param data contains the texture data
  63445. * @param texture defines the BabylonJS internal texture
  63446. * @param callback defines the method to call once ready to upload
  63447. */
  63448. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63449. }
  63450. }
  63451. declare module "babylonjs/Misc/basis" {
  63452. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63453. /**
  63454. * Info about the .basis files
  63455. */
  63456. class BasisFileInfo {
  63457. /**
  63458. * If the file has alpha
  63459. */
  63460. hasAlpha: boolean;
  63461. /**
  63462. * Info about each image of the basis file
  63463. */
  63464. images: Array<{
  63465. levels: Array<{
  63466. width: number;
  63467. height: number;
  63468. transcodedPixels: ArrayBufferView;
  63469. }>;
  63470. }>;
  63471. }
  63472. /**
  63473. * Result of transcoding a basis file
  63474. */
  63475. class TranscodeResult {
  63476. /**
  63477. * Info about the .basis file
  63478. */
  63479. fileInfo: BasisFileInfo;
  63480. /**
  63481. * Format to use when loading the file
  63482. */
  63483. format: number;
  63484. }
  63485. /**
  63486. * Configuration options for the Basis transcoder
  63487. */
  63488. export class BasisTranscodeConfiguration {
  63489. /**
  63490. * Supported compression formats used to determine the supported output format of the transcoder
  63491. */
  63492. supportedCompressionFormats?: {
  63493. /**
  63494. * etc1 compression format
  63495. */
  63496. etc1?: boolean;
  63497. /**
  63498. * s3tc compression format
  63499. */
  63500. s3tc?: boolean;
  63501. /**
  63502. * pvrtc compression format
  63503. */
  63504. pvrtc?: boolean;
  63505. /**
  63506. * etc2 compression format
  63507. */
  63508. etc2?: boolean;
  63509. };
  63510. /**
  63511. * If mipmap levels should be loaded for transcoded images (Default: true)
  63512. */
  63513. loadMipmapLevels?: boolean;
  63514. /**
  63515. * Index of a single image to load (Default: all images)
  63516. */
  63517. loadSingleImage?: number;
  63518. }
  63519. /**
  63520. * Used to load .Basis files
  63521. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63522. */
  63523. export class BasisTools {
  63524. private static _IgnoreSupportedFormats;
  63525. /**
  63526. * URL to use when loading the basis transcoder
  63527. */
  63528. static JSModuleURL: string;
  63529. /**
  63530. * URL to use when loading the wasm module for the transcoder
  63531. */
  63532. static WasmModuleURL: string;
  63533. /**
  63534. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63535. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63536. * @returns internal format corresponding to the Basis format
  63537. */
  63538. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63539. private static _WorkerPromise;
  63540. private static _Worker;
  63541. private static _actionId;
  63542. private static _CreateWorkerAsync;
  63543. /**
  63544. * Transcodes a loaded image file to compressed pixel data
  63545. * @param data image data to transcode
  63546. * @param config configuration options for the transcoding
  63547. * @returns a promise resulting in the transcoded image
  63548. */
  63549. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63550. /**
  63551. * Loads a texture from the transcode result
  63552. * @param texture texture load to
  63553. * @param transcodeResult the result of transcoding the basis file to load from
  63554. */
  63555. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63556. }
  63557. }
  63558. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  63559. import { Nullable } from "babylonjs/types";
  63560. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63561. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63562. /**
  63563. * Loader for .basis file format
  63564. */
  63565. export class _BasisTextureLoader implements IInternalTextureLoader {
  63566. /**
  63567. * Defines whether the loader supports cascade loading the different faces.
  63568. */
  63569. readonly supportCascades: boolean;
  63570. /**
  63571. * This returns if the loader support the current file information.
  63572. * @param extension defines the file extension of the file being loaded
  63573. * @returns true if the loader can load the specified file
  63574. */
  63575. canLoad(extension: string): boolean;
  63576. /**
  63577. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63578. * @param data contains the texture data
  63579. * @param texture defines the BabylonJS internal texture
  63580. * @param createPolynomials will be true if polynomials have been requested
  63581. * @param onLoad defines the callback to trigger once the texture is ready
  63582. * @param onError defines the callback to trigger in case of error
  63583. */
  63584. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63585. /**
  63586. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63587. * @param data contains the texture data
  63588. * @param texture defines the BabylonJS internal texture
  63589. * @param callback defines the method to call once ready to upload
  63590. */
  63591. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63592. }
  63593. }
  63594. declare module "babylonjs/Materials/Textures/Loaders/index" {
  63595. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  63596. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  63597. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  63598. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  63599. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  63600. }
  63601. declare module "babylonjs/Materials/Textures/Packer/frame" {
  63602. import { Vector2 } from "babylonjs/Maths/math.vector";
  63603. /**
  63604. * Defines the basic options interface of a TexturePacker Frame
  63605. */
  63606. export interface ITexturePackerFrame {
  63607. /**
  63608. * The frame ID
  63609. */
  63610. id: number;
  63611. /**
  63612. * The frames Scale
  63613. */
  63614. scale: Vector2;
  63615. /**
  63616. * The Frames offset
  63617. */
  63618. offset: Vector2;
  63619. }
  63620. /**
  63621. * This is a support class for frame Data on texture packer sets.
  63622. */
  63623. export class TexturePackerFrame implements ITexturePackerFrame {
  63624. /**
  63625. * The frame ID
  63626. */
  63627. id: number;
  63628. /**
  63629. * The frames Scale
  63630. */
  63631. scale: Vector2;
  63632. /**
  63633. * The Frames offset
  63634. */
  63635. offset: Vector2;
  63636. /**
  63637. * Initializes a texture package frame.
  63638. * @param id The numerical frame identifier
  63639. * @param scale Scalar Vector2 for UV frame
  63640. * @param offset Vector2 for the frame position in UV units.
  63641. * @returns TexturePackerFrame
  63642. */
  63643. constructor(id: number, scale: Vector2, offset: Vector2);
  63644. }
  63645. }
  63646. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63648. import { Scene } from "babylonjs/scene";
  63649. import { Nullable } from "babylonjs/types";
  63650. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63651. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63652. /**
  63653. * Defines the basic options interface of a TexturePacker
  63654. */
  63655. export interface ITexturePackerOptions {
  63656. /**
  63657. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63658. */
  63659. map?: string[];
  63660. /**
  63661. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63662. */
  63663. uvsIn?: string;
  63664. /**
  63665. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63666. */
  63667. uvsOut?: string;
  63668. /**
  63669. * number representing the layout style. Defaults to LAYOUT_STRIP
  63670. */
  63671. layout?: number;
  63672. /**
  63673. * number of columns if using custom column count layout(2). This defaults to 4.
  63674. */
  63675. colnum?: number;
  63676. /**
  63677. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63678. */
  63679. updateInputMeshes?: boolean;
  63680. /**
  63681. * boolean flag to dispose all the source textures. Defaults to true.
  63682. */
  63683. disposeSources?: boolean;
  63684. /**
  63685. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63686. */
  63687. fillBlanks?: boolean;
  63688. /**
  63689. * string value representing the context fill style color. Defaults to 'black'.
  63690. */
  63691. customFillColor?: string;
  63692. /**
  63693. * Width and Height Value of each Frame in the TexturePacker Sets
  63694. */
  63695. frameSize?: number;
  63696. /**
  63697. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63698. */
  63699. paddingRatio?: number;
  63700. /**
  63701. * Number that declares the fill method for the padding gutter.
  63702. */
  63703. paddingMode?: number;
  63704. /**
  63705. * If in SUBUV_COLOR padding mode what color to use.
  63706. */
  63707. paddingColor?: Color3 | Color4;
  63708. }
  63709. /**
  63710. * Defines the basic interface of a TexturePacker JSON File
  63711. */
  63712. export interface ITexturePackerJSON {
  63713. /**
  63714. * The frame ID
  63715. */
  63716. name: string;
  63717. /**
  63718. * The base64 channel data
  63719. */
  63720. sets: any;
  63721. /**
  63722. * The options of the Packer
  63723. */
  63724. options: ITexturePackerOptions;
  63725. /**
  63726. * The frame data of the Packer
  63727. */
  63728. frames: Array<number>;
  63729. }
  63730. /**
  63731. * This is a support class that generates a series of packed texture sets.
  63732. * @see https://doc.babylonjs.com/babylon101/materials
  63733. */
  63734. export class TexturePacker {
  63735. /** Packer Layout Constant 0 */
  63736. static readonly LAYOUT_STRIP: number;
  63737. /** Packer Layout Constant 1 */
  63738. static readonly LAYOUT_POWER2: number;
  63739. /** Packer Layout Constant 2 */
  63740. static readonly LAYOUT_COLNUM: number;
  63741. /** Packer Layout Constant 0 */
  63742. static readonly SUBUV_WRAP: number;
  63743. /** Packer Layout Constant 1 */
  63744. static readonly SUBUV_EXTEND: number;
  63745. /** Packer Layout Constant 2 */
  63746. static readonly SUBUV_COLOR: number;
  63747. /** The Name of the Texture Package */
  63748. name: string;
  63749. /** The scene scope of the TexturePacker */
  63750. scene: Scene;
  63751. /** The Meshes to target */
  63752. meshes: AbstractMesh[];
  63753. /** Arguments passed with the Constructor */
  63754. options: ITexturePackerOptions;
  63755. /** The promise that is started upon initialization */
  63756. promise: Nullable<Promise<TexturePacker | string>>;
  63757. /** The Container object for the channel sets that are generated */
  63758. sets: object;
  63759. /** The Container array for the frames that are generated */
  63760. frames: TexturePackerFrame[];
  63761. /** The expected number of textures the system is parsing. */
  63762. private _expecting;
  63763. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63764. private _paddingValue;
  63765. /**
  63766. * Initializes a texture package series from an array of meshes or a single mesh.
  63767. * @param name The name of the package
  63768. * @param meshes The target meshes to compose the package from
  63769. * @param options The arguments that texture packer should follow while building.
  63770. * @param scene The scene which the textures are scoped to.
  63771. * @returns TexturePacker
  63772. */
  63773. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63774. /**
  63775. * Starts the package process
  63776. * @param resolve The promises resolution function
  63777. * @returns TexturePacker
  63778. */
  63779. private _createFrames;
  63780. /**
  63781. * Calculates the Size of the Channel Sets
  63782. * @returns Vector2
  63783. */
  63784. private _calculateSize;
  63785. /**
  63786. * Calculates the UV data for the frames.
  63787. * @param baseSize the base frameSize
  63788. * @param padding the base frame padding
  63789. * @param dtSize size of the Dynamic Texture for that channel
  63790. * @param dtUnits is 1/dtSize
  63791. * @param update flag to update the input meshes
  63792. */
  63793. private _calculateMeshUVFrames;
  63794. /**
  63795. * Calculates the frames Offset.
  63796. * @param index of the frame
  63797. * @returns Vector2
  63798. */
  63799. private _getFrameOffset;
  63800. /**
  63801. * Updates a Mesh to the frame data
  63802. * @param mesh that is the target
  63803. * @param frameID or the frame index
  63804. */
  63805. private _updateMeshUV;
  63806. /**
  63807. * Updates a Meshes materials to use the texture packer channels
  63808. * @param m is the mesh to target
  63809. * @param force all channels on the packer to be set.
  63810. */
  63811. private _updateTextureReferences;
  63812. /**
  63813. * Public method to set a Mesh to a frame
  63814. * @param m that is the target
  63815. * @param frameID or the frame index
  63816. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63817. */
  63818. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63819. /**
  63820. * Starts the async promise to compile the texture packer.
  63821. * @returns Promise<void>
  63822. */
  63823. processAsync(): Promise<void>;
  63824. /**
  63825. * Disposes all textures associated with this packer
  63826. */
  63827. dispose(): void;
  63828. /**
  63829. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63830. * @param imageType is the image type to use.
  63831. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63832. */
  63833. download(imageType?: string, quality?: number): void;
  63834. /**
  63835. * Public method to load a texturePacker JSON file.
  63836. * @param data of the JSON file in string format.
  63837. */
  63838. updateFromJSON(data: string): void;
  63839. }
  63840. }
  63841. declare module "babylonjs/Materials/Textures/Packer/index" {
  63842. export * from "babylonjs/Materials/Textures/Packer/packer";
  63843. export * from "babylonjs/Materials/Textures/Packer/frame";
  63844. }
  63845. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63846. import { Scene } from "babylonjs/scene";
  63847. import { Texture } from "babylonjs/Materials/Textures/texture";
  63848. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63849. /**
  63850. * 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.
  63851. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63852. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63853. */
  63854. export class CustomProceduralTexture extends ProceduralTexture {
  63855. private _animate;
  63856. private _time;
  63857. private _config;
  63858. private _texturePath;
  63859. /**
  63860. * Instantiates a new Custom Procedural Texture.
  63861. * 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.
  63862. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63863. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63864. * @param name Define the name of the texture
  63865. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63866. * @param size Define the size of the texture to create
  63867. * @param scene Define the scene the texture belongs to
  63868. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63869. * @param generateMipMaps Define if the texture should creates mip maps or not
  63870. */
  63871. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63872. private _loadJson;
  63873. /**
  63874. * Is the texture ready to be used ? (rendered at least once)
  63875. * @returns true if ready, otherwise, false.
  63876. */
  63877. isReady(): boolean;
  63878. /**
  63879. * Render the texture to its associated render target.
  63880. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63881. */
  63882. render(useCameraPostProcess?: boolean): void;
  63883. /**
  63884. * Update the list of dependant textures samplers in the shader.
  63885. */
  63886. updateTextures(): void;
  63887. /**
  63888. * Update the uniform values of the procedural texture in the shader.
  63889. */
  63890. updateShaderUniforms(): void;
  63891. /**
  63892. * Define if the texture animates or not.
  63893. */
  63894. get animate(): boolean;
  63895. set animate(value: boolean);
  63896. }
  63897. }
  63898. declare module "babylonjs/Shaders/noise.fragment" {
  63899. /** @hidden */
  63900. export var noisePixelShader: {
  63901. name: string;
  63902. shader: string;
  63903. };
  63904. }
  63905. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63906. import { Nullable } from "babylonjs/types";
  63907. import { Scene } from "babylonjs/scene";
  63908. import { Texture } from "babylonjs/Materials/Textures/texture";
  63909. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63910. import "babylonjs/Shaders/noise.fragment";
  63911. /**
  63912. * Class used to generate noise procedural textures
  63913. */
  63914. export class NoiseProceduralTexture extends ProceduralTexture {
  63915. private _time;
  63916. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63917. brightness: number;
  63918. /** Defines the number of octaves to process */
  63919. octaves: number;
  63920. /** Defines the level of persistence (0.8 by default) */
  63921. persistence: number;
  63922. /** Gets or sets animation speed factor (default is 1) */
  63923. animationSpeedFactor: number;
  63924. /**
  63925. * Creates a new NoiseProceduralTexture
  63926. * @param name defines the name fo the texture
  63927. * @param size defines the size of the texture (default is 256)
  63928. * @param scene defines the hosting scene
  63929. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63930. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63931. */
  63932. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63933. private _updateShaderUniforms;
  63934. protected _getDefines(): string;
  63935. /** Generate the current state of the procedural texture */
  63936. render(useCameraPostProcess?: boolean): void;
  63937. /**
  63938. * Serializes this noise procedural texture
  63939. * @returns a serialized noise procedural texture object
  63940. */
  63941. serialize(): any;
  63942. /**
  63943. * Clone the texture.
  63944. * @returns the cloned texture
  63945. */
  63946. clone(): NoiseProceduralTexture;
  63947. /**
  63948. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63949. * @param parsedTexture defines parsed texture data
  63950. * @param scene defines the current scene
  63951. * @param rootUrl defines the root URL containing noise procedural texture information
  63952. * @returns a parsed NoiseProceduralTexture
  63953. */
  63954. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63955. }
  63956. }
  63957. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63958. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63959. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63960. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63961. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63962. }
  63963. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63964. import { Nullable } from "babylonjs/types";
  63965. import { Scene } from "babylonjs/scene";
  63966. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63967. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63968. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63969. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63970. /**
  63971. * Raw cube texture where the raw buffers are passed in
  63972. */
  63973. export class RawCubeTexture extends CubeTexture {
  63974. /**
  63975. * Creates a cube texture where the raw buffers are passed in.
  63976. * @param scene defines the scene the texture is attached to
  63977. * @param data defines the array of data to use to create each face
  63978. * @param size defines the size of the textures
  63979. * @param format defines the format of the data
  63980. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63981. * @param generateMipMaps defines if the engine should generate the mip levels
  63982. * @param invertY defines if data must be stored with Y axis inverted
  63983. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63984. * @param compression defines the compression used (null by default)
  63985. */
  63986. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63987. /**
  63988. * Updates the raw cube texture.
  63989. * @param data defines the data to store
  63990. * @param format defines the data format
  63991. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63992. * @param invertY defines if data must be stored with Y axis inverted
  63993. * @param compression defines the compression used (null by default)
  63994. * @param level defines which level of the texture to update
  63995. */
  63996. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63997. /**
  63998. * Updates a raw cube texture with RGBD encoded data.
  63999. * @param data defines the array of data [mipmap][face] to use to create each face
  64000. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64001. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64002. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64003. * @returns a promsie that resolves when the operation is complete
  64004. */
  64005. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64006. /**
  64007. * Clones the raw cube texture.
  64008. * @return a new cube texture
  64009. */
  64010. clone(): CubeTexture;
  64011. /** @hidden */
  64012. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64013. }
  64014. }
  64015. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64016. import { Scene } from "babylonjs/scene";
  64017. import { Texture } from "babylonjs/Materials/Textures/texture";
  64018. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64019. /**
  64020. * Class used to store 2D array textures containing user data
  64021. */
  64022. export class RawTexture2DArray extends Texture {
  64023. /** Gets or sets the texture format to use */
  64024. format: number;
  64025. /**
  64026. * Create a new RawTexture2DArray
  64027. * @param data defines the data of the texture
  64028. * @param width defines the width of the texture
  64029. * @param height defines the height of the texture
  64030. * @param depth defines the number of layers of the texture
  64031. * @param format defines the texture format to use
  64032. * @param scene defines the hosting scene
  64033. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64034. * @param invertY defines if texture must be stored with Y axis inverted
  64035. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64036. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64037. */
  64038. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64039. /** Gets or sets the texture format to use */
  64040. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64041. /**
  64042. * Update the texture with new data
  64043. * @param data defines the data to store in the texture
  64044. */
  64045. update(data: ArrayBufferView): void;
  64046. }
  64047. }
  64048. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64049. import { Scene } from "babylonjs/scene";
  64050. import { Texture } from "babylonjs/Materials/Textures/texture";
  64051. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64052. /**
  64053. * Class used to store 3D textures containing user data
  64054. */
  64055. export class RawTexture3D extends Texture {
  64056. /** Gets or sets the texture format to use */
  64057. format: number;
  64058. /**
  64059. * Create a new RawTexture3D
  64060. * @param data defines the data of the texture
  64061. * @param width defines the width of the texture
  64062. * @param height defines the height of the texture
  64063. * @param depth defines the depth of the texture
  64064. * @param format defines the texture format to use
  64065. * @param scene defines the hosting scene
  64066. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64067. * @param invertY defines if texture must be stored with Y axis inverted
  64068. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64069. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64070. */
  64071. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64072. /** Gets or sets the texture format to use */
  64073. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64074. /**
  64075. * Update the texture with new data
  64076. * @param data defines the data to store in the texture
  64077. */
  64078. update(data: ArrayBufferView): void;
  64079. }
  64080. }
  64081. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64082. import { Scene } from "babylonjs/scene";
  64083. import { Plane } from "babylonjs/Maths/math.plane";
  64084. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64085. /**
  64086. * Creates a refraction texture used by refraction channel of the standard material.
  64087. * It is like a mirror but to see through a material.
  64088. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64089. */
  64090. export class RefractionTexture extends RenderTargetTexture {
  64091. /**
  64092. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64093. * 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.
  64094. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64095. */
  64096. refractionPlane: Plane;
  64097. /**
  64098. * Define how deep under the surface we should see.
  64099. */
  64100. depth: number;
  64101. /**
  64102. * Creates a refraction texture used by refraction channel of the standard material.
  64103. * It is like a mirror but to see through a material.
  64104. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64105. * @param name Define the texture name
  64106. * @param size Define the size of the underlying texture
  64107. * @param scene Define the scene the refraction belongs to
  64108. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64109. */
  64110. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64111. /**
  64112. * Clone the refraction texture.
  64113. * @returns the cloned texture
  64114. */
  64115. clone(): RefractionTexture;
  64116. /**
  64117. * Serialize the texture to a JSON representation you could use in Parse later on
  64118. * @returns the serialized JSON representation
  64119. */
  64120. serialize(): any;
  64121. }
  64122. }
  64123. declare module "babylonjs/Materials/Textures/index" {
  64124. export * from "babylonjs/Materials/Textures/baseTexture";
  64125. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64126. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64127. export * from "babylonjs/Materials/Textures/cubeTexture";
  64128. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64129. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64130. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64131. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64132. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64133. export * from "babylonjs/Materials/Textures/internalTexture";
  64134. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64135. export * from "babylonjs/Materials/Textures/Loaders/index";
  64136. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64137. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64138. export * from "babylonjs/Materials/Textures/Packer/index";
  64139. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64140. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64141. export * from "babylonjs/Materials/Textures/rawTexture";
  64142. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64143. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64144. export * from "babylonjs/Materials/Textures/refractionTexture";
  64145. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64146. export * from "babylonjs/Materials/Textures/texture";
  64147. export * from "babylonjs/Materials/Textures/videoTexture";
  64148. }
  64149. declare module "babylonjs/Materials/Node/Enums/index" {
  64150. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64151. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64152. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64153. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64154. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64155. }
  64156. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64157. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64158. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64160. import { Mesh } from "babylonjs/Meshes/mesh";
  64161. import { Effect } from "babylonjs/Materials/effect";
  64162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64163. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64164. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64165. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64166. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64167. /**
  64168. * Block used to add support for vertex skinning (bones)
  64169. */
  64170. export class BonesBlock extends NodeMaterialBlock {
  64171. /**
  64172. * Creates a new BonesBlock
  64173. * @param name defines the block name
  64174. */
  64175. constructor(name: string);
  64176. /**
  64177. * Initialize the block and prepare the context for build
  64178. * @param state defines the state that will be used for the build
  64179. */
  64180. initialize(state: NodeMaterialBuildState): void;
  64181. /**
  64182. * Gets the current class name
  64183. * @returns the class name
  64184. */
  64185. getClassName(): string;
  64186. /**
  64187. * Gets the matrix indices input component
  64188. */
  64189. get matricesIndices(): NodeMaterialConnectionPoint;
  64190. /**
  64191. * Gets the matrix weights input component
  64192. */
  64193. get matricesWeights(): NodeMaterialConnectionPoint;
  64194. /**
  64195. * Gets the extra matrix indices input component
  64196. */
  64197. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64198. /**
  64199. * Gets the extra matrix weights input component
  64200. */
  64201. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64202. /**
  64203. * Gets the world input component
  64204. */
  64205. get world(): NodeMaterialConnectionPoint;
  64206. /**
  64207. * Gets the output component
  64208. */
  64209. get output(): NodeMaterialConnectionPoint;
  64210. autoConfigure(material: NodeMaterial): void;
  64211. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64212. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64214. protected _buildBlock(state: NodeMaterialBuildState): this;
  64215. }
  64216. }
  64217. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64218. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64219. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64222. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64223. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64224. /**
  64225. * Block used to add support for instances
  64226. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64227. */
  64228. export class InstancesBlock extends NodeMaterialBlock {
  64229. /**
  64230. * Creates a new InstancesBlock
  64231. * @param name defines the block name
  64232. */
  64233. constructor(name: string);
  64234. /**
  64235. * Gets the current class name
  64236. * @returns the class name
  64237. */
  64238. getClassName(): string;
  64239. /**
  64240. * Gets the first world row input component
  64241. */
  64242. get world0(): NodeMaterialConnectionPoint;
  64243. /**
  64244. * Gets the second world row input component
  64245. */
  64246. get world1(): NodeMaterialConnectionPoint;
  64247. /**
  64248. * Gets the third world row input component
  64249. */
  64250. get world2(): NodeMaterialConnectionPoint;
  64251. /**
  64252. * Gets the forth world row input component
  64253. */
  64254. get world3(): NodeMaterialConnectionPoint;
  64255. /**
  64256. * Gets the world input component
  64257. */
  64258. get world(): NodeMaterialConnectionPoint;
  64259. /**
  64260. * Gets the output component
  64261. */
  64262. get output(): NodeMaterialConnectionPoint;
  64263. /**
  64264. * Gets the isntanceID component
  64265. */
  64266. get instanceID(): NodeMaterialConnectionPoint;
  64267. autoConfigure(material: NodeMaterial): void;
  64268. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64269. protected _buildBlock(state: NodeMaterialBuildState): this;
  64270. }
  64271. }
  64272. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64273. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64274. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64275. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64277. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64278. import { Effect } from "babylonjs/Materials/effect";
  64279. import { Mesh } from "babylonjs/Meshes/mesh";
  64280. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64281. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64282. /**
  64283. * Block used to add morph targets support to vertex shader
  64284. */
  64285. export class MorphTargetsBlock extends NodeMaterialBlock {
  64286. private _repeatableContentAnchor;
  64287. /**
  64288. * Create a new MorphTargetsBlock
  64289. * @param name defines the block name
  64290. */
  64291. constructor(name: string);
  64292. /**
  64293. * Gets the current class name
  64294. * @returns the class name
  64295. */
  64296. getClassName(): string;
  64297. /**
  64298. * Gets the position input component
  64299. */
  64300. get position(): NodeMaterialConnectionPoint;
  64301. /**
  64302. * Gets the normal input component
  64303. */
  64304. get normal(): NodeMaterialConnectionPoint;
  64305. /**
  64306. * Gets the tangent input component
  64307. */
  64308. get tangent(): NodeMaterialConnectionPoint;
  64309. /**
  64310. * Gets the tangent input component
  64311. */
  64312. get uv(): NodeMaterialConnectionPoint;
  64313. /**
  64314. * Gets the position output component
  64315. */
  64316. get positionOutput(): NodeMaterialConnectionPoint;
  64317. /**
  64318. * Gets the normal output component
  64319. */
  64320. get normalOutput(): NodeMaterialConnectionPoint;
  64321. /**
  64322. * Gets the tangent output component
  64323. */
  64324. get tangentOutput(): NodeMaterialConnectionPoint;
  64325. /**
  64326. * Gets the tangent output component
  64327. */
  64328. get uvOutput(): NodeMaterialConnectionPoint;
  64329. initialize(state: NodeMaterialBuildState): void;
  64330. autoConfigure(material: NodeMaterial): void;
  64331. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64332. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64333. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64334. protected _buildBlock(state: NodeMaterialBuildState): this;
  64335. }
  64336. }
  64337. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64338. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64339. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64340. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64341. import { Nullable } from "babylonjs/types";
  64342. import { Scene } from "babylonjs/scene";
  64343. import { Effect } from "babylonjs/Materials/effect";
  64344. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64345. import { Mesh } from "babylonjs/Meshes/mesh";
  64346. import { Light } from "babylonjs/Lights/light";
  64347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64348. /**
  64349. * Block used to get data information from a light
  64350. */
  64351. export class LightInformationBlock extends NodeMaterialBlock {
  64352. private _lightDataUniformName;
  64353. private _lightColorUniformName;
  64354. private _lightTypeDefineName;
  64355. /**
  64356. * Gets or sets the light associated with this block
  64357. */
  64358. light: Nullable<Light>;
  64359. /**
  64360. * Creates a new LightInformationBlock
  64361. * @param name defines the block name
  64362. */
  64363. constructor(name: string);
  64364. /**
  64365. * Gets the current class name
  64366. * @returns the class name
  64367. */
  64368. getClassName(): string;
  64369. /**
  64370. * Gets the world position input component
  64371. */
  64372. get worldPosition(): NodeMaterialConnectionPoint;
  64373. /**
  64374. * Gets the direction output component
  64375. */
  64376. get direction(): NodeMaterialConnectionPoint;
  64377. /**
  64378. * Gets the direction output component
  64379. */
  64380. get color(): NodeMaterialConnectionPoint;
  64381. /**
  64382. * Gets the direction output component
  64383. */
  64384. get intensity(): NodeMaterialConnectionPoint;
  64385. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64386. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64387. protected _buildBlock(state: NodeMaterialBuildState): this;
  64388. serialize(): any;
  64389. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64390. }
  64391. }
  64392. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64393. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64394. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64395. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64396. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64397. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64398. }
  64399. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64404. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64405. import { Effect } from "babylonjs/Materials/effect";
  64406. import { Mesh } from "babylonjs/Meshes/mesh";
  64407. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64408. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64409. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64410. /**
  64411. * Block used to add image processing support to fragment shader
  64412. */
  64413. export class ImageProcessingBlock extends NodeMaterialBlock {
  64414. /**
  64415. * Create a new ImageProcessingBlock
  64416. * @param name defines the block name
  64417. */
  64418. constructor(name: string);
  64419. /**
  64420. * Gets the current class name
  64421. * @returns the class name
  64422. */
  64423. getClassName(): string;
  64424. /**
  64425. * Gets the color input component
  64426. */
  64427. get color(): NodeMaterialConnectionPoint;
  64428. /**
  64429. * Gets the output component
  64430. */
  64431. get output(): NodeMaterialConnectionPoint;
  64432. /**
  64433. * Initialize the block and prepare the context for build
  64434. * @param state defines the state that will be used for the build
  64435. */
  64436. initialize(state: NodeMaterialBuildState): void;
  64437. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64439. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64440. protected _buildBlock(state: NodeMaterialBuildState): this;
  64441. }
  64442. }
  64443. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  64444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64447. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64449. import { Effect } from "babylonjs/Materials/effect";
  64450. import { Mesh } from "babylonjs/Meshes/mesh";
  64451. import { Scene } from "babylonjs/scene";
  64452. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  64453. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  64454. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  64455. /**
  64456. * Block used to pertub normals based on a normal map
  64457. */
  64458. export class PerturbNormalBlock extends NodeMaterialBlock {
  64459. private _tangentSpaceParameterName;
  64460. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64461. invertX: boolean;
  64462. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64463. invertY: boolean;
  64464. /**
  64465. * Create a new PerturbNormalBlock
  64466. * @param name defines the block name
  64467. */
  64468. constructor(name: string);
  64469. /**
  64470. * Gets the current class name
  64471. * @returns the class name
  64472. */
  64473. getClassName(): string;
  64474. /**
  64475. * Gets the world position input component
  64476. */
  64477. get worldPosition(): NodeMaterialConnectionPoint;
  64478. /**
  64479. * Gets the world normal input component
  64480. */
  64481. get worldNormal(): NodeMaterialConnectionPoint;
  64482. /**
  64483. * Gets the world tangent input component
  64484. */
  64485. get worldTangent(): NodeMaterialConnectionPoint;
  64486. /**
  64487. * Gets the uv input component
  64488. */
  64489. get uv(): NodeMaterialConnectionPoint;
  64490. /**
  64491. * Gets the normal map color input component
  64492. */
  64493. get normalMapColor(): NodeMaterialConnectionPoint;
  64494. /**
  64495. * Gets the strength input component
  64496. */
  64497. get strength(): NodeMaterialConnectionPoint;
  64498. /**
  64499. * Gets the output component
  64500. */
  64501. get output(): NodeMaterialConnectionPoint;
  64502. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64503. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64504. autoConfigure(material: NodeMaterial): void;
  64505. protected _buildBlock(state: NodeMaterialBuildState): this;
  64506. protected _dumpPropertiesCode(): string;
  64507. serialize(): any;
  64508. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64509. }
  64510. }
  64511. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  64512. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64514. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64515. /**
  64516. * Block used to discard a pixel if a value is smaller than a cutoff
  64517. */
  64518. export class DiscardBlock extends NodeMaterialBlock {
  64519. /**
  64520. * Create a new DiscardBlock
  64521. * @param name defines the block name
  64522. */
  64523. constructor(name: string);
  64524. /**
  64525. * Gets the current class name
  64526. * @returns the class name
  64527. */
  64528. getClassName(): string;
  64529. /**
  64530. * Gets the color input component
  64531. */
  64532. get value(): NodeMaterialConnectionPoint;
  64533. /**
  64534. * Gets the cutoff input component
  64535. */
  64536. get cutoff(): NodeMaterialConnectionPoint;
  64537. protected _buildBlock(state: NodeMaterialBuildState): this;
  64538. }
  64539. }
  64540. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  64541. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64542. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64543. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64544. /**
  64545. * Block used to test if the fragment shader is front facing
  64546. */
  64547. export class FrontFacingBlock extends NodeMaterialBlock {
  64548. /**
  64549. * Creates a new FrontFacingBlock
  64550. * @param name defines the block name
  64551. */
  64552. constructor(name: string);
  64553. /**
  64554. * Gets the current class name
  64555. * @returns the class name
  64556. */
  64557. getClassName(): string;
  64558. /**
  64559. * Gets the output component
  64560. */
  64561. get output(): NodeMaterialConnectionPoint;
  64562. protected _buildBlock(state: NodeMaterialBuildState): this;
  64563. }
  64564. }
  64565. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  64566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64569. /**
  64570. * Block used to get the derivative value on x and y of a given input
  64571. */
  64572. export class DerivativeBlock extends NodeMaterialBlock {
  64573. /**
  64574. * Create a new DerivativeBlock
  64575. * @param name defines the block name
  64576. */
  64577. constructor(name: string);
  64578. /**
  64579. * Gets the current class name
  64580. * @returns the class name
  64581. */
  64582. getClassName(): string;
  64583. /**
  64584. * Gets the input component
  64585. */
  64586. get input(): NodeMaterialConnectionPoint;
  64587. /**
  64588. * Gets the derivative output on x
  64589. */
  64590. get dx(): NodeMaterialConnectionPoint;
  64591. /**
  64592. * Gets the derivative output on y
  64593. */
  64594. get dy(): NodeMaterialConnectionPoint;
  64595. protected _buildBlock(state: NodeMaterialBuildState): this;
  64596. }
  64597. }
  64598. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  64599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64602. /**
  64603. * Block used to make gl_FragCoord available
  64604. */
  64605. export class FragCoordBlock extends NodeMaterialBlock {
  64606. /**
  64607. * Creates a new FragCoordBlock
  64608. * @param name defines the block name
  64609. */
  64610. constructor(name: string);
  64611. /**
  64612. * Gets the current class name
  64613. * @returns the class name
  64614. */
  64615. getClassName(): string;
  64616. /**
  64617. * Gets the xy component
  64618. */
  64619. get xy(): NodeMaterialConnectionPoint;
  64620. /**
  64621. * Gets the xyz component
  64622. */
  64623. get xyz(): NodeMaterialConnectionPoint;
  64624. /**
  64625. * Gets the xyzw component
  64626. */
  64627. get xyzw(): NodeMaterialConnectionPoint;
  64628. /**
  64629. * Gets the x component
  64630. */
  64631. get x(): NodeMaterialConnectionPoint;
  64632. /**
  64633. * Gets the y component
  64634. */
  64635. get y(): NodeMaterialConnectionPoint;
  64636. /**
  64637. * Gets the z component
  64638. */
  64639. get z(): NodeMaterialConnectionPoint;
  64640. /**
  64641. * Gets the w component
  64642. */
  64643. get output(): NodeMaterialConnectionPoint;
  64644. protected writeOutputs(state: NodeMaterialBuildState): string;
  64645. protected _buildBlock(state: NodeMaterialBuildState): this;
  64646. }
  64647. }
  64648. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  64649. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64652. import { Effect } from "babylonjs/Materials/effect";
  64653. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64654. import { Mesh } from "babylonjs/Meshes/mesh";
  64655. /**
  64656. * Block used to get the screen sizes
  64657. */
  64658. export class ScreenSizeBlock extends NodeMaterialBlock {
  64659. private _varName;
  64660. private _scene;
  64661. /**
  64662. * Creates a new ScreenSizeBlock
  64663. * @param name defines the block name
  64664. */
  64665. constructor(name: string);
  64666. /**
  64667. * Gets the current class name
  64668. * @returns the class name
  64669. */
  64670. getClassName(): string;
  64671. /**
  64672. * Gets the xy component
  64673. */
  64674. get xy(): NodeMaterialConnectionPoint;
  64675. /**
  64676. * Gets the x component
  64677. */
  64678. get x(): NodeMaterialConnectionPoint;
  64679. /**
  64680. * Gets the y component
  64681. */
  64682. get y(): NodeMaterialConnectionPoint;
  64683. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64684. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64685. protected _buildBlock(state: NodeMaterialBuildState): this;
  64686. }
  64687. }
  64688. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  64689. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  64690. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  64691. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  64692. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  64693. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  64694. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  64695. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  64696. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  64697. }
  64698. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  64699. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64700. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64701. import { Mesh } from "babylonjs/Meshes/mesh";
  64702. import { Effect } from "babylonjs/Materials/effect";
  64703. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64705. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64706. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64707. /**
  64708. * Block used to add support for scene fog
  64709. */
  64710. export class FogBlock extends NodeMaterialBlock {
  64711. private _fogDistanceName;
  64712. private _fogParameters;
  64713. /**
  64714. * Create a new FogBlock
  64715. * @param name defines the block name
  64716. */
  64717. constructor(name: string);
  64718. /**
  64719. * Gets the current class name
  64720. * @returns the class name
  64721. */
  64722. getClassName(): string;
  64723. /**
  64724. * Gets the world position input component
  64725. */
  64726. get worldPosition(): NodeMaterialConnectionPoint;
  64727. /**
  64728. * Gets the view input component
  64729. */
  64730. get view(): NodeMaterialConnectionPoint;
  64731. /**
  64732. * Gets the color input component
  64733. */
  64734. get input(): NodeMaterialConnectionPoint;
  64735. /**
  64736. * Gets the fog color input component
  64737. */
  64738. get fogColor(): NodeMaterialConnectionPoint;
  64739. /**
  64740. * Gets the output component
  64741. */
  64742. get output(): NodeMaterialConnectionPoint;
  64743. autoConfigure(material: NodeMaterial): void;
  64744. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64745. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64746. protected _buildBlock(state: NodeMaterialBuildState): this;
  64747. }
  64748. }
  64749. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64750. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64751. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64752. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64754. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64755. import { Effect } from "babylonjs/Materials/effect";
  64756. import { Mesh } from "babylonjs/Meshes/mesh";
  64757. import { Light } from "babylonjs/Lights/light";
  64758. import { Nullable } from "babylonjs/types";
  64759. import { Scene } from "babylonjs/scene";
  64760. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64761. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64762. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64763. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64764. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64765. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64766. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64767. /**
  64768. * Block used to add light in the fragment shader
  64769. */
  64770. export class LightBlock extends NodeMaterialBlock {
  64771. private _lightId;
  64772. /**
  64773. * Gets or sets the light associated with this block
  64774. */
  64775. light: Nullable<Light>;
  64776. /**
  64777. * Create a new LightBlock
  64778. * @param name defines the block name
  64779. */
  64780. constructor(name: string);
  64781. /**
  64782. * Gets the current class name
  64783. * @returns the class name
  64784. */
  64785. getClassName(): string;
  64786. /**
  64787. * Gets the world position input component
  64788. */
  64789. get worldPosition(): NodeMaterialConnectionPoint;
  64790. /**
  64791. * Gets the world normal input component
  64792. */
  64793. get worldNormal(): NodeMaterialConnectionPoint;
  64794. /**
  64795. * Gets the camera (or eye) position component
  64796. */
  64797. get cameraPosition(): NodeMaterialConnectionPoint;
  64798. /**
  64799. * Gets the glossiness component
  64800. */
  64801. get glossiness(): NodeMaterialConnectionPoint;
  64802. /**
  64803. * Gets the glossinness power component
  64804. */
  64805. get glossPower(): NodeMaterialConnectionPoint;
  64806. /**
  64807. * Gets the diffuse color component
  64808. */
  64809. get diffuseColor(): NodeMaterialConnectionPoint;
  64810. /**
  64811. * Gets the specular color component
  64812. */
  64813. get specularColor(): NodeMaterialConnectionPoint;
  64814. /**
  64815. * Gets the diffuse output component
  64816. */
  64817. get diffuseOutput(): NodeMaterialConnectionPoint;
  64818. /**
  64819. * Gets the specular output component
  64820. */
  64821. get specularOutput(): NodeMaterialConnectionPoint;
  64822. /**
  64823. * Gets the shadow output component
  64824. */
  64825. get shadow(): NodeMaterialConnectionPoint;
  64826. autoConfigure(material: NodeMaterial): void;
  64827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64828. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64829. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64830. private _injectVertexCode;
  64831. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64832. serialize(): any;
  64833. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64834. }
  64835. }
  64836. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64837. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64838. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64839. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64840. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64841. /**
  64842. * Block used to read a reflection texture from a sampler
  64843. */
  64844. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64845. /**
  64846. * Create a new ReflectionTextureBlock
  64847. * @param name defines the block name
  64848. */
  64849. constructor(name: string);
  64850. /**
  64851. * Gets the current class name
  64852. * @returns the class name
  64853. */
  64854. getClassName(): string;
  64855. /**
  64856. * Gets the world position input component
  64857. */
  64858. get position(): NodeMaterialConnectionPoint;
  64859. /**
  64860. * Gets the world position input component
  64861. */
  64862. get worldPosition(): NodeMaterialConnectionPoint;
  64863. /**
  64864. * Gets the world normal input component
  64865. */
  64866. get worldNormal(): NodeMaterialConnectionPoint;
  64867. /**
  64868. * Gets the world input component
  64869. */
  64870. get world(): NodeMaterialConnectionPoint;
  64871. /**
  64872. * Gets the camera (or eye) position component
  64873. */
  64874. get cameraPosition(): NodeMaterialConnectionPoint;
  64875. /**
  64876. * Gets the view input component
  64877. */
  64878. get view(): NodeMaterialConnectionPoint;
  64879. /**
  64880. * Gets the rgb output component
  64881. */
  64882. get rgb(): NodeMaterialConnectionPoint;
  64883. /**
  64884. * Gets the rgba output component
  64885. */
  64886. get rgba(): NodeMaterialConnectionPoint;
  64887. /**
  64888. * Gets the r output component
  64889. */
  64890. get r(): NodeMaterialConnectionPoint;
  64891. /**
  64892. * Gets the g output component
  64893. */
  64894. get g(): NodeMaterialConnectionPoint;
  64895. /**
  64896. * Gets the b output component
  64897. */
  64898. get b(): NodeMaterialConnectionPoint;
  64899. /**
  64900. * Gets the a output component
  64901. */
  64902. get a(): NodeMaterialConnectionPoint;
  64903. autoConfigure(material: NodeMaterial): void;
  64904. protected _buildBlock(state: NodeMaterialBuildState): this;
  64905. }
  64906. }
  64907. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64908. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64909. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64910. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64911. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64912. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64913. }
  64914. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64915. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64916. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64917. }
  64918. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64919. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64920. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64921. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64922. /**
  64923. * Block used to add 2 vectors
  64924. */
  64925. export class AddBlock extends NodeMaterialBlock {
  64926. /**
  64927. * Creates a new AddBlock
  64928. * @param name defines the block name
  64929. */
  64930. constructor(name: string);
  64931. /**
  64932. * Gets the current class name
  64933. * @returns the class name
  64934. */
  64935. getClassName(): string;
  64936. /**
  64937. * Gets the left operand input component
  64938. */
  64939. get left(): NodeMaterialConnectionPoint;
  64940. /**
  64941. * Gets the right operand input component
  64942. */
  64943. get right(): NodeMaterialConnectionPoint;
  64944. /**
  64945. * Gets the output component
  64946. */
  64947. get output(): NodeMaterialConnectionPoint;
  64948. protected _buildBlock(state: NodeMaterialBuildState): this;
  64949. }
  64950. }
  64951. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64952. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64953. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64954. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64955. /**
  64956. * Block used to scale a vector by a float
  64957. */
  64958. export class ScaleBlock extends NodeMaterialBlock {
  64959. /**
  64960. * Creates a new ScaleBlock
  64961. * @param name defines the block name
  64962. */
  64963. constructor(name: string);
  64964. /**
  64965. * Gets the current class name
  64966. * @returns the class name
  64967. */
  64968. getClassName(): string;
  64969. /**
  64970. * Gets the input component
  64971. */
  64972. get input(): NodeMaterialConnectionPoint;
  64973. /**
  64974. * Gets the factor input component
  64975. */
  64976. get factor(): NodeMaterialConnectionPoint;
  64977. /**
  64978. * Gets the output component
  64979. */
  64980. get output(): NodeMaterialConnectionPoint;
  64981. protected _buildBlock(state: NodeMaterialBuildState): this;
  64982. }
  64983. }
  64984. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64985. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64986. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64987. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64988. import { Scene } from "babylonjs/scene";
  64989. /**
  64990. * Block used to clamp a float
  64991. */
  64992. export class ClampBlock extends NodeMaterialBlock {
  64993. /** Gets or sets the minimum range */
  64994. minimum: number;
  64995. /** Gets or sets the maximum range */
  64996. maximum: number;
  64997. /**
  64998. * Creates a new ClampBlock
  64999. * @param name defines the block name
  65000. */
  65001. constructor(name: string);
  65002. /**
  65003. * Gets the current class name
  65004. * @returns the class name
  65005. */
  65006. getClassName(): string;
  65007. /**
  65008. * Gets the value input component
  65009. */
  65010. get value(): NodeMaterialConnectionPoint;
  65011. /**
  65012. * Gets the output component
  65013. */
  65014. get output(): NodeMaterialConnectionPoint;
  65015. protected _buildBlock(state: NodeMaterialBuildState): this;
  65016. protected _dumpPropertiesCode(): string;
  65017. serialize(): any;
  65018. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65019. }
  65020. }
  65021. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65023. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65025. /**
  65026. * Block used to apply a cross product between 2 vectors
  65027. */
  65028. export class CrossBlock extends NodeMaterialBlock {
  65029. /**
  65030. * Creates a new CrossBlock
  65031. * @param name defines the block name
  65032. */
  65033. constructor(name: string);
  65034. /**
  65035. * Gets the current class name
  65036. * @returns the class name
  65037. */
  65038. getClassName(): string;
  65039. /**
  65040. * Gets the left operand input component
  65041. */
  65042. get left(): NodeMaterialConnectionPoint;
  65043. /**
  65044. * Gets the right operand input component
  65045. */
  65046. get right(): NodeMaterialConnectionPoint;
  65047. /**
  65048. * Gets the output component
  65049. */
  65050. get output(): NodeMaterialConnectionPoint;
  65051. protected _buildBlock(state: NodeMaterialBuildState): this;
  65052. }
  65053. }
  65054. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65055. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65056. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65057. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65058. /**
  65059. * Block used to apply a dot product between 2 vectors
  65060. */
  65061. export class DotBlock extends NodeMaterialBlock {
  65062. /**
  65063. * Creates a new DotBlock
  65064. * @param name defines the block name
  65065. */
  65066. constructor(name: string);
  65067. /**
  65068. * Gets the current class name
  65069. * @returns the class name
  65070. */
  65071. getClassName(): string;
  65072. /**
  65073. * Gets the left operand input component
  65074. */
  65075. get left(): NodeMaterialConnectionPoint;
  65076. /**
  65077. * Gets the right operand input component
  65078. */
  65079. get right(): NodeMaterialConnectionPoint;
  65080. /**
  65081. * Gets the output component
  65082. */
  65083. get output(): NodeMaterialConnectionPoint;
  65084. protected _buildBlock(state: NodeMaterialBuildState): this;
  65085. }
  65086. }
  65087. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65090. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65091. /**
  65092. * Block used to normalize a vector
  65093. */
  65094. export class NormalizeBlock extends NodeMaterialBlock {
  65095. /**
  65096. * Creates a new NormalizeBlock
  65097. * @param name defines the block name
  65098. */
  65099. constructor(name: string);
  65100. /**
  65101. * Gets the current class name
  65102. * @returns the class name
  65103. */
  65104. getClassName(): string;
  65105. /**
  65106. * Gets the input component
  65107. */
  65108. get input(): NodeMaterialConnectionPoint;
  65109. /**
  65110. * Gets the output component
  65111. */
  65112. get output(): NodeMaterialConnectionPoint;
  65113. protected _buildBlock(state: NodeMaterialBuildState): this;
  65114. }
  65115. }
  65116. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65118. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65119. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65120. import { Scene } from "babylonjs/scene";
  65121. /**
  65122. * Operations supported by the Trigonometry block
  65123. */
  65124. export enum TrigonometryBlockOperations {
  65125. /** Cos */
  65126. Cos = 0,
  65127. /** Sin */
  65128. Sin = 1,
  65129. /** Abs */
  65130. Abs = 2,
  65131. /** Exp */
  65132. Exp = 3,
  65133. /** Exp2 */
  65134. Exp2 = 4,
  65135. /** Round */
  65136. Round = 5,
  65137. /** Floor */
  65138. Floor = 6,
  65139. /** Ceiling */
  65140. Ceiling = 7,
  65141. /** Square root */
  65142. Sqrt = 8,
  65143. /** Log */
  65144. Log = 9,
  65145. /** Tangent */
  65146. Tan = 10,
  65147. /** Arc tangent */
  65148. ArcTan = 11,
  65149. /** Arc cosinus */
  65150. ArcCos = 12,
  65151. /** Arc sinus */
  65152. ArcSin = 13,
  65153. /** Fraction */
  65154. Fract = 14,
  65155. /** Sign */
  65156. Sign = 15,
  65157. /** To radians (from degrees) */
  65158. Radians = 16,
  65159. /** To degrees (from radians) */
  65160. Degrees = 17
  65161. }
  65162. /**
  65163. * Block used to apply trigonometry operation to floats
  65164. */
  65165. export class TrigonometryBlock extends NodeMaterialBlock {
  65166. /**
  65167. * Gets or sets the operation applied by the block
  65168. */
  65169. operation: TrigonometryBlockOperations;
  65170. /**
  65171. * Creates a new TrigonometryBlock
  65172. * @param name defines the block name
  65173. */
  65174. constructor(name: string);
  65175. /**
  65176. * Gets the current class name
  65177. * @returns the class name
  65178. */
  65179. getClassName(): string;
  65180. /**
  65181. * Gets the input component
  65182. */
  65183. get input(): NodeMaterialConnectionPoint;
  65184. /**
  65185. * Gets the output component
  65186. */
  65187. get output(): NodeMaterialConnectionPoint;
  65188. protected _buildBlock(state: NodeMaterialBuildState): this;
  65189. serialize(): any;
  65190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65191. protected _dumpPropertiesCode(): string;
  65192. }
  65193. }
  65194. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65195. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65196. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65197. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65198. /**
  65199. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65200. */
  65201. export class ColorMergerBlock extends NodeMaterialBlock {
  65202. /**
  65203. * Create a new ColorMergerBlock
  65204. * @param name defines the block name
  65205. */
  65206. constructor(name: string);
  65207. /**
  65208. * Gets the current class name
  65209. * @returns the class name
  65210. */
  65211. getClassName(): string;
  65212. /**
  65213. * Gets the rgb component (input)
  65214. */
  65215. get rgbIn(): NodeMaterialConnectionPoint;
  65216. /**
  65217. * Gets the r component (input)
  65218. */
  65219. get r(): NodeMaterialConnectionPoint;
  65220. /**
  65221. * Gets the g component (input)
  65222. */
  65223. get g(): NodeMaterialConnectionPoint;
  65224. /**
  65225. * Gets the b component (input)
  65226. */
  65227. get b(): NodeMaterialConnectionPoint;
  65228. /**
  65229. * Gets the a component (input)
  65230. */
  65231. get a(): NodeMaterialConnectionPoint;
  65232. /**
  65233. * Gets the rgba component (output)
  65234. */
  65235. get rgba(): NodeMaterialConnectionPoint;
  65236. /**
  65237. * Gets the rgb component (output)
  65238. */
  65239. get rgbOut(): NodeMaterialConnectionPoint;
  65240. /**
  65241. * Gets the rgb component (output)
  65242. * @deprecated Please use rgbOut instead.
  65243. */
  65244. get rgb(): NodeMaterialConnectionPoint;
  65245. protected _buildBlock(state: NodeMaterialBuildState): this;
  65246. }
  65247. }
  65248. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65249. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65250. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65251. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65252. /**
  65253. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65254. */
  65255. export class VectorSplitterBlock extends NodeMaterialBlock {
  65256. /**
  65257. * Create a new VectorSplitterBlock
  65258. * @param name defines the block name
  65259. */
  65260. constructor(name: string);
  65261. /**
  65262. * Gets the current class name
  65263. * @returns the class name
  65264. */
  65265. getClassName(): string;
  65266. /**
  65267. * Gets the xyzw component (input)
  65268. */
  65269. get xyzw(): NodeMaterialConnectionPoint;
  65270. /**
  65271. * Gets the xyz component (input)
  65272. */
  65273. get xyzIn(): NodeMaterialConnectionPoint;
  65274. /**
  65275. * Gets the xy component (input)
  65276. */
  65277. get xyIn(): NodeMaterialConnectionPoint;
  65278. /**
  65279. * Gets the xyz component (output)
  65280. */
  65281. get xyzOut(): NodeMaterialConnectionPoint;
  65282. /**
  65283. * Gets the xy component (output)
  65284. */
  65285. get xyOut(): NodeMaterialConnectionPoint;
  65286. /**
  65287. * Gets the x component (output)
  65288. */
  65289. get x(): NodeMaterialConnectionPoint;
  65290. /**
  65291. * Gets the y component (output)
  65292. */
  65293. get y(): NodeMaterialConnectionPoint;
  65294. /**
  65295. * Gets the z component (output)
  65296. */
  65297. get z(): NodeMaterialConnectionPoint;
  65298. /**
  65299. * Gets the w component (output)
  65300. */
  65301. get w(): NodeMaterialConnectionPoint;
  65302. protected _inputRename(name: string): string;
  65303. protected _outputRename(name: string): string;
  65304. protected _buildBlock(state: NodeMaterialBuildState): this;
  65305. }
  65306. }
  65307. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65311. /**
  65312. * Block used to lerp between 2 values
  65313. */
  65314. export class LerpBlock extends NodeMaterialBlock {
  65315. /**
  65316. * Creates a new LerpBlock
  65317. * @param name defines the block name
  65318. */
  65319. constructor(name: string);
  65320. /**
  65321. * Gets the current class name
  65322. * @returns the class name
  65323. */
  65324. getClassName(): string;
  65325. /**
  65326. * Gets the left operand input component
  65327. */
  65328. get left(): NodeMaterialConnectionPoint;
  65329. /**
  65330. * Gets the right operand input component
  65331. */
  65332. get right(): NodeMaterialConnectionPoint;
  65333. /**
  65334. * Gets the gradient operand input component
  65335. */
  65336. get gradient(): NodeMaterialConnectionPoint;
  65337. /**
  65338. * Gets the output component
  65339. */
  65340. get output(): NodeMaterialConnectionPoint;
  65341. protected _buildBlock(state: NodeMaterialBuildState): this;
  65342. }
  65343. }
  65344. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65346. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65347. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65348. /**
  65349. * Block used to divide 2 vectors
  65350. */
  65351. export class DivideBlock extends NodeMaterialBlock {
  65352. /**
  65353. * Creates a new DivideBlock
  65354. * @param name defines the block name
  65355. */
  65356. constructor(name: string);
  65357. /**
  65358. * Gets the current class name
  65359. * @returns the class name
  65360. */
  65361. getClassName(): string;
  65362. /**
  65363. * Gets the left operand input component
  65364. */
  65365. get left(): NodeMaterialConnectionPoint;
  65366. /**
  65367. * Gets the right operand input component
  65368. */
  65369. get right(): NodeMaterialConnectionPoint;
  65370. /**
  65371. * Gets the output component
  65372. */
  65373. get output(): NodeMaterialConnectionPoint;
  65374. protected _buildBlock(state: NodeMaterialBuildState): this;
  65375. }
  65376. }
  65377. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  65378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65380. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65381. /**
  65382. * Block used to subtract 2 vectors
  65383. */
  65384. export class SubtractBlock extends NodeMaterialBlock {
  65385. /**
  65386. * Creates a new SubtractBlock
  65387. * @param name defines the block name
  65388. */
  65389. constructor(name: string);
  65390. /**
  65391. * Gets the current class name
  65392. * @returns the class name
  65393. */
  65394. getClassName(): string;
  65395. /**
  65396. * Gets the left operand input component
  65397. */
  65398. get left(): NodeMaterialConnectionPoint;
  65399. /**
  65400. * Gets the right operand input component
  65401. */
  65402. get right(): NodeMaterialConnectionPoint;
  65403. /**
  65404. * Gets the output component
  65405. */
  65406. get output(): NodeMaterialConnectionPoint;
  65407. protected _buildBlock(state: NodeMaterialBuildState): this;
  65408. }
  65409. }
  65410. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65414. /**
  65415. * Block used to step a value
  65416. */
  65417. export class StepBlock extends NodeMaterialBlock {
  65418. /**
  65419. * Creates a new StepBlock
  65420. * @param name defines the block name
  65421. */
  65422. constructor(name: string);
  65423. /**
  65424. * Gets the current class name
  65425. * @returns the class name
  65426. */
  65427. getClassName(): string;
  65428. /**
  65429. * Gets the value operand input component
  65430. */
  65431. get value(): NodeMaterialConnectionPoint;
  65432. /**
  65433. * Gets the edge operand input component
  65434. */
  65435. get edge(): NodeMaterialConnectionPoint;
  65436. /**
  65437. * Gets the output component
  65438. */
  65439. get output(): NodeMaterialConnectionPoint;
  65440. protected _buildBlock(state: NodeMaterialBuildState): this;
  65441. }
  65442. }
  65443. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  65444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65447. /**
  65448. * Block used to get the opposite (1 - x) of a value
  65449. */
  65450. export class OneMinusBlock extends NodeMaterialBlock {
  65451. /**
  65452. * Creates a new OneMinusBlock
  65453. * @param name defines the block name
  65454. */
  65455. constructor(name: string);
  65456. /**
  65457. * Gets the current class name
  65458. * @returns the class name
  65459. */
  65460. getClassName(): string;
  65461. /**
  65462. * Gets the input component
  65463. */
  65464. get input(): NodeMaterialConnectionPoint;
  65465. /**
  65466. * Gets the output component
  65467. */
  65468. get output(): NodeMaterialConnectionPoint;
  65469. protected _buildBlock(state: NodeMaterialBuildState): this;
  65470. }
  65471. }
  65472. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  65473. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65474. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65475. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65476. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65477. /**
  65478. * Block used to get the view direction
  65479. */
  65480. export class ViewDirectionBlock extends NodeMaterialBlock {
  65481. /**
  65482. * Creates a new ViewDirectionBlock
  65483. * @param name defines the block name
  65484. */
  65485. constructor(name: string);
  65486. /**
  65487. * Gets the current class name
  65488. * @returns the class name
  65489. */
  65490. getClassName(): string;
  65491. /**
  65492. * Gets the world position component
  65493. */
  65494. get worldPosition(): NodeMaterialConnectionPoint;
  65495. /**
  65496. * Gets the camera position component
  65497. */
  65498. get cameraPosition(): NodeMaterialConnectionPoint;
  65499. /**
  65500. * Gets the output component
  65501. */
  65502. get output(): NodeMaterialConnectionPoint;
  65503. autoConfigure(material: NodeMaterial): void;
  65504. protected _buildBlock(state: NodeMaterialBuildState): this;
  65505. }
  65506. }
  65507. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  65508. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65509. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65510. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65511. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65512. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  65513. /**
  65514. * Block used to compute fresnel value
  65515. */
  65516. export class FresnelBlock extends NodeMaterialBlock {
  65517. /**
  65518. * Create a new FresnelBlock
  65519. * @param name defines the block name
  65520. */
  65521. constructor(name: string);
  65522. /**
  65523. * Gets the current class name
  65524. * @returns the class name
  65525. */
  65526. getClassName(): string;
  65527. /**
  65528. * Gets the world normal input component
  65529. */
  65530. get worldNormal(): NodeMaterialConnectionPoint;
  65531. /**
  65532. * Gets the view direction input component
  65533. */
  65534. get viewDirection(): NodeMaterialConnectionPoint;
  65535. /**
  65536. * Gets the bias input component
  65537. */
  65538. get bias(): NodeMaterialConnectionPoint;
  65539. /**
  65540. * Gets the camera (or eye) position component
  65541. */
  65542. get power(): NodeMaterialConnectionPoint;
  65543. /**
  65544. * Gets the fresnel output component
  65545. */
  65546. get fresnel(): NodeMaterialConnectionPoint;
  65547. autoConfigure(material: NodeMaterial): void;
  65548. protected _buildBlock(state: NodeMaterialBuildState): this;
  65549. }
  65550. }
  65551. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  65552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65555. /**
  65556. * Block used to get the max of 2 values
  65557. */
  65558. export class MaxBlock extends NodeMaterialBlock {
  65559. /**
  65560. * Creates a new MaxBlock
  65561. * @param name defines the block name
  65562. */
  65563. constructor(name: string);
  65564. /**
  65565. * Gets the current class name
  65566. * @returns the class name
  65567. */
  65568. getClassName(): string;
  65569. /**
  65570. * Gets the left operand input component
  65571. */
  65572. get left(): NodeMaterialConnectionPoint;
  65573. /**
  65574. * Gets the right operand input component
  65575. */
  65576. get right(): NodeMaterialConnectionPoint;
  65577. /**
  65578. * Gets the output component
  65579. */
  65580. get output(): NodeMaterialConnectionPoint;
  65581. protected _buildBlock(state: NodeMaterialBuildState): this;
  65582. }
  65583. }
  65584. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  65585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65588. /**
  65589. * Block used to get the min of 2 values
  65590. */
  65591. export class MinBlock extends NodeMaterialBlock {
  65592. /**
  65593. * Creates a new MinBlock
  65594. * @param name defines the block name
  65595. */
  65596. constructor(name: string);
  65597. /**
  65598. * Gets the current class name
  65599. * @returns the class name
  65600. */
  65601. getClassName(): string;
  65602. /**
  65603. * Gets the left operand input component
  65604. */
  65605. get left(): NodeMaterialConnectionPoint;
  65606. /**
  65607. * Gets the right operand input component
  65608. */
  65609. get right(): NodeMaterialConnectionPoint;
  65610. /**
  65611. * Gets the output component
  65612. */
  65613. get output(): NodeMaterialConnectionPoint;
  65614. protected _buildBlock(state: NodeMaterialBuildState): this;
  65615. }
  65616. }
  65617. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  65618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65621. /**
  65622. * Block used to get the distance between 2 values
  65623. */
  65624. export class DistanceBlock extends NodeMaterialBlock {
  65625. /**
  65626. * Creates a new DistanceBlock
  65627. * @param name defines the block name
  65628. */
  65629. constructor(name: string);
  65630. /**
  65631. * Gets the current class name
  65632. * @returns the class name
  65633. */
  65634. getClassName(): string;
  65635. /**
  65636. * Gets the left operand input component
  65637. */
  65638. get left(): NodeMaterialConnectionPoint;
  65639. /**
  65640. * Gets the right operand input component
  65641. */
  65642. get right(): NodeMaterialConnectionPoint;
  65643. /**
  65644. * Gets the output component
  65645. */
  65646. get output(): NodeMaterialConnectionPoint;
  65647. protected _buildBlock(state: NodeMaterialBuildState): this;
  65648. }
  65649. }
  65650. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  65651. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65652. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65653. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65654. /**
  65655. * Block used to get the length of a vector
  65656. */
  65657. export class LengthBlock extends NodeMaterialBlock {
  65658. /**
  65659. * Creates a new LengthBlock
  65660. * @param name defines the block name
  65661. */
  65662. constructor(name: string);
  65663. /**
  65664. * Gets the current class name
  65665. * @returns the class name
  65666. */
  65667. getClassName(): string;
  65668. /**
  65669. * Gets the value input component
  65670. */
  65671. get value(): NodeMaterialConnectionPoint;
  65672. /**
  65673. * Gets the output component
  65674. */
  65675. get output(): NodeMaterialConnectionPoint;
  65676. protected _buildBlock(state: NodeMaterialBuildState): this;
  65677. }
  65678. }
  65679. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  65680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65683. /**
  65684. * Block used to get negative version of a value (i.e. x * -1)
  65685. */
  65686. export class NegateBlock extends NodeMaterialBlock {
  65687. /**
  65688. * Creates a new NegateBlock
  65689. * @param name defines the block name
  65690. */
  65691. constructor(name: string);
  65692. /**
  65693. * Gets the current class name
  65694. * @returns the class name
  65695. */
  65696. getClassName(): string;
  65697. /**
  65698. * Gets the value input component
  65699. */
  65700. get value(): NodeMaterialConnectionPoint;
  65701. /**
  65702. * Gets the output component
  65703. */
  65704. get output(): NodeMaterialConnectionPoint;
  65705. protected _buildBlock(state: NodeMaterialBuildState): this;
  65706. }
  65707. }
  65708. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65710. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65712. /**
  65713. * Block used to get the value of the first parameter raised to the power of the second
  65714. */
  65715. export class PowBlock extends NodeMaterialBlock {
  65716. /**
  65717. * Creates a new PowBlock
  65718. * @param name defines the block name
  65719. */
  65720. constructor(name: string);
  65721. /**
  65722. * Gets the current class name
  65723. * @returns the class name
  65724. */
  65725. getClassName(): string;
  65726. /**
  65727. * Gets the value operand input component
  65728. */
  65729. get value(): NodeMaterialConnectionPoint;
  65730. /**
  65731. * Gets the power operand input component
  65732. */
  65733. get power(): NodeMaterialConnectionPoint;
  65734. /**
  65735. * Gets the output component
  65736. */
  65737. get output(): NodeMaterialConnectionPoint;
  65738. protected _buildBlock(state: NodeMaterialBuildState): this;
  65739. }
  65740. }
  65741. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65745. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65746. /**
  65747. * Block used to get a random number
  65748. */
  65749. export class RandomNumberBlock extends NodeMaterialBlock {
  65750. /**
  65751. * Creates a new RandomNumberBlock
  65752. * @param name defines the block name
  65753. */
  65754. constructor(name: string);
  65755. /**
  65756. * Gets the current class name
  65757. * @returns the class name
  65758. */
  65759. getClassName(): string;
  65760. /**
  65761. * Gets the seed input component
  65762. */
  65763. get seed(): NodeMaterialConnectionPoint;
  65764. /**
  65765. * Gets the output component
  65766. */
  65767. get output(): NodeMaterialConnectionPoint;
  65768. protected _buildBlock(state: NodeMaterialBuildState): this;
  65769. }
  65770. }
  65771. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65773. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65774. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65775. /**
  65776. * Block used to compute arc tangent of 2 values
  65777. */
  65778. export class ArcTan2Block extends NodeMaterialBlock {
  65779. /**
  65780. * Creates a new ArcTan2Block
  65781. * @param name defines the block name
  65782. */
  65783. constructor(name: string);
  65784. /**
  65785. * Gets the current class name
  65786. * @returns the class name
  65787. */
  65788. getClassName(): string;
  65789. /**
  65790. * Gets the x operand input component
  65791. */
  65792. get x(): NodeMaterialConnectionPoint;
  65793. /**
  65794. * Gets the y operand input component
  65795. */
  65796. get y(): NodeMaterialConnectionPoint;
  65797. /**
  65798. * Gets the output component
  65799. */
  65800. get output(): NodeMaterialConnectionPoint;
  65801. protected _buildBlock(state: NodeMaterialBuildState): this;
  65802. }
  65803. }
  65804. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65805. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65808. /**
  65809. * Block used to smooth step a value
  65810. */
  65811. export class SmoothStepBlock extends NodeMaterialBlock {
  65812. /**
  65813. * Creates a new SmoothStepBlock
  65814. * @param name defines the block name
  65815. */
  65816. constructor(name: string);
  65817. /**
  65818. * Gets the current class name
  65819. * @returns the class name
  65820. */
  65821. getClassName(): string;
  65822. /**
  65823. * Gets the value operand input component
  65824. */
  65825. get value(): NodeMaterialConnectionPoint;
  65826. /**
  65827. * Gets the first edge operand input component
  65828. */
  65829. get edge0(): NodeMaterialConnectionPoint;
  65830. /**
  65831. * Gets the second edge operand input component
  65832. */
  65833. get edge1(): NodeMaterialConnectionPoint;
  65834. /**
  65835. * Gets the output component
  65836. */
  65837. get output(): NodeMaterialConnectionPoint;
  65838. protected _buildBlock(state: NodeMaterialBuildState): this;
  65839. }
  65840. }
  65841. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65842. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65843. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65844. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65845. /**
  65846. * Block used to get the reciprocal (1 / x) of a value
  65847. */
  65848. export class ReciprocalBlock extends NodeMaterialBlock {
  65849. /**
  65850. * Creates a new ReciprocalBlock
  65851. * @param name defines the block name
  65852. */
  65853. constructor(name: string);
  65854. /**
  65855. * Gets the current class name
  65856. * @returns the class name
  65857. */
  65858. getClassName(): string;
  65859. /**
  65860. * Gets the input component
  65861. */
  65862. get input(): NodeMaterialConnectionPoint;
  65863. /**
  65864. * Gets the output component
  65865. */
  65866. get output(): NodeMaterialConnectionPoint;
  65867. protected _buildBlock(state: NodeMaterialBuildState): this;
  65868. }
  65869. }
  65870. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65871. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65872. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65873. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65874. /**
  65875. * Block used to replace a color by another one
  65876. */
  65877. export class ReplaceColorBlock extends NodeMaterialBlock {
  65878. /**
  65879. * Creates a new ReplaceColorBlock
  65880. * @param name defines the block name
  65881. */
  65882. constructor(name: string);
  65883. /**
  65884. * Gets the current class name
  65885. * @returns the class name
  65886. */
  65887. getClassName(): string;
  65888. /**
  65889. * Gets the value input component
  65890. */
  65891. get value(): NodeMaterialConnectionPoint;
  65892. /**
  65893. * Gets the reference input component
  65894. */
  65895. get reference(): NodeMaterialConnectionPoint;
  65896. /**
  65897. * Gets the distance input component
  65898. */
  65899. get distance(): NodeMaterialConnectionPoint;
  65900. /**
  65901. * Gets the replacement input component
  65902. */
  65903. get replacement(): NodeMaterialConnectionPoint;
  65904. /**
  65905. * Gets the output component
  65906. */
  65907. get output(): NodeMaterialConnectionPoint;
  65908. protected _buildBlock(state: NodeMaterialBuildState): this;
  65909. }
  65910. }
  65911. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65912. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65914. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65915. /**
  65916. * Block used to posterize a value
  65917. * @see https://en.wikipedia.org/wiki/Posterization
  65918. */
  65919. export class PosterizeBlock extends NodeMaterialBlock {
  65920. /**
  65921. * Creates a new PosterizeBlock
  65922. * @param name defines the block name
  65923. */
  65924. constructor(name: string);
  65925. /**
  65926. * Gets the current class name
  65927. * @returns the class name
  65928. */
  65929. getClassName(): string;
  65930. /**
  65931. * Gets the value input component
  65932. */
  65933. get value(): NodeMaterialConnectionPoint;
  65934. /**
  65935. * Gets the steps input component
  65936. */
  65937. get steps(): NodeMaterialConnectionPoint;
  65938. /**
  65939. * Gets the output component
  65940. */
  65941. get output(): NodeMaterialConnectionPoint;
  65942. protected _buildBlock(state: NodeMaterialBuildState): this;
  65943. }
  65944. }
  65945. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65946. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65947. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65949. import { Scene } from "babylonjs/scene";
  65950. /**
  65951. * Operations supported by the Wave block
  65952. */
  65953. export enum WaveBlockKind {
  65954. /** SawTooth */
  65955. SawTooth = 0,
  65956. /** Square */
  65957. Square = 1,
  65958. /** Triangle */
  65959. Triangle = 2
  65960. }
  65961. /**
  65962. * Block used to apply wave operation to floats
  65963. */
  65964. export class WaveBlock extends NodeMaterialBlock {
  65965. /**
  65966. * Gets or sets the kibnd of wave to be applied by the block
  65967. */
  65968. kind: WaveBlockKind;
  65969. /**
  65970. * Creates a new WaveBlock
  65971. * @param name defines the block name
  65972. */
  65973. constructor(name: string);
  65974. /**
  65975. * Gets the current class name
  65976. * @returns the class name
  65977. */
  65978. getClassName(): string;
  65979. /**
  65980. * Gets the input component
  65981. */
  65982. get input(): NodeMaterialConnectionPoint;
  65983. /**
  65984. * Gets the output component
  65985. */
  65986. get output(): NodeMaterialConnectionPoint;
  65987. protected _buildBlock(state: NodeMaterialBuildState): this;
  65988. serialize(): any;
  65989. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65990. }
  65991. }
  65992. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65993. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65994. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65995. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65996. import { Color3 } from "babylonjs/Maths/math.color";
  65997. import { Scene } from "babylonjs/scene";
  65998. /**
  65999. * Class used to store a color step for the GradientBlock
  66000. */
  66001. export class GradientBlockColorStep {
  66002. /**
  66003. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66004. */
  66005. step: number;
  66006. /**
  66007. * Gets or sets the color associated with this step
  66008. */
  66009. color: Color3;
  66010. /**
  66011. * Creates a new GradientBlockColorStep
  66012. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66013. * @param color defines the color associated with this step
  66014. */
  66015. constructor(
  66016. /**
  66017. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66018. */
  66019. step: number,
  66020. /**
  66021. * Gets or sets the color associated with this step
  66022. */
  66023. color: Color3);
  66024. }
  66025. /**
  66026. * Block used to return a color from a gradient based on an input value between 0 and 1
  66027. */
  66028. export class GradientBlock extends NodeMaterialBlock {
  66029. /**
  66030. * Gets or sets the list of color steps
  66031. */
  66032. colorSteps: GradientBlockColorStep[];
  66033. /**
  66034. * Creates a new GradientBlock
  66035. * @param name defines the block name
  66036. */
  66037. constructor(name: string);
  66038. /**
  66039. * Gets the current class name
  66040. * @returns the class name
  66041. */
  66042. getClassName(): string;
  66043. /**
  66044. * Gets the gradient input component
  66045. */
  66046. get gradient(): NodeMaterialConnectionPoint;
  66047. /**
  66048. * Gets the output component
  66049. */
  66050. get output(): NodeMaterialConnectionPoint;
  66051. private _writeColorConstant;
  66052. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66053. serialize(): any;
  66054. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66055. protected _dumpPropertiesCode(): string;
  66056. }
  66057. }
  66058. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66060. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66061. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66062. /**
  66063. * Block used to normalize lerp between 2 values
  66064. */
  66065. export class NLerpBlock extends NodeMaterialBlock {
  66066. /**
  66067. * Creates a new NLerpBlock
  66068. * @param name defines the block name
  66069. */
  66070. constructor(name: string);
  66071. /**
  66072. * Gets the current class name
  66073. * @returns the class name
  66074. */
  66075. getClassName(): string;
  66076. /**
  66077. * Gets the left operand input component
  66078. */
  66079. get left(): NodeMaterialConnectionPoint;
  66080. /**
  66081. * Gets the right operand input component
  66082. */
  66083. get right(): NodeMaterialConnectionPoint;
  66084. /**
  66085. * Gets the gradient operand input component
  66086. */
  66087. get gradient(): NodeMaterialConnectionPoint;
  66088. /**
  66089. * Gets the output component
  66090. */
  66091. get output(): NodeMaterialConnectionPoint;
  66092. protected _buildBlock(state: NodeMaterialBuildState): this;
  66093. }
  66094. }
  66095. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66096. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66097. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66098. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66099. import { Scene } from "babylonjs/scene";
  66100. /**
  66101. * block used to Generate a Worley Noise 3D Noise Pattern
  66102. */
  66103. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66104. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66105. manhattanDistance: boolean;
  66106. /**
  66107. * Creates a new WorleyNoise3DBlock
  66108. * @param name defines the block name
  66109. */
  66110. constructor(name: string);
  66111. /**
  66112. * Gets the current class name
  66113. * @returns the class name
  66114. */
  66115. getClassName(): string;
  66116. /**
  66117. * Gets the seed input component
  66118. */
  66119. get seed(): NodeMaterialConnectionPoint;
  66120. /**
  66121. * Gets the jitter input component
  66122. */
  66123. get jitter(): NodeMaterialConnectionPoint;
  66124. /**
  66125. * Gets the output component
  66126. */
  66127. get output(): NodeMaterialConnectionPoint;
  66128. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66129. /**
  66130. * Exposes the properties to the UI?
  66131. */
  66132. protected _dumpPropertiesCode(): string;
  66133. /**
  66134. * Exposes the properties to the Seralize?
  66135. */
  66136. serialize(): any;
  66137. /**
  66138. * Exposes the properties to the deseralize?
  66139. */
  66140. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66141. }
  66142. }
  66143. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66147. /**
  66148. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66149. */
  66150. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66151. /**
  66152. * Creates a new SimplexPerlin3DBlock
  66153. * @param name defines the block name
  66154. */
  66155. constructor(name: string);
  66156. /**
  66157. * Gets the current class name
  66158. * @returns the class name
  66159. */
  66160. getClassName(): string;
  66161. /**
  66162. * Gets the seed operand input component
  66163. */
  66164. get seed(): NodeMaterialConnectionPoint;
  66165. /**
  66166. * Gets the output component
  66167. */
  66168. get output(): NodeMaterialConnectionPoint;
  66169. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66170. }
  66171. }
  66172. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66173. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66174. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66176. /**
  66177. * Block used to blend normals
  66178. */
  66179. export class NormalBlendBlock extends NodeMaterialBlock {
  66180. /**
  66181. * Creates a new NormalBlendBlock
  66182. * @param name defines the block name
  66183. */
  66184. constructor(name: string);
  66185. /**
  66186. * Gets the current class name
  66187. * @returns the class name
  66188. */
  66189. getClassName(): string;
  66190. /**
  66191. * Gets the first input component
  66192. */
  66193. get normalMap0(): NodeMaterialConnectionPoint;
  66194. /**
  66195. * Gets the second input component
  66196. */
  66197. get normalMap1(): NodeMaterialConnectionPoint;
  66198. /**
  66199. * Gets the output component
  66200. */
  66201. get output(): NodeMaterialConnectionPoint;
  66202. protected _buildBlock(state: NodeMaterialBuildState): this;
  66203. }
  66204. }
  66205. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66206. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66207. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66208. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66209. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66210. /**
  66211. * Block used to rotate a 2d vector by a given angle
  66212. */
  66213. export class Rotate2dBlock extends NodeMaterialBlock {
  66214. /**
  66215. * Creates a new Rotate2dBlock
  66216. * @param name defines the block name
  66217. */
  66218. constructor(name: string);
  66219. /**
  66220. * Gets the current class name
  66221. * @returns the class name
  66222. */
  66223. getClassName(): string;
  66224. /**
  66225. * Gets the input vector
  66226. */
  66227. get input(): NodeMaterialConnectionPoint;
  66228. /**
  66229. * Gets the input angle
  66230. */
  66231. get angle(): NodeMaterialConnectionPoint;
  66232. /**
  66233. * Gets the output component
  66234. */
  66235. get output(): NodeMaterialConnectionPoint;
  66236. autoConfigure(material: NodeMaterial): void;
  66237. protected _buildBlock(state: NodeMaterialBuildState): this;
  66238. }
  66239. }
  66240. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66241. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66243. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66244. /**
  66245. * Block used to get the reflected vector from a direction and a normal
  66246. */
  66247. export class ReflectBlock extends NodeMaterialBlock {
  66248. /**
  66249. * Creates a new ReflectBlock
  66250. * @param name defines the block name
  66251. */
  66252. constructor(name: string);
  66253. /**
  66254. * Gets the current class name
  66255. * @returns the class name
  66256. */
  66257. getClassName(): string;
  66258. /**
  66259. * Gets the incident component
  66260. */
  66261. get incident(): NodeMaterialConnectionPoint;
  66262. /**
  66263. * Gets the normal component
  66264. */
  66265. get normal(): NodeMaterialConnectionPoint;
  66266. /**
  66267. * Gets the output component
  66268. */
  66269. get output(): NodeMaterialConnectionPoint;
  66270. protected _buildBlock(state: NodeMaterialBuildState): this;
  66271. }
  66272. }
  66273. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66274. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66275. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66276. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66277. /**
  66278. * Block used to get the refracted vector from a direction and a normal
  66279. */
  66280. export class RefractBlock extends NodeMaterialBlock {
  66281. /**
  66282. * Creates a new RefractBlock
  66283. * @param name defines the block name
  66284. */
  66285. constructor(name: string);
  66286. /**
  66287. * Gets the current class name
  66288. * @returns the class name
  66289. */
  66290. getClassName(): string;
  66291. /**
  66292. * Gets the incident component
  66293. */
  66294. get incident(): NodeMaterialConnectionPoint;
  66295. /**
  66296. * Gets the normal component
  66297. */
  66298. get normal(): NodeMaterialConnectionPoint;
  66299. /**
  66300. * Gets the index of refraction component
  66301. */
  66302. get ior(): NodeMaterialConnectionPoint;
  66303. /**
  66304. * Gets the output component
  66305. */
  66306. get output(): NodeMaterialConnectionPoint;
  66307. protected _buildBlock(state: NodeMaterialBuildState): this;
  66308. }
  66309. }
  66310. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66311. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66312. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66313. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66314. /**
  66315. * Block used to desaturate a color
  66316. */
  66317. export class DesaturateBlock extends NodeMaterialBlock {
  66318. /**
  66319. * Creates a new DesaturateBlock
  66320. * @param name defines the block name
  66321. */
  66322. constructor(name: string);
  66323. /**
  66324. * Gets the current class name
  66325. * @returns the class name
  66326. */
  66327. getClassName(): string;
  66328. /**
  66329. * Gets the color operand input component
  66330. */
  66331. get color(): NodeMaterialConnectionPoint;
  66332. /**
  66333. * Gets the level operand input component
  66334. */
  66335. get level(): NodeMaterialConnectionPoint;
  66336. /**
  66337. * Gets the output component
  66338. */
  66339. get output(): NodeMaterialConnectionPoint;
  66340. protected _buildBlock(state: NodeMaterialBuildState): this;
  66341. }
  66342. }
  66343. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66344. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66345. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66346. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66347. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66348. import { Nullable } from "babylonjs/types";
  66349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66350. import { Scene } from "babylonjs/scene";
  66351. /**
  66352. * Block used to implement the ambient occlusion module of the PBR material
  66353. */
  66354. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  66355. /**
  66356. * Create a new AmbientOcclusionBlock
  66357. * @param name defines the block name
  66358. */
  66359. constructor(name: string);
  66360. /**
  66361. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  66362. */
  66363. useAmbientInGrayScale: boolean;
  66364. /**
  66365. * Initialize the block and prepare the context for build
  66366. * @param state defines the state that will be used for the build
  66367. */
  66368. initialize(state: NodeMaterialBuildState): void;
  66369. /**
  66370. * Gets the current class name
  66371. * @returns the class name
  66372. */
  66373. getClassName(): string;
  66374. /**
  66375. * Gets the texture input component
  66376. */
  66377. get texture(): NodeMaterialConnectionPoint;
  66378. /**
  66379. * Gets the texture intensity component
  66380. */
  66381. get intensity(): NodeMaterialConnectionPoint;
  66382. /**
  66383. * Gets the direct light intensity input component
  66384. */
  66385. get directLightIntensity(): NodeMaterialConnectionPoint;
  66386. /**
  66387. * Gets the ambient occlusion object output component
  66388. */
  66389. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66390. /**
  66391. * Gets the main code of the block (fragment side)
  66392. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  66393. * @returns the shader code
  66394. */
  66395. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  66396. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66397. protected _buildBlock(state: NodeMaterialBuildState): this;
  66398. protected _dumpPropertiesCode(): string;
  66399. serialize(): any;
  66400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66401. }
  66402. }
  66403. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66404. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66405. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66406. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66407. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66409. import { Nullable } from "babylonjs/types";
  66410. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66411. import { Mesh } from "babylonjs/Meshes/mesh";
  66412. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66413. import { Effect } from "babylonjs/Materials/effect";
  66414. import { Scene } from "babylonjs/scene";
  66415. /**
  66416. * Block used to implement the reflection module of the PBR material
  66417. */
  66418. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66419. /** @hidden */
  66420. _defineLODReflectionAlpha: string;
  66421. /** @hidden */
  66422. _defineLinearSpecularReflection: string;
  66423. private _vEnvironmentIrradianceName;
  66424. /** @hidden */
  66425. _vReflectionMicrosurfaceInfosName: string;
  66426. /** @hidden */
  66427. _vReflectionInfosName: string;
  66428. /** @hidden */
  66429. _vReflectionFilteringInfoName: string;
  66430. private _scene;
  66431. /**
  66432. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66433. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66434. * It's less burden on the user side in the editor part.
  66435. */
  66436. /** @hidden */
  66437. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66438. /** @hidden */
  66439. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66440. /** @hidden */
  66441. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  66442. /**
  66443. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  66444. * diffuse part of the IBL.
  66445. */
  66446. useSphericalHarmonics: boolean;
  66447. /**
  66448. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  66449. */
  66450. forceIrradianceInFragment: boolean;
  66451. /**
  66452. * Create a new ReflectionBlock
  66453. * @param name defines the block name
  66454. */
  66455. constructor(name: string);
  66456. /**
  66457. * Gets the current class name
  66458. * @returns the class name
  66459. */
  66460. getClassName(): string;
  66461. /**
  66462. * Gets the position input component
  66463. */
  66464. get position(): NodeMaterialConnectionPoint;
  66465. /**
  66466. * Gets the world position input component
  66467. */
  66468. get worldPosition(): NodeMaterialConnectionPoint;
  66469. /**
  66470. * Gets the world normal input component
  66471. */
  66472. get worldNormal(): NodeMaterialConnectionPoint;
  66473. /**
  66474. * Gets the world input component
  66475. */
  66476. get world(): NodeMaterialConnectionPoint;
  66477. /**
  66478. * Gets the camera (or eye) position component
  66479. */
  66480. get cameraPosition(): NodeMaterialConnectionPoint;
  66481. /**
  66482. * Gets the view input component
  66483. */
  66484. get view(): NodeMaterialConnectionPoint;
  66485. /**
  66486. * Gets the color input component
  66487. */
  66488. get color(): NodeMaterialConnectionPoint;
  66489. /**
  66490. * Gets the reflection object output component
  66491. */
  66492. get reflection(): NodeMaterialConnectionPoint;
  66493. /**
  66494. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  66495. */
  66496. get hasTexture(): boolean;
  66497. /**
  66498. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  66499. */
  66500. get reflectionColor(): string;
  66501. protected _getTexture(): Nullable<BaseTexture>;
  66502. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66503. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66504. /**
  66505. * Gets the code to inject in the vertex shader
  66506. * @param state current state of the node material building
  66507. * @returns the shader code
  66508. */
  66509. handleVertexSide(state: NodeMaterialBuildState): string;
  66510. /**
  66511. * Gets the main code of the block (fragment side)
  66512. * @param state current state of the node material building
  66513. * @param normalVarName name of the existing variable corresponding to the normal
  66514. * @returns the shader code
  66515. */
  66516. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  66517. protected _buildBlock(state: NodeMaterialBuildState): this;
  66518. protected _dumpPropertiesCode(): string;
  66519. serialize(): any;
  66520. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66521. }
  66522. }
  66523. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  66524. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66525. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66526. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66527. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66529. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66530. import { Scene } from "babylonjs/scene";
  66531. import { Nullable } from "babylonjs/types";
  66532. /**
  66533. * Block used to implement the sheen module of the PBR material
  66534. */
  66535. export class SheenBlock extends NodeMaterialBlock {
  66536. /**
  66537. * Create a new SheenBlock
  66538. * @param name defines the block name
  66539. */
  66540. constructor(name: string);
  66541. /**
  66542. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  66543. * It allows the strength of the sheen effect to not depend on the base color of the material,
  66544. * making it easier to setup and tweak the effect
  66545. */
  66546. albedoScaling: boolean;
  66547. /**
  66548. * Defines if the sheen is linked to the sheen color.
  66549. */
  66550. linkSheenWithAlbedo: boolean;
  66551. /**
  66552. * Initialize the block and prepare the context for build
  66553. * @param state defines the state that will be used for the build
  66554. */
  66555. initialize(state: NodeMaterialBuildState): void;
  66556. /**
  66557. * Gets the current class name
  66558. * @returns the class name
  66559. */
  66560. getClassName(): string;
  66561. /**
  66562. * Gets the intensity input component
  66563. */
  66564. get intensity(): NodeMaterialConnectionPoint;
  66565. /**
  66566. * Gets the color input component
  66567. */
  66568. get color(): NodeMaterialConnectionPoint;
  66569. /**
  66570. * Gets the roughness input component
  66571. */
  66572. get roughness(): NodeMaterialConnectionPoint;
  66573. /**
  66574. * Gets the sheen object output component
  66575. */
  66576. get sheen(): NodeMaterialConnectionPoint;
  66577. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66578. /**
  66579. * Gets the main code of the block (fragment side)
  66580. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66581. * @returns the shader code
  66582. */
  66583. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  66584. protected _buildBlock(state: NodeMaterialBuildState): this;
  66585. protected _dumpPropertiesCode(): string;
  66586. serialize(): any;
  66587. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66588. }
  66589. }
  66590. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  66591. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66593. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66595. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66596. import { Scene } from "babylonjs/scene";
  66597. import { Nullable } from "babylonjs/types";
  66598. import { Mesh } from "babylonjs/Meshes/mesh";
  66599. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66600. import { Effect } from "babylonjs/Materials/effect";
  66601. /**
  66602. * Block used to implement the reflectivity module of the PBR material
  66603. */
  66604. export class ReflectivityBlock extends NodeMaterialBlock {
  66605. private _metallicReflectanceColor;
  66606. private _metallicF0Factor;
  66607. /** @hidden */
  66608. _vMetallicReflectanceFactorsName: string;
  66609. /**
  66610. * The property below is set by the main PBR block prior to calling methods of this class.
  66611. */
  66612. /** @hidden */
  66613. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  66614. /**
  66615. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  66616. */
  66617. useAmbientOcclusionFromMetallicTextureRed: boolean;
  66618. /**
  66619. * Specifies if the metallic texture contains the metallness information in its blue channel.
  66620. */
  66621. useMetallnessFromMetallicTextureBlue: boolean;
  66622. /**
  66623. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  66624. */
  66625. useRoughnessFromMetallicTextureAlpha: boolean;
  66626. /**
  66627. * Specifies if the metallic texture contains the roughness information in its green channel.
  66628. */
  66629. useRoughnessFromMetallicTextureGreen: boolean;
  66630. /**
  66631. * Create a new ReflectivityBlock
  66632. * @param name defines the block name
  66633. */
  66634. constructor(name: string);
  66635. /**
  66636. * Initialize the block and prepare the context for build
  66637. * @param state defines the state that will be used for the build
  66638. */
  66639. initialize(state: NodeMaterialBuildState): void;
  66640. /**
  66641. * Gets the current class name
  66642. * @returns the class name
  66643. */
  66644. getClassName(): string;
  66645. /**
  66646. * Gets the metallic input component
  66647. */
  66648. get metallic(): NodeMaterialConnectionPoint;
  66649. /**
  66650. * Gets the roughness input component
  66651. */
  66652. get roughness(): NodeMaterialConnectionPoint;
  66653. /**
  66654. * Gets the texture input component
  66655. */
  66656. get texture(): NodeMaterialConnectionPoint;
  66657. /**
  66658. * Gets the reflectivity object output component
  66659. */
  66660. get reflectivity(): NodeMaterialConnectionPoint;
  66661. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66662. /**
  66663. * Gets the main code of the block (fragment side)
  66664. * @param state current state of the node material building
  66665. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  66666. * @returns the shader code
  66667. */
  66668. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  66669. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66670. protected _buildBlock(state: NodeMaterialBuildState): this;
  66671. protected _dumpPropertiesCode(): string;
  66672. serialize(): any;
  66673. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66674. }
  66675. }
  66676. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  66677. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66678. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66679. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66680. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66682. /**
  66683. * Block used to implement the anisotropy module of the PBR material
  66684. */
  66685. export class AnisotropyBlock extends NodeMaterialBlock {
  66686. /**
  66687. * The two properties below are set by the main PBR block prior to calling methods of this class.
  66688. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66689. * It's less burden on the user side in the editor part.
  66690. */
  66691. /** @hidden */
  66692. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66693. /** @hidden */
  66694. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66695. /**
  66696. * Create a new AnisotropyBlock
  66697. * @param name defines the block name
  66698. */
  66699. constructor(name: string);
  66700. /**
  66701. * Initialize the block and prepare the context for build
  66702. * @param state defines the state that will be used for the build
  66703. */
  66704. initialize(state: NodeMaterialBuildState): void;
  66705. /**
  66706. * Gets the current class name
  66707. * @returns the class name
  66708. */
  66709. getClassName(): string;
  66710. /**
  66711. * Gets the intensity input component
  66712. */
  66713. get intensity(): NodeMaterialConnectionPoint;
  66714. /**
  66715. * Gets the direction input component
  66716. */
  66717. get direction(): NodeMaterialConnectionPoint;
  66718. /**
  66719. * Gets the texture input component
  66720. */
  66721. get texture(): NodeMaterialConnectionPoint;
  66722. /**
  66723. * Gets the uv input component
  66724. */
  66725. get uv(): NodeMaterialConnectionPoint;
  66726. /**
  66727. * Gets the worldTangent input component
  66728. */
  66729. get worldTangent(): NodeMaterialConnectionPoint;
  66730. /**
  66731. * Gets the anisotropy object output component
  66732. */
  66733. get anisotropy(): NodeMaterialConnectionPoint;
  66734. private _generateTBNSpace;
  66735. /**
  66736. * Gets the main code of the block (fragment side)
  66737. * @param state current state of the node material building
  66738. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66739. * @returns the shader code
  66740. */
  66741. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66742. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66743. protected _buildBlock(state: NodeMaterialBuildState): this;
  66744. }
  66745. }
  66746. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66747. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66748. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66749. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66750. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66752. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66753. import { Nullable } from "babylonjs/types";
  66754. import { Mesh } from "babylonjs/Meshes/mesh";
  66755. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66756. import { Effect } from "babylonjs/Materials/effect";
  66757. /**
  66758. * Block used to implement the clear coat module of the PBR material
  66759. */
  66760. export class ClearCoatBlock extends NodeMaterialBlock {
  66761. private _scene;
  66762. /**
  66763. * Create a new ClearCoatBlock
  66764. * @param name defines the block name
  66765. */
  66766. constructor(name: string);
  66767. /**
  66768. * Initialize the block and prepare the context for build
  66769. * @param state defines the state that will be used for the build
  66770. */
  66771. initialize(state: NodeMaterialBuildState): void;
  66772. /**
  66773. * Gets the current class name
  66774. * @returns the class name
  66775. */
  66776. getClassName(): string;
  66777. /**
  66778. * Gets the intensity input component
  66779. */
  66780. get intensity(): NodeMaterialConnectionPoint;
  66781. /**
  66782. * Gets the roughness input component
  66783. */
  66784. get roughness(): NodeMaterialConnectionPoint;
  66785. /**
  66786. * Gets the ior input component
  66787. */
  66788. get ior(): NodeMaterialConnectionPoint;
  66789. /**
  66790. * Gets the texture input component
  66791. */
  66792. get texture(): NodeMaterialConnectionPoint;
  66793. /**
  66794. * Gets the bump texture input component
  66795. */
  66796. get bumpTexture(): NodeMaterialConnectionPoint;
  66797. /**
  66798. * Gets the uv input component
  66799. */
  66800. get uv(): NodeMaterialConnectionPoint;
  66801. /**
  66802. * Gets the tint color input component
  66803. */
  66804. get tintColor(): NodeMaterialConnectionPoint;
  66805. /**
  66806. * Gets the tint "at distance" input component
  66807. */
  66808. get tintAtDistance(): NodeMaterialConnectionPoint;
  66809. /**
  66810. * Gets the tint thickness input component
  66811. */
  66812. get tintThickness(): NodeMaterialConnectionPoint;
  66813. /**
  66814. * Gets the world tangent input component
  66815. */
  66816. get worldTangent(): NodeMaterialConnectionPoint;
  66817. /**
  66818. * Gets the clear coat object output component
  66819. */
  66820. get clearcoat(): NodeMaterialConnectionPoint;
  66821. autoConfigure(material: NodeMaterial): void;
  66822. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66823. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66824. private _generateTBNSpace;
  66825. /**
  66826. * Gets the main code of the block (fragment side)
  66827. * @param state current state of the node material building
  66828. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66829. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66830. * @param worldPosVarName name of the variable holding the world position
  66831. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66832. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66833. * @param worldNormalVarName name of the variable holding the world normal
  66834. * @returns the shader code
  66835. */
  66836. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66837. protected _buildBlock(state: NodeMaterialBuildState): this;
  66838. }
  66839. }
  66840. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66844. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66846. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66847. import { Nullable } from "babylonjs/types";
  66848. /**
  66849. * Block used to implement the sub surface module of the PBR material
  66850. */
  66851. export class SubSurfaceBlock extends NodeMaterialBlock {
  66852. /**
  66853. * Create a new SubSurfaceBlock
  66854. * @param name defines the block name
  66855. */
  66856. constructor(name: string);
  66857. /**
  66858. * Stores the intensity of the different subsurface effects in the thickness texture.
  66859. * * the green channel is the translucency intensity.
  66860. * * the blue channel is the scattering intensity.
  66861. * * the alpha channel is the refraction intensity.
  66862. */
  66863. useMaskFromThicknessTexture: boolean;
  66864. /**
  66865. * Initialize the block and prepare the context for build
  66866. * @param state defines the state that will be used for the build
  66867. */
  66868. initialize(state: NodeMaterialBuildState): void;
  66869. /**
  66870. * Gets the current class name
  66871. * @returns the class name
  66872. */
  66873. getClassName(): string;
  66874. /**
  66875. * Gets the min thickness input component
  66876. */
  66877. get minThickness(): NodeMaterialConnectionPoint;
  66878. /**
  66879. * Gets the max thickness input component
  66880. */
  66881. get maxThickness(): NodeMaterialConnectionPoint;
  66882. /**
  66883. * Gets the thickness texture component
  66884. */
  66885. get thicknessTexture(): NodeMaterialConnectionPoint;
  66886. /**
  66887. * Gets the tint color input component
  66888. */
  66889. get tintColor(): NodeMaterialConnectionPoint;
  66890. /**
  66891. * Gets the translucency intensity input component
  66892. */
  66893. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66894. /**
  66895. * Gets the translucency diffusion distance input component
  66896. */
  66897. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66898. /**
  66899. * Gets the refraction object parameters
  66900. */
  66901. get refraction(): NodeMaterialConnectionPoint;
  66902. /**
  66903. * Gets the sub surface object output component
  66904. */
  66905. get subsurface(): NodeMaterialConnectionPoint;
  66906. autoConfigure(material: NodeMaterial): void;
  66907. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66908. /**
  66909. * Gets the main code of the block (fragment side)
  66910. * @param state current state of the node material building
  66911. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66912. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66913. * @param worldPosVarName name of the variable holding the world position
  66914. * @returns the shader code
  66915. */
  66916. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66917. protected _buildBlock(state: NodeMaterialBuildState): this;
  66918. }
  66919. }
  66920. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66924. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66925. import { Light } from "babylonjs/Lights/light";
  66926. import { Nullable } from "babylonjs/types";
  66927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66928. import { Effect } from "babylonjs/Materials/effect";
  66929. import { Mesh } from "babylonjs/Meshes/mesh";
  66930. import { Scene } from "babylonjs/scene";
  66931. /**
  66932. * Block used to implement the PBR metallic/roughness model
  66933. */
  66934. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66935. /**
  66936. * Gets or sets the light associated with this block
  66937. */
  66938. light: Nullable<Light>;
  66939. private _lightId;
  66940. private _scene;
  66941. private _environmentBRDFTexture;
  66942. private _environmentBrdfSamplerName;
  66943. private _vNormalWName;
  66944. private _invertNormalName;
  66945. /**
  66946. * Create a new ReflectionBlock
  66947. * @param name defines the block name
  66948. */
  66949. constructor(name: string);
  66950. /**
  66951. * Intensity of the direct lights e.g. the four lights available in your scene.
  66952. * This impacts both the direct diffuse and specular highlights.
  66953. */
  66954. directIntensity: number;
  66955. /**
  66956. * Intensity of the environment e.g. how much the environment will light the object
  66957. * either through harmonics for rough material or through the refelction for shiny ones.
  66958. */
  66959. environmentIntensity: number;
  66960. /**
  66961. * This is a special control allowing the reduction of the specular highlights coming from the
  66962. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66963. */
  66964. specularIntensity: number;
  66965. /**
  66966. * Defines the falloff type used in this material.
  66967. * It by default is Physical.
  66968. */
  66969. lightFalloff: number;
  66970. /**
  66971. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66972. */
  66973. useAlphaFromAlbedoTexture: boolean;
  66974. /**
  66975. * Specifies that alpha test should be used
  66976. */
  66977. useAlphaTest: boolean;
  66978. /**
  66979. * Defines the alpha limits in alpha test mode.
  66980. */
  66981. alphaTestCutoff: number;
  66982. /**
  66983. * Specifies that alpha blending should be used
  66984. */
  66985. useAlphaBlending: boolean;
  66986. /**
  66987. * Defines if the alpha value should be determined via the rgb values.
  66988. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66989. */
  66990. opacityRGB: boolean;
  66991. /**
  66992. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66993. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66994. */
  66995. useRadianceOverAlpha: boolean;
  66996. /**
  66997. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66998. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66999. */
  67000. useSpecularOverAlpha: boolean;
  67001. /**
  67002. * Enables specular anti aliasing in the PBR shader.
  67003. * It will both interacts on the Geometry for analytical and IBL lighting.
  67004. * It also prefilter the roughness map based on the bump values.
  67005. */
  67006. enableSpecularAntiAliasing: boolean;
  67007. /**
  67008. * Enables realtime filtering on the texture.
  67009. */
  67010. realTimeFiltering: boolean;
  67011. /**
  67012. * Quality switch for realtime filtering
  67013. */
  67014. realTimeFilteringQuality: number;
  67015. /**
  67016. * Defines if the material uses energy conservation.
  67017. */
  67018. useEnergyConservation: boolean;
  67019. /**
  67020. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67021. * too much the area relying on ambient texture to define their ambient occlusion.
  67022. */
  67023. useRadianceOcclusion: boolean;
  67024. /**
  67025. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67026. * makes the reflect vector face the model (under horizon).
  67027. */
  67028. useHorizonOcclusion: boolean;
  67029. /**
  67030. * If set to true, no lighting calculations will be applied.
  67031. */
  67032. unlit: boolean;
  67033. /**
  67034. * Force normal to face away from face.
  67035. */
  67036. forceNormalForward: boolean;
  67037. /**
  67038. * Defines the material debug mode.
  67039. * It helps seeing only some components of the material while troubleshooting.
  67040. */
  67041. debugMode: number;
  67042. /**
  67043. * Specify from where on screen the debug mode should start.
  67044. * The value goes from -1 (full screen) to 1 (not visible)
  67045. * It helps with side by side comparison against the final render
  67046. * This defaults to 0
  67047. */
  67048. debugLimit: number;
  67049. /**
  67050. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67051. * You can use the factor to better multiply the final value.
  67052. */
  67053. debugFactor: number;
  67054. /**
  67055. * Initialize the block and prepare the context for build
  67056. * @param state defines the state that will be used for the build
  67057. */
  67058. initialize(state: NodeMaterialBuildState): void;
  67059. /**
  67060. * Gets the current class name
  67061. * @returns the class name
  67062. */
  67063. getClassName(): string;
  67064. /**
  67065. * Gets the world position input component
  67066. */
  67067. get worldPosition(): NodeMaterialConnectionPoint;
  67068. /**
  67069. * Gets the world normal input component
  67070. */
  67071. get worldNormal(): NodeMaterialConnectionPoint;
  67072. /**
  67073. * Gets the perturbed normal input component
  67074. */
  67075. get perturbedNormal(): NodeMaterialConnectionPoint;
  67076. /**
  67077. * Gets the camera position input component
  67078. */
  67079. get cameraPosition(): NodeMaterialConnectionPoint;
  67080. /**
  67081. * Gets the base color input component
  67082. */
  67083. get baseColor(): NodeMaterialConnectionPoint;
  67084. /**
  67085. * Gets the opacity texture input component
  67086. */
  67087. get opacityTexture(): NodeMaterialConnectionPoint;
  67088. /**
  67089. * Gets the ambient color input component
  67090. */
  67091. get ambientColor(): NodeMaterialConnectionPoint;
  67092. /**
  67093. * Gets the reflectivity object parameters
  67094. */
  67095. get reflectivity(): NodeMaterialConnectionPoint;
  67096. /**
  67097. * Gets the ambient occlusion object parameters
  67098. */
  67099. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67100. /**
  67101. * Gets the reflection object parameters
  67102. */
  67103. get reflection(): NodeMaterialConnectionPoint;
  67104. /**
  67105. * Gets the sheen object parameters
  67106. */
  67107. get sheen(): NodeMaterialConnectionPoint;
  67108. /**
  67109. * Gets the clear coat object parameters
  67110. */
  67111. get clearcoat(): NodeMaterialConnectionPoint;
  67112. /**
  67113. * Gets the sub surface object parameters
  67114. */
  67115. get subsurface(): NodeMaterialConnectionPoint;
  67116. /**
  67117. * Gets the anisotropy object parameters
  67118. */
  67119. get anisotropy(): NodeMaterialConnectionPoint;
  67120. /**
  67121. * Gets the ambient output component
  67122. */
  67123. get ambient(): NodeMaterialConnectionPoint;
  67124. /**
  67125. * Gets the diffuse output component
  67126. */
  67127. get diffuse(): NodeMaterialConnectionPoint;
  67128. /**
  67129. * Gets the specular output component
  67130. */
  67131. get specular(): NodeMaterialConnectionPoint;
  67132. /**
  67133. * Gets the sheen output component
  67134. */
  67135. get sheenDir(): NodeMaterialConnectionPoint;
  67136. /**
  67137. * Gets the clear coat output component
  67138. */
  67139. get clearcoatDir(): NodeMaterialConnectionPoint;
  67140. /**
  67141. * Gets the indirect diffuse output component
  67142. */
  67143. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67144. /**
  67145. * Gets the indirect specular output component
  67146. */
  67147. get specularIndirect(): NodeMaterialConnectionPoint;
  67148. /**
  67149. * Gets the indirect sheen output component
  67150. */
  67151. get sheenIndirect(): NodeMaterialConnectionPoint;
  67152. /**
  67153. * Gets the indirect clear coat output component
  67154. */
  67155. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67156. /**
  67157. * Gets the refraction output component
  67158. */
  67159. get refraction(): NodeMaterialConnectionPoint;
  67160. /**
  67161. * Gets the global lighting output component
  67162. */
  67163. get lighting(): NodeMaterialConnectionPoint;
  67164. /**
  67165. * Gets the shadow output component
  67166. */
  67167. get shadow(): NodeMaterialConnectionPoint;
  67168. /**
  67169. * Gets the alpha output component
  67170. */
  67171. get alpha(): NodeMaterialConnectionPoint;
  67172. autoConfigure(material: NodeMaterial): void;
  67173. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67174. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67175. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67176. private _injectVertexCode;
  67177. /**
  67178. * Gets the code corresponding to the albedo/opacity module
  67179. * @returns the shader code
  67180. */
  67181. getAlbedoOpacityCode(): string;
  67182. protected _buildBlock(state: NodeMaterialBuildState): this;
  67183. protected _dumpPropertiesCode(): string;
  67184. serialize(): any;
  67185. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67186. }
  67187. }
  67188. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67189. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67190. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67191. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67192. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67193. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67194. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67195. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67196. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67197. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67198. }
  67199. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67200. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67201. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67202. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67203. }
  67204. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67205. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67206. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67207. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67208. /**
  67209. * Block used to compute value of one parameter modulo another
  67210. */
  67211. export class ModBlock extends NodeMaterialBlock {
  67212. /**
  67213. * Creates a new ModBlock
  67214. * @param name defines the block name
  67215. */
  67216. constructor(name: string);
  67217. /**
  67218. * Gets the current class name
  67219. * @returns the class name
  67220. */
  67221. getClassName(): string;
  67222. /**
  67223. * Gets the left operand input component
  67224. */
  67225. get left(): NodeMaterialConnectionPoint;
  67226. /**
  67227. * Gets the right operand input component
  67228. */
  67229. get right(): NodeMaterialConnectionPoint;
  67230. /**
  67231. * Gets the output component
  67232. */
  67233. get output(): NodeMaterialConnectionPoint;
  67234. protected _buildBlock(state: NodeMaterialBuildState): this;
  67235. }
  67236. }
  67237. declare module "babylonjs/Materials/Node/Blocks/index" {
  67238. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67239. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67240. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67241. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67242. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67243. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67244. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67245. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67246. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67247. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67248. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67249. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67250. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67251. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67252. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67253. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67254. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67255. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67256. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67257. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67258. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67259. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67260. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67261. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67262. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67263. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67264. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67265. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67266. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67267. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67268. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67269. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67270. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67271. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67272. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67273. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67274. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67275. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67276. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67277. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67278. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67279. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67280. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67281. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67282. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67283. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67284. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67285. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67286. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67287. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67288. }
  67289. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67290. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67291. }
  67292. declare module "babylonjs/Materials/Node/index" {
  67293. export * from "babylonjs/Materials/Node/Enums/index";
  67294. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67295. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67296. export * from "babylonjs/Materials/Node/nodeMaterial";
  67297. export * from "babylonjs/Materials/Node/Blocks/index";
  67298. export * from "babylonjs/Materials/Node/Optimizers/index";
  67299. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67300. }
  67301. declare module "babylonjs/Materials/index" {
  67302. export * from "babylonjs/Materials/Background/index";
  67303. export * from "babylonjs/Materials/colorCurves";
  67304. export * from "babylonjs/Materials/iEffectFallbacks";
  67305. export * from "babylonjs/Materials/effectFallbacks";
  67306. export * from "babylonjs/Materials/effect";
  67307. export * from "babylonjs/Materials/fresnelParameters";
  67308. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67309. export * from "babylonjs/Materials/material";
  67310. export * from "babylonjs/Materials/materialDefines";
  67311. export * from "babylonjs/Materials/materialHelper";
  67312. export * from "babylonjs/Materials/multiMaterial";
  67313. export * from "babylonjs/Materials/PBR/index";
  67314. export * from "babylonjs/Materials/pushMaterial";
  67315. export * from "babylonjs/Materials/shaderMaterial";
  67316. export * from "babylonjs/Materials/standardMaterial";
  67317. export * from "babylonjs/Materials/Textures/index";
  67318. export * from "babylonjs/Materials/uniformBuffer";
  67319. export * from "babylonjs/Materials/materialFlags";
  67320. export * from "babylonjs/Materials/Node/index";
  67321. export * from "babylonjs/Materials/effectRenderer";
  67322. export * from "babylonjs/Materials/shadowDepthWrapper";
  67323. }
  67324. declare module "babylonjs/Maths/index" {
  67325. export * from "babylonjs/Maths/math.scalar";
  67326. export * from "babylonjs/Maths/math";
  67327. export * from "babylonjs/Maths/sphericalPolynomial";
  67328. }
  67329. declare module "babylonjs/Misc/workerPool" {
  67330. import { IDisposable } from "babylonjs/scene";
  67331. /**
  67332. * Helper class to push actions to a pool of workers.
  67333. */
  67334. export class WorkerPool implements IDisposable {
  67335. private _workerInfos;
  67336. private _pendingActions;
  67337. /**
  67338. * Constructor
  67339. * @param workers Array of workers to use for actions
  67340. */
  67341. constructor(workers: Array<Worker>);
  67342. /**
  67343. * Terminates all workers and clears any pending actions.
  67344. */
  67345. dispose(): void;
  67346. /**
  67347. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67348. * pended until a worker has completed its action.
  67349. * @param action The action to perform. Call onComplete when the action is complete.
  67350. */
  67351. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67352. private _execute;
  67353. }
  67354. }
  67355. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  67356. import { IDisposable } from "babylonjs/scene";
  67357. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67358. /**
  67359. * Configuration for Draco compression
  67360. */
  67361. export interface IDracoCompressionConfiguration {
  67362. /**
  67363. * Configuration for the decoder.
  67364. */
  67365. decoder: {
  67366. /**
  67367. * The url to the WebAssembly module.
  67368. */
  67369. wasmUrl?: string;
  67370. /**
  67371. * The url to the WebAssembly binary.
  67372. */
  67373. wasmBinaryUrl?: string;
  67374. /**
  67375. * The url to the fallback JavaScript module.
  67376. */
  67377. fallbackUrl?: string;
  67378. };
  67379. }
  67380. /**
  67381. * Draco compression (https://google.github.io/draco/)
  67382. *
  67383. * This class wraps the Draco module.
  67384. *
  67385. * **Encoder**
  67386. *
  67387. * The encoder is not currently implemented.
  67388. *
  67389. * **Decoder**
  67390. *
  67391. * 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.
  67392. *
  67393. * To update the configuration, use the following code:
  67394. * ```javascript
  67395. * DracoCompression.Configuration = {
  67396. * decoder: {
  67397. * wasmUrl: "<url to the WebAssembly library>",
  67398. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67399. * fallbackUrl: "<url to the fallback JavaScript library>",
  67400. * }
  67401. * };
  67402. * ```
  67403. *
  67404. * 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.
  67405. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67406. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67407. *
  67408. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67409. * ```javascript
  67410. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67411. * ```
  67412. *
  67413. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67414. */
  67415. export class DracoCompression implements IDisposable {
  67416. private _workerPoolPromise?;
  67417. private _decoderModulePromise?;
  67418. /**
  67419. * The configuration. Defaults to the following urls:
  67420. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67421. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67422. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67423. */
  67424. static Configuration: IDracoCompressionConfiguration;
  67425. /**
  67426. * Returns true if the decoder configuration is available.
  67427. */
  67428. static get DecoderAvailable(): boolean;
  67429. /**
  67430. * Default number of workers to create when creating the draco compression object.
  67431. */
  67432. static DefaultNumWorkers: number;
  67433. private static GetDefaultNumWorkers;
  67434. private static _Default;
  67435. /**
  67436. * Default instance for the draco compression object.
  67437. */
  67438. static get Default(): DracoCompression;
  67439. /**
  67440. * Constructor
  67441. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  67442. */
  67443. constructor(numWorkers?: number);
  67444. /**
  67445. * Stop all async operations and release resources.
  67446. */
  67447. dispose(): void;
  67448. /**
  67449. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  67450. * @returns a promise that resolves when ready
  67451. */
  67452. whenReadyAsync(): Promise<void>;
  67453. /**
  67454. * Decode Draco compressed mesh data to vertex data.
  67455. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  67456. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  67457. * @returns A promise that resolves with the decoded vertex data
  67458. */
  67459. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  67460. [kind: string]: number;
  67461. }): Promise<VertexData>;
  67462. }
  67463. }
  67464. declare module "babylonjs/Meshes/Compression/index" {
  67465. export * from "babylonjs/Meshes/Compression/dracoCompression";
  67466. }
  67467. declare module "babylonjs/Meshes/csg" {
  67468. import { Nullable } from "babylonjs/types";
  67469. import { Scene } from "babylonjs/scene";
  67470. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67471. import { Mesh } from "babylonjs/Meshes/mesh";
  67472. import { Material } from "babylonjs/Materials/material";
  67473. /**
  67474. * Class for building Constructive Solid Geometry
  67475. */
  67476. export class CSG {
  67477. private polygons;
  67478. /**
  67479. * The world matrix
  67480. */
  67481. matrix: Matrix;
  67482. /**
  67483. * Stores the position
  67484. */
  67485. position: Vector3;
  67486. /**
  67487. * Stores the rotation
  67488. */
  67489. rotation: Vector3;
  67490. /**
  67491. * Stores the rotation quaternion
  67492. */
  67493. rotationQuaternion: Nullable<Quaternion>;
  67494. /**
  67495. * Stores the scaling vector
  67496. */
  67497. scaling: Vector3;
  67498. /**
  67499. * Convert the Mesh to CSG
  67500. * @param mesh The Mesh to convert to CSG
  67501. * @returns A new CSG from the Mesh
  67502. */
  67503. static FromMesh(mesh: Mesh): CSG;
  67504. /**
  67505. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  67506. * @param polygons Polygons used to construct a CSG solid
  67507. */
  67508. private static FromPolygons;
  67509. /**
  67510. * Clones, or makes a deep copy, of the CSG
  67511. * @returns A new CSG
  67512. */
  67513. clone(): CSG;
  67514. /**
  67515. * Unions this CSG with another CSG
  67516. * @param csg The CSG to union against this CSG
  67517. * @returns The unioned CSG
  67518. */
  67519. union(csg: CSG): CSG;
  67520. /**
  67521. * Unions this CSG with another CSG in place
  67522. * @param csg The CSG to union against this CSG
  67523. */
  67524. unionInPlace(csg: CSG): void;
  67525. /**
  67526. * Subtracts this CSG with another CSG
  67527. * @param csg The CSG to subtract against this CSG
  67528. * @returns A new CSG
  67529. */
  67530. subtract(csg: CSG): CSG;
  67531. /**
  67532. * Subtracts this CSG with another CSG in place
  67533. * @param csg The CSG to subtact against this CSG
  67534. */
  67535. subtractInPlace(csg: CSG): void;
  67536. /**
  67537. * Intersect this CSG with another CSG
  67538. * @param csg The CSG to intersect against this CSG
  67539. * @returns A new CSG
  67540. */
  67541. intersect(csg: CSG): CSG;
  67542. /**
  67543. * Intersects this CSG with another CSG in place
  67544. * @param csg The CSG to intersect against this CSG
  67545. */
  67546. intersectInPlace(csg: CSG): void;
  67547. /**
  67548. * Return a new CSG solid with solid and empty space switched. This solid is
  67549. * not modified.
  67550. * @returns A new CSG solid with solid and empty space switched
  67551. */
  67552. inverse(): CSG;
  67553. /**
  67554. * Inverses the CSG in place
  67555. */
  67556. inverseInPlace(): void;
  67557. /**
  67558. * This is used to keep meshes transformations so they can be restored
  67559. * when we build back a Babylon Mesh
  67560. * NB : All CSG operations are performed in world coordinates
  67561. * @param csg The CSG to copy the transform attributes from
  67562. * @returns This CSG
  67563. */
  67564. copyTransformAttributes(csg: CSG): CSG;
  67565. /**
  67566. * Build Raw mesh from CSG
  67567. * Coordinates here are in world space
  67568. * @param name The name of the mesh geometry
  67569. * @param scene The Scene
  67570. * @param keepSubMeshes Specifies if the submeshes should be kept
  67571. * @returns A new Mesh
  67572. */
  67573. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67574. /**
  67575. * Build Mesh from CSG taking material and transforms into account
  67576. * @param name The name of the Mesh
  67577. * @param material The material of the Mesh
  67578. * @param scene The Scene
  67579. * @param keepSubMeshes Specifies if submeshes should be kept
  67580. * @returns The new Mesh
  67581. */
  67582. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67583. }
  67584. }
  67585. declare module "babylonjs/Meshes/trailMesh" {
  67586. import { Mesh } from "babylonjs/Meshes/mesh";
  67587. import { Scene } from "babylonjs/scene";
  67588. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67589. /**
  67590. * Class used to create a trail following a mesh
  67591. */
  67592. export class TrailMesh extends Mesh {
  67593. private _generator;
  67594. private _autoStart;
  67595. private _running;
  67596. private _diameter;
  67597. private _length;
  67598. private _sectionPolygonPointsCount;
  67599. private _sectionVectors;
  67600. private _sectionNormalVectors;
  67601. private _beforeRenderObserver;
  67602. /**
  67603. * @constructor
  67604. * @param name The value used by scene.getMeshByName() to do a lookup.
  67605. * @param generator The mesh or transform node to generate a trail.
  67606. * @param scene The scene to add this mesh to.
  67607. * @param diameter Diameter of trailing mesh. Default is 1.
  67608. * @param length Length of trailing mesh. Default is 60.
  67609. * @param autoStart Automatically start trailing mesh. Default true.
  67610. */
  67611. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  67612. /**
  67613. * "TrailMesh"
  67614. * @returns "TrailMesh"
  67615. */
  67616. getClassName(): string;
  67617. private _createMesh;
  67618. /**
  67619. * Start trailing mesh.
  67620. */
  67621. start(): void;
  67622. /**
  67623. * Stop trailing mesh.
  67624. */
  67625. stop(): void;
  67626. /**
  67627. * Update trailing mesh geometry.
  67628. */
  67629. update(): void;
  67630. /**
  67631. * Returns a new TrailMesh object.
  67632. * @param name is a string, the name given to the new mesh
  67633. * @param newGenerator use new generator object for cloned trail mesh
  67634. * @returns a new mesh
  67635. */
  67636. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  67637. /**
  67638. * Serializes this trail mesh
  67639. * @param serializationObject object to write serialization to
  67640. */
  67641. serialize(serializationObject: any): void;
  67642. /**
  67643. * Parses a serialized trail mesh
  67644. * @param parsedMesh the serialized mesh
  67645. * @param scene the scene to create the trail mesh in
  67646. * @returns the created trail mesh
  67647. */
  67648. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  67649. }
  67650. }
  67651. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  67652. import { Nullable } from "babylonjs/types";
  67653. import { Scene } from "babylonjs/scene";
  67654. import { Vector4 } from "babylonjs/Maths/math.vector";
  67655. import { Color4 } from "babylonjs/Maths/math.color";
  67656. import { Mesh } from "babylonjs/Meshes/mesh";
  67657. /**
  67658. * Class containing static functions to help procedurally build meshes
  67659. */
  67660. export class TiledBoxBuilder {
  67661. /**
  67662. * Creates a box mesh
  67663. * 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)
  67664. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67668. * @param name defines the name of the mesh
  67669. * @param options defines the options used to create the mesh
  67670. * @param scene defines the hosting scene
  67671. * @returns the box mesh
  67672. */
  67673. static CreateTiledBox(name: string, options: {
  67674. pattern?: number;
  67675. width?: number;
  67676. height?: number;
  67677. depth?: number;
  67678. tileSize?: number;
  67679. tileWidth?: number;
  67680. tileHeight?: number;
  67681. alignHorizontal?: number;
  67682. alignVertical?: number;
  67683. faceUV?: Vector4[];
  67684. faceColors?: Color4[];
  67685. sideOrientation?: number;
  67686. updatable?: boolean;
  67687. }, scene?: Nullable<Scene>): Mesh;
  67688. }
  67689. }
  67690. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  67691. import { Vector4 } from "babylonjs/Maths/math.vector";
  67692. import { Mesh } from "babylonjs/Meshes/mesh";
  67693. /**
  67694. * Class containing static functions to help procedurally build meshes
  67695. */
  67696. export class TorusKnotBuilder {
  67697. /**
  67698. * Creates a torus knot mesh
  67699. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67700. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67701. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67702. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67706. * @param name defines the name of the mesh
  67707. * @param options defines the options used to create the mesh
  67708. * @param scene defines the hosting scene
  67709. * @returns the torus knot mesh
  67710. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67711. */
  67712. static CreateTorusKnot(name: string, options: {
  67713. radius?: number;
  67714. tube?: number;
  67715. radialSegments?: number;
  67716. tubularSegments?: number;
  67717. p?: number;
  67718. q?: number;
  67719. updatable?: boolean;
  67720. sideOrientation?: number;
  67721. frontUVs?: Vector4;
  67722. backUVs?: Vector4;
  67723. }, scene: any): Mesh;
  67724. }
  67725. }
  67726. declare module "babylonjs/Meshes/polygonMesh" {
  67727. import { Scene } from "babylonjs/scene";
  67728. import { Vector2 } from "babylonjs/Maths/math.vector";
  67729. import { Mesh } from "babylonjs/Meshes/mesh";
  67730. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67731. import { Path2 } from "babylonjs/Maths/math.path";
  67732. /**
  67733. * Polygon
  67734. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  67735. */
  67736. export class Polygon {
  67737. /**
  67738. * Creates a rectangle
  67739. * @param xmin bottom X coord
  67740. * @param ymin bottom Y coord
  67741. * @param xmax top X coord
  67742. * @param ymax top Y coord
  67743. * @returns points that make the resulting rectation
  67744. */
  67745. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67746. /**
  67747. * Creates a circle
  67748. * @param radius radius of circle
  67749. * @param cx scale in x
  67750. * @param cy scale in y
  67751. * @param numberOfSides number of sides that make up the circle
  67752. * @returns points that make the resulting circle
  67753. */
  67754. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67755. /**
  67756. * Creates a polygon from input string
  67757. * @param input Input polygon data
  67758. * @returns the parsed points
  67759. */
  67760. static Parse(input: string): Vector2[];
  67761. /**
  67762. * Starts building a polygon from x and y coordinates
  67763. * @param x x coordinate
  67764. * @param y y coordinate
  67765. * @returns the started path2
  67766. */
  67767. static StartingAt(x: number, y: number): Path2;
  67768. }
  67769. /**
  67770. * Builds a polygon
  67771. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67772. */
  67773. export class PolygonMeshBuilder {
  67774. private _points;
  67775. private _outlinepoints;
  67776. private _holes;
  67777. private _name;
  67778. private _scene;
  67779. private _epoints;
  67780. private _eholes;
  67781. private _addToepoint;
  67782. /**
  67783. * Babylon reference to the earcut plugin.
  67784. */
  67785. bjsEarcut: any;
  67786. /**
  67787. * Creates a PolygonMeshBuilder
  67788. * @param name name of the builder
  67789. * @param contours Path of the polygon
  67790. * @param scene scene to add to when creating the mesh
  67791. * @param earcutInjection can be used to inject your own earcut reference
  67792. */
  67793. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67794. /**
  67795. * Adds a whole within the polygon
  67796. * @param hole Array of points defining the hole
  67797. * @returns this
  67798. */
  67799. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67800. /**
  67801. * Creates the polygon
  67802. * @param updatable If the mesh should be updatable
  67803. * @param depth The depth of the mesh created
  67804. * @returns the created mesh
  67805. */
  67806. build(updatable?: boolean, depth?: number): Mesh;
  67807. /**
  67808. * Creates the polygon
  67809. * @param depth The depth of the mesh created
  67810. * @returns the created VertexData
  67811. */
  67812. buildVertexData(depth?: number): VertexData;
  67813. /**
  67814. * Adds a side to the polygon
  67815. * @param positions points that make the polygon
  67816. * @param normals normals of the polygon
  67817. * @param uvs uvs of the polygon
  67818. * @param indices indices of the polygon
  67819. * @param bounds bounds of the polygon
  67820. * @param points points of the polygon
  67821. * @param depth depth of the polygon
  67822. * @param flip flip of the polygon
  67823. */
  67824. private addSide;
  67825. }
  67826. }
  67827. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67828. import { Scene } from "babylonjs/scene";
  67829. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67830. import { Color4 } from "babylonjs/Maths/math.color";
  67831. import { Mesh } from "babylonjs/Meshes/mesh";
  67832. import { Nullable } from "babylonjs/types";
  67833. /**
  67834. * Class containing static functions to help procedurally build meshes
  67835. */
  67836. export class PolygonBuilder {
  67837. /**
  67838. * Creates a polygon mesh
  67839. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67840. * * 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
  67841. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67844. * * Remember you can only change the shape positions, not their number when updating a polygon
  67845. * @param name defines the name of the mesh
  67846. * @param options defines the options used to create the mesh
  67847. * @param scene defines the hosting scene
  67848. * @param earcutInjection can be used to inject your own earcut reference
  67849. * @returns the polygon mesh
  67850. */
  67851. static CreatePolygon(name: string, options: {
  67852. shape: Vector3[];
  67853. holes?: Vector3[][];
  67854. depth?: number;
  67855. faceUV?: Vector4[];
  67856. faceColors?: Color4[];
  67857. updatable?: boolean;
  67858. sideOrientation?: number;
  67859. frontUVs?: Vector4;
  67860. backUVs?: Vector4;
  67861. wrap?: boolean;
  67862. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67863. /**
  67864. * Creates an extruded polygon mesh, with depth in the Y direction.
  67865. * * 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)
  67866. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67867. * @param name defines the name of the mesh
  67868. * @param options defines the options used to create the mesh
  67869. * @param scene defines the hosting scene
  67870. * @param earcutInjection can be used to inject your own earcut reference
  67871. * @returns the polygon mesh
  67872. */
  67873. static ExtrudePolygon(name: string, options: {
  67874. shape: Vector3[];
  67875. holes?: Vector3[][];
  67876. depth?: number;
  67877. faceUV?: Vector4[];
  67878. faceColors?: Color4[];
  67879. updatable?: boolean;
  67880. sideOrientation?: number;
  67881. frontUVs?: Vector4;
  67882. backUVs?: Vector4;
  67883. wrap?: boolean;
  67884. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67885. }
  67886. }
  67887. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67888. import { Scene } from "babylonjs/scene";
  67889. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67890. import { Mesh } from "babylonjs/Meshes/mesh";
  67891. import { Nullable } from "babylonjs/types";
  67892. /**
  67893. * Class containing static functions to help procedurally build meshes
  67894. */
  67895. export class LatheBuilder {
  67896. /**
  67897. * Creates lathe mesh.
  67898. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67899. * * 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
  67900. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67901. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67902. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67903. * * 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
  67904. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67905. * * 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
  67906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67908. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67910. * @param name defines the name of the mesh
  67911. * @param options defines the options used to create the mesh
  67912. * @param scene defines the hosting scene
  67913. * @returns the lathe mesh
  67914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67915. */
  67916. static CreateLathe(name: string, options: {
  67917. shape: Vector3[];
  67918. radius?: number;
  67919. tessellation?: number;
  67920. clip?: number;
  67921. arc?: number;
  67922. closed?: boolean;
  67923. updatable?: boolean;
  67924. sideOrientation?: number;
  67925. frontUVs?: Vector4;
  67926. backUVs?: Vector4;
  67927. cap?: number;
  67928. invertUV?: boolean;
  67929. }, scene?: Nullable<Scene>): Mesh;
  67930. }
  67931. }
  67932. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67933. import { Nullable } from "babylonjs/types";
  67934. import { Scene } from "babylonjs/scene";
  67935. import { Vector4 } from "babylonjs/Maths/math.vector";
  67936. import { Mesh } from "babylonjs/Meshes/mesh";
  67937. /**
  67938. * Class containing static functions to help procedurally build meshes
  67939. */
  67940. export class TiledPlaneBuilder {
  67941. /**
  67942. * Creates a tiled plane mesh
  67943. * * The parameter `pattern` will, depending on value, do nothing or
  67944. * * * flip (reflect about central vertical) alternate tiles across and up
  67945. * * * flip every tile on alternate rows
  67946. * * * rotate (180 degs) alternate tiles across and up
  67947. * * * rotate every tile on alternate rows
  67948. * * * flip and rotate alternate tiles across and up
  67949. * * * flip and rotate every tile on alternate rows
  67950. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67951. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67953. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67954. * * 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)
  67955. * * 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)
  67956. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67957. * @param name defines the name of the mesh
  67958. * @param options defines the options used to create the mesh
  67959. * @param scene defines the hosting scene
  67960. * @returns the box mesh
  67961. */
  67962. static CreateTiledPlane(name: string, options: {
  67963. pattern?: number;
  67964. tileSize?: number;
  67965. tileWidth?: number;
  67966. tileHeight?: number;
  67967. size?: number;
  67968. width?: number;
  67969. height?: number;
  67970. alignHorizontal?: number;
  67971. alignVertical?: number;
  67972. sideOrientation?: number;
  67973. frontUVs?: Vector4;
  67974. backUVs?: Vector4;
  67975. updatable?: boolean;
  67976. }, scene?: Nullable<Scene>): Mesh;
  67977. }
  67978. }
  67979. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67980. import { Nullable } from "babylonjs/types";
  67981. import { Scene } from "babylonjs/scene";
  67982. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67983. import { Mesh } from "babylonjs/Meshes/mesh";
  67984. /**
  67985. * Class containing static functions to help procedurally build meshes
  67986. */
  67987. export class TubeBuilder {
  67988. /**
  67989. * Creates a tube mesh.
  67990. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67991. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67992. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67993. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67994. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67995. * * 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)
  67996. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67997. * * 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
  67998. * * 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
  67999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68000. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68001. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68003. * @param name defines the name of the mesh
  68004. * @param options defines the options used to create the mesh
  68005. * @param scene defines the hosting scene
  68006. * @returns the tube mesh
  68007. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68008. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68009. */
  68010. static CreateTube(name: string, options: {
  68011. path: Vector3[];
  68012. radius?: number;
  68013. tessellation?: number;
  68014. radiusFunction?: {
  68015. (i: number, distance: number): number;
  68016. };
  68017. cap?: number;
  68018. arc?: number;
  68019. updatable?: boolean;
  68020. sideOrientation?: number;
  68021. frontUVs?: Vector4;
  68022. backUVs?: Vector4;
  68023. instance?: Mesh;
  68024. invertUV?: boolean;
  68025. }, scene?: Nullable<Scene>): Mesh;
  68026. }
  68027. }
  68028. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68029. import { Scene } from "babylonjs/scene";
  68030. import { Vector4 } from "babylonjs/Maths/math.vector";
  68031. import { Mesh } from "babylonjs/Meshes/mesh";
  68032. import { Nullable } from "babylonjs/types";
  68033. /**
  68034. * Class containing static functions to help procedurally build meshes
  68035. */
  68036. export class IcoSphereBuilder {
  68037. /**
  68038. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68039. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68040. * * 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`)
  68041. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68042. * * 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
  68043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68044. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68046. * @param name defines the name of the mesh
  68047. * @param options defines the options used to create the mesh
  68048. * @param scene defines the hosting scene
  68049. * @returns the icosahedron mesh
  68050. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68051. */
  68052. static CreateIcoSphere(name: string, options: {
  68053. radius?: number;
  68054. radiusX?: number;
  68055. radiusY?: number;
  68056. radiusZ?: number;
  68057. flat?: boolean;
  68058. subdivisions?: number;
  68059. sideOrientation?: number;
  68060. frontUVs?: Vector4;
  68061. backUVs?: Vector4;
  68062. updatable?: boolean;
  68063. }, scene?: Nullable<Scene>): Mesh;
  68064. }
  68065. }
  68066. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68067. import { Vector3 } from "babylonjs/Maths/math.vector";
  68068. import { Mesh } from "babylonjs/Meshes/mesh";
  68069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68070. /**
  68071. * Class containing static functions to help procedurally build meshes
  68072. */
  68073. export class DecalBuilder {
  68074. /**
  68075. * Creates a decal mesh.
  68076. * 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
  68077. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68078. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68079. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68080. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68081. * @param name defines the name of the mesh
  68082. * @param sourceMesh defines the mesh where the decal must be applied
  68083. * @param options defines the options used to create the mesh
  68084. * @param scene defines the hosting scene
  68085. * @returns the decal mesh
  68086. * @see https://doc.babylonjs.com/how_to/decals
  68087. */
  68088. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68089. position?: Vector3;
  68090. normal?: Vector3;
  68091. size?: Vector3;
  68092. angle?: number;
  68093. }): Mesh;
  68094. }
  68095. }
  68096. declare module "babylonjs/Meshes/meshBuilder" {
  68097. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68098. import { Nullable } from "babylonjs/types";
  68099. import { Scene } from "babylonjs/scene";
  68100. import { Mesh } from "babylonjs/Meshes/mesh";
  68101. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68102. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68104. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68105. import { Plane } from "babylonjs/Maths/math.plane";
  68106. /**
  68107. * Class containing static functions to help procedurally build meshes
  68108. */
  68109. export class MeshBuilder {
  68110. /**
  68111. * Creates a box mesh
  68112. * * The parameter `size` sets the size (float) of each box side (default 1)
  68113. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68114. * * 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)
  68115. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68119. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68120. * @param name defines the name of the mesh
  68121. * @param options defines the options used to create the mesh
  68122. * @param scene defines the hosting scene
  68123. * @returns the box mesh
  68124. */
  68125. static CreateBox(name: string, options: {
  68126. size?: number;
  68127. width?: number;
  68128. height?: number;
  68129. depth?: number;
  68130. faceUV?: Vector4[];
  68131. faceColors?: Color4[];
  68132. sideOrientation?: number;
  68133. frontUVs?: Vector4;
  68134. backUVs?: Vector4;
  68135. wrap?: boolean;
  68136. topBaseAt?: number;
  68137. bottomBaseAt?: number;
  68138. updatable?: boolean;
  68139. }, scene?: Nullable<Scene>): Mesh;
  68140. /**
  68141. * Creates a tiled box mesh
  68142. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68144. * @param name defines the name of the mesh
  68145. * @param options defines the options used to create the mesh
  68146. * @param scene defines the hosting scene
  68147. * @returns the tiled box mesh
  68148. */
  68149. static CreateTiledBox(name: string, options: {
  68150. pattern?: number;
  68151. size?: number;
  68152. width?: number;
  68153. height?: number;
  68154. depth: number;
  68155. tileSize?: number;
  68156. tileWidth?: number;
  68157. tileHeight?: number;
  68158. faceUV?: Vector4[];
  68159. faceColors?: Color4[];
  68160. alignHorizontal?: number;
  68161. alignVertical?: number;
  68162. sideOrientation?: number;
  68163. updatable?: boolean;
  68164. }, scene?: Nullable<Scene>): Mesh;
  68165. /**
  68166. * Creates a sphere mesh
  68167. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68168. * * 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`)
  68169. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68170. * * 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
  68171. * * 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)
  68172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68173. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68175. * @param name defines the name of the mesh
  68176. * @param options defines the options used to create the mesh
  68177. * @param scene defines the hosting scene
  68178. * @returns the sphere mesh
  68179. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68180. */
  68181. static CreateSphere(name: string, options: {
  68182. segments?: number;
  68183. diameter?: number;
  68184. diameterX?: number;
  68185. diameterY?: number;
  68186. diameterZ?: number;
  68187. arc?: number;
  68188. slice?: number;
  68189. sideOrientation?: number;
  68190. frontUVs?: Vector4;
  68191. backUVs?: Vector4;
  68192. updatable?: boolean;
  68193. }, scene?: Nullable<Scene>): Mesh;
  68194. /**
  68195. * Creates a plane polygonal mesh. By default, this is a disc
  68196. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68197. * * 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
  68198. * * 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
  68199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68202. * @param name defines the name of the mesh
  68203. * @param options defines the options used to create the mesh
  68204. * @param scene defines the hosting scene
  68205. * @returns the plane polygonal mesh
  68206. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68207. */
  68208. static CreateDisc(name: string, options: {
  68209. radius?: number;
  68210. tessellation?: number;
  68211. arc?: number;
  68212. updatable?: boolean;
  68213. sideOrientation?: number;
  68214. frontUVs?: Vector4;
  68215. backUVs?: Vector4;
  68216. }, scene?: Nullable<Scene>): Mesh;
  68217. /**
  68218. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68219. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68220. * * 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`)
  68221. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68222. * * 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
  68223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68226. * @param name defines the name of the mesh
  68227. * @param options defines the options used to create the mesh
  68228. * @param scene defines the hosting scene
  68229. * @returns the icosahedron mesh
  68230. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68231. */
  68232. static CreateIcoSphere(name: string, options: {
  68233. radius?: number;
  68234. radiusX?: number;
  68235. radiusY?: number;
  68236. radiusZ?: number;
  68237. flat?: boolean;
  68238. subdivisions?: number;
  68239. sideOrientation?: number;
  68240. frontUVs?: Vector4;
  68241. backUVs?: Vector4;
  68242. updatable?: boolean;
  68243. }, scene?: Nullable<Scene>): Mesh;
  68244. /**
  68245. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68246. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68247. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68248. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68249. * * 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
  68250. * * 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
  68251. * * 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
  68252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68254. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68255. * * 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
  68256. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68257. * * 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
  68258. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68260. * @param name defines the name of the mesh
  68261. * @param options defines the options used to create the mesh
  68262. * @param scene defines the hosting scene
  68263. * @returns the ribbon mesh
  68264. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68265. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68266. */
  68267. static CreateRibbon(name: string, options: {
  68268. pathArray: Vector3[][];
  68269. closeArray?: boolean;
  68270. closePath?: boolean;
  68271. offset?: number;
  68272. updatable?: boolean;
  68273. sideOrientation?: number;
  68274. frontUVs?: Vector4;
  68275. backUVs?: Vector4;
  68276. instance?: Mesh;
  68277. invertUV?: boolean;
  68278. uvs?: Vector2[];
  68279. colors?: Color4[];
  68280. }, scene?: Nullable<Scene>): Mesh;
  68281. /**
  68282. * Creates a cylinder or a cone mesh
  68283. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68284. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68285. * * 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.
  68286. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68287. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68288. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68289. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68290. * * 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).
  68291. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68292. * * 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).
  68293. * * 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
  68294. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68295. * * 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
  68296. * * 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.
  68297. * * If `enclose` is false, a ring surface is one element.
  68298. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68299. * * 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
  68300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68303. * @param name defines the name of the mesh
  68304. * @param options defines the options used to create the mesh
  68305. * @param scene defines the hosting scene
  68306. * @returns the cylinder mesh
  68307. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68308. */
  68309. static CreateCylinder(name: string, options: {
  68310. height?: number;
  68311. diameterTop?: number;
  68312. diameterBottom?: number;
  68313. diameter?: number;
  68314. tessellation?: number;
  68315. subdivisions?: number;
  68316. arc?: number;
  68317. faceColors?: Color4[];
  68318. faceUV?: Vector4[];
  68319. updatable?: boolean;
  68320. hasRings?: boolean;
  68321. enclose?: boolean;
  68322. cap?: number;
  68323. sideOrientation?: number;
  68324. frontUVs?: Vector4;
  68325. backUVs?: Vector4;
  68326. }, scene?: Nullable<Scene>): Mesh;
  68327. /**
  68328. * Creates a torus mesh
  68329. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68330. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68331. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68333. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68335. * @param name defines the name of the mesh
  68336. * @param options defines the options used to create the mesh
  68337. * @param scene defines the hosting scene
  68338. * @returns the torus mesh
  68339. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68340. */
  68341. static CreateTorus(name: string, options: {
  68342. diameter?: number;
  68343. thickness?: number;
  68344. tessellation?: number;
  68345. updatable?: boolean;
  68346. sideOrientation?: number;
  68347. frontUVs?: Vector4;
  68348. backUVs?: Vector4;
  68349. }, scene?: Nullable<Scene>): Mesh;
  68350. /**
  68351. * Creates a torus knot mesh
  68352. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68353. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68354. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68355. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68359. * @param name defines the name of the mesh
  68360. * @param options defines the options used to create the mesh
  68361. * @param scene defines the hosting scene
  68362. * @returns the torus knot mesh
  68363. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68364. */
  68365. static CreateTorusKnot(name: string, options: {
  68366. radius?: number;
  68367. tube?: number;
  68368. radialSegments?: number;
  68369. tubularSegments?: number;
  68370. p?: number;
  68371. q?: number;
  68372. updatable?: boolean;
  68373. sideOrientation?: number;
  68374. frontUVs?: Vector4;
  68375. backUVs?: Vector4;
  68376. }, scene?: Nullable<Scene>): Mesh;
  68377. /**
  68378. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  68379. * * 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
  68380. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  68381. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  68382. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  68383. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  68384. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  68385. * * 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
  68386. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  68387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  68389. * @param name defines the name of the new line system
  68390. * @param options defines the options used to create the line system
  68391. * @param scene defines the hosting scene
  68392. * @returns a new line system mesh
  68393. */
  68394. static CreateLineSystem(name: string, options: {
  68395. lines: Vector3[][];
  68396. updatable?: boolean;
  68397. instance?: Nullable<LinesMesh>;
  68398. colors?: Nullable<Color4[][]>;
  68399. useVertexAlpha?: boolean;
  68400. }, scene: Nullable<Scene>): LinesMesh;
  68401. /**
  68402. * Creates a line mesh
  68403. * 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
  68404. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68405. * * The parameter `points` is an array successive Vector3
  68406. * * 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
  68407. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68408. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68409. * * When updating an instance, remember that only point positions can change, not the number of points
  68410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68412. * @param name defines the name of the new line system
  68413. * @param options defines the options used to create the line system
  68414. * @param scene defines the hosting scene
  68415. * @returns a new line mesh
  68416. */
  68417. static CreateLines(name: string, options: {
  68418. points: Vector3[];
  68419. updatable?: boolean;
  68420. instance?: Nullable<LinesMesh>;
  68421. colors?: Color4[];
  68422. useVertexAlpha?: boolean;
  68423. }, scene?: Nullable<Scene>): LinesMesh;
  68424. /**
  68425. * Creates a dashed line mesh
  68426. * * 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
  68427. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68428. * * The parameter `points` is an array successive Vector3
  68429. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68430. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68431. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68432. * * 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
  68433. * * When updating an instance, remember that only point positions can change, not the number of points
  68434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68435. * @param name defines the name of the mesh
  68436. * @param options defines the options used to create the mesh
  68437. * @param scene defines the hosting scene
  68438. * @returns the dashed line mesh
  68439. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  68440. */
  68441. static CreateDashedLines(name: string, options: {
  68442. points: Vector3[];
  68443. dashSize?: number;
  68444. gapSize?: number;
  68445. dashNb?: number;
  68446. updatable?: boolean;
  68447. instance?: LinesMesh;
  68448. }, scene?: Nullable<Scene>): LinesMesh;
  68449. /**
  68450. * 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.
  68451. * * 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.
  68452. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68453. * * 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.
  68454. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  68455. * * 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
  68456. * * 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
  68457. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  68458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68460. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  68461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68462. * @param name defines the name of the mesh
  68463. * @param options defines the options used to create the mesh
  68464. * @param scene defines the hosting scene
  68465. * @returns the extruded shape mesh
  68466. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68468. */
  68469. static ExtrudeShape(name: string, options: {
  68470. shape: Vector3[];
  68471. path: Vector3[];
  68472. scale?: number;
  68473. rotation?: number;
  68474. cap?: number;
  68475. updatable?: boolean;
  68476. sideOrientation?: number;
  68477. frontUVs?: Vector4;
  68478. backUVs?: Vector4;
  68479. instance?: Mesh;
  68480. invertUV?: boolean;
  68481. }, scene?: Nullable<Scene>): Mesh;
  68482. /**
  68483. * Creates an custom extruded shape mesh.
  68484. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  68485. * * 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.
  68486. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68487. * * 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
  68488. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  68489. * * 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
  68490. * * It must returns a float value that will be the scale value applied to the shape on each path point
  68491. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  68492. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  68493. * * 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
  68494. * * 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
  68495. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  68496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68498. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68500. * @param name defines the name of the mesh
  68501. * @param options defines the options used to create the mesh
  68502. * @param scene defines the hosting scene
  68503. * @returns the custom extruded shape mesh
  68504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  68505. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68506. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68507. */
  68508. static ExtrudeShapeCustom(name: string, options: {
  68509. shape: Vector3[];
  68510. path: Vector3[];
  68511. scaleFunction?: any;
  68512. rotationFunction?: any;
  68513. ribbonCloseArray?: boolean;
  68514. ribbonClosePath?: boolean;
  68515. cap?: number;
  68516. updatable?: boolean;
  68517. sideOrientation?: number;
  68518. frontUVs?: Vector4;
  68519. backUVs?: Vector4;
  68520. instance?: Mesh;
  68521. invertUV?: boolean;
  68522. }, scene?: Nullable<Scene>): Mesh;
  68523. /**
  68524. * Creates lathe mesh.
  68525. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68526. * * 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
  68527. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68528. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68529. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68530. * * 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
  68531. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68532. * * 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
  68533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68534. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68535. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68537. * @param name defines the name of the mesh
  68538. * @param options defines the options used to create the mesh
  68539. * @param scene defines the hosting scene
  68540. * @returns the lathe mesh
  68541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68542. */
  68543. static CreateLathe(name: string, options: {
  68544. shape: Vector3[];
  68545. radius?: number;
  68546. tessellation?: number;
  68547. clip?: number;
  68548. arc?: number;
  68549. closed?: boolean;
  68550. updatable?: boolean;
  68551. sideOrientation?: number;
  68552. frontUVs?: Vector4;
  68553. backUVs?: Vector4;
  68554. cap?: number;
  68555. invertUV?: boolean;
  68556. }, scene?: Nullable<Scene>): Mesh;
  68557. /**
  68558. * Creates a tiled plane mesh
  68559. * * You can set a limited pattern arrangement with the tiles
  68560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68561. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68563. * @param name defines the name of the mesh
  68564. * @param options defines the options used to create the mesh
  68565. * @param scene defines the hosting scene
  68566. * @returns the plane mesh
  68567. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68568. */
  68569. static CreateTiledPlane(name: string, options: {
  68570. pattern?: number;
  68571. tileSize?: number;
  68572. tileWidth?: number;
  68573. tileHeight?: number;
  68574. size?: number;
  68575. width?: number;
  68576. height?: number;
  68577. alignHorizontal?: number;
  68578. alignVertical?: number;
  68579. sideOrientation?: number;
  68580. frontUVs?: Vector4;
  68581. backUVs?: Vector4;
  68582. updatable?: boolean;
  68583. }, scene?: Nullable<Scene>): Mesh;
  68584. /**
  68585. * Creates a plane mesh
  68586. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  68587. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  68588. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  68589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68592. * @param name defines the name of the mesh
  68593. * @param options defines the options used to create the mesh
  68594. * @param scene defines the hosting scene
  68595. * @returns the plane mesh
  68596. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68597. */
  68598. static CreatePlane(name: string, options: {
  68599. size?: number;
  68600. width?: number;
  68601. height?: number;
  68602. sideOrientation?: number;
  68603. frontUVs?: Vector4;
  68604. backUVs?: Vector4;
  68605. updatable?: boolean;
  68606. sourcePlane?: Plane;
  68607. }, scene?: Nullable<Scene>): Mesh;
  68608. /**
  68609. * Creates a ground mesh
  68610. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  68611. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  68612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68613. * @param name defines the name of the mesh
  68614. * @param options defines the options used to create the mesh
  68615. * @param scene defines the hosting scene
  68616. * @returns the ground mesh
  68617. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  68618. */
  68619. static CreateGround(name: string, options: {
  68620. width?: number;
  68621. height?: number;
  68622. subdivisions?: number;
  68623. subdivisionsX?: number;
  68624. subdivisionsY?: number;
  68625. updatable?: boolean;
  68626. }, scene?: Nullable<Scene>): Mesh;
  68627. /**
  68628. * Creates a tiled ground mesh
  68629. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  68630. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  68631. * * 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
  68632. * * 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
  68633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68634. * @param name defines the name of the mesh
  68635. * @param options defines the options used to create the mesh
  68636. * @param scene defines the hosting scene
  68637. * @returns the tiled ground mesh
  68638. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  68639. */
  68640. static CreateTiledGround(name: string, options: {
  68641. xmin: number;
  68642. zmin: number;
  68643. xmax: number;
  68644. zmax: number;
  68645. subdivisions?: {
  68646. w: number;
  68647. h: number;
  68648. };
  68649. precision?: {
  68650. w: number;
  68651. h: number;
  68652. };
  68653. updatable?: boolean;
  68654. }, scene?: Nullable<Scene>): Mesh;
  68655. /**
  68656. * Creates a ground mesh from a height map
  68657. * * The parameter `url` sets the URL of the height map image resource.
  68658. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  68659. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  68660. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  68661. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  68662. * * 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.
  68663. * * 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).
  68664. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  68665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68666. * @param name defines the name of the mesh
  68667. * @param url defines the url to the height map
  68668. * @param options defines the options used to create the mesh
  68669. * @param scene defines the hosting scene
  68670. * @returns the ground mesh
  68671. * @see https://doc.babylonjs.com/babylon101/height_map
  68672. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  68673. */
  68674. static CreateGroundFromHeightMap(name: string, url: string, options: {
  68675. width?: number;
  68676. height?: number;
  68677. subdivisions?: number;
  68678. minHeight?: number;
  68679. maxHeight?: number;
  68680. colorFilter?: Color3;
  68681. alphaFilter?: number;
  68682. updatable?: boolean;
  68683. onReady?: (mesh: GroundMesh) => void;
  68684. }, scene?: Nullable<Scene>): GroundMesh;
  68685. /**
  68686. * Creates a polygon mesh
  68687. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68688. * * 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
  68689. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68691. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68692. * * Remember you can only change the shape positions, not their number when updating a polygon
  68693. * @param name defines the name of the mesh
  68694. * @param options defines the options used to create the mesh
  68695. * @param scene defines the hosting scene
  68696. * @param earcutInjection can be used to inject your own earcut reference
  68697. * @returns the polygon mesh
  68698. */
  68699. static CreatePolygon(name: string, options: {
  68700. shape: Vector3[];
  68701. holes?: Vector3[][];
  68702. depth?: number;
  68703. faceUV?: Vector4[];
  68704. faceColors?: Color4[];
  68705. updatable?: boolean;
  68706. sideOrientation?: number;
  68707. frontUVs?: Vector4;
  68708. backUVs?: Vector4;
  68709. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68710. /**
  68711. * Creates an extruded polygon mesh, with depth in the Y direction.
  68712. * * 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)
  68713. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68714. * @param name defines the name of the mesh
  68715. * @param options defines the options used to create the mesh
  68716. * @param scene defines the hosting scene
  68717. * @param earcutInjection can be used to inject your own earcut reference
  68718. * @returns the polygon mesh
  68719. */
  68720. static ExtrudePolygon(name: string, options: {
  68721. shape: Vector3[];
  68722. holes?: Vector3[][];
  68723. depth?: number;
  68724. faceUV?: Vector4[];
  68725. faceColors?: Color4[];
  68726. updatable?: boolean;
  68727. sideOrientation?: number;
  68728. frontUVs?: Vector4;
  68729. backUVs?: Vector4;
  68730. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68731. /**
  68732. * Creates a tube mesh.
  68733. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68734. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68735. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68736. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68737. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68738. * * 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)
  68739. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68740. * * 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
  68741. * * 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
  68742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68744. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68746. * @param name defines the name of the mesh
  68747. * @param options defines the options used to create the mesh
  68748. * @param scene defines the hosting scene
  68749. * @returns the tube mesh
  68750. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68751. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68752. */
  68753. static CreateTube(name: string, options: {
  68754. path: Vector3[];
  68755. radius?: number;
  68756. tessellation?: number;
  68757. radiusFunction?: {
  68758. (i: number, distance: number): number;
  68759. };
  68760. cap?: number;
  68761. arc?: number;
  68762. updatable?: boolean;
  68763. sideOrientation?: number;
  68764. frontUVs?: Vector4;
  68765. backUVs?: Vector4;
  68766. instance?: Mesh;
  68767. invertUV?: boolean;
  68768. }, scene?: Nullable<Scene>): Mesh;
  68769. /**
  68770. * Creates a polyhedron mesh
  68771. * * 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
  68772. * * The parameter `size` (positive float, default 1) sets the polygon size
  68773. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68774. * * 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`
  68775. * * 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
  68776. * * 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)`)
  68777. * * 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
  68778. * * 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
  68779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68782. * @param name defines the name of the mesh
  68783. * @param options defines the options used to create the mesh
  68784. * @param scene defines the hosting scene
  68785. * @returns the polyhedron mesh
  68786. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68787. */
  68788. static CreatePolyhedron(name: string, options: {
  68789. type?: number;
  68790. size?: number;
  68791. sizeX?: number;
  68792. sizeY?: number;
  68793. sizeZ?: number;
  68794. custom?: any;
  68795. faceUV?: Vector4[];
  68796. faceColors?: Color4[];
  68797. flat?: boolean;
  68798. updatable?: boolean;
  68799. sideOrientation?: number;
  68800. frontUVs?: Vector4;
  68801. backUVs?: Vector4;
  68802. }, scene?: Nullable<Scene>): Mesh;
  68803. /**
  68804. * Creates a decal mesh.
  68805. * 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
  68806. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68807. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68808. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68809. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68810. * @param name defines the name of the mesh
  68811. * @param sourceMesh defines the mesh where the decal must be applied
  68812. * @param options defines the options used to create the mesh
  68813. * @param scene defines the hosting scene
  68814. * @returns the decal mesh
  68815. * @see https://doc.babylonjs.com/how_to/decals
  68816. */
  68817. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68818. position?: Vector3;
  68819. normal?: Vector3;
  68820. size?: Vector3;
  68821. angle?: number;
  68822. }): Mesh;
  68823. }
  68824. }
  68825. declare module "babylonjs/Meshes/meshSimplification" {
  68826. import { Mesh } from "babylonjs/Meshes/mesh";
  68827. /**
  68828. * A simplifier interface for future simplification implementations
  68829. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68830. */
  68831. export interface ISimplifier {
  68832. /**
  68833. * Simplification of a given mesh according to the given settings.
  68834. * Since this requires computation, it is assumed that the function runs async.
  68835. * @param settings The settings of the simplification, including quality and distance
  68836. * @param successCallback A callback that will be called after the mesh was simplified.
  68837. * @param errorCallback in case of an error, this callback will be called. optional.
  68838. */
  68839. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68840. }
  68841. /**
  68842. * Expected simplification settings.
  68843. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68844. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68845. */
  68846. export interface ISimplificationSettings {
  68847. /**
  68848. * Gets or sets the expected quality
  68849. */
  68850. quality: number;
  68851. /**
  68852. * Gets or sets the distance when this optimized version should be used
  68853. */
  68854. distance: number;
  68855. /**
  68856. * Gets an already optimized mesh
  68857. */
  68858. optimizeMesh?: boolean;
  68859. }
  68860. /**
  68861. * Class used to specify simplification options
  68862. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68863. */
  68864. export class SimplificationSettings implements ISimplificationSettings {
  68865. /** expected quality */
  68866. quality: number;
  68867. /** distance when this optimized version should be used */
  68868. distance: number;
  68869. /** already optimized mesh */
  68870. optimizeMesh?: boolean | undefined;
  68871. /**
  68872. * Creates a SimplificationSettings
  68873. * @param quality expected quality
  68874. * @param distance distance when this optimized version should be used
  68875. * @param optimizeMesh already optimized mesh
  68876. */
  68877. constructor(
  68878. /** expected quality */
  68879. quality: number,
  68880. /** distance when this optimized version should be used */
  68881. distance: number,
  68882. /** already optimized mesh */
  68883. optimizeMesh?: boolean | undefined);
  68884. }
  68885. /**
  68886. * Interface used to define a simplification task
  68887. */
  68888. export interface ISimplificationTask {
  68889. /**
  68890. * Array of settings
  68891. */
  68892. settings: Array<ISimplificationSettings>;
  68893. /**
  68894. * Simplification type
  68895. */
  68896. simplificationType: SimplificationType;
  68897. /**
  68898. * Mesh to simplify
  68899. */
  68900. mesh: Mesh;
  68901. /**
  68902. * Callback called on success
  68903. */
  68904. successCallback?: () => void;
  68905. /**
  68906. * Defines if parallel processing can be used
  68907. */
  68908. parallelProcessing: boolean;
  68909. }
  68910. /**
  68911. * Queue used to order the simplification tasks
  68912. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68913. */
  68914. export class SimplificationQueue {
  68915. private _simplificationArray;
  68916. /**
  68917. * Gets a boolean indicating that the process is still running
  68918. */
  68919. running: boolean;
  68920. /**
  68921. * Creates a new queue
  68922. */
  68923. constructor();
  68924. /**
  68925. * Adds a new simplification task
  68926. * @param task defines a task to add
  68927. */
  68928. addTask(task: ISimplificationTask): void;
  68929. /**
  68930. * Execute next task
  68931. */
  68932. executeNext(): void;
  68933. /**
  68934. * Execute a simplification task
  68935. * @param task defines the task to run
  68936. */
  68937. runSimplification(task: ISimplificationTask): void;
  68938. private getSimplifier;
  68939. }
  68940. /**
  68941. * The implemented types of simplification
  68942. * At the moment only Quadratic Error Decimation is implemented
  68943. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68944. */
  68945. export enum SimplificationType {
  68946. /** Quadratic error decimation */
  68947. QUADRATIC = 0
  68948. }
  68949. /**
  68950. * An implementation of the Quadratic Error simplification algorithm.
  68951. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68952. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68953. * @author RaananW
  68954. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68955. */
  68956. export class QuadraticErrorSimplification implements ISimplifier {
  68957. private _mesh;
  68958. private triangles;
  68959. private vertices;
  68960. private references;
  68961. private _reconstructedMesh;
  68962. /** Gets or sets the number pf sync interations */
  68963. syncIterations: number;
  68964. /** Gets or sets the aggressiveness of the simplifier */
  68965. aggressiveness: number;
  68966. /** Gets or sets the number of allowed iterations for decimation */
  68967. decimationIterations: number;
  68968. /** Gets or sets the espilon to use for bounding box computation */
  68969. boundingBoxEpsilon: number;
  68970. /**
  68971. * Creates a new QuadraticErrorSimplification
  68972. * @param _mesh defines the target mesh
  68973. */
  68974. constructor(_mesh: Mesh);
  68975. /**
  68976. * Simplification of a given mesh according to the given settings.
  68977. * Since this requires computation, it is assumed that the function runs async.
  68978. * @param settings The settings of the simplification, including quality and distance
  68979. * @param successCallback A callback that will be called after the mesh was simplified.
  68980. */
  68981. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68982. private runDecimation;
  68983. private initWithMesh;
  68984. private init;
  68985. private reconstructMesh;
  68986. private initDecimatedMesh;
  68987. private isFlipped;
  68988. private updateTriangles;
  68989. private identifyBorder;
  68990. private updateMesh;
  68991. private vertexError;
  68992. private calculateError;
  68993. }
  68994. }
  68995. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68996. import { Scene } from "babylonjs/scene";
  68997. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68998. import { ISceneComponent } from "babylonjs/sceneComponent";
  68999. module "babylonjs/scene" {
  69000. interface Scene {
  69001. /** @hidden (Backing field) */
  69002. _simplificationQueue: SimplificationQueue;
  69003. /**
  69004. * Gets or sets the simplification queue attached to the scene
  69005. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69006. */
  69007. simplificationQueue: SimplificationQueue;
  69008. }
  69009. }
  69010. module "babylonjs/Meshes/mesh" {
  69011. interface Mesh {
  69012. /**
  69013. * Simplify the mesh according to the given array of settings.
  69014. * Function will return immediately and will simplify async
  69015. * @param settings a collection of simplification settings
  69016. * @param parallelProcessing should all levels calculate parallel or one after the other
  69017. * @param simplificationType the type of simplification to run
  69018. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69019. * @returns the current mesh
  69020. */
  69021. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69022. }
  69023. }
  69024. /**
  69025. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69026. * created in a scene
  69027. */
  69028. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69029. /**
  69030. * The component name helpfull to identify the component in the list of scene components.
  69031. */
  69032. readonly name: string;
  69033. /**
  69034. * The scene the component belongs to.
  69035. */
  69036. scene: Scene;
  69037. /**
  69038. * Creates a new instance of the component for the given scene
  69039. * @param scene Defines the scene to register the component in
  69040. */
  69041. constructor(scene: Scene);
  69042. /**
  69043. * Registers the component in a given scene
  69044. */
  69045. register(): void;
  69046. /**
  69047. * Rebuilds the elements related to this component in case of
  69048. * context lost for instance.
  69049. */
  69050. rebuild(): void;
  69051. /**
  69052. * Disposes the component and the associated ressources
  69053. */
  69054. dispose(): void;
  69055. private _beforeCameraUpdate;
  69056. }
  69057. }
  69058. declare module "babylonjs/Meshes/Builders/index" {
  69059. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69060. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69061. export * from "babylonjs/Meshes/Builders/discBuilder";
  69062. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69063. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69064. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69065. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69066. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69067. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69068. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69069. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69070. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69071. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69072. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69073. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69074. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69075. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69076. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69077. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69078. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69079. }
  69080. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69081. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69082. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69083. import { Matrix } from "babylonjs/Maths/math.vector";
  69084. module "babylonjs/Meshes/mesh" {
  69085. interface Mesh {
  69086. /**
  69087. * Creates a new thin instance
  69088. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69089. * @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
  69090. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69091. */
  69092. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69093. /**
  69094. * Adds the transformation (matrix) of the current mesh as a thin instance
  69095. * @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
  69096. * @returns the thin instance index number
  69097. */
  69098. thinInstanceAddSelf(refresh: boolean): number;
  69099. /**
  69100. * Registers a custom attribute to be used with thin instances
  69101. * @param kind name of the attribute
  69102. * @param stride size in floats of the attribute
  69103. */
  69104. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69105. /**
  69106. * Sets the matrix of a thin instance
  69107. * @param index index of the thin instance
  69108. * @param matrix matrix to set
  69109. * @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
  69110. */
  69111. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69112. /**
  69113. * Sets the value of a custom attribute for a thin instance
  69114. * @param kind name of the attribute
  69115. * @param index index of the thin instance
  69116. * @param value value to set
  69117. * @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
  69118. */
  69119. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69120. /**
  69121. * 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.
  69122. */
  69123. thinInstanceCount: number;
  69124. /**
  69125. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69126. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69127. * @param buffer buffer to set
  69128. * @param stride size in floats of each value of the buffer
  69129. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69130. */
  69131. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69132. /**
  69133. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69134. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69135. */
  69136. thinInstanceBufferUpdated(kind: string): void;
  69137. /**
  69138. * Refreshes the bounding info, taking into account all the thin instances defined
  69139. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69140. */
  69141. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69142. /** @hidden */
  69143. _thinInstanceInitializeUserStorage(): void;
  69144. /** @hidden */
  69145. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69146. /** @hidden */
  69147. _userThinInstanceBuffersStorage: {
  69148. data: {
  69149. [key: string]: Float32Array;
  69150. };
  69151. sizes: {
  69152. [key: string]: number;
  69153. };
  69154. vertexBuffers: {
  69155. [key: string]: Nullable<VertexBuffer>;
  69156. };
  69157. strides: {
  69158. [key: string]: number;
  69159. };
  69160. };
  69161. }
  69162. }
  69163. }
  69164. declare module "babylonjs/Meshes/index" {
  69165. export * from "babylonjs/Meshes/abstractMesh";
  69166. export * from "babylonjs/Meshes/buffer";
  69167. export * from "babylonjs/Meshes/Compression/index";
  69168. export * from "babylonjs/Meshes/csg";
  69169. export * from "babylonjs/Meshes/geometry";
  69170. export * from "babylonjs/Meshes/groundMesh";
  69171. export * from "babylonjs/Meshes/trailMesh";
  69172. export * from "babylonjs/Meshes/instancedMesh";
  69173. export * from "babylonjs/Meshes/linesMesh";
  69174. export * from "babylonjs/Meshes/mesh";
  69175. export * from "babylonjs/Meshes/mesh.vertexData";
  69176. export * from "babylonjs/Meshes/meshBuilder";
  69177. export * from "babylonjs/Meshes/meshSimplification";
  69178. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69179. export * from "babylonjs/Meshes/polygonMesh";
  69180. export * from "babylonjs/Meshes/subMesh";
  69181. export * from "babylonjs/Meshes/meshLODLevel";
  69182. export * from "babylonjs/Meshes/transformNode";
  69183. export * from "babylonjs/Meshes/Builders/index";
  69184. export * from "babylonjs/Meshes/dataBuffer";
  69185. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69186. import "babylonjs/Meshes/thinInstanceMesh";
  69187. export * from "babylonjs/Meshes/thinInstanceMesh";
  69188. }
  69189. declare module "babylonjs/Morph/index" {
  69190. export * from "babylonjs/Morph/morphTarget";
  69191. export * from "babylonjs/Morph/morphTargetManager";
  69192. }
  69193. declare module "babylonjs/Navigation/INavigationEngine" {
  69194. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69195. import { Vector3 } from "babylonjs/Maths/math";
  69196. import { Mesh } from "babylonjs/Meshes/mesh";
  69197. import { Scene } from "babylonjs/scene";
  69198. /**
  69199. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69200. */
  69201. export interface INavigationEnginePlugin {
  69202. /**
  69203. * plugin name
  69204. */
  69205. name: string;
  69206. /**
  69207. * Creates a navigation mesh
  69208. * @param meshes array of all the geometry used to compute the navigatio mesh
  69209. * @param parameters bunch of parameters used to filter geometry
  69210. */
  69211. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69212. /**
  69213. * Create a navigation mesh debug mesh
  69214. * @param scene is where the mesh will be added
  69215. * @returns debug display mesh
  69216. */
  69217. createDebugNavMesh(scene: Scene): Mesh;
  69218. /**
  69219. * Get a navigation mesh constrained position, closest to the parameter position
  69220. * @param position world position
  69221. * @returns the closest point to position constrained by the navigation mesh
  69222. */
  69223. getClosestPoint(position: Vector3): Vector3;
  69224. /**
  69225. * Get a navigation mesh constrained position, closest to the parameter position
  69226. * @param position world position
  69227. * @param result output the closest point to position constrained by the navigation mesh
  69228. */
  69229. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69230. /**
  69231. * Get a navigation mesh constrained position, within a particular radius
  69232. * @param position world position
  69233. * @param maxRadius the maximum distance to the constrained world position
  69234. * @returns the closest point to position constrained by the navigation mesh
  69235. */
  69236. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69237. /**
  69238. * Get a navigation mesh constrained position, within a particular radius
  69239. * @param position world position
  69240. * @param maxRadius the maximum distance to the constrained world position
  69241. * @param result output the closest point to position constrained by the navigation mesh
  69242. */
  69243. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69244. /**
  69245. * Compute the final position from a segment made of destination-position
  69246. * @param position world position
  69247. * @param destination world position
  69248. * @returns the resulting point along the navmesh
  69249. */
  69250. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69251. /**
  69252. * Compute the final position from a segment made of destination-position
  69253. * @param position world position
  69254. * @param destination world position
  69255. * @param result output the resulting point along the navmesh
  69256. */
  69257. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69258. /**
  69259. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69260. * @param start world position
  69261. * @param end world position
  69262. * @returns array containing world position composing the path
  69263. */
  69264. computePath(start: Vector3, end: Vector3): Vector3[];
  69265. /**
  69266. * If this plugin is supported
  69267. * @returns true if plugin is supported
  69268. */
  69269. isSupported(): boolean;
  69270. /**
  69271. * Create a new Crowd so you can add agents
  69272. * @param maxAgents the maximum agent count in the crowd
  69273. * @param maxAgentRadius the maximum radius an agent can have
  69274. * @param scene to attach the crowd to
  69275. * @returns the crowd you can add agents to
  69276. */
  69277. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69278. /**
  69279. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69280. * The queries will try to find a solution within those bounds
  69281. * default is (1,1,1)
  69282. * @param extent x,y,z value that define the extent around the queries point of reference
  69283. */
  69284. setDefaultQueryExtent(extent: Vector3): void;
  69285. /**
  69286. * Get the Bounding box extent specified by setDefaultQueryExtent
  69287. * @returns the box extent values
  69288. */
  69289. getDefaultQueryExtent(): Vector3;
  69290. /**
  69291. * build the navmesh from a previously saved state using getNavmeshData
  69292. * @param data the Uint8Array returned by getNavmeshData
  69293. */
  69294. buildFromNavmeshData(data: Uint8Array): void;
  69295. /**
  69296. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69297. * @returns data the Uint8Array that can be saved and reused
  69298. */
  69299. getNavmeshData(): Uint8Array;
  69300. /**
  69301. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69302. * @param result output the box extent values
  69303. */
  69304. getDefaultQueryExtentToRef(result: Vector3): void;
  69305. /**
  69306. * Release all resources
  69307. */
  69308. dispose(): void;
  69309. }
  69310. /**
  69311. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69312. */
  69313. export interface ICrowd {
  69314. /**
  69315. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69316. * You can attach anything to that node. The node position is updated in the scene update tick.
  69317. * @param pos world position that will be constrained by the navigation mesh
  69318. * @param parameters agent parameters
  69319. * @param transform hooked to the agent that will be update by the scene
  69320. * @returns agent index
  69321. */
  69322. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69323. /**
  69324. * Returns the agent position in world space
  69325. * @param index agent index returned by addAgent
  69326. * @returns world space position
  69327. */
  69328. getAgentPosition(index: number): Vector3;
  69329. /**
  69330. * Gets the agent position result in world space
  69331. * @param index agent index returned by addAgent
  69332. * @param result output world space position
  69333. */
  69334. getAgentPositionToRef(index: number, result: Vector3): void;
  69335. /**
  69336. * Gets the agent velocity in world space
  69337. * @param index agent index returned by addAgent
  69338. * @returns world space velocity
  69339. */
  69340. getAgentVelocity(index: number): Vector3;
  69341. /**
  69342. * Gets the agent velocity result in world space
  69343. * @param index agent index returned by addAgent
  69344. * @param result output world space velocity
  69345. */
  69346. getAgentVelocityToRef(index: number, result: Vector3): void;
  69347. /**
  69348. * remove a particular agent previously created
  69349. * @param index agent index returned by addAgent
  69350. */
  69351. removeAgent(index: number): void;
  69352. /**
  69353. * get the list of all agents attached to this crowd
  69354. * @returns list of agent indices
  69355. */
  69356. getAgents(): number[];
  69357. /**
  69358. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69359. * @param deltaTime in seconds
  69360. */
  69361. update(deltaTime: number): void;
  69362. /**
  69363. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69364. * @param index agent index returned by addAgent
  69365. * @param destination targeted world position
  69366. */
  69367. agentGoto(index: number, destination: Vector3): void;
  69368. /**
  69369. * Teleport the agent to a new position
  69370. * @param index agent index returned by addAgent
  69371. * @param destination targeted world position
  69372. */
  69373. agentTeleport(index: number, destination: Vector3): void;
  69374. /**
  69375. * Update agent parameters
  69376. * @param index agent index returned by addAgent
  69377. * @param parameters agent parameters
  69378. */
  69379. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69380. /**
  69381. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69382. * The queries will try to find a solution within those bounds
  69383. * default is (1,1,1)
  69384. * @param extent x,y,z value that define the extent around the queries point of reference
  69385. */
  69386. setDefaultQueryExtent(extent: Vector3): void;
  69387. /**
  69388. * Get the Bounding box extent specified by setDefaultQueryExtent
  69389. * @returns the box extent values
  69390. */
  69391. getDefaultQueryExtent(): Vector3;
  69392. /**
  69393. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69394. * @param result output the box extent values
  69395. */
  69396. getDefaultQueryExtentToRef(result: Vector3): void;
  69397. /**
  69398. * Release all resources
  69399. */
  69400. dispose(): void;
  69401. }
  69402. /**
  69403. * Configures an agent
  69404. */
  69405. export interface IAgentParameters {
  69406. /**
  69407. * Agent radius. [Limit: >= 0]
  69408. */
  69409. radius: number;
  69410. /**
  69411. * Agent height. [Limit: > 0]
  69412. */
  69413. height: number;
  69414. /**
  69415. * Maximum allowed acceleration. [Limit: >= 0]
  69416. */
  69417. maxAcceleration: number;
  69418. /**
  69419. * Maximum allowed speed. [Limit: >= 0]
  69420. */
  69421. maxSpeed: number;
  69422. /**
  69423. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69424. */
  69425. collisionQueryRange: number;
  69426. /**
  69427. * The path visibility optimization range. [Limit: > 0]
  69428. */
  69429. pathOptimizationRange: number;
  69430. /**
  69431. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69432. */
  69433. separationWeight: number;
  69434. }
  69435. /**
  69436. * Configures the navigation mesh creation
  69437. */
  69438. export interface INavMeshParameters {
  69439. /**
  69440. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  69441. */
  69442. cs: number;
  69443. /**
  69444. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  69445. */
  69446. ch: number;
  69447. /**
  69448. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  69449. */
  69450. walkableSlopeAngle: number;
  69451. /**
  69452. * Minimum floor to 'ceiling' height that will still allow the floor area to
  69453. * be considered walkable. [Limit: >= 3] [Units: vx]
  69454. */
  69455. walkableHeight: number;
  69456. /**
  69457. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  69458. */
  69459. walkableClimb: number;
  69460. /**
  69461. * The distance to erode/shrink the walkable area of the heightfield away from
  69462. * obstructions. [Limit: >=0] [Units: vx]
  69463. */
  69464. walkableRadius: number;
  69465. /**
  69466. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  69467. */
  69468. maxEdgeLen: number;
  69469. /**
  69470. * The maximum distance a simplfied contour's border edges should deviate
  69471. * the original raw contour. [Limit: >=0] [Units: vx]
  69472. */
  69473. maxSimplificationError: number;
  69474. /**
  69475. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  69476. */
  69477. minRegionArea: number;
  69478. /**
  69479. * Any regions with a span count smaller than this value will, if possible,
  69480. * be merged with larger regions. [Limit: >=0] [Units: vx]
  69481. */
  69482. mergeRegionArea: number;
  69483. /**
  69484. * The maximum number of vertices allowed for polygons generated during the
  69485. * contour to polygon conversion process. [Limit: >= 3]
  69486. */
  69487. maxVertsPerPoly: number;
  69488. /**
  69489. * Sets the sampling distance to use when generating the detail mesh.
  69490. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  69491. */
  69492. detailSampleDist: number;
  69493. /**
  69494. * The maximum distance the detail mesh surface should deviate from heightfield
  69495. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  69496. */
  69497. detailSampleMaxError: number;
  69498. }
  69499. }
  69500. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  69501. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  69502. import { Mesh } from "babylonjs/Meshes/mesh";
  69503. import { Scene } from "babylonjs/scene";
  69504. import { Vector3 } from "babylonjs/Maths/math";
  69505. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69506. /**
  69507. * RecastJS navigation plugin
  69508. */
  69509. export class RecastJSPlugin implements INavigationEnginePlugin {
  69510. /**
  69511. * Reference to the Recast library
  69512. */
  69513. bjsRECAST: any;
  69514. /**
  69515. * plugin name
  69516. */
  69517. name: string;
  69518. /**
  69519. * the first navmesh created. We might extend this to support multiple navmeshes
  69520. */
  69521. navMesh: any;
  69522. /**
  69523. * Initializes the recastJS plugin
  69524. * @param recastInjection can be used to inject your own recast reference
  69525. */
  69526. constructor(recastInjection?: any);
  69527. /**
  69528. * Creates a navigation mesh
  69529. * @param meshes array of all the geometry used to compute the navigatio mesh
  69530. * @param parameters bunch of parameters used to filter geometry
  69531. */
  69532. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69533. /**
  69534. * Create a navigation mesh debug mesh
  69535. * @param scene is where the mesh will be added
  69536. * @returns debug display mesh
  69537. */
  69538. createDebugNavMesh(scene: Scene): Mesh;
  69539. /**
  69540. * Get a navigation mesh constrained position, closest to the parameter position
  69541. * @param position world position
  69542. * @returns the closest point to position constrained by the navigation mesh
  69543. */
  69544. getClosestPoint(position: Vector3): Vector3;
  69545. /**
  69546. * Get a navigation mesh constrained position, closest to the parameter position
  69547. * @param position world position
  69548. * @param result output the closest point to position constrained by the navigation mesh
  69549. */
  69550. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69551. /**
  69552. * Get a navigation mesh constrained position, within a particular radius
  69553. * @param position world position
  69554. * @param maxRadius the maximum distance to the constrained world position
  69555. * @returns the closest point to position constrained by the navigation mesh
  69556. */
  69557. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69558. /**
  69559. * Get a navigation mesh constrained position, within a particular radius
  69560. * @param position world position
  69561. * @param maxRadius the maximum distance to the constrained world position
  69562. * @param result output the closest point to position constrained by the navigation mesh
  69563. */
  69564. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69565. /**
  69566. * Compute the final position from a segment made of destination-position
  69567. * @param position world position
  69568. * @param destination world position
  69569. * @returns the resulting point along the navmesh
  69570. */
  69571. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69572. /**
  69573. * Compute the final position from a segment made of destination-position
  69574. * @param position world position
  69575. * @param destination world position
  69576. * @param result output the resulting point along the navmesh
  69577. */
  69578. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69579. /**
  69580. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69581. * @param start world position
  69582. * @param end world position
  69583. * @returns array containing world position composing the path
  69584. */
  69585. computePath(start: Vector3, end: Vector3): Vector3[];
  69586. /**
  69587. * Create a new Crowd so you can add agents
  69588. * @param maxAgents the maximum agent count in the crowd
  69589. * @param maxAgentRadius the maximum radius an agent can have
  69590. * @param scene to attach the crowd to
  69591. * @returns the crowd you can add agents to
  69592. */
  69593. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69594. /**
  69595. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69596. * The queries will try to find a solution within those bounds
  69597. * default is (1,1,1)
  69598. * @param extent x,y,z value that define the extent around the queries point of reference
  69599. */
  69600. setDefaultQueryExtent(extent: Vector3): void;
  69601. /**
  69602. * Get the Bounding box extent specified by setDefaultQueryExtent
  69603. * @returns the box extent values
  69604. */
  69605. getDefaultQueryExtent(): Vector3;
  69606. /**
  69607. * build the navmesh from a previously saved state using getNavmeshData
  69608. * @param data the Uint8Array returned by getNavmeshData
  69609. */
  69610. buildFromNavmeshData(data: Uint8Array): void;
  69611. /**
  69612. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69613. * @returns data the Uint8Array that can be saved and reused
  69614. */
  69615. getNavmeshData(): Uint8Array;
  69616. /**
  69617. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69618. * @param result output the box extent values
  69619. */
  69620. getDefaultQueryExtentToRef(result: Vector3): void;
  69621. /**
  69622. * Disposes
  69623. */
  69624. dispose(): void;
  69625. /**
  69626. * If this plugin is supported
  69627. * @returns true if plugin is supported
  69628. */
  69629. isSupported(): boolean;
  69630. }
  69631. /**
  69632. * Recast detour crowd implementation
  69633. */
  69634. export class RecastJSCrowd implements ICrowd {
  69635. /**
  69636. * Recast/detour plugin
  69637. */
  69638. bjsRECASTPlugin: RecastJSPlugin;
  69639. /**
  69640. * Link to the detour crowd
  69641. */
  69642. recastCrowd: any;
  69643. /**
  69644. * One transform per agent
  69645. */
  69646. transforms: TransformNode[];
  69647. /**
  69648. * All agents created
  69649. */
  69650. agents: number[];
  69651. /**
  69652. * Link to the scene is kept to unregister the crowd from the scene
  69653. */
  69654. private _scene;
  69655. /**
  69656. * Observer for crowd updates
  69657. */
  69658. private _onBeforeAnimationsObserver;
  69659. /**
  69660. * Constructor
  69661. * @param plugin recastJS plugin
  69662. * @param maxAgents the maximum agent count in the crowd
  69663. * @param maxAgentRadius the maximum radius an agent can have
  69664. * @param scene to attach the crowd to
  69665. * @returns the crowd you can add agents to
  69666. */
  69667. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  69668. /**
  69669. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69670. * You can attach anything to that node. The node position is updated in the scene update tick.
  69671. * @param pos world position that will be constrained by the navigation mesh
  69672. * @param parameters agent parameters
  69673. * @param transform hooked to the agent that will be update by the scene
  69674. * @returns agent index
  69675. */
  69676. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69677. /**
  69678. * Returns the agent position in world space
  69679. * @param index agent index returned by addAgent
  69680. * @returns world space position
  69681. */
  69682. getAgentPosition(index: number): Vector3;
  69683. /**
  69684. * Returns the agent position result in world space
  69685. * @param index agent index returned by addAgent
  69686. * @param result output world space position
  69687. */
  69688. getAgentPositionToRef(index: number, result: Vector3): void;
  69689. /**
  69690. * Returns the agent velocity in world space
  69691. * @param index agent index returned by addAgent
  69692. * @returns world space velocity
  69693. */
  69694. getAgentVelocity(index: number): Vector3;
  69695. /**
  69696. * Returns the agent velocity result in world space
  69697. * @param index agent index returned by addAgent
  69698. * @param result output world space velocity
  69699. */
  69700. getAgentVelocityToRef(index: number, result: Vector3): void;
  69701. /**
  69702. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69703. * @param index agent index returned by addAgent
  69704. * @param destination targeted world position
  69705. */
  69706. agentGoto(index: number, destination: Vector3): void;
  69707. /**
  69708. * Teleport the agent to a new position
  69709. * @param index agent index returned by addAgent
  69710. * @param destination targeted world position
  69711. */
  69712. agentTeleport(index: number, destination: Vector3): void;
  69713. /**
  69714. * Update agent parameters
  69715. * @param index agent index returned by addAgent
  69716. * @param parameters agent parameters
  69717. */
  69718. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69719. /**
  69720. * remove a particular agent previously created
  69721. * @param index agent index returned by addAgent
  69722. */
  69723. removeAgent(index: number): void;
  69724. /**
  69725. * get the list of all agents attached to this crowd
  69726. * @returns list of agent indices
  69727. */
  69728. getAgents(): number[];
  69729. /**
  69730. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69731. * @param deltaTime in seconds
  69732. */
  69733. update(deltaTime: number): void;
  69734. /**
  69735. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69736. * The queries will try to find a solution within those bounds
  69737. * default is (1,1,1)
  69738. * @param extent x,y,z value that define the extent around the queries point of reference
  69739. */
  69740. setDefaultQueryExtent(extent: Vector3): void;
  69741. /**
  69742. * Get the Bounding box extent specified by setDefaultQueryExtent
  69743. * @returns the box extent values
  69744. */
  69745. getDefaultQueryExtent(): Vector3;
  69746. /**
  69747. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69748. * @param result output the box extent values
  69749. */
  69750. getDefaultQueryExtentToRef(result: Vector3): void;
  69751. /**
  69752. * Release all resources
  69753. */
  69754. dispose(): void;
  69755. }
  69756. }
  69757. declare module "babylonjs/Navigation/Plugins/index" {
  69758. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69759. }
  69760. declare module "babylonjs/Navigation/index" {
  69761. export * from "babylonjs/Navigation/INavigationEngine";
  69762. export * from "babylonjs/Navigation/Plugins/index";
  69763. }
  69764. declare module "babylonjs/Offline/database" {
  69765. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69766. /**
  69767. * Class used to enable access to IndexedDB
  69768. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69769. */
  69770. export class Database implements IOfflineProvider {
  69771. private _callbackManifestChecked;
  69772. private _currentSceneUrl;
  69773. private _db;
  69774. private _enableSceneOffline;
  69775. private _enableTexturesOffline;
  69776. private _manifestVersionFound;
  69777. private _mustUpdateRessources;
  69778. private _hasReachedQuota;
  69779. private _isSupported;
  69780. private _idbFactory;
  69781. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69782. private static IsUASupportingBlobStorage;
  69783. /**
  69784. * Gets a boolean indicating if Database storate is enabled (off by default)
  69785. */
  69786. static IDBStorageEnabled: boolean;
  69787. /**
  69788. * Gets a boolean indicating if scene must be saved in the database
  69789. */
  69790. get enableSceneOffline(): boolean;
  69791. /**
  69792. * Gets a boolean indicating if textures must be saved in the database
  69793. */
  69794. get enableTexturesOffline(): boolean;
  69795. /**
  69796. * Creates a new Database
  69797. * @param urlToScene defines the url to load the scene
  69798. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69799. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69800. */
  69801. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69802. private static _ParseURL;
  69803. private static _ReturnFullUrlLocation;
  69804. private _checkManifestFile;
  69805. /**
  69806. * Open the database and make it available
  69807. * @param successCallback defines the callback to call on success
  69808. * @param errorCallback defines the callback to call on error
  69809. */
  69810. open(successCallback: () => void, errorCallback: () => void): void;
  69811. /**
  69812. * Loads an image from the database
  69813. * @param url defines the url to load from
  69814. * @param image defines the target DOM image
  69815. */
  69816. loadImage(url: string, image: HTMLImageElement): void;
  69817. private _loadImageFromDBAsync;
  69818. private _saveImageIntoDBAsync;
  69819. private _checkVersionFromDB;
  69820. private _loadVersionFromDBAsync;
  69821. private _saveVersionIntoDBAsync;
  69822. /**
  69823. * Loads a file from database
  69824. * @param url defines the URL to load from
  69825. * @param sceneLoaded defines a callback to call on success
  69826. * @param progressCallBack defines a callback to call when progress changed
  69827. * @param errorCallback defines a callback to call on error
  69828. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69829. */
  69830. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69831. private _loadFileAsync;
  69832. private _saveFileAsync;
  69833. /**
  69834. * Validates if xhr data is correct
  69835. * @param xhr defines the request to validate
  69836. * @param dataType defines the expected data type
  69837. * @returns true if data is correct
  69838. */
  69839. private static _ValidateXHRData;
  69840. }
  69841. }
  69842. declare module "babylonjs/Offline/index" {
  69843. export * from "babylonjs/Offline/database";
  69844. export * from "babylonjs/Offline/IOfflineProvider";
  69845. }
  69846. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69847. /** @hidden */
  69848. export var gpuUpdateParticlesPixelShader: {
  69849. name: string;
  69850. shader: string;
  69851. };
  69852. }
  69853. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69854. /** @hidden */
  69855. export var gpuUpdateParticlesVertexShader: {
  69856. name: string;
  69857. shader: string;
  69858. };
  69859. }
  69860. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69861. /** @hidden */
  69862. export var clipPlaneFragmentDeclaration2: {
  69863. name: string;
  69864. shader: string;
  69865. };
  69866. }
  69867. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69868. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69869. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69870. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69871. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69872. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69873. /** @hidden */
  69874. export var gpuRenderParticlesPixelShader: {
  69875. name: string;
  69876. shader: string;
  69877. };
  69878. }
  69879. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69880. /** @hidden */
  69881. export var clipPlaneVertexDeclaration2: {
  69882. name: string;
  69883. shader: string;
  69884. };
  69885. }
  69886. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69887. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69888. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69889. /** @hidden */
  69890. export var gpuRenderParticlesVertexShader: {
  69891. name: string;
  69892. shader: string;
  69893. };
  69894. }
  69895. declare module "babylonjs/Particles/gpuParticleSystem" {
  69896. import { Nullable } from "babylonjs/types";
  69897. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69898. import { Observable } from "babylonjs/Misc/observable";
  69899. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69900. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69901. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69902. import { Scene, IDisposable } from "babylonjs/scene";
  69903. import { Effect } from "babylonjs/Materials/effect";
  69904. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69905. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69906. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69907. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69908. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69909. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69910. /**
  69911. * This represents a GPU particle system in Babylon
  69912. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69913. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69914. */
  69915. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69916. /**
  69917. * The layer mask we are rendering the particles through.
  69918. */
  69919. layerMask: number;
  69920. private _capacity;
  69921. private _activeCount;
  69922. private _currentActiveCount;
  69923. private _accumulatedCount;
  69924. private _renderEffect;
  69925. private _updateEffect;
  69926. private _buffer0;
  69927. private _buffer1;
  69928. private _spriteBuffer;
  69929. private _updateVAO;
  69930. private _renderVAO;
  69931. private _targetIndex;
  69932. private _sourceBuffer;
  69933. private _targetBuffer;
  69934. private _engine;
  69935. private _currentRenderId;
  69936. private _started;
  69937. private _stopped;
  69938. private _timeDelta;
  69939. private _randomTexture;
  69940. private _randomTexture2;
  69941. private _attributesStrideSize;
  69942. private _updateEffectOptions;
  69943. private _randomTextureSize;
  69944. private _actualFrame;
  69945. private _customEffect;
  69946. private readonly _rawTextureWidth;
  69947. /**
  69948. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69949. */
  69950. static get IsSupported(): boolean;
  69951. /**
  69952. * An event triggered when the system is disposed.
  69953. */
  69954. onDisposeObservable: Observable<IParticleSystem>;
  69955. /**
  69956. * Gets the maximum number of particles active at the same time.
  69957. * @returns The max number of active particles.
  69958. */
  69959. getCapacity(): number;
  69960. /**
  69961. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69962. * to override the particles.
  69963. */
  69964. forceDepthWrite: boolean;
  69965. /**
  69966. * Gets or set the number of active particles
  69967. */
  69968. get activeParticleCount(): number;
  69969. set activeParticleCount(value: number);
  69970. private _preWarmDone;
  69971. /**
  69972. * Specifies if the particles are updated in emitter local space or world space.
  69973. */
  69974. isLocal: boolean;
  69975. /**
  69976. * Is this system ready to be used/rendered
  69977. * @return true if the system is ready
  69978. */
  69979. isReady(): boolean;
  69980. /**
  69981. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69982. * @returns True if it has been started, otherwise false.
  69983. */
  69984. isStarted(): boolean;
  69985. /**
  69986. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69987. * @returns True if it has been stopped, otherwise false.
  69988. */
  69989. isStopped(): boolean;
  69990. /**
  69991. * Gets a boolean indicating that the system is stopping
  69992. * @returns true if the system is currently stopping
  69993. */
  69994. isStopping(): boolean;
  69995. /**
  69996. * Gets the number of particles active at the same time.
  69997. * @returns The number of active particles.
  69998. */
  69999. getActiveCount(): number;
  70000. /**
  70001. * Starts the particle system and begins to emit
  70002. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70003. */
  70004. start(delay?: number): void;
  70005. /**
  70006. * Stops the particle system.
  70007. */
  70008. stop(): void;
  70009. /**
  70010. * Remove all active particles
  70011. */
  70012. reset(): void;
  70013. /**
  70014. * Returns the string "GPUParticleSystem"
  70015. * @returns a string containing the class name
  70016. */
  70017. getClassName(): string;
  70018. /**
  70019. * Gets the custom effect used to render the particles
  70020. * @param blendMode Blend mode for which the effect should be retrieved
  70021. * @returns The effect
  70022. */
  70023. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70024. /**
  70025. * Sets the custom effect used to render the particles
  70026. * @param effect The effect to set
  70027. * @param blendMode Blend mode for which the effect should be set
  70028. */
  70029. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70030. /** @hidden */
  70031. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70032. /**
  70033. * Observable that will be called just before the particles are drawn
  70034. */
  70035. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70036. /**
  70037. * Gets the name of the particle vertex shader
  70038. */
  70039. get vertexShaderName(): string;
  70040. private _colorGradientsTexture;
  70041. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70042. /**
  70043. * Adds a new color gradient
  70044. * @param gradient defines the gradient to use (between 0 and 1)
  70045. * @param color1 defines the color to affect to the specified gradient
  70046. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70047. * @returns the current particle system
  70048. */
  70049. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70050. private _refreshColorGradient;
  70051. /** Force the system to rebuild all gradients that need to be resync */
  70052. forceRefreshGradients(): void;
  70053. /**
  70054. * Remove a specific color gradient
  70055. * @param gradient defines the gradient to remove
  70056. * @returns the current particle system
  70057. */
  70058. removeColorGradient(gradient: number): GPUParticleSystem;
  70059. private _angularSpeedGradientsTexture;
  70060. private _sizeGradientsTexture;
  70061. private _velocityGradientsTexture;
  70062. private _limitVelocityGradientsTexture;
  70063. private _dragGradientsTexture;
  70064. private _addFactorGradient;
  70065. /**
  70066. * Adds a new size gradient
  70067. * @param gradient defines the gradient to use (between 0 and 1)
  70068. * @param factor defines the size factor to affect to the specified gradient
  70069. * @returns the current particle system
  70070. */
  70071. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70072. /**
  70073. * Remove a specific size gradient
  70074. * @param gradient defines the gradient to remove
  70075. * @returns the current particle system
  70076. */
  70077. removeSizeGradient(gradient: number): GPUParticleSystem;
  70078. private _refreshFactorGradient;
  70079. /**
  70080. * Adds a new angular speed gradient
  70081. * @param gradient defines the gradient to use (between 0 and 1)
  70082. * @param factor defines the angular speed to affect to the specified gradient
  70083. * @returns the current particle system
  70084. */
  70085. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70086. /**
  70087. * Remove a specific angular speed gradient
  70088. * @param gradient defines the gradient to remove
  70089. * @returns the current particle system
  70090. */
  70091. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70092. /**
  70093. * Adds a new velocity gradient
  70094. * @param gradient defines the gradient to use (between 0 and 1)
  70095. * @param factor defines the velocity to affect to the specified gradient
  70096. * @returns the current particle system
  70097. */
  70098. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70099. /**
  70100. * Remove a specific velocity gradient
  70101. * @param gradient defines the gradient to remove
  70102. * @returns the current particle system
  70103. */
  70104. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70105. /**
  70106. * Adds a new limit velocity gradient
  70107. * @param gradient defines the gradient to use (between 0 and 1)
  70108. * @param factor defines the limit velocity value to affect to the specified gradient
  70109. * @returns the current particle system
  70110. */
  70111. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70112. /**
  70113. * Remove a specific limit velocity gradient
  70114. * @param gradient defines the gradient to remove
  70115. * @returns the current particle system
  70116. */
  70117. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70118. /**
  70119. * Adds a new drag gradient
  70120. * @param gradient defines the gradient to use (between 0 and 1)
  70121. * @param factor defines the drag value to affect to the specified gradient
  70122. * @returns the current particle system
  70123. */
  70124. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70125. /**
  70126. * Remove a specific drag gradient
  70127. * @param gradient defines the gradient to remove
  70128. * @returns the current particle system
  70129. */
  70130. removeDragGradient(gradient: number): GPUParticleSystem;
  70131. /**
  70132. * Not supported by GPUParticleSystem
  70133. * @param gradient defines the gradient to use (between 0 and 1)
  70134. * @param factor defines the emit rate value to affect to the specified gradient
  70135. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70136. * @returns the current particle system
  70137. */
  70138. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70139. /**
  70140. * Not supported by GPUParticleSystem
  70141. * @param gradient defines the gradient to remove
  70142. * @returns the current particle system
  70143. */
  70144. removeEmitRateGradient(gradient: number): IParticleSystem;
  70145. /**
  70146. * Not supported by GPUParticleSystem
  70147. * @param gradient defines the gradient to use (between 0 and 1)
  70148. * @param factor defines the start size value to affect to the specified gradient
  70149. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70150. * @returns the current particle system
  70151. */
  70152. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70153. /**
  70154. * Not supported by GPUParticleSystem
  70155. * @param gradient defines the gradient to remove
  70156. * @returns the current particle system
  70157. */
  70158. removeStartSizeGradient(gradient: number): IParticleSystem;
  70159. /**
  70160. * Not supported by GPUParticleSystem
  70161. * @param gradient defines the gradient to use (between 0 and 1)
  70162. * @param min defines the color remap minimal range
  70163. * @param max defines the color remap maximal range
  70164. * @returns the current particle system
  70165. */
  70166. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70167. /**
  70168. * Not supported by GPUParticleSystem
  70169. * @param gradient defines the gradient to remove
  70170. * @returns the current particle system
  70171. */
  70172. removeColorRemapGradient(): IParticleSystem;
  70173. /**
  70174. * Not supported by GPUParticleSystem
  70175. * @param gradient defines the gradient to use (between 0 and 1)
  70176. * @param min defines the alpha remap minimal range
  70177. * @param max defines the alpha remap maximal range
  70178. * @returns the current particle system
  70179. */
  70180. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70181. /**
  70182. * Not supported by GPUParticleSystem
  70183. * @param gradient defines the gradient to remove
  70184. * @returns the current particle system
  70185. */
  70186. removeAlphaRemapGradient(): IParticleSystem;
  70187. /**
  70188. * Not supported by GPUParticleSystem
  70189. * @param gradient defines the gradient to use (between 0 and 1)
  70190. * @param color defines the color to affect to the specified gradient
  70191. * @returns the current particle system
  70192. */
  70193. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70194. /**
  70195. * Not supported by GPUParticleSystem
  70196. * @param gradient defines the gradient to remove
  70197. * @returns the current particle system
  70198. */
  70199. removeRampGradient(): IParticleSystem;
  70200. /**
  70201. * Not supported by GPUParticleSystem
  70202. * @returns the list of ramp gradients
  70203. */
  70204. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70205. /**
  70206. * Not supported by GPUParticleSystem
  70207. * Gets or sets a boolean indicating that ramp gradients must be used
  70208. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70209. */
  70210. get useRampGradients(): boolean;
  70211. set useRampGradients(value: boolean);
  70212. /**
  70213. * Not supported by GPUParticleSystem
  70214. * @param gradient defines the gradient to use (between 0 and 1)
  70215. * @param factor defines the life time factor to affect to the specified gradient
  70216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70217. * @returns the current particle system
  70218. */
  70219. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70220. /**
  70221. * Not supported by GPUParticleSystem
  70222. * @param gradient defines the gradient to remove
  70223. * @returns the current particle system
  70224. */
  70225. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70226. /**
  70227. * Instantiates a GPU particle system.
  70228. * 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.
  70229. * @param name The name of the particle system
  70230. * @param options The options used to create the system
  70231. * @param scene The scene the particle system belongs to
  70232. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70233. * @param customEffect a custom effect used to change the way particles are rendered by default
  70234. */
  70235. constructor(name: string, options: Partial<{
  70236. capacity: number;
  70237. randomTextureSize: number;
  70238. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70239. protected _reset(): void;
  70240. private _createUpdateVAO;
  70241. private _createRenderVAO;
  70242. private _initialize;
  70243. /** @hidden */
  70244. _recreateUpdateEffect(): void;
  70245. private _getEffect;
  70246. /**
  70247. * Fill the defines array according to the current settings of the particle system
  70248. * @param defines Array to be updated
  70249. * @param blendMode blend mode to take into account when updating the array
  70250. */
  70251. fillDefines(defines: Array<string>, blendMode?: number): void;
  70252. /**
  70253. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70254. * @param uniforms Uniforms array to fill
  70255. * @param attributes Attributes array to fill
  70256. * @param samplers Samplers array to fill
  70257. */
  70258. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70259. /** @hidden */
  70260. _recreateRenderEffect(): Effect;
  70261. /**
  70262. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70263. * @param preWarm defines if we are in the pre-warmimg phase
  70264. */
  70265. animate(preWarm?: boolean): void;
  70266. private _createFactorGradientTexture;
  70267. private _createSizeGradientTexture;
  70268. private _createAngularSpeedGradientTexture;
  70269. private _createVelocityGradientTexture;
  70270. private _createLimitVelocityGradientTexture;
  70271. private _createDragGradientTexture;
  70272. private _createColorGradientTexture;
  70273. /**
  70274. * Renders the particle system in its current state
  70275. * @param preWarm defines if the system should only update the particles but not render them
  70276. * @returns the current number of particles
  70277. */
  70278. render(preWarm?: boolean): number;
  70279. /**
  70280. * Rebuilds the particle system
  70281. */
  70282. rebuild(): void;
  70283. private _releaseBuffers;
  70284. private _releaseVAOs;
  70285. /**
  70286. * Disposes the particle system and free the associated resources
  70287. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70288. */
  70289. dispose(disposeTexture?: boolean): void;
  70290. /**
  70291. * Clones the particle system.
  70292. * @param name The name of the cloned object
  70293. * @param newEmitter The new emitter to use
  70294. * @returns the cloned particle system
  70295. */
  70296. clone(name: string, newEmitter: any): GPUParticleSystem;
  70297. /**
  70298. * Serializes the particle system to a JSON object
  70299. * @param serializeTexture defines if the texture must be serialized as well
  70300. * @returns the JSON object
  70301. */
  70302. serialize(serializeTexture?: boolean): any;
  70303. /**
  70304. * Parses a JSON object to create a GPU particle system.
  70305. * @param parsedParticleSystem The JSON object to parse
  70306. * @param scene The scene to create the particle system in
  70307. * @param rootUrl The root url to use to load external dependencies like texture
  70308. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70309. * @returns the parsed GPU particle system
  70310. */
  70311. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70312. }
  70313. }
  70314. declare module "babylonjs/Particles/particleSystemSet" {
  70315. import { Nullable } from "babylonjs/types";
  70316. import { Color3 } from "babylonjs/Maths/math.color";
  70317. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70319. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70320. import { Scene, IDisposable } from "babylonjs/scene";
  70321. /**
  70322. * Represents a set of particle systems working together to create a specific effect
  70323. */
  70324. export class ParticleSystemSet implements IDisposable {
  70325. /**
  70326. * Gets or sets base Assets URL
  70327. */
  70328. static BaseAssetsUrl: string;
  70329. private _emitterCreationOptions;
  70330. private _emitterNode;
  70331. /**
  70332. * Gets the particle system list
  70333. */
  70334. systems: IParticleSystem[];
  70335. /**
  70336. * Gets the emitter node used with this set
  70337. */
  70338. get emitterNode(): Nullable<TransformNode>;
  70339. /**
  70340. * Creates a new emitter mesh as a sphere
  70341. * @param options defines the options used to create the sphere
  70342. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70343. * @param scene defines the hosting scene
  70344. */
  70345. setEmitterAsSphere(options: {
  70346. diameter: number;
  70347. segments: number;
  70348. color: Color3;
  70349. }, renderingGroupId: number, scene: Scene): void;
  70350. /**
  70351. * Starts all particle systems of the set
  70352. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70353. */
  70354. start(emitter?: AbstractMesh): void;
  70355. /**
  70356. * Release all associated resources
  70357. */
  70358. dispose(): void;
  70359. /**
  70360. * Serialize the set into a JSON compatible object
  70361. * @param serializeTexture defines if the texture must be serialized as well
  70362. * @returns a JSON compatible representation of the set
  70363. */
  70364. serialize(serializeTexture?: boolean): any;
  70365. /**
  70366. * Parse a new ParticleSystemSet from a serialized source
  70367. * @param data defines a JSON compatible representation of the set
  70368. * @param scene defines the hosting scene
  70369. * @param gpu defines if we want GPU particles or CPU particles
  70370. * @returns a new ParticleSystemSet
  70371. */
  70372. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  70373. }
  70374. }
  70375. declare module "babylonjs/Particles/particleHelper" {
  70376. import { Nullable } from "babylonjs/types";
  70377. import { Scene } from "babylonjs/scene";
  70378. import { Vector3 } from "babylonjs/Maths/math.vector";
  70379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70380. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70381. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  70382. /**
  70383. * This class is made for on one-liner static method to help creating particle system set.
  70384. */
  70385. export class ParticleHelper {
  70386. /**
  70387. * Gets or sets base Assets URL
  70388. */
  70389. static BaseAssetsUrl: string;
  70390. /** Define the Url to load snippets */
  70391. static SnippetUrl: string;
  70392. /**
  70393. * Create a default particle system that you can tweak
  70394. * @param emitter defines the emitter to use
  70395. * @param capacity defines the system capacity (default is 500 particles)
  70396. * @param scene defines the hosting scene
  70397. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70398. * @returns the new Particle system
  70399. */
  70400. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70401. /**
  70402. * This is the main static method (one-liner) of this helper to create different particle systems
  70403. * @param type This string represents the type to the particle system to create
  70404. * @param scene The scene where the particle system should live
  70405. * @param gpu If the system will use gpu
  70406. * @returns the ParticleSystemSet created
  70407. */
  70408. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70409. /**
  70410. * Static function used to export a particle system to a ParticleSystemSet variable.
  70411. * Please note that the emitter shape is not exported
  70412. * @param systems defines the particle systems to export
  70413. * @returns the created particle system set
  70414. */
  70415. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70416. /**
  70417. * Creates a particle system from a snippet saved in a remote file
  70418. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70419. * @param url defines the url to load from
  70420. * @param scene defines the hosting scene
  70421. * @param gpu If the system will use gpu
  70422. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70423. * @returns a promise that will resolve to the new particle system
  70424. */
  70425. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70426. /**
  70427. * Creates a particle system from a snippet saved by the particle system editor
  70428. * @param snippetId defines the snippet to load
  70429. * @param scene defines the hosting scene
  70430. * @param gpu If the system will use gpu
  70431. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70432. * @returns a promise that will resolve to the new particle system
  70433. */
  70434. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70435. }
  70436. }
  70437. declare module "babylonjs/Particles/particleSystemComponent" {
  70438. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70439. import { Effect } from "babylonjs/Materials/effect";
  70440. import "babylonjs/Shaders/particles.vertex";
  70441. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70442. module "babylonjs/Engines/engine" {
  70443. interface Engine {
  70444. /**
  70445. * Create an effect to use with particle systems.
  70446. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  70447. * the particle system for which you want to create a custom effect in the last parameter
  70448. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  70449. * @param uniformsNames defines a list of attribute names
  70450. * @param samplers defines an array of string used to represent textures
  70451. * @param defines defines the string containing the defines to use to compile the shaders
  70452. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  70453. * @param onCompiled defines a function to call when the effect creation is successful
  70454. * @param onError defines a function to call when the effect creation has failed
  70455. * @param particleSystem the particle system you want to create the effect for
  70456. * @returns the new Effect
  70457. */
  70458. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  70459. }
  70460. }
  70461. module "babylonjs/Meshes/mesh" {
  70462. interface Mesh {
  70463. /**
  70464. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  70465. * @returns an array of IParticleSystem
  70466. */
  70467. getEmittedParticleSystems(): IParticleSystem[];
  70468. /**
  70469. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  70470. * @returns an array of IParticleSystem
  70471. */
  70472. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  70473. }
  70474. }
  70475. }
  70476. declare module "babylonjs/Particles/pointsCloudSystem" {
  70477. import { Color4 } from "babylonjs/Maths/math";
  70478. import { Mesh } from "babylonjs/Meshes/mesh";
  70479. import { Scene, IDisposable } from "babylonjs/scene";
  70480. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  70481. /** Defines the 4 color options */
  70482. export enum PointColor {
  70483. /** color value */
  70484. Color = 2,
  70485. /** uv value */
  70486. UV = 1,
  70487. /** random value */
  70488. Random = 0,
  70489. /** stated value */
  70490. Stated = 3
  70491. }
  70492. /**
  70493. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  70494. * 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.
  70495. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  70496. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  70497. *
  70498. * Full documentation here : TO BE ENTERED
  70499. */
  70500. export class PointsCloudSystem implements IDisposable {
  70501. /**
  70502. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  70503. * Example : var p = SPS.particles[i];
  70504. */
  70505. particles: CloudPoint[];
  70506. /**
  70507. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  70508. */
  70509. nbParticles: number;
  70510. /**
  70511. * This a counter for your own usage. It's not set by any SPS functions.
  70512. */
  70513. counter: number;
  70514. /**
  70515. * The PCS name. This name is also given to the underlying mesh.
  70516. */
  70517. name: string;
  70518. /**
  70519. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  70520. */
  70521. mesh: Mesh;
  70522. /**
  70523. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  70524. * Please read :
  70525. */
  70526. vars: any;
  70527. /**
  70528. * @hidden
  70529. */
  70530. _size: number;
  70531. private _scene;
  70532. private _promises;
  70533. private _positions;
  70534. private _indices;
  70535. private _normals;
  70536. private _colors;
  70537. private _uvs;
  70538. private _indices32;
  70539. private _positions32;
  70540. private _colors32;
  70541. private _uvs32;
  70542. private _updatable;
  70543. private _isVisibilityBoxLocked;
  70544. private _alwaysVisible;
  70545. private _groups;
  70546. private _groupCounter;
  70547. private _computeParticleColor;
  70548. private _computeParticleTexture;
  70549. private _computeParticleRotation;
  70550. private _computeBoundingBox;
  70551. private _isReady;
  70552. /**
  70553. * Creates a PCS (Points Cloud System) object
  70554. * @param name (String) is the PCS name, this will be the underlying mesh name
  70555. * @param pointSize (number) is the size for each point
  70556. * @param scene (Scene) is the scene in which the PCS is added
  70557. * @param options defines the options of the PCS e.g.
  70558. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  70559. */
  70560. constructor(name: string, pointSize: number, scene: Scene, options?: {
  70561. updatable?: boolean;
  70562. });
  70563. /**
  70564. * Builds the PCS underlying mesh. Returns a standard Mesh.
  70565. * If no points were added to the PCS, the returned mesh is just a single point.
  70566. * @returns a promise for the created mesh
  70567. */
  70568. buildMeshAsync(): Promise<Mesh>;
  70569. /**
  70570. * @hidden
  70571. */
  70572. private _buildMesh;
  70573. private _addParticle;
  70574. private _randomUnitVector;
  70575. private _getColorIndicesForCoord;
  70576. private _setPointsColorOrUV;
  70577. private _colorFromTexture;
  70578. private _calculateDensity;
  70579. /**
  70580. * Adds points to the PCS in random positions within a unit sphere
  70581. * @param nb (positive integer) the number of particles to be created from this model
  70582. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  70583. * @returns the number of groups in the system
  70584. */
  70585. addPoints(nb: number, pointFunction?: any): number;
  70586. /**
  70587. * Adds points to the PCS from the surface of the model shape
  70588. * @param mesh is any Mesh object that will be used as a surface model for the points
  70589. * @param nb (positive integer) the number of particles to be created from this model
  70590. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70591. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70592. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70593. * @returns the number of groups in the system
  70594. */
  70595. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70596. /**
  70597. * Adds points to the PCS inside the model shape
  70598. * @param mesh is any Mesh object that will be used as a surface model for the points
  70599. * @param nb (positive integer) the number of particles to be created from this model
  70600. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70601. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70602. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70603. * @returns the number of groups in the system
  70604. */
  70605. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70606. /**
  70607. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  70608. * This method calls `updateParticle()` for each particle of the SPS.
  70609. * For an animated SPS, it is usually called within the render loop.
  70610. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  70611. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  70612. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  70613. * @returns the PCS.
  70614. */
  70615. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  70616. /**
  70617. * Disposes the PCS.
  70618. */
  70619. dispose(): void;
  70620. /**
  70621. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  70622. * doc :
  70623. * @returns the PCS.
  70624. */
  70625. refreshVisibleSize(): PointsCloudSystem;
  70626. /**
  70627. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  70628. * @param size the size (float) of the visibility box
  70629. * note : this doesn't lock the PCS mesh bounding box.
  70630. * doc :
  70631. */
  70632. setVisibilityBox(size: number): void;
  70633. /**
  70634. * Gets whether the PCS is always visible or not
  70635. * doc :
  70636. */
  70637. get isAlwaysVisible(): boolean;
  70638. /**
  70639. * Sets the PCS as always visible or not
  70640. * doc :
  70641. */
  70642. set isAlwaysVisible(val: boolean);
  70643. /**
  70644. * Tells to `setParticles()` to compute the particle rotations or not
  70645. * Default value : false. The PCS is faster when it's set to false
  70646. * Note : particle rotations are only applied to parent particles
  70647. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  70648. */
  70649. set computeParticleRotation(val: boolean);
  70650. /**
  70651. * Tells to `setParticles()` to compute the particle colors or not.
  70652. * Default value : true. The PCS is faster when it's set to false.
  70653. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70654. */
  70655. set computeParticleColor(val: boolean);
  70656. set computeParticleTexture(val: boolean);
  70657. /**
  70658. * Gets if `setParticles()` computes the particle colors or not.
  70659. * Default value : false. The PCS is faster when it's set to false.
  70660. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70661. */
  70662. get computeParticleColor(): boolean;
  70663. /**
  70664. * Gets if `setParticles()` computes the particle textures or not.
  70665. * Default value : false. The PCS is faster when it's set to false.
  70666. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  70667. */
  70668. get computeParticleTexture(): boolean;
  70669. /**
  70670. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  70671. */
  70672. set computeBoundingBox(val: boolean);
  70673. /**
  70674. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  70675. */
  70676. get computeBoundingBox(): boolean;
  70677. /**
  70678. * This function does nothing. It may be overwritten to set all the particle first values.
  70679. * The PCS doesn't call this function, you may have to call it by your own.
  70680. * doc :
  70681. */
  70682. initParticles(): void;
  70683. /**
  70684. * This function does nothing. It may be overwritten to recycle a particle
  70685. * The PCS doesn't call this function, you can to call it
  70686. * doc :
  70687. * @param particle The particle to recycle
  70688. * @returns the recycled particle
  70689. */
  70690. recycleParticle(particle: CloudPoint): CloudPoint;
  70691. /**
  70692. * Updates a particle : this function should be overwritten by the user.
  70693. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  70694. * doc :
  70695. * @example : just set a particle position or velocity and recycle conditions
  70696. * @param particle The particle to update
  70697. * @returns the updated particle
  70698. */
  70699. updateParticle(particle: CloudPoint): CloudPoint;
  70700. /**
  70701. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  70702. * This does nothing and may be overwritten by the user.
  70703. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70704. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70705. * @param update the boolean update value actually passed to setParticles()
  70706. */
  70707. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70708. /**
  70709. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  70710. * This will be passed three parameters.
  70711. * This does nothing and may be overwritten by the user.
  70712. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70713. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70714. * @param update the boolean update value actually passed to setParticles()
  70715. */
  70716. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70717. }
  70718. }
  70719. declare module "babylonjs/Particles/cloudPoint" {
  70720. import { Nullable } from "babylonjs/types";
  70721. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  70722. import { Mesh } from "babylonjs/Meshes/mesh";
  70723. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  70724. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  70725. /**
  70726. * Represents one particle of a points cloud system.
  70727. */
  70728. export class CloudPoint {
  70729. /**
  70730. * particle global index
  70731. */
  70732. idx: number;
  70733. /**
  70734. * The color of the particle
  70735. */
  70736. color: Nullable<Color4>;
  70737. /**
  70738. * The world space position of the particle.
  70739. */
  70740. position: Vector3;
  70741. /**
  70742. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  70743. */
  70744. rotation: Vector3;
  70745. /**
  70746. * The world space rotation quaternion of the particle.
  70747. */
  70748. rotationQuaternion: Nullable<Quaternion>;
  70749. /**
  70750. * The uv of the particle.
  70751. */
  70752. uv: Nullable<Vector2>;
  70753. /**
  70754. * The current speed of the particle.
  70755. */
  70756. velocity: Vector3;
  70757. /**
  70758. * The pivot point in the particle local space.
  70759. */
  70760. pivot: Vector3;
  70761. /**
  70762. * Must the particle be translated from its pivot point in its local space ?
  70763. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70764. * Default : false
  70765. */
  70766. translateFromPivot: boolean;
  70767. /**
  70768. * Index of this particle in the global "positions" array (Internal use)
  70769. * @hidden
  70770. */
  70771. _pos: number;
  70772. /**
  70773. * @hidden Index of this particle in the global "indices" array (Internal use)
  70774. */
  70775. _ind: number;
  70776. /**
  70777. * Group this particle belongs to
  70778. */
  70779. _group: PointsGroup;
  70780. /**
  70781. * Group id of this particle
  70782. */
  70783. groupId: number;
  70784. /**
  70785. * Index of the particle in its group id (Internal use)
  70786. */
  70787. idxInGroup: number;
  70788. /**
  70789. * @hidden Particle BoundingInfo object (Internal use)
  70790. */
  70791. _boundingInfo: BoundingInfo;
  70792. /**
  70793. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70794. */
  70795. _pcs: PointsCloudSystem;
  70796. /**
  70797. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70798. */
  70799. _stillInvisible: boolean;
  70800. /**
  70801. * @hidden Last computed particle rotation matrix
  70802. */
  70803. _rotationMatrix: number[];
  70804. /**
  70805. * Parent particle Id, if any.
  70806. * Default null.
  70807. */
  70808. parentId: Nullable<number>;
  70809. /**
  70810. * @hidden Internal global position in the PCS.
  70811. */
  70812. _globalPosition: Vector3;
  70813. /**
  70814. * Creates a Point Cloud object.
  70815. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70816. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70817. * @param group (PointsGroup) is the group the particle belongs to
  70818. * @param groupId (integer) is the group identifier in the PCS.
  70819. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70820. * @param pcs defines the PCS it is associated to
  70821. */
  70822. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70823. /**
  70824. * get point size
  70825. */
  70826. get size(): Vector3;
  70827. /**
  70828. * Set point size
  70829. */
  70830. set size(scale: Vector3);
  70831. /**
  70832. * Legacy support, changed quaternion to rotationQuaternion
  70833. */
  70834. get quaternion(): Nullable<Quaternion>;
  70835. /**
  70836. * Legacy support, changed quaternion to rotationQuaternion
  70837. */
  70838. set quaternion(q: Nullable<Quaternion>);
  70839. /**
  70840. * Returns a boolean. True if the particle intersects a mesh, else false
  70841. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70842. * @param target is the object (point or mesh) what the intersection is computed against
  70843. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70844. * @returns true if it intersects
  70845. */
  70846. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70847. /**
  70848. * get the rotation matrix of the particle
  70849. * @hidden
  70850. */
  70851. getRotationMatrix(m: Matrix): void;
  70852. }
  70853. /**
  70854. * Represents a group of points in a points cloud system
  70855. * * PCS internal tool, don't use it manually.
  70856. */
  70857. export class PointsGroup {
  70858. /**
  70859. * The group id
  70860. * @hidden
  70861. */
  70862. groupID: number;
  70863. /**
  70864. * image data for group (internal use)
  70865. * @hidden
  70866. */
  70867. _groupImageData: Nullable<ArrayBufferView>;
  70868. /**
  70869. * Image Width (internal use)
  70870. * @hidden
  70871. */
  70872. _groupImgWidth: number;
  70873. /**
  70874. * Image Height (internal use)
  70875. * @hidden
  70876. */
  70877. _groupImgHeight: number;
  70878. /**
  70879. * Custom position function (internal use)
  70880. * @hidden
  70881. */
  70882. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70883. /**
  70884. * density per facet for surface points
  70885. * @hidden
  70886. */
  70887. _groupDensity: number[];
  70888. /**
  70889. * Only when points are colored by texture carries pointer to texture list array
  70890. * @hidden
  70891. */
  70892. _textureNb: number;
  70893. /**
  70894. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70895. * PCS internal tool, don't use it manually.
  70896. * @hidden
  70897. */
  70898. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70899. }
  70900. }
  70901. declare module "babylonjs/Particles/index" {
  70902. export * from "babylonjs/Particles/baseParticleSystem";
  70903. export * from "babylonjs/Particles/EmitterTypes/index";
  70904. export * from "babylonjs/Particles/gpuParticleSystem";
  70905. export * from "babylonjs/Particles/IParticleSystem";
  70906. export * from "babylonjs/Particles/particle";
  70907. export * from "babylonjs/Particles/particleHelper";
  70908. export * from "babylonjs/Particles/particleSystem";
  70909. import "babylonjs/Particles/particleSystemComponent";
  70910. export * from "babylonjs/Particles/particleSystemComponent";
  70911. export * from "babylonjs/Particles/particleSystemSet";
  70912. export * from "babylonjs/Particles/solidParticle";
  70913. export * from "babylonjs/Particles/solidParticleSystem";
  70914. export * from "babylonjs/Particles/cloudPoint";
  70915. export * from "babylonjs/Particles/pointsCloudSystem";
  70916. export * from "babylonjs/Particles/subEmitter";
  70917. }
  70918. declare module "babylonjs/Physics/physicsEngineComponent" {
  70919. import { Nullable } from "babylonjs/types";
  70920. import { Observable, Observer } from "babylonjs/Misc/observable";
  70921. import { Vector3 } from "babylonjs/Maths/math.vector";
  70922. import { Mesh } from "babylonjs/Meshes/mesh";
  70923. import { ISceneComponent } from "babylonjs/sceneComponent";
  70924. import { Scene } from "babylonjs/scene";
  70925. import { Node } from "babylonjs/node";
  70926. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70927. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70928. module "babylonjs/scene" {
  70929. interface Scene {
  70930. /** @hidden (Backing field) */
  70931. _physicsEngine: Nullable<IPhysicsEngine>;
  70932. /** @hidden */
  70933. _physicsTimeAccumulator: number;
  70934. /**
  70935. * Gets the current physics engine
  70936. * @returns a IPhysicsEngine or null if none attached
  70937. */
  70938. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70939. /**
  70940. * Enables physics to the current scene
  70941. * @param gravity defines the scene's gravity for the physics engine
  70942. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70943. * @return a boolean indicating if the physics engine was initialized
  70944. */
  70945. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70946. /**
  70947. * Disables and disposes the physics engine associated with the scene
  70948. */
  70949. disablePhysicsEngine(): void;
  70950. /**
  70951. * Gets a boolean indicating if there is an active physics engine
  70952. * @returns a boolean indicating if there is an active physics engine
  70953. */
  70954. isPhysicsEnabled(): boolean;
  70955. /**
  70956. * Deletes a physics compound impostor
  70957. * @param compound defines the compound to delete
  70958. */
  70959. deleteCompoundImpostor(compound: any): void;
  70960. /**
  70961. * An event triggered when physic simulation is about to be run
  70962. */
  70963. onBeforePhysicsObservable: Observable<Scene>;
  70964. /**
  70965. * An event triggered when physic simulation has been done
  70966. */
  70967. onAfterPhysicsObservable: Observable<Scene>;
  70968. }
  70969. }
  70970. module "babylonjs/Meshes/abstractMesh" {
  70971. interface AbstractMesh {
  70972. /** @hidden */
  70973. _physicsImpostor: Nullable<PhysicsImpostor>;
  70974. /**
  70975. * Gets or sets impostor used for physic simulation
  70976. * @see https://doc.babylonjs.com/features/physics_engine
  70977. */
  70978. physicsImpostor: Nullable<PhysicsImpostor>;
  70979. /**
  70980. * Gets the current physics impostor
  70981. * @see https://doc.babylonjs.com/features/physics_engine
  70982. * @returns a physics impostor or null
  70983. */
  70984. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70985. /** Apply a physic impulse to the mesh
  70986. * @param force defines the force to apply
  70987. * @param contactPoint defines where to apply the force
  70988. * @returns the current mesh
  70989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  70990. */
  70991. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70992. /**
  70993. * Creates a physic joint between two meshes
  70994. * @param otherMesh defines the other mesh to use
  70995. * @param pivot1 defines the pivot to use on this mesh
  70996. * @param pivot2 defines the pivot to use on the other mesh
  70997. * @param options defines additional options (can be plugin dependent)
  70998. * @returns the current mesh
  70999. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71000. */
  71001. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71002. /** @hidden */
  71003. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71004. }
  71005. }
  71006. /**
  71007. * Defines the physics engine scene component responsible to manage a physics engine
  71008. */
  71009. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71010. /**
  71011. * The component name helpful to identify the component in the list of scene components.
  71012. */
  71013. readonly name: string;
  71014. /**
  71015. * The scene the component belongs to.
  71016. */
  71017. scene: Scene;
  71018. /**
  71019. * Creates a new instance of the component for the given scene
  71020. * @param scene Defines the scene to register the component in
  71021. */
  71022. constructor(scene: Scene);
  71023. /**
  71024. * Registers the component in a given scene
  71025. */
  71026. register(): void;
  71027. /**
  71028. * Rebuilds the elements related to this component in case of
  71029. * context lost for instance.
  71030. */
  71031. rebuild(): void;
  71032. /**
  71033. * Disposes the component and the associated ressources
  71034. */
  71035. dispose(): void;
  71036. }
  71037. }
  71038. declare module "babylonjs/Physics/physicsHelper" {
  71039. import { Nullable } from "babylonjs/types";
  71040. import { Vector3 } from "babylonjs/Maths/math.vector";
  71041. import { Mesh } from "babylonjs/Meshes/mesh";
  71042. import { Scene } from "babylonjs/scene";
  71043. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71044. /**
  71045. * A helper for physics simulations
  71046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71047. */
  71048. export class PhysicsHelper {
  71049. private _scene;
  71050. private _physicsEngine;
  71051. /**
  71052. * Initializes the Physics helper
  71053. * @param scene Babylon.js scene
  71054. */
  71055. constructor(scene: Scene);
  71056. /**
  71057. * Applies a radial explosion impulse
  71058. * @param origin the origin of the explosion
  71059. * @param radiusOrEventOptions the radius or the options of radial explosion
  71060. * @param strength the explosion strength
  71061. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71062. * @returns A physics radial explosion event, or null
  71063. */
  71064. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71065. /**
  71066. * Applies a radial explosion force
  71067. * @param origin the origin of the explosion
  71068. * @param radiusOrEventOptions the radius or the options of radial explosion
  71069. * @param strength the explosion strength
  71070. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71071. * @returns A physics radial explosion event, or null
  71072. */
  71073. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71074. /**
  71075. * Creates a gravitational field
  71076. * @param origin the origin of the explosion
  71077. * @param radiusOrEventOptions the radius or the options of radial explosion
  71078. * @param strength the explosion strength
  71079. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71080. * @returns A physics gravitational field event, or null
  71081. */
  71082. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71083. /**
  71084. * Creates a physics updraft event
  71085. * @param origin the origin of the updraft
  71086. * @param radiusOrEventOptions the radius or the options of the updraft
  71087. * @param strength the strength of the updraft
  71088. * @param height the height of the updraft
  71089. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71090. * @returns A physics updraft event, or null
  71091. */
  71092. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71093. /**
  71094. * Creates a physics vortex event
  71095. * @param origin the of the vortex
  71096. * @param radiusOrEventOptions the radius or the options of the vortex
  71097. * @param strength the strength of the vortex
  71098. * @param height the height of the vortex
  71099. * @returns a Physics vortex event, or null
  71100. * A physics vortex event or null
  71101. */
  71102. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71103. }
  71104. /**
  71105. * Represents a physics radial explosion event
  71106. */
  71107. class PhysicsRadialExplosionEvent {
  71108. private _scene;
  71109. private _options;
  71110. private _sphere;
  71111. private _dataFetched;
  71112. /**
  71113. * Initializes a radial explosioin event
  71114. * @param _scene BabylonJS scene
  71115. * @param _options The options for the vortex event
  71116. */
  71117. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71118. /**
  71119. * Returns the data related to the radial explosion event (sphere).
  71120. * @returns The radial explosion event data
  71121. */
  71122. getData(): PhysicsRadialExplosionEventData;
  71123. /**
  71124. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71125. * @param impostor A physics imposter
  71126. * @param origin the origin of the explosion
  71127. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71128. */
  71129. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71130. /**
  71131. * Triggers affecterd impostors callbacks
  71132. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71133. */
  71134. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71135. /**
  71136. * Disposes the sphere.
  71137. * @param force Specifies if the sphere should be disposed by force
  71138. */
  71139. dispose(force?: boolean): void;
  71140. /*** Helpers ***/
  71141. private _prepareSphere;
  71142. private _intersectsWithSphere;
  71143. }
  71144. /**
  71145. * Represents a gravitational field event
  71146. */
  71147. class PhysicsGravitationalFieldEvent {
  71148. private _physicsHelper;
  71149. private _scene;
  71150. private _origin;
  71151. private _options;
  71152. private _tickCallback;
  71153. private _sphere;
  71154. private _dataFetched;
  71155. /**
  71156. * Initializes the physics gravitational field event
  71157. * @param _physicsHelper A physics helper
  71158. * @param _scene BabylonJS scene
  71159. * @param _origin The origin position of the gravitational field event
  71160. * @param _options The options for the vortex event
  71161. */
  71162. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71163. /**
  71164. * Returns the data related to the gravitational field event (sphere).
  71165. * @returns A gravitational field event
  71166. */
  71167. getData(): PhysicsGravitationalFieldEventData;
  71168. /**
  71169. * Enables the gravitational field.
  71170. */
  71171. enable(): void;
  71172. /**
  71173. * Disables the gravitational field.
  71174. */
  71175. disable(): void;
  71176. /**
  71177. * Disposes the sphere.
  71178. * @param force The force to dispose from the gravitational field event
  71179. */
  71180. dispose(force?: boolean): void;
  71181. private _tick;
  71182. }
  71183. /**
  71184. * Represents a physics updraft event
  71185. */
  71186. class PhysicsUpdraftEvent {
  71187. private _scene;
  71188. private _origin;
  71189. private _options;
  71190. private _physicsEngine;
  71191. private _originTop;
  71192. private _originDirection;
  71193. private _tickCallback;
  71194. private _cylinder;
  71195. private _cylinderPosition;
  71196. private _dataFetched;
  71197. /**
  71198. * Initializes the physics updraft event
  71199. * @param _scene BabylonJS scene
  71200. * @param _origin The origin position of the updraft
  71201. * @param _options The options for the updraft event
  71202. */
  71203. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71204. /**
  71205. * Returns the data related to the updraft event (cylinder).
  71206. * @returns A physics updraft event
  71207. */
  71208. getData(): PhysicsUpdraftEventData;
  71209. /**
  71210. * Enables the updraft.
  71211. */
  71212. enable(): void;
  71213. /**
  71214. * Disables the updraft.
  71215. */
  71216. disable(): void;
  71217. /**
  71218. * Disposes the cylinder.
  71219. * @param force Specifies if the updraft should be disposed by force
  71220. */
  71221. dispose(force?: boolean): void;
  71222. private getImpostorHitData;
  71223. private _tick;
  71224. /*** Helpers ***/
  71225. private _prepareCylinder;
  71226. private _intersectsWithCylinder;
  71227. }
  71228. /**
  71229. * Represents a physics vortex event
  71230. */
  71231. class PhysicsVortexEvent {
  71232. private _scene;
  71233. private _origin;
  71234. private _options;
  71235. private _physicsEngine;
  71236. private _originTop;
  71237. private _tickCallback;
  71238. private _cylinder;
  71239. private _cylinderPosition;
  71240. private _dataFetched;
  71241. /**
  71242. * Initializes the physics vortex event
  71243. * @param _scene The BabylonJS scene
  71244. * @param _origin The origin position of the vortex
  71245. * @param _options The options for the vortex event
  71246. */
  71247. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71248. /**
  71249. * Returns the data related to the vortex event (cylinder).
  71250. * @returns The physics vortex event data
  71251. */
  71252. getData(): PhysicsVortexEventData;
  71253. /**
  71254. * Enables the vortex.
  71255. */
  71256. enable(): void;
  71257. /**
  71258. * Disables the cortex.
  71259. */
  71260. disable(): void;
  71261. /**
  71262. * Disposes the sphere.
  71263. * @param force
  71264. */
  71265. dispose(force?: boolean): void;
  71266. private getImpostorHitData;
  71267. private _tick;
  71268. /*** Helpers ***/
  71269. private _prepareCylinder;
  71270. private _intersectsWithCylinder;
  71271. }
  71272. /**
  71273. * Options fot the radial explosion event
  71274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71275. */
  71276. export class PhysicsRadialExplosionEventOptions {
  71277. /**
  71278. * The radius of the sphere for the radial explosion.
  71279. */
  71280. radius: number;
  71281. /**
  71282. * The strenth of the explosion.
  71283. */
  71284. strength: number;
  71285. /**
  71286. * The strenght of the force in correspondence to the distance of the affected object
  71287. */
  71288. falloff: PhysicsRadialImpulseFalloff;
  71289. /**
  71290. * Sphere options for the radial explosion.
  71291. */
  71292. sphere: {
  71293. segments: number;
  71294. diameter: number;
  71295. };
  71296. /**
  71297. * Sphere options for the radial explosion.
  71298. */
  71299. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71300. }
  71301. /**
  71302. * Options fot the updraft event
  71303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71304. */
  71305. export class PhysicsUpdraftEventOptions {
  71306. /**
  71307. * The radius of the cylinder for the vortex
  71308. */
  71309. radius: number;
  71310. /**
  71311. * The strenth of the updraft.
  71312. */
  71313. strength: number;
  71314. /**
  71315. * The height of the cylinder for the updraft.
  71316. */
  71317. height: number;
  71318. /**
  71319. * The mode for the the updraft.
  71320. */
  71321. updraftMode: PhysicsUpdraftMode;
  71322. }
  71323. /**
  71324. * Options fot the vortex event
  71325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71326. */
  71327. export class PhysicsVortexEventOptions {
  71328. /**
  71329. * The radius of the cylinder for the vortex
  71330. */
  71331. radius: number;
  71332. /**
  71333. * The strenth of the vortex.
  71334. */
  71335. strength: number;
  71336. /**
  71337. * The height of the cylinder for the vortex.
  71338. */
  71339. height: number;
  71340. /**
  71341. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71342. */
  71343. centripetalForceThreshold: number;
  71344. /**
  71345. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71346. */
  71347. centripetalForceMultiplier: number;
  71348. /**
  71349. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71350. */
  71351. centrifugalForceMultiplier: number;
  71352. /**
  71353. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  71354. */
  71355. updraftForceMultiplier: number;
  71356. }
  71357. /**
  71358. * The strenght of the force in correspondence to the distance of the affected object
  71359. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71360. */
  71361. export enum PhysicsRadialImpulseFalloff {
  71362. /** Defines that impulse is constant in strength across it's whole radius */
  71363. Constant = 0,
  71364. /** Defines that impulse gets weaker if it's further from the origin */
  71365. Linear = 1
  71366. }
  71367. /**
  71368. * The strength of the force in correspondence to the distance of the affected object
  71369. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71370. */
  71371. export enum PhysicsUpdraftMode {
  71372. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  71373. Center = 0,
  71374. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  71375. Perpendicular = 1
  71376. }
  71377. /**
  71378. * Interface for a physics hit data
  71379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71380. */
  71381. export interface PhysicsHitData {
  71382. /**
  71383. * The force applied at the contact point
  71384. */
  71385. force: Vector3;
  71386. /**
  71387. * The contact point
  71388. */
  71389. contactPoint: Vector3;
  71390. /**
  71391. * The distance from the origin to the contact point
  71392. */
  71393. distanceFromOrigin: number;
  71394. }
  71395. /**
  71396. * Interface for radial explosion event data
  71397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71398. */
  71399. export interface PhysicsRadialExplosionEventData {
  71400. /**
  71401. * A sphere used for the radial explosion event
  71402. */
  71403. sphere: Mesh;
  71404. }
  71405. /**
  71406. * Interface for gravitational field event data
  71407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71408. */
  71409. export interface PhysicsGravitationalFieldEventData {
  71410. /**
  71411. * A sphere mesh used for the gravitational field event
  71412. */
  71413. sphere: Mesh;
  71414. }
  71415. /**
  71416. * Interface for updraft event data
  71417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71418. */
  71419. export interface PhysicsUpdraftEventData {
  71420. /**
  71421. * A cylinder used for the updraft event
  71422. */
  71423. cylinder: Mesh;
  71424. }
  71425. /**
  71426. * Interface for vortex event data
  71427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71428. */
  71429. export interface PhysicsVortexEventData {
  71430. /**
  71431. * A cylinder used for the vortex event
  71432. */
  71433. cylinder: Mesh;
  71434. }
  71435. /**
  71436. * Interface for an affected physics impostor
  71437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71438. */
  71439. export interface PhysicsAffectedImpostorWithData {
  71440. /**
  71441. * The impostor affected by the effect
  71442. */
  71443. impostor: PhysicsImpostor;
  71444. /**
  71445. * The data about the hit/horce from the explosion
  71446. */
  71447. hitData: PhysicsHitData;
  71448. }
  71449. }
  71450. declare module "babylonjs/Physics/Plugins/index" {
  71451. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  71452. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  71453. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  71454. }
  71455. declare module "babylonjs/Physics/index" {
  71456. export * from "babylonjs/Physics/IPhysicsEngine";
  71457. export * from "babylonjs/Physics/physicsEngine";
  71458. export * from "babylonjs/Physics/physicsEngineComponent";
  71459. export * from "babylonjs/Physics/physicsHelper";
  71460. export * from "babylonjs/Physics/physicsImpostor";
  71461. export * from "babylonjs/Physics/physicsJoint";
  71462. export * from "babylonjs/Physics/Plugins/index";
  71463. }
  71464. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  71465. /** @hidden */
  71466. export var blackAndWhitePixelShader: {
  71467. name: string;
  71468. shader: string;
  71469. };
  71470. }
  71471. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  71472. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71473. import { Camera } from "babylonjs/Cameras/camera";
  71474. import { Engine } from "babylonjs/Engines/engine";
  71475. import "babylonjs/Shaders/blackAndWhite.fragment";
  71476. /**
  71477. * Post process used to render in black and white
  71478. */
  71479. export class BlackAndWhitePostProcess extends PostProcess {
  71480. /**
  71481. * Linear about to convert he result to black and white (default: 1)
  71482. */
  71483. degree: number;
  71484. /**
  71485. * Creates a black and white post process
  71486. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  71487. * @param name The name of the effect.
  71488. * @param options The required width/height ratio to downsize to before computing the render pass.
  71489. * @param camera The camera to apply the render pass to.
  71490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71491. * @param engine The engine which the post process will be applied. (default: current engine)
  71492. * @param reusable If the post process can be reused on the same frame. (default: false)
  71493. */
  71494. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71495. }
  71496. }
  71497. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  71498. import { Nullable } from "babylonjs/types";
  71499. import { Camera } from "babylonjs/Cameras/camera";
  71500. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71501. import { Engine } from "babylonjs/Engines/engine";
  71502. /**
  71503. * This represents a set of one or more post processes in Babylon.
  71504. * A post process can be used to apply a shader to a texture after it is rendered.
  71505. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71506. */
  71507. export class PostProcessRenderEffect {
  71508. private _postProcesses;
  71509. private _getPostProcesses;
  71510. private _singleInstance;
  71511. private _cameras;
  71512. private _indicesForCamera;
  71513. /**
  71514. * Name of the effect
  71515. * @hidden
  71516. */
  71517. _name: string;
  71518. /**
  71519. * Instantiates a post process render effect.
  71520. * A post process can be used to apply a shader to a texture after it is rendered.
  71521. * @param engine The engine the effect is tied to
  71522. * @param name The name of the effect
  71523. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  71524. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  71525. */
  71526. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  71527. /**
  71528. * Checks if all the post processes in the effect are supported.
  71529. */
  71530. get isSupported(): boolean;
  71531. /**
  71532. * Updates the current state of the effect
  71533. * @hidden
  71534. */
  71535. _update(): void;
  71536. /**
  71537. * Attaches the effect on cameras
  71538. * @param cameras The camera to attach to.
  71539. * @hidden
  71540. */
  71541. _attachCameras(cameras: Camera): void;
  71542. /**
  71543. * Attaches the effect on cameras
  71544. * @param cameras The camera to attach to.
  71545. * @hidden
  71546. */
  71547. _attachCameras(cameras: Camera[]): void;
  71548. /**
  71549. * Detaches the effect on cameras
  71550. * @param cameras The camera to detatch from.
  71551. * @hidden
  71552. */
  71553. _detachCameras(cameras: Camera): void;
  71554. /**
  71555. * Detatches the effect on cameras
  71556. * @param cameras The camera to detatch from.
  71557. * @hidden
  71558. */
  71559. _detachCameras(cameras: Camera[]): void;
  71560. /**
  71561. * Enables the effect on given cameras
  71562. * @param cameras The camera to enable.
  71563. * @hidden
  71564. */
  71565. _enable(cameras: Camera): void;
  71566. /**
  71567. * Enables the effect on given cameras
  71568. * @param cameras The camera to enable.
  71569. * @hidden
  71570. */
  71571. _enable(cameras: Nullable<Camera[]>): void;
  71572. /**
  71573. * Disables the effect on the given cameras
  71574. * @param cameras The camera to disable.
  71575. * @hidden
  71576. */
  71577. _disable(cameras: Camera): void;
  71578. /**
  71579. * Disables the effect on the given cameras
  71580. * @param cameras The camera to disable.
  71581. * @hidden
  71582. */
  71583. _disable(cameras: Nullable<Camera[]>): void;
  71584. /**
  71585. * Gets a list of the post processes contained in the effect.
  71586. * @param camera The camera to get the post processes on.
  71587. * @returns The list of the post processes in the effect.
  71588. */
  71589. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  71590. }
  71591. }
  71592. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  71593. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71594. /** @hidden */
  71595. export var extractHighlightsPixelShader: {
  71596. name: string;
  71597. shader: string;
  71598. };
  71599. }
  71600. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  71601. import { Nullable } from "babylonjs/types";
  71602. import { Camera } from "babylonjs/Cameras/camera";
  71603. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71604. import { Engine } from "babylonjs/Engines/engine";
  71605. import "babylonjs/Shaders/extractHighlights.fragment";
  71606. /**
  71607. * 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.
  71608. */
  71609. export class ExtractHighlightsPostProcess extends PostProcess {
  71610. /**
  71611. * The luminance threshold, pixels below this value will be set to black.
  71612. */
  71613. threshold: number;
  71614. /** @hidden */
  71615. _exposure: number;
  71616. /**
  71617. * Post process which has the input texture to be used when performing highlight extraction
  71618. * @hidden
  71619. */
  71620. _inputPostProcess: Nullable<PostProcess>;
  71621. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71622. }
  71623. }
  71624. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  71625. /** @hidden */
  71626. export var bloomMergePixelShader: {
  71627. name: string;
  71628. shader: string;
  71629. };
  71630. }
  71631. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  71632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71633. import { Nullable } from "babylonjs/types";
  71634. import { Engine } from "babylonjs/Engines/engine";
  71635. import { Camera } from "babylonjs/Cameras/camera";
  71636. import "babylonjs/Shaders/bloomMerge.fragment";
  71637. /**
  71638. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71639. */
  71640. export class BloomMergePostProcess extends PostProcess {
  71641. /** Weight of the bloom to be added to the original input. */
  71642. weight: number;
  71643. /**
  71644. * Creates a new instance of @see BloomMergePostProcess
  71645. * @param name The name of the effect.
  71646. * @param originalFromInput Post process which's input will be used for the merge.
  71647. * @param blurred Blurred highlights post process which's output will be used.
  71648. * @param weight Weight of the bloom to be added to the original input.
  71649. * @param options The required width/height ratio to downsize to before computing the render pass.
  71650. * @param camera The camera to apply the render pass to.
  71651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71652. * @param engine The engine which the post process will be applied. (default: current engine)
  71653. * @param reusable If the post process can be reused on the same frame. (default: false)
  71654. * @param textureType Type of textures used when performing the post process. (default: 0)
  71655. * @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)
  71656. */
  71657. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  71658. /** Weight of the bloom to be added to the original input. */
  71659. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71660. }
  71661. }
  71662. declare module "babylonjs/PostProcesses/bloomEffect" {
  71663. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71664. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71665. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71666. import { Camera } from "babylonjs/Cameras/camera";
  71667. import { Scene } from "babylonjs/scene";
  71668. /**
  71669. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  71670. */
  71671. export class BloomEffect extends PostProcessRenderEffect {
  71672. private bloomScale;
  71673. /**
  71674. * @hidden Internal
  71675. */
  71676. _effects: Array<PostProcess>;
  71677. /**
  71678. * @hidden Internal
  71679. */
  71680. _downscale: ExtractHighlightsPostProcess;
  71681. private _blurX;
  71682. private _blurY;
  71683. private _merge;
  71684. /**
  71685. * The luminance threshold to find bright areas of the image to bloom.
  71686. */
  71687. get threshold(): number;
  71688. set threshold(value: number);
  71689. /**
  71690. * The strength of the bloom.
  71691. */
  71692. get weight(): number;
  71693. set weight(value: number);
  71694. /**
  71695. * Specifies the size of the bloom blur kernel, relative to the final output size
  71696. */
  71697. get kernel(): number;
  71698. set kernel(value: number);
  71699. /**
  71700. * Creates a new instance of @see BloomEffect
  71701. * @param scene The scene the effect belongs to.
  71702. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  71703. * @param bloomKernel The size of the kernel to be used when applying the blur.
  71704. * @param bloomWeight The the strength of bloom.
  71705. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71706. * @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)
  71707. */
  71708. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  71709. /**
  71710. * Disposes each of the internal effects for a given camera.
  71711. * @param camera The camera to dispose the effect on.
  71712. */
  71713. disposeEffects(camera: Camera): void;
  71714. /**
  71715. * @hidden Internal
  71716. */
  71717. _updateEffects(): void;
  71718. /**
  71719. * Internal
  71720. * @returns if all the contained post processes are ready.
  71721. * @hidden
  71722. */
  71723. _isReady(): boolean;
  71724. }
  71725. }
  71726. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  71727. /** @hidden */
  71728. export var chromaticAberrationPixelShader: {
  71729. name: string;
  71730. shader: string;
  71731. };
  71732. }
  71733. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  71734. import { Vector2 } from "babylonjs/Maths/math.vector";
  71735. import { Nullable } from "babylonjs/types";
  71736. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71737. import { Camera } from "babylonjs/Cameras/camera";
  71738. import { Engine } from "babylonjs/Engines/engine";
  71739. import "babylonjs/Shaders/chromaticAberration.fragment";
  71740. /**
  71741. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  71742. */
  71743. export class ChromaticAberrationPostProcess extends PostProcess {
  71744. /**
  71745. * The amount of seperation of rgb channels (default: 30)
  71746. */
  71747. aberrationAmount: number;
  71748. /**
  71749. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71750. */
  71751. radialIntensity: number;
  71752. /**
  71753. * 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))
  71754. */
  71755. direction: Vector2;
  71756. /**
  71757. * 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))
  71758. */
  71759. centerPosition: Vector2;
  71760. /**
  71761. * Creates a new instance ChromaticAberrationPostProcess
  71762. * @param name The name of the effect.
  71763. * @param screenWidth The width of the screen to apply the effect on.
  71764. * @param screenHeight The height of the screen to apply the effect on.
  71765. * @param options The required width/height ratio to downsize to before computing the render pass.
  71766. * @param camera The camera to apply the render pass to.
  71767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71768. * @param engine The engine which the post process will be applied. (default: current engine)
  71769. * @param reusable If the post process can be reused on the same frame. (default: false)
  71770. * @param textureType Type of textures used when performing the post process. (default: 0)
  71771. * @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)
  71772. */
  71773. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71774. }
  71775. }
  71776. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71777. /** @hidden */
  71778. export var circleOfConfusionPixelShader: {
  71779. name: string;
  71780. shader: string;
  71781. };
  71782. }
  71783. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71784. import { Nullable } from "babylonjs/types";
  71785. import { Engine } from "babylonjs/Engines/engine";
  71786. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71787. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71788. import { Camera } from "babylonjs/Cameras/camera";
  71789. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71790. /**
  71791. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71792. */
  71793. export class CircleOfConfusionPostProcess extends PostProcess {
  71794. /**
  71795. * 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.
  71796. */
  71797. lensSize: number;
  71798. /**
  71799. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71800. */
  71801. fStop: number;
  71802. /**
  71803. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71804. */
  71805. focusDistance: number;
  71806. /**
  71807. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71808. */
  71809. focalLength: number;
  71810. private _depthTexture;
  71811. /**
  71812. * Creates a new instance CircleOfConfusionPostProcess
  71813. * @param name The name of the effect.
  71814. * @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.
  71815. * @param options The required width/height ratio to downsize to before computing the render pass.
  71816. * @param camera The camera to apply the render pass to.
  71817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71818. * @param engine The engine which the post process will be applied. (default: current engine)
  71819. * @param reusable If the post process can be reused on the same frame. (default: false)
  71820. * @param textureType Type of textures used when performing the post process. (default: 0)
  71821. * @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)
  71822. */
  71823. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71824. /**
  71825. * 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.
  71826. */
  71827. set depthTexture(value: RenderTargetTexture);
  71828. }
  71829. }
  71830. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71831. /** @hidden */
  71832. export var colorCorrectionPixelShader: {
  71833. name: string;
  71834. shader: string;
  71835. };
  71836. }
  71837. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71838. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71839. import { Engine } from "babylonjs/Engines/engine";
  71840. import { Camera } from "babylonjs/Cameras/camera";
  71841. import "babylonjs/Shaders/colorCorrection.fragment";
  71842. /**
  71843. *
  71844. * This post-process allows the modification of rendered colors by using
  71845. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71846. *
  71847. * The object needs to be provided an url to a texture containing the color
  71848. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71849. * Use an image editing software to tweak the LUT to match your needs.
  71850. *
  71851. * For an example of a color LUT, see here:
  71852. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71853. * For explanations on color grading, see here:
  71854. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71855. *
  71856. */
  71857. export class ColorCorrectionPostProcess extends PostProcess {
  71858. private _colorTableTexture;
  71859. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71860. }
  71861. }
  71862. declare module "babylonjs/Shaders/convolution.fragment" {
  71863. /** @hidden */
  71864. export var convolutionPixelShader: {
  71865. name: string;
  71866. shader: string;
  71867. };
  71868. }
  71869. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71870. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71871. import { Nullable } from "babylonjs/types";
  71872. import { Camera } from "babylonjs/Cameras/camera";
  71873. import { Engine } from "babylonjs/Engines/engine";
  71874. import "babylonjs/Shaders/convolution.fragment";
  71875. /**
  71876. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71877. * input texture to perform effects such as edge detection or sharpening
  71878. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71879. */
  71880. export class ConvolutionPostProcess extends PostProcess {
  71881. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71882. kernel: number[];
  71883. /**
  71884. * Creates a new instance ConvolutionPostProcess
  71885. * @param name The name of the effect.
  71886. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71887. * @param options The required width/height ratio to downsize to before computing the render pass.
  71888. * @param camera The camera to apply the render pass to.
  71889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71890. * @param engine The engine which the post process will be applied. (default: current engine)
  71891. * @param reusable If the post process can be reused on the same frame. (default: false)
  71892. * @param textureType Type of textures used when performing the post process. (default: 0)
  71893. */
  71894. constructor(name: string,
  71895. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71896. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71897. /**
  71898. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71899. */
  71900. static EdgeDetect0Kernel: number[];
  71901. /**
  71902. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71903. */
  71904. static EdgeDetect1Kernel: number[];
  71905. /**
  71906. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71907. */
  71908. static EdgeDetect2Kernel: number[];
  71909. /**
  71910. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71911. */
  71912. static SharpenKernel: number[];
  71913. /**
  71914. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71915. */
  71916. static EmbossKernel: number[];
  71917. /**
  71918. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71919. */
  71920. static GaussianKernel: number[];
  71921. }
  71922. }
  71923. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71924. import { Nullable } from "babylonjs/types";
  71925. import { Vector2 } from "babylonjs/Maths/math.vector";
  71926. import { Camera } from "babylonjs/Cameras/camera";
  71927. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71928. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71929. import { Engine } from "babylonjs/Engines/engine";
  71930. import { Scene } from "babylonjs/scene";
  71931. /**
  71932. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71933. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71934. * based on samples that have a large difference in distance than the center pixel.
  71935. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71936. */
  71937. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71938. direction: Vector2;
  71939. /**
  71940. * Creates a new instance CircleOfConfusionPostProcess
  71941. * @param name The name of the effect.
  71942. * @param scene The scene the effect belongs to.
  71943. * @param direction The direction the blur should be applied.
  71944. * @param kernel The size of the kernel used to blur.
  71945. * @param options The required width/height ratio to downsize to before computing the render pass.
  71946. * @param camera The camera to apply the render pass to.
  71947. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71948. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71950. * @param engine The engine which the post process will be applied. (default: current engine)
  71951. * @param reusable If the post process can be reused on the same frame. (default: false)
  71952. * @param textureType Type of textures used when performing the post process. (default: 0)
  71953. * @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)
  71954. */
  71955. 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);
  71956. }
  71957. }
  71958. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71959. /** @hidden */
  71960. export var depthOfFieldMergePixelShader: {
  71961. name: string;
  71962. shader: string;
  71963. };
  71964. }
  71965. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71966. import { Nullable } from "babylonjs/types";
  71967. import { Camera } from "babylonjs/Cameras/camera";
  71968. import { Effect } from "babylonjs/Materials/effect";
  71969. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71970. import { Engine } from "babylonjs/Engines/engine";
  71971. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71972. /**
  71973. * Options to be set when merging outputs from the default pipeline.
  71974. */
  71975. export class DepthOfFieldMergePostProcessOptions {
  71976. /**
  71977. * The original image to merge on top of
  71978. */
  71979. originalFromInput: PostProcess;
  71980. /**
  71981. * Parameters to perform the merge of the depth of field effect
  71982. */
  71983. depthOfField?: {
  71984. circleOfConfusion: PostProcess;
  71985. blurSteps: Array<PostProcess>;
  71986. };
  71987. /**
  71988. * Parameters to perform the merge of bloom effect
  71989. */
  71990. bloom?: {
  71991. blurred: PostProcess;
  71992. weight: number;
  71993. };
  71994. }
  71995. /**
  71996. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71997. */
  71998. export class DepthOfFieldMergePostProcess extends PostProcess {
  71999. private blurSteps;
  72000. /**
  72001. * Creates a new instance of DepthOfFieldMergePostProcess
  72002. * @param name The name of the effect.
  72003. * @param originalFromInput Post process which's input will be used for the merge.
  72004. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72005. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72006. * @param options The required width/height ratio to downsize to before computing the render pass.
  72007. * @param camera The camera to apply the render pass to.
  72008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72009. * @param engine The engine which the post process will be applied. (default: current engine)
  72010. * @param reusable If the post process can be reused on the same frame. (default: false)
  72011. * @param textureType Type of textures used when performing the post process. (default: 0)
  72012. * @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)
  72013. */
  72014. 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);
  72015. /**
  72016. * Updates the effect with the current post process compile time values and recompiles the shader.
  72017. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72018. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72019. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72020. * @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
  72021. * @param onCompiled Called when the shader has been compiled.
  72022. * @param onError Called if there is an error when compiling a shader.
  72023. */
  72024. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72025. }
  72026. }
  72027. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72028. import { Nullable } from "babylonjs/types";
  72029. import { Camera } from "babylonjs/Cameras/camera";
  72030. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72031. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72032. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72033. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72034. import { Scene } from "babylonjs/scene";
  72035. /**
  72036. * Specifies the level of max blur that should be applied when using the depth of field effect
  72037. */
  72038. export enum DepthOfFieldEffectBlurLevel {
  72039. /**
  72040. * Subtle blur
  72041. */
  72042. Low = 0,
  72043. /**
  72044. * Medium blur
  72045. */
  72046. Medium = 1,
  72047. /**
  72048. * Large blur
  72049. */
  72050. High = 2
  72051. }
  72052. /**
  72053. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72054. */
  72055. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72056. private _circleOfConfusion;
  72057. /**
  72058. * @hidden Internal, blurs from high to low
  72059. */
  72060. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72061. private _depthOfFieldBlurY;
  72062. private _dofMerge;
  72063. /**
  72064. * @hidden Internal post processes in depth of field effect
  72065. */
  72066. _effects: Array<PostProcess>;
  72067. /**
  72068. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72069. */
  72070. set focalLength(value: number);
  72071. get focalLength(): number;
  72072. /**
  72073. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72074. */
  72075. set fStop(value: number);
  72076. get fStop(): number;
  72077. /**
  72078. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72079. */
  72080. set focusDistance(value: number);
  72081. get focusDistance(): number;
  72082. /**
  72083. * 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.
  72084. */
  72085. set lensSize(value: number);
  72086. get lensSize(): number;
  72087. /**
  72088. * Creates a new instance DepthOfFieldEffect
  72089. * @param scene The scene the effect belongs to.
  72090. * @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.
  72091. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72092. * @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)
  72093. */
  72094. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72095. /**
  72096. * Get the current class name of the current effet
  72097. * @returns "DepthOfFieldEffect"
  72098. */
  72099. getClassName(): string;
  72100. /**
  72101. * 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.
  72102. */
  72103. set depthTexture(value: RenderTargetTexture);
  72104. /**
  72105. * Disposes each of the internal effects for a given camera.
  72106. * @param camera The camera to dispose the effect on.
  72107. */
  72108. disposeEffects(camera: Camera): void;
  72109. /**
  72110. * @hidden Internal
  72111. */
  72112. _updateEffects(): void;
  72113. /**
  72114. * Internal
  72115. * @returns if all the contained post processes are ready.
  72116. * @hidden
  72117. */
  72118. _isReady(): boolean;
  72119. }
  72120. }
  72121. declare module "babylonjs/Shaders/displayPass.fragment" {
  72122. /** @hidden */
  72123. export var displayPassPixelShader: {
  72124. name: string;
  72125. shader: string;
  72126. };
  72127. }
  72128. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72129. import { Nullable } from "babylonjs/types";
  72130. import { Camera } from "babylonjs/Cameras/camera";
  72131. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72132. import { Engine } from "babylonjs/Engines/engine";
  72133. import "babylonjs/Shaders/displayPass.fragment";
  72134. /**
  72135. * DisplayPassPostProcess which produces an output the same as it's input
  72136. */
  72137. export class DisplayPassPostProcess extends PostProcess {
  72138. /**
  72139. * Creates the DisplayPassPostProcess
  72140. * @param name The name of the effect.
  72141. * @param options The required width/height ratio to downsize to before computing the render pass.
  72142. * @param camera The camera to apply the render pass to.
  72143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72144. * @param engine The engine which the post process will be applied. (default: current engine)
  72145. * @param reusable If the post process can be reused on the same frame. (default: false)
  72146. */
  72147. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72148. }
  72149. }
  72150. declare module "babylonjs/Shaders/filter.fragment" {
  72151. /** @hidden */
  72152. export var filterPixelShader: {
  72153. name: string;
  72154. shader: string;
  72155. };
  72156. }
  72157. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72158. import { Nullable } from "babylonjs/types";
  72159. import { Matrix } from "babylonjs/Maths/math.vector";
  72160. import { Camera } from "babylonjs/Cameras/camera";
  72161. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72162. import { Engine } from "babylonjs/Engines/engine";
  72163. import "babylonjs/Shaders/filter.fragment";
  72164. /**
  72165. * Applies a kernel filter to the image
  72166. */
  72167. export class FilterPostProcess extends PostProcess {
  72168. /** The matrix to be applied to the image */
  72169. kernelMatrix: Matrix;
  72170. /**
  72171. *
  72172. * @param name The name of the effect.
  72173. * @param kernelMatrix The matrix to be applied to the image
  72174. * @param options The required width/height ratio to downsize to before computing the render pass.
  72175. * @param camera The camera to apply the render pass to.
  72176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72177. * @param engine The engine which the post process will be applied. (default: current engine)
  72178. * @param reusable If the post process can be reused on the same frame. (default: false)
  72179. */
  72180. constructor(name: string,
  72181. /** The matrix to be applied to the image */
  72182. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72183. }
  72184. }
  72185. declare module "babylonjs/Shaders/fxaa.fragment" {
  72186. /** @hidden */
  72187. export var fxaaPixelShader: {
  72188. name: string;
  72189. shader: string;
  72190. };
  72191. }
  72192. declare module "babylonjs/Shaders/fxaa.vertex" {
  72193. /** @hidden */
  72194. export var fxaaVertexShader: {
  72195. name: string;
  72196. shader: string;
  72197. };
  72198. }
  72199. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72200. import { Nullable } from "babylonjs/types";
  72201. import { Camera } from "babylonjs/Cameras/camera";
  72202. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72203. import { Engine } from "babylonjs/Engines/engine";
  72204. import "babylonjs/Shaders/fxaa.fragment";
  72205. import "babylonjs/Shaders/fxaa.vertex";
  72206. /**
  72207. * Fxaa post process
  72208. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72209. */
  72210. export class FxaaPostProcess extends PostProcess {
  72211. /** @hidden */
  72212. texelWidth: number;
  72213. /** @hidden */
  72214. texelHeight: number;
  72215. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72216. private _getDefines;
  72217. }
  72218. }
  72219. declare module "babylonjs/Shaders/grain.fragment" {
  72220. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72221. /** @hidden */
  72222. export var grainPixelShader: {
  72223. name: string;
  72224. shader: string;
  72225. };
  72226. }
  72227. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72228. import { Nullable } from "babylonjs/types";
  72229. import { Camera } from "babylonjs/Cameras/camera";
  72230. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72231. import { Engine } from "babylonjs/Engines/engine";
  72232. import "babylonjs/Shaders/grain.fragment";
  72233. /**
  72234. * The GrainPostProcess adds noise to the image at mid luminance levels
  72235. */
  72236. export class GrainPostProcess extends PostProcess {
  72237. /**
  72238. * The intensity of the grain added (default: 30)
  72239. */
  72240. intensity: number;
  72241. /**
  72242. * If the grain should be randomized on every frame
  72243. */
  72244. animated: boolean;
  72245. /**
  72246. * Creates a new instance of @see GrainPostProcess
  72247. * @param name The name of the effect.
  72248. * @param options The required width/height ratio to downsize to before computing the render pass.
  72249. * @param camera The camera to apply the render pass to.
  72250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72251. * @param engine The engine which the post process will be applied. (default: current engine)
  72252. * @param reusable If the post process can be reused on the same frame. (default: false)
  72253. * @param textureType Type of textures used when performing the post process. (default: 0)
  72254. * @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)
  72255. */
  72256. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72257. }
  72258. }
  72259. declare module "babylonjs/Shaders/highlights.fragment" {
  72260. /** @hidden */
  72261. export var highlightsPixelShader: {
  72262. name: string;
  72263. shader: string;
  72264. };
  72265. }
  72266. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72267. import { Nullable } from "babylonjs/types";
  72268. import { Camera } from "babylonjs/Cameras/camera";
  72269. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72270. import { Engine } from "babylonjs/Engines/engine";
  72271. import "babylonjs/Shaders/highlights.fragment";
  72272. /**
  72273. * Extracts highlights from the image
  72274. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72275. */
  72276. export class HighlightsPostProcess extends PostProcess {
  72277. /**
  72278. * Extracts highlights from the image
  72279. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72280. * @param name The name of the effect.
  72281. * @param options The required width/height ratio to downsize to before computing the render pass.
  72282. * @param camera The camera to apply the render pass to.
  72283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72284. * @param engine The engine which the post process will be applied. (default: current engine)
  72285. * @param reusable If the post process can be reused on the same frame. (default: false)
  72286. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72287. */
  72288. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72289. }
  72290. }
  72291. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72292. /** @hidden */
  72293. export var mrtFragmentDeclaration: {
  72294. name: string;
  72295. shader: string;
  72296. };
  72297. }
  72298. declare module "babylonjs/Shaders/geometry.fragment" {
  72299. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72300. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72301. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72302. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72303. /** @hidden */
  72304. export var geometryPixelShader: {
  72305. name: string;
  72306. shader: string;
  72307. };
  72308. }
  72309. declare module "babylonjs/Shaders/geometry.vertex" {
  72310. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72311. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72312. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72313. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72314. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72315. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72316. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72317. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72318. /** @hidden */
  72319. export var geometryVertexShader: {
  72320. name: string;
  72321. shader: string;
  72322. };
  72323. }
  72324. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72325. import { Matrix } from "babylonjs/Maths/math.vector";
  72326. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72327. import { Mesh } from "babylonjs/Meshes/mesh";
  72328. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72329. import { Effect } from "babylonjs/Materials/effect";
  72330. import { Scene } from "babylonjs/scene";
  72331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72332. import "babylonjs/Shaders/geometry.fragment";
  72333. import "babylonjs/Shaders/geometry.vertex";
  72334. /** @hidden */
  72335. interface ISavedTransformationMatrix {
  72336. world: Matrix;
  72337. viewProjection: Matrix;
  72338. }
  72339. /**
  72340. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72341. */
  72342. export class GeometryBufferRenderer {
  72343. /**
  72344. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72345. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72346. */
  72347. static readonly POSITION_TEXTURE_TYPE: number;
  72348. /**
  72349. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72350. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72351. */
  72352. static readonly VELOCITY_TEXTURE_TYPE: number;
  72353. /**
  72354. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  72355. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  72356. */
  72357. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  72358. /**
  72359. * Dictionary used to store the previous transformation matrices of each rendered mesh
  72360. * in order to compute objects velocities when enableVelocity is set to "true"
  72361. * @hidden
  72362. */
  72363. _previousTransformationMatrices: {
  72364. [index: number]: ISavedTransformationMatrix;
  72365. };
  72366. /**
  72367. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  72368. * in order to compute objects velocities when enableVelocity is set to "true"
  72369. * @hidden
  72370. */
  72371. _previousBonesTransformationMatrices: {
  72372. [index: number]: Float32Array;
  72373. };
  72374. /**
  72375. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  72376. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  72377. */
  72378. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  72379. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  72380. renderTransparentMeshes: boolean;
  72381. private _scene;
  72382. private _multiRenderTarget;
  72383. private _ratio;
  72384. private _enablePosition;
  72385. private _enableVelocity;
  72386. private _enableReflectivity;
  72387. private _positionIndex;
  72388. private _velocityIndex;
  72389. private _reflectivityIndex;
  72390. protected _effect: Effect;
  72391. protected _cachedDefines: string;
  72392. /**
  72393. * Set the render list (meshes to be rendered) used in the G buffer.
  72394. */
  72395. set renderList(meshes: Mesh[]);
  72396. /**
  72397. * Gets wether or not G buffer are supported by the running hardware.
  72398. * This requires draw buffer supports
  72399. */
  72400. get isSupported(): boolean;
  72401. /**
  72402. * Returns the index of the given texture type in the G-Buffer textures array
  72403. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72404. * @returns the index of the given texture type in the G-Buffer textures array
  72405. */
  72406. getTextureIndex(textureType: number): number;
  72407. /**
  72408. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72409. */
  72410. get enablePosition(): boolean;
  72411. /**
  72412. * Sets whether or not objects positions are enabled for the G buffer.
  72413. */
  72414. set enablePosition(enable: boolean);
  72415. /**
  72416. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72417. */
  72418. get enableVelocity(): boolean;
  72419. /**
  72420. * Sets wether or not objects velocities are enabled for the G buffer.
  72421. */
  72422. set enableVelocity(enable: boolean);
  72423. /**
  72424. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72425. */
  72426. get enableReflectivity(): boolean;
  72427. /**
  72428. * Sets wether or not objects roughness are enabled for the G buffer.
  72429. */
  72430. set enableReflectivity(enable: boolean);
  72431. /**
  72432. * Gets the scene associated with the buffer.
  72433. */
  72434. get scene(): Scene;
  72435. /**
  72436. * Gets the ratio used by the buffer during its creation.
  72437. * How big is the buffer related to the main canvas.
  72438. */
  72439. get ratio(): number;
  72440. /** @hidden */
  72441. static _SceneComponentInitialization: (scene: Scene) => void;
  72442. /**
  72443. * Creates a new G Buffer for the scene
  72444. * @param scene The scene the buffer belongs to
  72445. * @param ratio How big is the buffer related to the main canvas.
  72446. */
  72447. constructor(scene: Scene, ratio?: number);
  72448. /**
  72449. * Checks wether everything is ready to render a submesh to the G buffer.
  72450. * @param subMesh the submesh to check readiness for
  72451. * @param useInstances is the mesh drawn using instance or not
  72452. * @returns true if ready otherwise false
  72453. */
  72454. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72455. /**
  72456. * Gets the current underlying G Buffer.
  72457. * @returns the buffer
  72458. */
  72459. getGBuffer(): MultiRenderTarget;
  72460. /**
  72461. * Gets the number of samples used to render the buffer (anti aliasing).
  72462. */
  72463. get samples(): number;
  72464. /**
  72465. * Sets the number of samples used to render the buffer (anti aliasing).
  72466. */
  72467. set samples(value: number);
  72468. /**
  72469. * Disposes the renderer and frees up associated resources.
  72470. */
  72471. dispose(): void;
  72472. protected _createRenderTargets(): void;
  72473. private _copyBonesTransformationMatrices;
  72474. }
  72475. }
  72476. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  72477. import { Nullable } from "babylonjs/types";
  72478. import { Scene } from "babylonjs/scene";
  72479. import { ISceneComponent } from "babylonjs/sceneComponent";
  72480. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  72481. module "babylonjs/scene" {
  72482. interface Scene {
  72483. /** @hidden (Backing field) */
  72484. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72485. /**
  72486. * Gets or Sets the current geometry buffer associated to the scene.
  72487. */
  72488. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72489. /**
  72490. * Enables a GeometryBufferRender and associates it with the scene
  72491. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  72492. * @returns the GeometryBufferRenderer
  72493. */
  72494. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  72495. /**
  72496. * Disables the GeometryBufferRender associated with the scene
  72497. */
  72498. disableGeometryBufferRenderer(): void;
  72499. }
  72500. }
  72501. /**
  72502. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72503. * in several rendering techniques.
  72504. */
  72505. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  72506. /**
  72507. * The component name helpful to identify the component in the list of scene components.
  72508. */
  72509. readonly name: string;
  72510. /**
  72511. * The scene the component belongs to.
  72512. */
  72513. scene: Scene;
  72514. /**
  72515. * Creates a new instance of the component for the given scene
  72516. * @param scene Defines the scene to register the component in
  72517. */
  72518. constructor(scene: Scene);
  72519. /**
  72520. * Registers the component in a given scene
  72521. */
  72522. register(): void;
  72523. /**
  72524. * Rebuilds the elements related to this component in case of
  72525. * context lost for instance.
  72526. */
  72527. rebuild(): void;
  72528. /**
  72529. * Disposes the component and the associated ressources
  72530. */
  72531. dispose(): void;
  72532. private _gatherRenderTargets;
  72533. }
  72534. }
  72535. declare module "babylonjs/Shaders/motionBlur.fragment" {
  72536. /** @hidden */
  72537. export var motionBlurPixelShader: {
  72538. name: string;
  72539. shader: string;
  72540. };
  72541. }
  72542. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  72543. import { Nullable } from "babylonjs/types";
  72544. import { Camera } from "babylonjs/Cameras/camera";
  72545. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72546. import { Scene } from "babylonjs/scene";
  72547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72548. import "babylonjs/Animations/animatable";
  72549. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72550. import "babylonjs/Shaders/motionBlur.fragment";
  72551. import { Engine } from "babylonjs/Engines/engine";
  72552. /**
  72553. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  72554. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  72555. * As an example, all you have to do is to create the post-process:
  72556. * var mb = new BABYLON.MotionBlurPostProcess(
  72557. * 'mb', // The name of the effect.
  72558. * scene, // The scene containing the objects to blur according to their velocity.
  72559. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  72560. * camera // The camera to apply the render pass to.
  72561. * );
  72562. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  72563. */
  72564. export class MotionBlurPostProcess extends PostProcess {
  72565. /**
  72566. * Defines how much the image is blurred by the movement. Default value is equal to 1
  72567. */
  72568. motionStrength: number;
  72569. /**
  72570. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  72571. */
  72572. get motionBlurSamples(): number;
  72573. /**
  72574. * Sets the number of iterations to be used for motion blur quality
  72575. */
  72576. set motionBlurSamples(samples: number);
  72577. private _motionBlurSamples;
  72578. private _geometryBufferRenderer;
  72579. /**
  72580. * Creates a new instance MotionBlurPostProcess
  72581. * @param name The name of the effect.
  72582. * @param scene The scene containing the objects to blur according to their velocity.
  72583. * @param options The required width/height ratio to downsize to before computing the render pass.
  72584. * @param camera The camera to apply the render pass to.
  72585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72586. * @param engine The engine which the post process will be applied. (default: current engine)
  72587. * @param reusable If the post process can be reused on the same frame. (default: false)
  72588. * @param textureType Type of textures used when performing the post process. (default: 0)
  72589. * @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)
  72590. */
  72591. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72592. /**
  72593. * Excludes the given skinned mesh from computing bones velocities.
  72594. * 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.
  72595. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  72596. */
  72597. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72598. /**
  72599. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  72600. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  72601. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  72602. */
  72603. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72604. /**
  72605. * Disposes the post process.
  72606. * @param camera The camera to dispose the post process on.
  72607. */
  72608. dispose(camera?: Camera): void;
  72609. }
  72610. }
  72611. declare module "babylonjs/Shaders/refraction.fragment" {
  72612. /** @hidden */
  72613. export var refractionPixelShader: {
  72614. name: string;
  72615. shader: string;
  72616. };
  72617. }
  72618. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  72619. import { Color3 } from "babylonjs/Maths/math.color";
  72620. import { Camera } from "babylonjs/Cameras/camera";
  72621. import { Texture } from "babylonjs/Materials/Textures/texture";
  72622. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72623. import { Engine } from "babylonjs/Engines/engine";
  72624. import "babylonjs/Shaders/refraction.fragment";
  72625. /**
  72626. * Post process which applies a refractin texture
  72627. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72628. */
  72629. export class RefractionPostProcess extends PostProcess {
  72630. /** the base color of the refraction (used to taint the rendering) */
  72631. color: Color3;
  72632. /** simulated refraction depth */
  72633. depth: number;
  72634. /** the coefficient of the base color (0 to remove base color tainting) */
  72635. colorLevel: number;
  72636. private _refTexture;
  72637. private _ownRefractionTexture;
  72638. /**
  72639. * Gets or sets the refraction texture
  72640. * Please note that you are responsible for disposing the texture if you set it manually
  72641. */
  72642. get refractionTexture(): Texture;
  72643. set refractionTexture(value: Texture);
  72644. /**
  72645. * Initializes the RefractionPostProcess
  72646. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72647. * @param name The name of the effect.
  72648. * @param refractionTextureUrl Url of the refraction texture to use
  72649. * @param color the base color of the refraction (used to taint the rendering)
  72650. * @param depth simulated refraction depth
  72651. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  72652. * @param camera The camera to apply the render pass to.
  72653. * @param options The required width/height ratio to downsize to before computing the render pass.
  72654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72655. * @param engine The engine which the post process will be applied. (default: current engine)
  72656. * @param reusable If the post process can be reused on the same frame. (default: false)
  72657. */
  72658. constructor(name: string, refractionTextureUrl: string,
  72659. /** the base color of the refraction (used to taint the rendering) */
  72660. color: Color3,
  72661. /** simulated refraction depth */
  72662. depth: number,
  72663. /** the coefficient of the base color (0 to remove base color tainting) */
  72664. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72665. /**
  72666. * Disposes of the post process
  72667. * @param camera Camera to dispose post process on
  72668. */
  72669. dispose(camera: Camera): void;
  72670. }
  72671. }
  72672. declare module "babylonjs/Shaders/sharpen.fragment" {
  72673. /** @hidden */
  72674. export var sharpenPixelShader: {
  72675. name: string;
  72676. shader: string;
  72677. };
  72678. }
  72679. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  72680. import { Nullable } from "babylonjs/types";
  72681. import { Camera } from "babylonjs/Cameras/camera";
  72682. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72683. import "babylonjs/Shaders/sharpen.fragment";
  72684. import { Engine } from "babylonjs/Engines/engine";
  72685. /**
  72686. * The SharpenPostProcess applies a sharpen kernel to every pixel
  72687. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72688. */
  72689. export class SharpenPostProcess extends PostProcess {
  72690. /**
  72691. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  72692. */
  72693. colorAmount: number;
  72694. /**
  72695. * How much sharpness should be applied (default: 0.3)
  72696. */
  72697. edgeAmount: number;
  72698. /**
  72699. * Creates a new instance ConvolutionPostProcess
  72700. * @param name The name of the effect.
  72701. * @param options The required width/height ratio to downsize to before computing the render pass.
  72702. * @param camera The camera to apply the render pass to.
  72703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72704. * @param engine The engine which the post process will be applied. (default: current engine)
  72705. * @param reusable If the post process can be reused on the same frame. (default: false)
  72706. * @param textureType Type of textures used when performing the post process. (default: 0)
  72707. * @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)
  72708. */
  72709. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72710. }
  72711. }
  72712. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  72713. import { Nullable } from "babylonjs/types";
  72714. import { Camera } from "babylonjs/Cameras/camera";
  72715. import { Engine } from "babylonjs/Engines/engine";
  72716. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72717. import { IInspectable } from "babylonjs/Misc/iInspectable";
  72718. /**
  72719. * PostProcessRenderPipeline
  72720. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72721. */
  72722. export class PostProcessRenderPipeline {
  72723. private engine;
  72724. private _renderEffects;
  72725. private _renderEffectsForIsolatedPass;
  72726. /**
  72727. * List of inspectable custom properties (used by the Inspector)
  72728. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72729. */
  72730. inspectableCustomProperties: IInspectable[];
  72731. /**
  72732. * @hidden
  72733. */
  72734. protected _cameras: Camera[];
  72735. /** @hidden */
  72736. _name: string;
  72737. /**
  72738. * Gets pipeline name
  72739. */
  72740. get name(): string;
  72741. /** Gets the list of attached cameras */
  72742. get cameras(): Camera[];
  72743. /**
  72744. * Initializes a PostProcessRenderPipeline
  72745. * @param engine engine to add the pipeline to
  72746. * @param name name of the pipeline
  72747. */
  72748. constructor(engine: Engine, name: string);
  72749. /**
  72750. * Gets the class name
  72751. * @returns "PostProcessRenderPipeline"
  72752. */
  72753. getClassName(): string;
  72754. /**
  72755. * If all the render effects in the pipeline are supported
  72756. */
  72757. get isSupported(): boolean;
  72758. /**
  72759. * Adds an effect to the pipeline
  72760. * @param renderEffect the effect to add
  72761. */
  72762. addEffect(renderEffect: PostProcessRenderEffect): void;
  72763. /** @hidden */
  72764. _rebuild(): void;
  72765. /** @hidden */
  72766. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72767. /** @hidden */
  72768. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72769. /** @hidden */
  72770. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72771. /** @hidden */
  72772. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72773. /** @hidden */
  72774. _attachCameras(cameras: Camera, unique: boolean): void;
  72775. /** @hidden */
  72776. _attachCameras(cameras: Camera[], unique: boolean): void;
  72777. /** @hidden */
  72778. _detachCameras(cameras: Camera): void;
  72779. /** @hidden */
  72780. _detachCameras(cameras: Nullable<Camera[]>): void;
  72781. /** @hidden */
  72782. _update(): void;
  72783. /** @hidden */
  72784. _reset(): void;
  72785. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72786. /**
  72787. * Disposes of the pipeline
  72788. */
  72789. dispose(): void;
  72790. }
  72791. }
  72792. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72793. import { Camera } from "babylonjs/Cameras/camera";
  72794. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72795. /**
  72796. * PostProcessRenderPipelineManager class
  72797. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72798. */
  72799. export class PostProcessRenderPipelineManager {
  72800. private _renderPipelines;
  72801. /**
  72802. * Initializes a PostProcessRenderPipelineManager
  72803. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72804. */
  72805. constructor();
  72806. /**
  72807. * Gets the list of supported render pipelines
  72808. */
  72809. get supportedPipelines(): PostProcessRenderPipeline[];
  72810. /**
  72811. * Adds a pipeline to the manager
  72812. * @param renderPipeline The pipeline to add
  72813. */
  72814. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72815. /**
  72816. * Attaches a camera to the pipeline
  72817. * @param renderPipelineName The name of the pipeline to attach to
  72818. * @param cameras the camera to attach
  72819. * @param unique if the camera can be attached multiple times to the pipeline
  72820. */
  72821. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72822. /**
  72823. * Detaches a camera from the pipeline
  72824. * @param renderPipelineName The name of the pipeline to detach from
  72825. * @param cameras the camera to detach
  72826. */
  72827. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72828. /**
  72829. * Enables an effect by name on a pipeline
  72830. * @param renderPipelineName the name of the pipeline to enable the effect in
  72831. * @param renderEffectName the name of the effect to enable
  72832. * @param cameras the cameras that the effect should be enabled on
  72833. */
  72834. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72835. /**
  72836. * Disables an effect by name on a pipeline
  72837. * @param renderPipelineName the name of the pipeline to disable the effect in
  72838. * @param renderEffectName the name of the effect to disable
  72839. * @param cameras the cameras that the effect should be disabled on
  72840. */
  72841. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72842. /**
  72843. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72844. */
  72845. update(): void;
  72846. /** @hidden */
  72847. _rebuild(): void;
  72848. /**
  72849. * Disposes of the manager and pipelines
  72850. */
  72851. dispose(): void;
  72852. }
  72853. }
  72854. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72855. import { ISceneComponent } from "babylonjs/sceneComponent";
  72856. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72857. import { Scene } from "babylonjs/scene";
  72858. module "babylonjs/scene" {
  72859. interface Scene {
  72860. /** @hidden (Backing field) */
  72861. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72862. /**
  72863. * Gets the postprocess render pipeline manager
  72864. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72865. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72866. */
  72867. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72868. }
  72869. }
  72870. /**
  72871. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72872. */
  72873. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72874. /**
  72875. * The component name helpfull to identify the component in the list of scene components.
  72876. */
  72877. readonly name: string;
  72878. /**
  72879. * The scene the component belongs to.
  72880. */
  72881. scene: Scene;
  72882. /**
  72883. * Creates a new instance of the component for the given scene
  72884. * @param scene Defines the scene to register the component in
  72885. */
  72886. constructor(scene: Scene);
  72887. /**
  72888. * Registers the component in a given scene
  72889. */
  72890. register(): void;
  72891. /**
  72892. * Rebuilds the elements related to this component in case of
  72893. * context lost for instance.
  72894. */
  72895. rebuild(): void;
  72896. /**
  72897. * Disposes the component and the associated ressources
  72898. */
  72899. dispose(): void;
  72900. private _gatherRenderTargets;
  72901. }
  72902. }
  72903. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72904. import { Nullable } from "babylonjs/types";
  72905. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72906. import { Camera } from "babylonjs/Cameras/camera";
  72907. import { IDisposable } from "babylonjs/scene";
  72908. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72909. import { Scene } from "babylonjs/scene";
  72910. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72911. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72912. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72913. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72914. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72915. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72916. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72917. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72918. import { Animation } from "babylonjs/Animations/animation";
  72919. /**
  72920. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72921. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72922. */
  72923. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72924. private _scene;
  72925. private _camerasToBeAttached;
  72926. /**
  72927. * ID of the sharpen post process,
  72928. */
  72929. private readonly SharpenPostProcessId;
  72930. /**
  72931. * @ignore
  72932. * ID of the image processing post process;
  72933. */
  72934. readonly ImageProcessingPostProcessId: string;
  72935. /**
  72936. * @ignore
  72937. * ID of the Fast Approximate Anti-Aliasing post process;
  72938. */
  72939. readonly FxaaPostProcessId: string;
  72940. /**
  72941. * ID of the chromatic aberration post process,
  72942. */
  72943. private readonly ChromaticAberrationPostProcessId;
  72944. /**
  72945. * ID of the grain post process
  72946. */
  72947. private readonly GrainPostProcessId;
  72948. /**
  72949. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72950. */
  72951. sharpen: SharpenPostProcess;
  72952. private _sharpenEffect;
  72953. private bloom;
  72954. /**
  72955. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72956. */
  72957. depthOfField: DepthOfFieldEffect;
  72958. /**
  72959. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72960. */
  72961. fxaa: FxaaPostProcess;
  72962. /**
  72963. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72964. */
  72965. imageProcessing: ImageProcessingPostProcess;
  72966. /**
  72967. * Chromatic aberration post process which will shift rgb colors in the image
  72968. */
  72969. chromaticAberration: ChromaticAberrationPostProcess;
  72970. private _chromaticAberrationEffect;
  72971. /**
  72972. * Grain post process which add noise to the image
  72973. */
  72974. grain: GrainPostProcess;
  72975. private _grainEffect;
  72976. /**
  72977. * Glow post process which adds a glow to emissive areas of the image
  72978. */
  72979. private _glowLayer;
  72980. /**
  72981. * Animations which can be used to tweak settings over a period of time
  72982. */
  72983. animations: Animation[];
  72984. private _imageProcessingConfigurationObserver;
  72985. private _sharpenEnabled;
  72986. private _bloomEnabled;
  72987. private _depthOfFieldEnabled;
  72988. private _depthOfFieldBlurLevel;
  72989. private _fxaaEnabled;
  72990. private _imageProcessingEnabled;
  72991. private _defaultPipelineTextureType;
  72992. private _bloomScale;
  72993. private _chromaticAberrationEnabled;
  72994. private _grainEnabled;
  72995. private _buildAllowed;
  72996. /**
  72997. * Gets active scene
  72998. */
  72999. get scene(): Scene;
  73000. /**
  73001. * Enable or disable the sharpen process from the pipeline
  73002. */
  73003. set sharpenEnabled(enabled: boolean);
  73004. get sharpenEnabled(): boolean;
  73005. private _resizeObserver;
  73006. private _hardwareScaleLevel;
  73007. private _bloomKernel;
  73008. /**
  73009. * Specifies the size of the bloom blur kernel, relative to the final output size
  73010. */
  73011. get bloomKernel(): number;
  73012. set bloomKernel(value: number);
  73013. /**
  73014. * Specifies the weight of the bloom in the final rendering
  73015. */
  73016. private _bloomWeight;
  73017. /**
  73018. * Specifies the luma threshold for the area that will be blurred by the bloom
  73019. */
  73020. private _bloomThreshold;
  73021. private _hdr;
  73022. /**
  73023. * The strength of the bloom.
  73024. */
  73025. set bloomWeight(value: number);
  73026. get bloomWeight(): number;
  73027. /**
  73028. * The strength of the bloom.
  73029. */
  73030. set bloomThreshold(value: number);
  73031. get bloomThreshold(): number;
  73032. /**
  73033. * The scale of the bloom, lower value will provide better performance.
  73034. */
  73035. set bloomScale(value: number);
  73036. get bloomScale(): number;
  73037. /**
  73038. * Enable or disable the bloom from the pipeline
  73039. */
  73040. set bloomEnabled(enabled: boolean);
  73041. get bloomEnabled(): boolean;
  73042. private _rebuildBloom;
  73043. /**
  73044. * If the depth of field is enabled.
  73045. */
  73046. get depthOfFieldEnabled(): boolean;
  73047. set depthOfFieldEnabled(enabled: boolean);
  73048. /**
  73049. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73050. */
  73051. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73052. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73053. /**
  73054. * If the anti aliasing is enabled.
  73055. */
  73056. set fxaaEnabled(enabled: boolean);
  73057. get fxaaEnabled(): boolean;
  73058. private _samples;
  73059. /**
  73060. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73061. */
  73062. set samples(sampleCount: number);
  73063. get samples(): number;
  73064. /**
  73065. * If image processing is enabled.
  73066. */
  73067. set imageProcessingEnabled(enabled: boolean);
  73068. get imageProcessingEnabled(): boolean;
  73069. /**
  73070. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73071. */
  73072. set glowLayerEnabled(enabled: boolean);
  73073. get glowLayerEnabled(): boolean;
  73074. /**
  73075. * Gets the glow layer (or null if not defined)
  73076. */
  73077. get glowLayer(): Nullable<GlowLayer>;
  73078. /**
  73079. * Enable or disable the chromaticAberration process from the pipeline
  73080. */
  73081. set chromaticAberrationEnabled(enabled: boolean);
  73082. get chromaticAberrationEnabled(): boolean;
  73083. /**
  73084. * Enable or disable the grain process from the pipeline
  73085. */
  73086. set grainEnabled(enabled: boolean);
  73087. get grainEnabled(): boolean;
  73088. /**
  73089. * @constructor
  73090. * @param name - The rendering pipeline name (default: "")
  73091. * @param hdr - If high dynamic range textures should be used (default: true)
  73092. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73093. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73094. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73095. */
  73096. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73097. /**
  73098. * Get the class name
  73099. * @returns "DefaultRenderingPipeline"
  73100. */
  73101. getClassName(): string;
  73102. /**
  73103. * Force the compilation of the entire pipeline.
  73104. */
  73105. prepare(): void;
  73106. private _hasCleared;
  73107. private _prevPostProcess;
  73108. private _prevPrevPostProcess;
  73109. private _setAutoClearAndTextureSharing;
  73110. private _depthOfFieldSceneObserver;
  73111. private _buildPipeline;
  73112. private _disposePostProcesses;
  73113. /**
  73114. * Adds a camera to the pipeline
  73115. * @param camera the camera to be added
  73116. */
  73117. addCamera(camera: Camera): void;
  73118. /**
  73119. * Removes a camera from the pipeline
  73120. * @param camera the camera to remove
  73121. */
  73122. removeCamera(camera: Camera): void;
  73123. /**
  73124. * Dispose of the pipeline and stop all post processes
  73125. */
  73126. dispose(): void;
  73127. /**
  73128. * Serialize the rendering pipeline (Used when exporting)
  73129. * @returns the serialized object
  73130. */
  73131. serialize(): any;
  73132. /**
  73133. * Parse the serialized pipeline
  73134. * @param source Source pipeline.
  73135. * @param scene The scene to load the pipeline to.
  73136. * @param rootUrl The URL of the serialized pipeline.
  73137. * @returns An instantiated pipeline from the serialized object.
  73138. */
  73139. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73140. }
  73141. }
  73142. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73143. /** @hidden */
  73144. export var lensHighlightsPixelShader: {
  73145. name: string;
  73146. shader: string;
  73147. };
  73148. }
  73149. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73150. /** @hidden */
  73151. export var depthOfFieldPixelShader: {
  73152. name: string;
  73153. shader: string;
  73154. };
  73155. }
  73156. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73157. import { Camera } from "babylonjs/Cameras/camera";
  73158. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73159. import { Scene } from "babylonjs/scene";
  73160. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73161. import "babylonjs/Shaders/chromaticAberration.fragment";
  73162. import "babylonjs/Shaders/lensHighlights.fragment";
  73163. import "babylonjs/Shaders/depthOfField.fragment";
  73164. /**
  73165. * BABYLON.JS Chromatic Aberration GLSL Shader
  73166. * Author: Olivier Guyot
  73167. * Separates very slightly R, G and B colors on the edges of the screen
  73168. * Inspired by Francois Tarlier & Martins Upitis
  73169. */
  73170. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73171. /**
  73172. * @ignore
  73173. * The chromatic aberration PostProcess id in the pipeline
  73174. */
  73175. LensChromaticAberrationEffect: string;
  73176. /**
  73177. * @ignore
  73178. * The highlights enhancing PostProcess id in the pipeline
  73179. */
  73180. HighlightsEnhancingEffect: string;
  73181. /**
  73182. * @ignore
  73183. * The depth-of-field PostProcess id in the pipeline
  73184. */
  73185. LensDepthOfFieldEffect: string;
  73186. private _scene;
  73187. private _depthTexture;
  73188. private _grainTexture;
  73189. private _chromaticAberrationPostProcess;
  73190. private _highlightsPostProcess;
  73191. private _depthOfFieldPostProcess;
  73192. private _edgeBlur;
  73193. private _grainAmount;
  73194. private _chromaticAberration;
  73195. private _distortion;
  73196. private _highlightsGain;
  73197. private _highlightsThreshold;
  73198. private _dofDistance;
  73199. private _dofAperture;
  73200. private _dofDarken;
  73201. private _dofPentagon;
  73202. private _blurNoise;
  73203. /**
  73204. * @constructor
  73205. *
  73206. * Effect parameters are as follow:
  73207. * {
  73208. * chromatic_aberration: number; // from 0 to x (1 for realism)
  73209. * edge_blur: number; // from 0 to x (1 for realism)
  73210. * distortion: number; // from 0 to x (1 for realism)
  73211. * grain_amount: number; // from 0 to 1
  73212. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73213. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73214. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73215. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73216. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73217. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73218. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73219. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73220. * }
  73221. * Note: if an effect parameter is unset, effect is disabled
  73222. *
  73223. * @param name The rendering pipeline name
  73224. * @param parameters - An object containing all parameters (see above)
  73225. * @param scene The scene linked to this pipeline
  73226. * @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)
  73227. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73228. */
  73229. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73230. /**
  73231. * Get the class name
  73232. * @returns "LensRenderingPipeline"
  73233. */
  73234. getClassName(): string;
  73235. /**
  73236. * Gets associated scene
  73237. */
  73238. get scene(): Scene;
  73239. /**
  73240. * Gets or sets the edge blur
  73241. */
  73242. get edgeBlur(): number;
  73243. set edgeBlur(value: number);
  73244. /**
  73245. * Gets or sets the grain amount
  73246. */
  73247. get grainAmount(): number;
  73248. set grainAmount(value: number);
  73249. /**
  73250. * Gets or sets the chromatic aberration amount
  73251. */
  73252. get chromaticAberration(): number;
  73253. set chromaticAberration(value: number);
  73254. /**
  73255. * Gets or sets the depth of field aperture
  73256. */
  73257. get dofAperture(): number;
  73258. set dofAperture(value: number);
  73259. /**
  73260. * Gets or sets the edge distortion
  73261. */
  73262. get edgeDistortion(): number;
  73263. set edgeDistortion(value: number);
  73264. /**
  73265. * Gets or sets the depth of field distortion
  73266. */
  73267. get dofDistortion(): number;
  73268. set dofDistortion(value: number);
  73269. /**
  73270. * Gets or sets the darken out of focus amount
  73271. */
  73272. get darkenOutOfFocus(): number;
  73273. set darkenOutOfFocus(value: number);
  73274. /**
  73275. * Gets or sets a boolean indicating if blur noise is enabled
  73276. */
  73277. get blurNoise(): boolean;
  73278. set blurNoise(value: boolean);
  73279. /**
  73280. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73281. */
  73282. get pentagonBokeh(): boolean;
  73283. set pentagonBokeh(value: boolean);
  73284. /**
  73285. * Gets or sets the highlight grain amount
  73286. */
  73287. get highlightsGain(): number;
  73288. set highlightsGain(value: number);
  73289. /**
  73290. * Gets or sets the highlight threshold
  73291. */
  73292. get highlightsThreshold(): number;
  73293. set highlightsThreshold(value: number);
  73294. /**
  73295. * Sets the amount of blur at the edges
  73296. * @param amount blur amount
  73297. */
  73298. setEdgeBlur(amount: number): void;
  73299. /**
  73300. * Sets edge blur to 0
  73301. */
  73302. disableEdgeBlur(): void;
  73303. /**
  73304. * Sets the amout of grain
  73305. * @param amount Amount of grain
  73306. */
  73307. setGrainAmount(amount: number): void;
  73308. /**
  73309. * Set grain amount to 0
  73310. */
  73311. disableGrain(): void;
  73312. /**
  73313. * Sets the chromatic aberration amount
  73314. * @param amount amount of chromatic aberration
  73315. */
  73316. setChromaticAberration(amount: number): void;
  73317. /**
  73318. * Sets chromatic aberration amount to 0
  73319. */
  73320. disableChromaticAberration(): void;
  73321. /**
  73322. * Sets the EdgeDistortion amount
  73323. * @param amount amount of EdgeDistortion
  73324. */
  73325. setEdgeDistortion(amount: number): void;
  73326. /**
  73327. * Sets edge distortion to 0
  73328. */
  73329. disableEdgeDistortion(): void;
  73330. /**
  73331. * Sets the FocusDistance amount
  73332. * @param amount amount of FocusDistance
  73333. */
  73334. setFocusDistance(amount: number): void;
  73335. /**
  73336. * Disables depth of field
  73337. */
  73338. disableDepthOfField(): void;
  73339. /**
  73340. * Sets the Aperture amount
  73341. * @param amount amount of Aperture
  73342. */
  73343. setAperture(amount: number): void;
  73344. /**
  73345. * Sets the DarkenOutOfFocus amount
  73346. * @param amount amount of DarkenOutOfFocus
  73347. */
  73348. setDarkenOutOfFocus(amount: number): void;
  73349. private _pentagonBokehIsEnabled;
  73350. /**
  73351. * Creates a pentagon bokeh effect
  73352. */
  73353. enablePentagonBokeh(): void;
  73354. /**
  73355. * Disables the pentagon bokeh effect
  73356. */
  73357. disablePentagonBokeh(): void;
  73358. /**
  73359. * Enables noise blur
  73360. */
  73361. enableNoiseBlur(): void;
  73362. /**
  73363. * Disables noise blur
  73364. */
  73365. disableNoiseBlur(): void;
  73366. /**
  73367. * Sets the HighlightsGain amount
  73368. * @param amount amount of HighlightsGain
  73369. */
  73370. setHighlightsGain(amount: number): void;
  73371. /**
  73372. * Sets the HighlightsThreshold amount
  73373. * @param amount amount of HighlightsThreshold
  73374. */
  73375. setHighlightsThreshold(amount: number): void;
  73376. /**
  73377. * Disables highlights
  73378. */
  73379. disableHighlights(): void;
  73380. /**
  73381. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  73382. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  73383. */
  73384. dispose(disableDepthRender?: boolean): void;
  73385. private _createChromaticAberrationPostProcess;
  73386. private _createHighlightsPostProcess;
  73387. private _createDepthOfFieldPostProcess;
  73388. private _createGrainTexture;
  73389. }
  73390. }
  73391. declare module "babylonjs/Shaders/ssao2.fragment" {
  73392. /** @hidden */
  73393. export var ssao2PixelShader: {
  73394. name: string;
  73395. shader: string;
  73396. };
  73397. }
  73398. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73399. /** @hidden */
  73400. export var ssaoCombinePixelShader: {
  73401. name: string;
  73402. shader: string;
  73403. };
  73404. }
  73405. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73406. import { Camera } from "babylonjs/Cameras/camera";
  73407. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73408. import { Scene } from "babylonjs/scene";
  73409. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73410. import "babylonjs/Shaders/ssao2.fragment";
  73411. import "babylonjs/Shaders/ssaoCombine.fragment";
  73412. /**
  73413. * Render pipeline to produce ssao effect
  73414. */
  73415. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73416. /**
  73417. * @ignore
  73418. * The PassPostProcess id in the pipeline that contains the original scene color
  73419. */
  73420. SSAOOriginalSceneColorEffect: string;
  73421. /**
  73422. * @ignore
  73423. * The SSAO PostProcess id in the pipeline
  73424. */
  73425. SSAORenderEffect: string;
  73426. /**
  73427. * @ignore
  73428. * The horizontal blur PostProcess id in the pipeline
  73429. */
  73430. SSAOBlurHRenderEffect: string;
  73431. /**
  73432. * @ignore
  73433. * The vertical blur PostProcess id in the pipeline
  73434. */
  73435. SSAOBlurVRenderEffect: string;
  73436. /**
  73437. * @ignore
  73438. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73439. */
  73440. SSAOCombineRenderEffect: string;
  73441. /**
  73442. * The output strength of the SSAO post-process. Default value is 1.0.
  73443. */
  73444. totalStrength: number;
  73445. /**
  73446. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  73447. */
  73448. maxZ: number;
  73449. /**
  73450. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  73451. */
  73452. minZAspect: number;
  73453. private _samples;
  73454. /**
  73455. * Number of samples used for the SSAO calculations. Default value is 8
  73456. */
  73457. set samples(n: number);
  73458. get samples(): number;
  73459. private _textureSamples;
  73460. /**
  73461. * Number of samples to use for antialiasing
  73462. */
  73463. set textureSamples(n: number);
  73464. get textureSamples(): number;
  73465. /**
  73466. * Ratio object used for SSAO ratio and blur ratio
  73467. */
  73468. private _ratio;
  73469. /**
  73470. * Dynamically generated sphere sampler.
  73471. */
  73472. private _sampleSphere;
  73473. /**
  73474. * Blur filter offsets
  73475. */
  73476. private _samplerOffsets;
  73477. private _expensiveBlur;
  73478. /**
  73479. * If bilateral blur should be used
  73480. */
  73481. set expensiveBlur(b: boolean);
  73482. get expensiveBlur(): boolean;
  73483. /**
  73484. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  73485. */
  73486. radius: number;
  73487. /**
  73488. * The base color of the SSAO post-process
  73489. * The final result is "base + ssao" between [0, 1]
  73490. */
  73491. base: number;
  73492. /**
  73493. * Support test.
  73494. */
  73495. static get IsSupported(): boolean;
  73496. private _scene;
  73497. private _depthTexture;
  73498. private _normalTexture;
  73499. private _randomTexture;
  73500. private _originalColorPostProcess;
  73501. private _ssaoPostProcess;
  73502. private _blurHPostProcess;
  73503. private _blurVPostProcess;
  73504. private _ssaoCombinePostProcess;
  73505. /**
  73506. * Gets active scene
  73507. */
  73508. get scene(): Scene;
  73509. /**
  73510. * @constructor
  73511. * @param name The rendering pipeline name
  73512. * @param scene The scene linked to this pipeline
  73513. * @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 }
  73514. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73515. */
  73516. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73517. /**
  73518. * Get the class name
  73519. * @returns "SSAO2RenderingPipeline"
  73520. */
  73521. getClassName(): string;
  73522. /**
  73523. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73524. */
  73525. dispose(disableGeometryBufferRenderer?: boolean): void;
  73526. private _createBlurPostProcess;
  73527. /** @hidden */
  73528. _rebuild(): void;
  73529. private _bits;
  73530. private _radicalInverse_VdC;
  73531. private _hammersley;
  73532. private _hemisphereSample_uniform;
  73533. private _generateHemisphere;
  73534. private _createSSAOPostProcess;
  73535. private _createSSAOCombinePostProcess;
  73536. private _createRandomTexture;
  73537. /**
  73538. * Serialize the rendering pipeline (Used when exporting)
  73539. * @returns the serialized object
  73540. */
  73541. serialize(): any;
  73542. /**
  73543. * Parse the serialized pipeline
  73544. * @param source Source pipeline.
  73545. * @param scene The scene to load the pipeline to.
  73546. * @param rootUrl The URL of the serialized pipeline.
  73547. * @returns An instantiated pipeline from the serialized object.
  73548. */
  73549. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  73550. }
  73551. }
  73552. declare module "babylonjs/Shaders/ssao.fragment" {
  73553. /** @hidden */
  73554. export var ssaoPixelShader: {
  73555. name: string;
  73556. shader: string;
  73557. };
  73558. }
  73559. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  73560. import { Camera } from "babylonjs/Cameras/camera";
  73561. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73562. import { Scene } from "babylonjs/scene";
  73563. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73564. import "babylonjs/Shaders/ssao.fragment";
  73565. import "babylonjs/Shaders/ssaoCombine.fragment";
  73566. /**
  73567. * Render pipeline to produce ssao effect
  73568. */
  73569. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  73570. /**
  73571. * @ignore
  73572. * The PassPostProcess id in the pipeline that contains the original scene color
  73573. */
  73574. SSAOOriginalSceneColorEffect: string;
  73575. /**
  73576. * @ignore
  73577. * The SSAO PostProcess id in the pipeline
  73578. */
  73579. SSAORenderEffect: string;
  73580. /**
  73581. * @ignore
  73582. * The horizontal blur PostProcess id in the pipeline
  73583. */
  73584. SSAOBlurHRenderEffect: string;
  73585. /**
  73586. * @ignore
  73587. * The vertical blur PostProcess id in the pipeline
  73588. */
  73589. SSAOBlurVRenderEffect: string;
  73590. /**
  73591. * @ignore
  73592. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73593. */
  73594. SSAOCombineRenderEffect: string;
  73595. /**
  73596. * The output strength of the SSAO post-process. Default value is 1.0.
  73597. */
  73598. totalStrength: number;
  73599. /**
  73600. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  73601. */
  73602. radius: number;
  73603. /**
  73604. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  73605. * Must not be equal to fallOff and superior to fallOff.
  73606. * Default value is 0.0075
  73607. */
  73608. area: number;
  73609. /**
  73610. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  73611. * Must not be equal to area and inferior to area.
  73612. * Default value is 0.000001
  73613. */
  73614. fallOff: number;
  73615. /**
  73616. * The base color of the SSAO post-process
  73617. * The final result is "base + ssao" between [0, 1]
  73618. */
  73619. base: number;
  73620. private _scene;
  73621. private _depthTexture;
  73622. private _randomTexture;
  73623. private _originalColorPostProcess;
  73624. private _ssaoPostProcess;
  73625. private _blurHPostProcess;
  73626. private _blurVPostProcess;
  73627. private _ssaoCombinePostProcess;
  73628. private _firstUpdate;
  73629. /**
  73630. * Gets active scene
  73631. */
  73632. get scene(): Scene;
  73633. /**
  73634. * @constructor
  73635. * @param name - The rendering pipeline name
  73636. * @param scene - The scene linked to this pipeline
  73637. * @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 }
  73638. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  73639. */
  73640. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73641. /**
  73642. * Get the class name
  73643. * @returns "SSAORenderingPipeline"
  73644. */
  73645. getClassName(): string;
  73646. /**
  73647. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73648. */
  73649. dispose(disableDepthRender?: boolean): void;
  73650. private _createBlurPostProcess;
  73651. /** @hidden */
  73652. _rebuild(): void;
  73653. private _createSSAOPostProcess;
  73654. private _createSSAOCombinePostProcess;
  73655. private _createRandomTexture;
  73656. }
  73657. }
  73658. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  73659. /** @hidden */
  73660. export var screenSpaceReflectionPixelShader: {
  73661. name: string;
  73662. shader: string;
  73663. };
  73664. }
  73665. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  73666. import { Nullable } from "babylonjs/types";
  73667. import { Camera } from "babylonjs/Cameras/camera";
  73668. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73669. import { Scene } from "babylonjs/scene";
  73670. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  73671. import { Engine } from "babylonjs/Engines/engine";
  73672. /**
  73673. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  73674. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  73675. */
  73676. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  73677. /**
  73678. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  73679. */
  73680. threshold: number;
  73681. /**
  73682. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  73683. */
  73684. strength: number;
  73685. /**
  73686. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  73687. */
  73688. reflectionSpecularFalloffExponent: number;
  73689. /**
  73690. * 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]
  73691. */
  73692. step: number;
  73693. /**
  73694. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  73695. */
  73696. roughnessFactor: number;
  73697. private _geometryBufferRenderer;
  73698. private _enableSmoothReflections;
  73699. private _reflectionSamples;
  73700. private _smoothSteps;
  73701. /**
  73702. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  73703. * @param name The name of the effect.
  73704. * @param scene The scene containing the objects to calculate reflections.
  73705. * @param options The required width/height ratio to downsize to before computing the render pass.
  73706. * @param camera The camera to apply the render pass to.
  73707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73708. * @param engine The engine which the post process will be applied. (default: current engine)
  73709. * @param reusable If the post process can be reused on the same frame. (default: false)
  73710. * @param textureType Type of textures used when performing the post process. (default: 0)
  73711. * @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)
  73712. */
  73713. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73714. /**
  73715. * Gets wether or not smoothing reflections is enabled.
  73716. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73717. */
  73718. get enableSmoothReflections(): boolean;
  73719. /**
  73720. * Sets wether or not smoothing reflections is enabled.
  73721. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73722. */
  73723. set enableSmoothReflections(enabled: boolean);
  73724. /**
  73725. * Gets the number of samples taken while computing reflections. More samples count is high,
  73726. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73727. */
  73728. get reflectionSamples(): number;
  73729. /**
  73730. * Sets the number of samples taken while computing reflections. More samples count is high,
  73731. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73732. */
  73733. set reflectionSamples(samples: number);
  73734. /**
  73735. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  73736. * more the post-process will require GPU power and can generate a drop in FPS.
  73737. * Default value (5.0) work pretty well in all cases but can be adjusted.
  73738. */
  73739. get smoothSteps(): number;
  73740. set smoothSteps(steps: number);
  73741. private _updateEffectDefines;
  73742. }
  73743. }
  73744. declare module "babylonjs/Shaders/standard.fragment" {
  73745. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  73746. /** @hidden */
  73747. export var standardPixelShader: {
  73748. name: string;
  73749. shader: string;
  73750. };
  73751. }
  73752. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  73753. import { Nullable } from "babylonjs/types";
  73754. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73755. import { Camera } from "babylonjs/Cameras/camera";
  73756. import { Texture } from "babylonjs/Materials/Textures/texture";
  73757. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73758. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73759. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73760. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73761. import { IDisposable } from "babylonjs/scene";
  73762. import { SpotLight } from "babylonjs/Lights/spotLight";
  73763. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  73764. import { Scene } from "babylonjs/scene";
  73765. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73766. import { Animation } from "babylonjs/Animations/animation";
  73767. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73768. import "babylonjs/Shaders/standard.fragment";
  73769. /**
  73770. * Standard rendering pipeline
  73771. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73772. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73773. */
  73774. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73775. /**
  73776. * Public members
  73777. */
  73778. /**
  73779. * Post-process which contains the original scene color before the pipeline applies all the effects
  73780. */
  73781. originalPostProcess: Nullable<PostProcess>;
  73782. /**
  73783. * Post-process used to down scale an image x4
  73784. */
  73785. downSampleX4PostProcess: Nullable<PostProcess>;
  73786. /**
  73787. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73788. */
  73789. brightPassPostProcess: Nullable<PostProcess>;
  73790. /**
  73791. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73792. */
  73793. blurHPostProcesses: PostProcess[];
  73794. /**
  73795. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73796. */
  73797. blurVPostProcesses: PostProcess[];
  73798. /**
  73799. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73800. */
  73801. textureAdderPostProcess: Nullable<PostProcess>;
  73802. /**
  73803. * Post-process used to create volumetric lighting effect
  73804. */
  73805. volumetricLightPostProcess: Nullable<PostProcess>;
  73806. /**
  73807. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73808. */
  73809. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73810. /**
  73811. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73812. */
  73813. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73814. /**
  73815. * Post-process used to merge the volumetric light effect and the real scene color
  73816. */
  73817. volumetricLightMergePostProces: Nullable<PostProcess>;
  73818. /**
  73819. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73820. */
  73821. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73822. /**
  73823. * Base post-process used to calculate the average luminance of the final image for HDR
  73824. */
  73825. luminancePostProcess: Nullable<PostProcess>;
  73826. /**
  73827. * Post-processes used to create down sample post-processes in order to get
  73828. * the average luminance of the final image for HDR
  73829. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73830. */
  73831. luminanceDownSamplePostProcesses: PostProcess[];
  73832. /**
  73833. * Post-process used to create a HDR effect (light adaptation)
  73834. */
  73835. hdrPostProcess: Nullable<PostProcess>;
  73836. /**
  73837. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73838. */
  73839. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73840. /**
  73841. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73842. */
  73843. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73844. /**
  73845. * Post-process used to merge the final HDR post-process and the real scene color
  73846. */
  73847. hdrFinalPostProcess: Nullable<PostProcess>;
  73848. /**
  73849. * Post-process used to create a lens flare effect
  73850. */
  73851. lensFlarePostProcess: Nullable<PostProcess>;
  73852. /**
  73853. * Post-process that merges the result of the lens flare post-process and the real scene color
  73854. */
  73855. lensFlareComposePostProcess: Nullable<PostProcess>;
  73856. /**
  73857. * Post-process used to create a motion blur effect
  73858. */
  73859. motionBlurPostProcess: Nullable<PostProcess>;
  73860. /**
  73861. * Post-process used to create a depth of field effect
  73862. */
  73863. depthOfFieldPostProcess: Nullable<PostProcess>;
  73864. /**
  73865. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73866. */
  73867. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73868. /**
  73869. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73870. */
  73871. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73872. /**
  73873. * Represents the brightness threshold in order to configure the illuminated surfaces
  73874. */
  73875. brightThreshold: number;
  73876. /**
  73877. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73878. */
  73879. blurWidth: number;
  73880. /**
  73881. * Sets if the blur for highlighted surfaces must be only horizontal
  73882. */
  73883. horizontalBlur: boolean;
  73884. /**
  73885. * Gets the overall exposure used by the pipeline
  73886. */
  73887. get exposure(): number;
  73888. /**
  73889. * Sets the overall exposure used by the pipeline
  73890. */
  73891. set exposure(value: number);
  73892. /**
  73893. * Texture used typically to simulate "dirty" on camera lens
  73894. */
  73895. lensTexture: Nullable<Texture>;
  73896. /**
  73897. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73898. */
  73899. volumetricLightCoefficient: number;
  73900. /**
  73901. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73902. */
  73903. volumetricLightPower: number;
  73904. /**
  73905. * Used the set the blur intensity to smooth the volumetric lights
  73906. */
  73907. volumetricLightBlurScale: number;
  73908. /**
  73909. * Light (spot or directional) used to generate the volumetric lights rays
  73910. * The source light must have a shadow generate so the pipeline can get its
  73911. * depth map
  73912. */
  73913. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73914. /**
  73915. * For eye adaptation, represents the minimum luminance the eye can see
  73916. */
  73917. hdrMinimumLuminance: number;
  73918. /**
  73919. * For eye adaptation, represents the decrease luminance speed
  73920. */
  73921. hdrDecreaseRate: number;
  73922. /**
  73923. * For eye adaptation, represents the increase luminance speed
  73924. */
  73925. hdrIncreaseRate: number;
  73926. /**
  73927. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73928. */
  73929. get hdrAutoExposure(): boolean;
  73930. /**
  73931. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73932. */
  73933. set hdrAutoExposure(value: boolean);
  73934. /**
  73935. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73936. */
  73937. lensColorTexture: Nullable<Texture>;
  73938. /**
  73939. * The overall strengh for the lens flare effect
  73940. */
  73941. lensFlareStrength: number;
  73942. /**
  73943. * Dispersion coefficient for lens flare ghosts
  73944. */
  73945. lensFlareGhostDispersal: number;
  73946. /**
  73947. * Main lens flare halo width
  73948. */
  73949. lensFlareHaloWidth: number;
  73950. /**
  73951. * Based on the lens distortion effect, defines how much the lens flare result
  73952. * is distorted
  73953. */
  73954. lensFlareDistortionStrength: number;
  73955. /**
  73956. * Configures the blur intensity used for for lens flare (halo)
  73957. */
  73958. lensFlareBlurWidth: number;
  73959. /**
  73960. * Lens star texture must be used to simulate rays on the flares and is available
  73961. * in the documentation
  73962. */
  73963. lensStarTexture: Nullable<Texture>;
  73964. /**
  73965. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73966. * flare effect by taking account of the dirt texture
  73967. */
  73968. lensFlareDirtTexture: Nullable<Texture>;
  73969. /**
  73970. * Represents the focal length for the depth of field effect
  73971. */
  73972. depthOfFieldDistance: number;
  73973. /**
  73974. * Represents the blur intensity for the blurred part of the depth of field effect
  73975. */
  73976. depthOfFieldBlurWidth: number;
  73977. /**
  73978. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73979. */
  73980. get motionStrength(): number;
  73981. /**
  73982. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73983. */
  73984. set motionStrength(strength: number);
  73985. /**
  73986. * Gets wether or not the motion blur post-process is object based or screen based.
  73987. */
  73988. get objectBasedMotionBlur(): boolean;
  73989. /**
  73990. * Sets wether or not the motion blur post-process should be object based or screen based
  73991. */
  73992. set objectBasedMotionBlur(value: boolean);
  73993. /**
  73994. * List of animations for the pipeline (IAnimatable implementation)
  73995. */
  73996. animations: Animation[];
  73997. /**
  73998. * Private members
  73999. */
  74000. private _scene;
  74001. private _currentDepthOfFieldSource;
  74002. private _basePostProcess;
  74003. private _fixedExposure;
  74004. private _currentExposure;
  74005. private _hdrAutoExposure;
  74006. private _hdrCurrentLuminance;
  74007. private _motionStrength;
  74008. private _isObjectBasedMotionBlur;
  74009. private _floatTextureType;
  74010. private _camerasToBeAttached;
  74011. private _ratio;
  74012. private _bloomEnabled;
  74013. private _depthOfFieldEnabled;
  74014. private _vlsEnabled;
  74015. private _lensFlareEnabled;
  74016. private _hdrEnabled;
  74017. private _motionBlurEnabled;
  74018. private _fxaaEnabled;
  74019. private _screenSpaceReflectionsEnabled;
  74020. private _motionBlurSamples;
  74021. private _volumetricLightStepsCount;
  74022. private _samples;
  74023. /**
  74024. * @ignore
  74025. * Specifies if the bloom pipeline is enabled
  74026. */
  74027. get BloomEnabled(): boolean;
  74028. set BloomEnabled(enabled: boolean);
  74029. /**
  74030. * @ignore
  74031. * Specifies if the depth of field pipeline is enabed
  74032. */
  74033. get DepthOfFieldEnabled(): boolean;
  74034. set DepthOfFieldEnabled(enabled: boolean);
  74035. /**
  74036. * @ignore
  74037. * Specifies if the lens flare pipeline is enabed
  74038. */
  74039. get LensFlareEnabled(): boolean;
  74040. set LensFlareEnabled(enabled: boolean);
  74041. /**
  74042. * @ignore
  74043. * Specifies if the HDR pipeline is enabled
  74044. */
  74045. get HDREnabled(): boolean;
  74046. set HDREnabled(enabled: boolean);
  74047. /**
  74048. * @ignore
  74049. * Specifies if the volumetric lights scattering effect is enabled
  74050. */
  74051. get VLSEnabled(): boolean;
  74052. set VLSEnabled(enabled: boolean);
  74053. /**
  74054. * @ignore
  74055. * Specifies if the motion blur effect is enabled
  74056. */
  74057. get MotionBlurEnabled(): boolean;
  74058. set MotionBlurEnabled(enabled: boolean);
  74059. /**
  74060. * Specifies if anti-aliasing is enabled
  74061. */
  74062. get fxaaEnabled(): boolean;
  74063. set fxaaEnabled(enabled: boolean);
  74064. /**
  74065. * Specifies if screen space reflections are enabled.
  74066. */
  74067. get screenSpaceReflectionsEnabled(): boolean;
  74068. set screenSpaceReflectionsEnabled(enabled: boolean);
  74069. /**
  74070. * Specifies the number of steps used to calculate the volumetric lights
  74071. * Typically in interval [50, 200]
  74072. */
  74073. get volumetricLightStepsCount(): number;
  74074. set volumetricLightStepsCount(count: number);
  74075. /**
  74076. * Specifies the number of samples used for the motion blur effect
  74077. * Typically in interval [16, 64]
  74078. */
  74079. get motionBlurSamples(): number;
  74080. set motionBlurSamples(samples: number);
  74081. /**
  74082. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74083. */
  74084. get samples(): number;
  74085. set samples(sampleCount: number);
  74086. /**
  74087. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74088. * @constructor
  74089. * @param name The rendering pipeline name
  74090. * @param scene The scene linked to this pipeline
  74091. * @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)
  74092. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74093. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74094. */
  74095. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74096. private _buildPipeline;
  74097. private _createDownSampleX4PostProcess;
  74098. private _createBrightPassPostProcess;
  74099. private _createBlurPostProcesses;
  74100. private _createTextureAdderPostProcess;
  74101. private _createVolumetricLightPostProcess;
  74102. private _createLuminancePostProcesses;
  74103. private _createHdrPostProcess;
  74104. private _createLensFlarePostProcess;
  74105. private _createDepthOfFieldPostProcess;
  74106. private _createMotionBlurPostProcess;
  74107. private _getDepthTexture;
  74108. private _disposePostProcesses;
  74109. /**
  74110. * Dispose of the pipeline and stop all post processes
  74111. */
  74112. dispose(): void;
  74113. /**
  74114. * Serialize the rendering pipeline (Used when exporting)
  74115. * @returns the serialized object
  74116. */
  74117. serialize(): any;
  74118. /**
  74119. * Parse the serialized pipeline
  74120. * @param source Source pipeline.
  74121. * @param scene The scene to load the pipeline to.
  74122. * @param rootUrl The URL of the serialized pipeline.
  74123. * @returns An instantiated pipeline from the serialized object.
  74124. */
  74125. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74126. /**
  74127. * Luminance steps
  74128. */
  74129. static LuminanceSteps: number;
  74130. }
  74131. }
  74132. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74133. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74134. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74135. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74136. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74137. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74138. }
  74139. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74140. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74141. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74142. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74143. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74144. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74145. }
  74146. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74147. /** @hidden */
  74148. export var stereoscopicInterlacePixelShader: {
  74149. name: string;
  74150. shader: string;
  74151. };
  74152. }
  74153. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74154. import { Camera } from "babylonjs/Cameras/camera";
  74155. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74156. import { Engine } from "babylonjs/Engines/engine";
  74157. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74158. /**
  74159. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74160. */
  74161. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74162. private _stepSize;
  74163. private _passedProcess;
  74164. /**
  74165. * Initializes a StereoscopicInterlacePostProcessI
  74166. * @param name The name of the effect.
  74167. * @param rigCameras The rig cameras to be appled to the post process
  74168. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74169. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74170. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74171. * @param engine The engine which the post process will be applied. (default: current engine)
  74172. * @param reusable If the post process can be reused on the same frame. (default: false)
  74173. */
  74174. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74175. }
  74176. /**
  74177. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74178. */
  74179. export class StereoscopicInterlacePostProcess extends PostProcess {
  74180. private _stepSize;
  74181. private _passedProcess;
  74182. /**
  74183. * Initializes a StereoscopicInterlacePostProcess
  74184. * @param name The name of the effect.
  74185. * @param rigCameras The rig cameras to be appled to the post process
  74186. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74187. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74188. * @param engine The engine which the post process will be applied. (default: current engine)
  74189. * @param reusable If the post process can be reused on the same frame. (default: false)
  74190. */
  74191. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74192. }
  74193. }
  74194. declare module "babylonjs/Shaders/tonemap.fragment" {
  74195. /** @hidden */
  74196. export var tonemapPixelShader: {
  74197. name: string;
  74198. shader: string;
  74199. };
  74200. }
  74201. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  74202. import { Camera } from "babylonjs/Cameras/camera";
  74203. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74204. import "babylonjs/Shaders/tonemap.fragment";
  74205. import { Engine } from "babylonjs/Engines/engine";
  74206. /** Defines operator used for tonemapping */
  74207. export enum TonemappingOperator {
  74208. /** Hable */
  74209. Hable = 0,
  74210. /** Reinhard */
  74211. Reinhard = 1,
  74212. /** HejiDawson */
  74213. HejiDawson = 2,
  74214. /** Photographic */
  74215. Photographic = 3
  74216. }
  74217. /**
  74218. * Defines a post process to apply tone mapping
  74219. */
  74220. export class TonemapPostProcess extends PostProcess {
  74221. private _operator;
  74222. /** Defines the required exposure adjustement */
  74223. exposureAdjustment: number;
  74224. /**
  74225. * Creates a new TonemapPostProcess
  74226. * @param name defines the name of the postprocess
  74227. * @param _operator defines the operator to use
  74228. * @param exposureAdjustment defines the required exposure adjustement
  74229. * @param camera defines the camera to use (can be null)
  74230. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74231. * @param engine defines the hosting engine (can be ignore if camera is set)
  74232. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74233. */
  74234. constructor(name: string, _operator: TonemappingOperator,
  74235. /** Defines the required exposure adjustement */
  74236. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74237. }
  74238. }
  74239. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74240. /** @hidden */
  74241. export var volumetricLightScatteringPixelShader: {
  74242. name: string;
  74243. shader: string;
  74244. };
  74245. }
  74246. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74247. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74248. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74249. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74250. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74251. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74252. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74253. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74254. /** @hidden */
  74255. export var volumetricLightScatteringPassVertexShader: {
  74256. name: string;
  74257. shader: string;
  74258. };
  74259. }
  74260. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74261. /** @hidden */
  74262. export var volumetricLightScatteringPassPixelShader: {
  74263. name: string;
  74264. shader: string;
  74265. };
  74266. }
  74267. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74268. import { Vector3 } from "babylonjs/Maths/math.vector";
  74269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74270. import { Mesh } from "babylonjs/Meshes/mesh";
  74271. import { Camera } from "babylonjs/Cameras/camera";
  74272. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74273. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74274. import { Scene } from "babylonjs/scene";
  74275. import "babylonjs/Meshes/Builders/planeBuilder";
  74276. import "babylonjs/Shaders/depth.vertex";
  74277. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74278. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74279. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74280. import { Engine } from "babylonjs/Engines/engine";
  74281. /**
  74282. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74283. */
  74284. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74285. private _volumetricLightScatteringPass;
  74286. private _volumetricLightScatteringRTT;
  74287. private _viewPort;
  74288. private _screenCoordinates;
  74289. private _cachedDefines;
  74290. /**
  74291. * If not undefined, the mesh position is computed from the attached node position
  74292. */
  74293. attachedNode: {
  74294. position: Vector3;
  74295. };
  74296. /**
  74297. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74298. */
  74299. customMeshPosition: Vector3;
  74300. /**
  74301. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74302. */
  74303. useCustomMeshPosition: boolean;
  74304. /**
  74305. * If the post-process should inverse the light scattering direction
  74306. */
  74307. invert: boolean;
  74308. /**
  74309. * The internal mesh used by the post-process
  74310. */
  74311. mesh: Mesh;
  74312. /**
  74313. * @hidden
  74314. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74315. */
  74316. get useDiffuseColor(): boolean;
  74317. set useDiffuseColor(useDiffuseColor: boolean);
  74318. /**
  74319. * Array containing the excluded meshes not rendered in the internal pass
  74320. */
  74321. excludedMeshes: AbstractMesh[];
  74322. /**
  74323. * Controls the overall intensity of the post-process
  74324. */
  74325. exposure: number;
  74326. /**
  74327. * Dissipates each sample's contribution in range [0, 1]
  74328. */
  74329. decay: number;
  74330. /**
  74331. * Controls the overall intensity of each sample
  74332. */
  74333. weight: number;
  74334. /**
  74335. * Controls the density of each sample
  74336. */
  74337. density: number;
  74338. /**
  74339. * @constructor
  74340. * @param name The post-process name
  74341. * @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)
  74342. * @param camera The camera that the post-process will be attached to
  74343. * @param mesh The mesh used to create the light scattering
  74344. * @param samples The post-process quality, default 100
  74345. * @param samplingModeThe post-process filtering mode
  74346. * @param engine The babylon engine
  74347. * @param reusable If the post-process is reusable
  74348. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  74349. */
  74350. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  74351. /**
  74352. * Returns the string "VolumetricLightScatteringPostProcess"
  74353. * @returns "VolumetricLightScatteringPostProcess"
  74354. */
  74355. getClassName(): string;
  74356. private _isReady;
  74357. /**
  74358. * Sets the new light position for light scattering effect
  74359. * @param position The new custom light position
  74360. */
  74361. setCustomMeshPosition(position: Vector3): void;
  74362. /**
  74363. * Returns the light position for light scattering effect
  74364. * @return Vector3 The custom light position
  74365. */
  74366. getCustomMeshPosition(): Vector3;
  74367. /**
  74368. * Disposes the internal assets and detaches the post-process from the camera
  74369. */
  74370. dispose(camera: Camera): void;
  74371. /**
  74372. * Returns the render target texture used by the post-process
  74373. * @return the render target texture used by the post-process
  74374. */
  74375. getPass(): RenderTargetTexture;
  74376. private _meshExcluded;
  74377. private _createPass;
  74378. private _updateMeshScreenCoordinates;
  74379. /**
  74380. * Creates a default mesh for the Volumeric Light Scattering post-process
  74381. * @param name The mesh name
  74382. * @param scene The scene where to create the mesh
  74383. * @return the default mesh
  74384. */
  74385. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  74386. }
  74387. }
  74388. declare module "babylonjs/PostProcesses/index" {
  74389. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  74390. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  74391. export * from "babylonjs/PostProcesses/bloomEffect";
  74392. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  74393. export * from "babylonjs/PostProcesses/blurPostProcess";
  74394. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74395. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  74396. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  74397. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  74398. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74399. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  74400. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  74401. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  74402. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74403. export * from "babylonjs/PostProcesses/filterPostProcess";
  74404. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  74405. export * from "babylonjs/PostProcesses/grainPostProcess";
  74406. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  74407. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74408. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  74409. export * from "babylonjs/PostProcesses/passPostProcess";
  74410. export * from "babylonjs/PostProcesses/postProcess";
  74411. export * from "babylonjs/PostProcesses/postProcessManager";
  74412. export * from "babylonjs/PostProcesses/refractionPostProcess";
  74413. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  74414. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  74415. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  74416. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  74417. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  74418. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  74419. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  74420. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74421. }
  74422. declare module "babylonjs/Probes/index" {
  74423. export * from "babylonjs/Probes/reflectionProbe";
  74424. }
  74425. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  74426. import { Scene } from "babylonjs/scene";
  74427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74428. import { SmartArray } from "babylonjs/Misc/smartArray";
  74429. import { ISceneComponent } from "babylonjs/sceneComponent";
  74430. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  74431. import "babylonjs/Meshes/Builders/boxBuilder";
  74432. import "babylonjs/Shaders/color.fragment";
  74433. import "babylonjs/Shaders/color.vertex";
  74434. import { Color3 } from "babylonjs/Maths/math.color";
  74435. import { Observable } from "babylonjs/Misc/observable";
  74436. module "babylonjs/scene" {
  74437. interface Scene {
  74438. /** @hidden (Backing field) */
  74439. _boundingBoxRenderer: BoundingBoxRenderer;
  74440. /** @hidden (Backing field) */
  74441. _forceShowBoundingBoxes: boolean;
  74442. /**
  74443. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  74444. */
  74445. forceShowBoundingBoxes: boolean;
  74446. /**
  74447. * Gets the bounding box renderer associated with the scene
  74448. * @returns a BoundingBoxRenderer
  74449. */
  74450. getBoundingBoxRenderer(): BoundingBoxRenderer;
  74451. }
  74452. }
  74453. module "babylonjs/Meshes/abstractMesh" {
  74454. interface AbstractMesh {
  74455. /** @hidden (Backing field) */
  74456. _showBoundingBox: boolean;
  74457. /**
  74458. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  74459. */
  74460. showBoundingBox: boolean;
  74461. }
  74462. }
  74463. /**
  74464. * Component responsible of rendering the bounding box of the meshes in a scene.
  74465. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  74466. */
  74467. export class BoundingBoxRenderer implements ISceneComponent {
  74468. /**
  74469. * The component name helpfull to identify the component in the list of scene components.
  74470. */
  74471. readonly name: string;
  74472. /**
  74473. * The scene the component belongs to.
  74474. */
  74475. scene: Scene;
  74476. /**
  74477. * Color of the bounding box lines placed in front of an object
  74478. */
  74479. frontColor: Color3;
  74480. /**
  74481. * Color of the bounding box lines placed behind an object
  74482. */
  74483. backColor: Color3;
  74484. /**
  74485. * Defines if the renderer should show the back lines or not
  74486. */
  74487. showBackLines: boolean;
  74488. /**
  74489. * Observable raised before rendering a bounding box
  74490. */
  74491. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  74492. /**
  74493. * Observable raised after rendering a bounding box
  74494. */
  74495. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  74496. /**
  74497. * @hidden
  74498. */
  74499. renderList: SmartArray<BoundingBox>;
  74500. private _colorShader;
  74501. private _vertexBuffers;
  74502. private _indexBuffer;
  74503. private _fillIndexBuffer;
  74504. private _fillIndexData;
  74505. /**
  74506. * Instantiates a new bounding box renderer in a scene.
  74507. * @param scene the scene the renderer renders in
  74508. */
  74509. constructor(scene: Scene);
  74510. /**
  74511. * Registers the component in a given scene
  74512. */
  74513. register(): void;
  74514. private _evaluateSubMesh;
  74515. private _activeMesh;
  74516. private _prepareRessources;
  74517. private _createIndexBuffer;
  74518. /**
  74519. * Rebuilds the elements related to this component in case of
  74520. * context lost for instance.
  74521. */
  74522. rebuild(): void;
  74523. /**
  74524. * @hidden
  74525. */
  74526. reset(): void;
  74527. /**
  74528. * Render the bounding boxes of a specific rendering group
  74529. * @param renderingGroupId defines the rendering group to render
  74530. */
  74531. render(renderingGroupId: number): void;
  74532. /**
  74533. * In case of occlusion queries, we can render the occlusion bounding box through this method
  74534. * @param mesh Define the mesh to render the occlusion bounding box for
  74535. */
  74536. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  74537. /**
  74538. * Dispose and release the resources attached to this renderer.
  74539. */
  74540. dispose(): void;
  74541. }
  74542. }
  74543. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  74544. import { Nullable } from "babylonjs/types";
  74545. import { Scene } from "babylonjs/scene";
  74546. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  74547. import { Camera } from "babylonjs/Cameras/camera";
  74548. import { ISceneComponent } from "babylonjs/sceneComponent";
  74549. module "babylonjs/scene" {
  74550. interface Scene {
  74551. /** @hidden (Backing field) */
  74552. _depthRenderer: {
  74553. [id: string]: DepthRenderer;
  74554. };
  74555. /**
  74556. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  74557. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  74558. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  74559. * @returns the created depth renderer
  74560. */
  74561. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  74562. /**
  74563. * Disables a depth renderer for a given camera
  74564. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  74565. */
  74566. disableDepthRenderer(camera?: Nullable<Camera>): void;
  74567. }
  74568. }
  74569. /**
  74570. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  74571. * in several rendering techniques.
  74572. */
  74573. export class DepthRendererSceneComponent implements ISceneComponent {
  74574. /**
  74575. * The component name helpfull to identify the component in the list of scene components.
  74576. */
  74577. readonly name: string;
  74578. /**
  74579. * The scene the component belongs to.
  74580. */
  74581. scene: Scene;
  74582. /**
  74583. * Creates a new instance of the component for the given scene
  74584. * @param scene Defines the scene to register the component in
  74585. */
  74586. constructor(scene: Scene);
  74587. /**
  74588. * Registers the component in a given scene
  74589. */
  74590. register(): void;
  74591. /**
  74592. * Rebuilds the elements related to this component in case of
  74593. * context lost for instance.
  74594. */
  74595. rebuild(): void;
  74596. /**
  74597. * Disposes the component and the associated ressources
  74598. */
  74599. dispose(): void;
  74600. private _gatherRenderTargets;
  74601. private _gatherActiveCameraRenderTargets;
  74602. }
  74603. }
  74604. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  74605. /** @hidden */
  74606. export var fibonacci: {
  74607. name: string;
  74608. shader: string;
  74609. };
  74610. }
  74611. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  74612. /** @hidden */
  74613. export var diffusionProfile: {
  74614. name: string;
  74615. shader: string;
  74616. };
  74617. }
  74618. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  74619. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  74620. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74621. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  74622. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  74623. /** @hidden */
  74624. export var subSurfaceScatteringPixelShader: {
  74625. name: string;
  74626. shader: string;
  74627. };
  74628. }
  74629. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  74630. import { Nullable } from "babylonjs/types";
  74631. import { Camera } from "babylonjs/Cameras/camera";
  74632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74633. import { Engine } from "babylonjs/Engines/engine";
  74634. import { Scene } from "babylonjs/scene";
  74635. import "babylonjs/Shaders/imageProcessing.fragment";
  74636. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  74637. import "babylonjs/Shaders/postprocess.vertex";
  74638. /**
  74639. * Sub surface scattering post process
  74640. */
  74641. export class SubSurfaceScatteringPostProcess extends PostProcess {
  74642. /** @hidden */
  74643. texelWidth: number;
  74644. /** @hidden */
  74645. texelHeight: number;
  74646. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74647. }
  74648. }
  74649. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  74650. import { Color3 } from "babylonjs/Maths/math.color";
  74651. /**
  74652. * Contains all parameters needed for the prepass to perform
  74653. * screen space subsurface scattering
  74654. */
  74655. export class SubSurfaceConfiguration {
  74656. private _ssDiffusionS;
  74657. private _ssFilterRadii;
  74658. private _ssDiffusionD;
  74659. /**
  74660. * Diffusion profile color for subsurface scattering
  74661. */
  74662. get ssDiffusionS(): number[];
  74663. /**
  74664. * Diffusion profile max color channel value for subsurface scattering
  74665. */
  74666. get ssDiffusionD(): number[];
  74667. /**
  74668. * Diffusion profile filter radius for subsurface scattering
  74669. */
  74670. get ssFilterRadii(): number[];
  74671. /**
  74672. * Diffusion profile colors for subsurface scattering
  74673. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  74674. * See ...
  74675. * Note that you can only store up to 5 of them
  74676. */
  74677. ssDiffusionProfileColors: Color3[];
  74678. /**
  74679. * Defines the ratio real world => scene units.
  74680. * Used for subsurface scattering
  74681. */
  74682. metersPerUnit: number;
  74683. /**
  74684. * Builds a subsurface configuration object
  74685. * @param scene The scene
  74686. */
  74687. constructor();
  74688. /**
  74689. * Adds a new diffusion profile.
  74690. * Useful for more realistic subsurface scattering on diverse materials.
  74691. * @param color The color of the diffusion profile. Should be the average color of the material.
  74692. * @return The index of the diffusion profile for the material subsurface configuration
  74693. */
  74694. addDiffusionProfile(color: Color3): number;
  74695. /**
  74696. * Deletes all diffusion profiles.
  74697. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  74698. */
  74699. clearAllDiffusionProfiles(): void;
  74700. /**
  74701. * Disposes this object
  74702. */
  74703. dispose(): void;
  74704. /**
  74705. * @hidden
  74706. * https://zero-radiance.github.io/post/sampling-diffusion/
  74707. *
  74708. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  74709. * ------------------------------------------------------------------------------------
  74710. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  74711. * PDF[r, phi, s] = r * R[r, phi, s]
  74712. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  74713. * ------------------------------------------------------------------------------------
  74714. * We importance sample the color channel with the widest scattering distance.
  74715. */
  74716. getDiffusionProfileParameters(color: Color3): number;
  74717. /**
  74718. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  74719. * 'u' is the random number (the value of the CDF): [0, 1).
  74720. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  74721. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  74722. */
  74723. private _sampleBurleyDiffusionProfile;
  74724. }
  74725. }
  74726. declare module "babylonjs/Rendering/prePassRenderer" {
  74727. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  74728. import { Scene } from "babylonjs/scene";
  74729. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74730. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  74731. import { Effect } from "babylonjs/Materials/effect";
  74732. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  74733. /**
  74734. * Renders a pre pass of the scene
  74735. * This means every mesh in the scene will be rendered to a render target texture
  74736. * And then this texture will be composited to the rendering canvas with post processes
  74737. * It is necessary for effects like subsurface scattering or deferred shading
  74738. */
  74739. export class PrePassRenderer {
  74740. /** @hidden */
  74741. static _SceneComponentInitialization: (scene: Scene) => void;
  74742. private _scene;
  74743. private _engine;
  74744. private _isDirty;
  74745. /**
  74746. * Number of textures in the multi render target texture where the scene is directly rendered
  74747. */
  74748. readonly mrtCount: number;
  74749. /**
  74750. * The render target where the scene is directly rendered
  74751. */
  74752. prePassRT: MultiRenderTarget;
  74753. private _mrtTypes;
  74754. private _multiRenderAttachments;
  74755. private _defaultAttachments;
  74756. private _clearAttachments;
  74757. private readonly _clearColor;
  74758. /**
  74759. * Image processing post process for composition
  74760. */
  74761. imageProcessingPostProcess: ImageProcessingPostProcess;
  74762. /**
  74763. * Post process for subsurface scattering
  74764. */
  74765. subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
  74766. /**
  74767. * Configuration for sub surface scattering post process
  74768. */
  74769. subSurfaceConfiguration: SubSurfaceConfiguration;
  74770. private _enabled;
  74771. /**
  74772. * Indicates if the prepass is enabled
  74773. */
  74774. get enabled(): boolean;
  74775. /**
  74776. * How many samples are used for MSAA of the scene render target
  74777. */
  74778. get samples(): number;
  74779. set samples(n: number);
  74780. /**
  74781. * Instanciates a prepass renderer
  74782. * @param scene The scene
  74783. */
  74784. constructor(scene: Scene);
  74785. private _initializeAttachments;
  74786. private _createEffects;
  74787. /**
  74788. * Indicates if rendering a prepass is supported
  74789. */
  74790. get isSupported(): boolean;
  74791. /**
  74792. * Sets the proper output textures to draw in the engine.
  74793. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  74794. */
  74795. bindAttachmentsForEffect(effect: Effect): void;
  74796. /**
  74797. * @hidden
  74798. */
  74799. _beforeCameraDraw(): void;
  74800. /**
  74801. * @hidden
  74802. */
  74803. _afterCameraDraw(): void;
  74804. private _checkRTSize;
  74805. private _bindFrameBuffer;
  74806. /**
  74807. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  74808. */
  74809. clear(): void;
  74810. private _setState;
  74811. private _enable;
  74812. private _disable;
  74813. /**
  74814. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  74815. */
  74816. markAsDirty(): void;
  74817. private _update;
  74818. /**
  74819. * Disposes the prepass renderer.
  74820. */
  74821. dispose(): void;
  74822. }
  74823. }
  74824. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  74825. import { Nullable } from "babylonjs/types";
  74826. import { Scene } from "babylonjs/scene";
  74827. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  74828. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74829. import { AbstractScene } from "babylonjs/abstractScene";
  74830. module "babylonjs/abstractScene" {
  74831. interface AbstractScene {
  74832. /** @hidden (Backing field) */
  74833. _prePassRenderer: Nullable<PrePassRenderer>;
  74834. /**
  74835. * Gets or Sets the current prepass renderer associated to the scene.
  74836. */
  74837. prePassRenderer: Nullable<PrePassRenderer>;
  74838. /**
  74839. * Enables the prepass and associates it with the scene
  74840. * @returns the PrePassRenderer
  74841. */
  74842. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  74843. /**
  74844. * Disables the prepass associated with the scene
  74845. */
  74846. disablePrePassRenderer(): void;
  74847. }
  74848. }
  74849. /**
  74850. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74851. * in several rendering techniques.
  74852. */
  74853. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  74854. /**
  74855. * The component name helpful to identify the component in the list of scene components.
  74856. */
  74857. readonly name: string;
  74858. /**
  74859. * The scene the component belongs to.
  74860. */
  74861. scene: Scene;
  74862. /**
  74863. * Creates a new instance of the component for the given scene
  74864. * @param scene Defines the scene to register the component in
  74865. */
  74866. constructor(scene: Scene);
  74867. /**
  74868. * Registers the component in a given scene
  74869. */
  74870. register(): void;
  74871. private _beforeCameraDraw;
  74872. private _afterCameraDraw;
  74873. private _beforeClearStage;
  74874. /**
  74875. * Serializes the component data to the specified json object
  74876. * @param serializationObject The object to serialize to
  74877. */
  74878. serialize(serializationObject: any): void;
  74879. /**
  74880. * Adds all the elements from the container to the scene
  74881. * @param container the container holding the elements
  74882. */
  74883. addFromContainer(container: AbstractScene): void;
  74884. /**
  74885. * Removes all the elements in the container from the scene
  74886. * @param container contains the elements to remove
  74887. * @param dispose if the removed element should be disposed (default: false)
  74888. */
  74889. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  74890. /**
  74891. * Rebuilds the elements related to this component in case of
  74892. * context lost for instance.
  74893. */
  74894. rebuild(): void;
  74895. /**
  74896. * Disposes the component and the associated ressources
  74897. */
  74898. dispose(): void;
  74899. }
  74900. }
  74901. declare module "babylonjs/Shaders/outline.fragment" {
  74902. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74903. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  74904. /** @hidden */
  74905. export var outlinePixelShader: {
  74906. name: string;
  74907. shader: string;
  74908. };
  74909. }
  74910. declare module "babylonjs/Shaders/outline.vertex" {
  74911. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74912. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74913. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74914. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74915. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74916. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74917. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74918. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74919. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  74920. /** @hidden */
  74921. export var outlineVertexShader: {
  74922. name: string;
  74923. shader: string;
  74924. };
  74925. }
  74926. declare module "babylonjs/Rendering/outlineRenderer" {
  74927. import { SubMesh } from "babylonjs/Meshes/subMesh";
  74928. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  74929. import { Scene } from "babylonjs/scene";
  74930. import { ISceneComponent } from "babylonjs/sceneComponent";
  74931. import "babylonjs/Shaders/outline.fragment";
  74932. import "babylonjs/Shaders/outline.vertex";
  74933. module "babylonjs/scene" {
  74934. interface Scene {
  74935. /** @hidden */
  74936. _outlineRenderer: OutlineRenderer;
  74937. /**
  74938. * Gets the outline renderer associated with the scene
  74939. * @returns a OutlineRenderer
  74940. */
  74941. getOutlineRenderer(): OutlineRenderer;
  74942. }
  74943. }
  74944. module "babylonjs/Meshes/abstractMesh" {
  74945. interface AbstractMesh {
  74946. /** @hidden (Backing field) */
  74947. _renderOutline: boolean;
  74948. /**
  74949. * Gets or sets a boolean indicating if the outline must be rendered as well
  74950. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  74951. */
  74952. renderOutline: boolean;
  74953. /** @hidden (Backing field) */
  74954. _renderOverlay: boolean;
  74955. /**
  74956. * Gets or sets a boolean indicating if the overlay must be rendered as well
  74957. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  74958. */
  74959. renderOverlay: boolean;
  74960. }
  74961. }
  74962. /**
  74963. * This class is responsible to draw bothe outline/overlay of meshes.
  74964. * It should not be used directly but through the available method on mesh.
  74965. */
  74966. export class OutlineRenderer implements ISceneComponent {
  74967. /**
  74968. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  74969. */
  74970. private static _StencilReference;
  74971. /**
  74972. * The name of the component. Each component must have a unique name.
  74973. */
  74974. name: string;
  74975. /**
  74976. * The scene the component belongs to.
  74977. */
  74978. scene: Scene;
  74979. /**
  74980. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  74981. */
  74982. zOffset: number;
  74983. private _engine;
  74984. private _effect;
  74985. private _cachedDefines;
  74986. private _savedDepthWrite;
  74987. /**
  74988. * Instantiates a new outline renderer. (There could be only one per scene).
  74989. * @param scene Defines the scene it belongs to
  74990. */
  74991. constructor(scene: Scene);
  74992. /**
  74993. * Register the component to one instance of a scene.
  74994. */
  74995. register(): void;
  74996. /**
  74997. * Rebuilds the elements related to this component in case of
  74998. * context lost for instance.
  74999. */
  75000. rebuild(): void;
  75001. /**
  75002. * Disposes the component and the associated ressources.
  75003. */
  75004. dispose(): void;
  75005. /**
  75006. * Renders the outline in the canvas.
  75007. * @param subMesh Defines the sumesh to render
  75008. * @param batch Defines the batch of meshes in case of instances
  75009. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75010. */
  75011. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75012. /**
  75013. * Returns whether or not the outline renderer is ready for a given submesh.
  75014. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75015. * @param subMesh Defines the submesh to check readyness for
  75016. * @param useInstances Defines wheter wee are trying to render instances or not
  75017. * @returns true if ready otherwise false
  75018. */
  75019. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75020. private _beforeRenderingMesh;
  75021. private _afterRenderingMesh;
  75022. }
  75023. }
  75024. declare module "babylonjs/Rendering/index" {
  75025. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75026. export * from "babylonjs/Rendering/depthRenderer";
  75027. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75028. export * from "babylonjs/Rendering/edgesRenderer";
  75029. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75030. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75031. export * from "babylonjs/Rendering/prePassRenderer";
  75032. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75033. export * from "babylonjs/Rendering/outlineRenderer";
  75034. export * from "babylonjs/Rendering/renderingGroup";
  75035. export * from "babylonjs/Rendering/renderingManager";
  75036. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75037. }
  75038. declare module "babylonjs/Sprites/ISprites" {
  75039. /**
  75040. * Defines the basic options interface of a Sprite Frame Source Size.
  75041. */
  75042. export interface ISpriteJSONSpriteSourceSize {
  75043. /**
  75044. * number of the original width of the Frame
  75045. */
  75046. w: number;
  75047. /**
  75048. * number of the original height of the Frame
  75049. */
  75050. h: number;
  75051. }
  75052. /**
  75053. * Defines the basic options interface of a Sprite Frame Data.
  75054. */
  75055. export interface ISpriteJSONSpriteFrameData {
  75056. /**
  75057. * number of the x offset of the Frame
  75058. */
  75059. x: number;
  75060. /**
  75061. * number of the y offset of the Frame
  75062. */
  75063. y: number;
  75064. /**
  75065. * number of the width of the Frame
  75066. */
  75067. w: number;
  75068. /**
  75069. * number of the height of the Frame
  75070. */
  75071. h: number;
  75072. }
  75073. /**
  75074. * Defines the basic options interface of a JSON Sprite.
  75075. */
  75076. export interface ISpriteJSONSprite {
  75077. /**
  75078. * string name of the Frame
  75079. */
  75080. filename: string;
  75081. /**
  75082. * ISpriteJSONSpriteFrame basic object of the frame data
  75083. */
  75084. frame: ISpriteJSONSpriteFrameData;
  75085. /**
  75086. * boolean to flag is the frame was rotated.
  75087. */
  75088. rotated: boolean;
  75089. /**
  75090. * boolean to flag is the frame was trimmed.
  75091. */
  75092. trimmed: boolean;
  75093. /**
  75094. * ISpriteJSONSpriteFrame basic object of the source data
  75095. */
  75096. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75097. /**
  75098. * ISpriteJSONSpriteFrame basic object of the source data
  75099. */
  75100. sourceSize: ISpriteJSONSpriteSourceSize;
  75101. }
  75102. /**
  75103. * Defines the basic options interface of a JSON atlas.
  75104. */
  75105. export interface ISpriteJSONAtlas {
  75106. /**
  75107. * Array of objects that contain the frame data.
  75108. */
  75109. frames: Array<ISpriteJSONSprite>;
  75110. /**
  75111. * object basic object containing the sprite meta data.
  75112. */
  75113. meta?: object;
  75114. }
  75115. }
  75116. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75117. /** @hidden */
  75118. export var spriteMapPixelShader: {
  75119. name: string;
  75120. shader: string;
  75121. };
  75122. }
  75123. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75124. /** @hidden */
  75125. export var spriteMapVertexShader: {
  75126. name: string;
  75127. shader: string;
  75128. };
  75129. }
  75130. declare module "babylonjs/Sprites/spriteMap" {
  75131. import { IDisposable, Scene } from "babylonjs/scene";
  75132. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75133. import { Texture } from "babylonjs/Materials/Textures/texture";
  75134. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75135. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75136. import "babylonjs/Meshes/Builders/planeBuilder";
  75137. import "babylonjs/Shaders/spriteMap.fragment";
  75138. import "babylonjs/Shaders/spriteMap.vertex";
  75139. /**
  75140. * Defines the basic options interface of a SpriteMap
  75141. */
  75142. export interface ISpriteMapOptions {
  75143. /**
  75144. * Vector2 of the number of cells in the grid.
  75145. */
  75146. stageSize?: Vector2;
  75147. /**
  75148. * Vector2 of the size of the output plane in World Units.
  75149. */
  75150. outputSize?: Vector2;
  75151. /**
  75152. * Vector3 of the position of the output plane in World Units.
  75153. */
  75154. outputPosition?: Vector3;
  75155. /**
  75156. * Vector3 of the rotation of the output plane.
  75157. */
  75158. outputRotation?: Vector3;
  75159. /**
  75160. * number of layers that the system will reserve in resources.
  75161. */
  75162. layerCount?: number;
  75163. /**
  75164. * number of max animation frames a single cell will reserve in resources.
  75165. */
  75166. maxAnimationFrames?: number;
  75167. /**
  75168. * number cell index of the base tile when the system compiles.
  75169. */
  75170. baseTile?: number;
  75171. /**
  75172. * boolean flip the sprite after its been repositioned by the framing data.
  75173. */
  75174. flipU?: boolean;
  75175. /**
  75176. * Vector3 scalar of the global RGB values of the SpriteMap.
  75177. */
  75178. colorMultiply?: Vector3;
  75179. }
  75180. /**
  75181. * Defines the IDisposable interface in order to be cleanable from resources.
  75182. */
  75183. export interface ISpriteMap extends IDisposable {
  75184. /**
  75185. * String name of the SpriteMap.
  75186. */
  75187. name: string;
  75188. /**
  75189. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75190. */
  75191. atlasJSON: ISpriteJSONAtlas;
  75192. /**
  75193. * Texture of the SpriteMap.
  75194. */
  75195. spriteSheet: Texture;
  75196. /**
  75197. * The parameters to initialize the SpriteMap with.
  75198. */
  75199. options: ISpriteMapOptions;
  75200. }
  75201. /**
  75202. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75203. */
  75204. export class SpriteMap implements ISpriteMap {
  75205. /** The Name of the spriteMap */
  75206. name: string;
  75207. /** The JSON file with the frame and meta data */
  75208. atlasJSON: ISpriteJSONAtlas;
  75209. /** The systems Sprite Sheet Texture */
  75210. spriteSheet: Texture;
  75211. /** Arguments passed with the Constructor */
  75212. options: ISpriteMapOptions;
  75213. /** Public Sprite Storage array, parsed from atlasJSON */
  75214. sprites: Array<ISpriteJSONSprite>;
  75215. /** Returns the Number of Sprites in the System */
  75216. get spriteCount(): number;
  75217. /** Returns the Position of Output Plane*/
  75218. get position(): Vector3;
  75219. /** Returns the Position of Output Plane*/
  75220. set position(v: Vector3);
  75221. /** Returns the Rotation of Output Plane*/
  75222. get rotation(): Vector3;
  75223. /** Returns the Rotation of Output Plane*/
  75224. set rotation(v: Vector3);
  75225. /** Sets the AnimationMap*/
  75226. get animationMap(): RawTexture;
  75227. /** Sets the AnimationMap*/
  75228. set animationMap(v: RawTexture);
  75229. /** Scene that the SpriteMap was created in */
  75230. private _scene;
  75231. /** Texture Buffer of Float32 that holds tile frame data*/
  75232. private _frameMap;
  75233. /** Texture Buffers of Float32 that holds tileMap data*/
  75234. private _tileMaps;
  75235. /** Texture Buffer of Float32 that holds Animation Data*/
  75236. private _animationMap;
  75237. /** Custom ShaderMaterial Central to the System*/
  75238. private _material;
  75239. /** Custom ShaderMaterial Central to the System*/
  75240. private _output;
  75241. /** Systems Time Ticker*/
  75242. private _time;
  75243. /**
  75244. * Creates a new SpriteMap
  75245. * @param name defines the SpriteMaps Name
  75246. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75247. * @param spriteSheet is the Texture that the Sprites are on.
  75248. * @param options a basic deployment configuration
  75249. * @param scene The Scene that the map is deployed on
  75250. */
  75251. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75252. /**
  75253. * Returns tileID location
  75254. * @returns Vector2 the cell position ID
  75255. */
  75256. getTileID(): Vector2;
  75257. /**
  75258. * Gets the UV location of the mouse over the SpriteMap.
  75259. * @returns Vector2 the UV position of the mouse interaction
  75260. */
  75261. getMousePosition(): Vector2;
  75262. /**
  75263. * Creates the "frame" texture Buffer
  75264. * -------------------------------------
  75265. * Structure of frames
  75266. * "filename": "Falling-Water-2.png",
  75267. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75268. * "rotated": true,
  75269. * "trimmed": true,
  75270. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75271. * "sourceSize": {"w":32,"h":32}
  75272. * @returns RawTexture of the frameMap
  75273. */
  75274. private _createFrameBuffer;
  75275. /**
  75276. * Creates the tileMap texture Buffer
  75277. * @param buffer normally and array of numbers, or a false to generate from scratch
  75278. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75279. * @returns RawTexture of the tileMap
  75280. */
  75281. private _createTileBuffer;
  75282. /**
  75283. * Modifies the data of the tileMaps
  75284. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75285. * @param pos is the iVector2 Coordinates of the Tile
  75286. * @param tile The SpriteIndex of the new Tile
  75287. */
  75288. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75289. /**
  75290. * Creates the animationMap texture Buffer
  75291. * @param buffer normally and array of numbers, or a false to generate from scratch
  75292. * @returns RawTexture of the animationMap
  75293. */
  75294. private _createTileAnimationBuffer;
  75295. /**
  75296. * Modifies the data of the animationMap
  75297. * @param cellID is the Index of the Sprite
  75298. * @param _frame is the target Animation frame
  75299. * @param toCell is the Target Index of the next frame of the animation
  75300. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75301. * @param speed is a global scalar of the time variable on the map.
  75302. */
  75303. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  75304. /**
  75305. * Exports the .tilemaps file
  75306. */
  75307. saveTileMaps(): void;
  75308. /**
  75309. * Imports the .tilemaps file
  75310. * @param url of the .tilemaps file
  75311. */
  75312. loadTileMaps(url: string): void;
  75313. /**
  75314. * Release associated resources
  75315. */
  75316. dispose(): void;
  75317. }
  75318. }
  75319. declare module "babylonjs/Sprites/spritePackedManager" {
  75320. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  75321. import { Scene } from "babylonjs/scene";
  75322. /**
  75323. * Class used to manage multiple sprites of different sizes on the same spritesheet
  75324. * @see https://doc.babylonjs.com/babylon101/sprites
  75325. */
  75326. export class SpritePackedManager extends SpriteManager {
  75327. /** defines the packed manager's name */
  75328. name: string;
  75329. /**
  75330. * Creates a new sprite manager from a packed sprite sheet
  75331. * @param name defines the manager's name
  75332. * @param imgUrl defines the sprite sheet url
  75333. * @param capacity defines the maximum allowed number of sprites
  75334. * @param scene defines the hosting scene
  75335. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  75336. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75337. * @param samplingMode defines the smapling mode to use with spritesheet
  75338. * @param fromPacked set to true; do not alter
  75339. */
  75340. constructor(
  75341. /** defines the packed manager's name */
  75342. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  75343. }
  75344. }
  75345. declare module "babylonjs/Sprites/index" {
  75346. export * from "babylonjs/Sprites/sprite";
  75347. export * from "babylonjs/Sprites/ISprites";
  75348. export * from "babylonjs/Sprites/spriteManager";
  75349. export * from "babylonjs/Sprites/spriteMap";
  75350. export * from "babylonjs/Sprites/spritePackedManager";
  75351. export * from "babylonjs/Sprites/spriteSceneComponent";
  75352. }
  75353. declare module "babylonjs/States/index" {
  75354. export * from "babylonjs/States/alphaCullingState";
  75355. export * from "babylonjs/States/depthCullingState";
  75356. export * from "babylonjs/States/stencilState";
  75357. }
  75358. declare module "babylonjs/Misc/assetsManager" {
  75359. import { Scene } from "babylonjs/scene";
  75360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75361. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75362. import { Skeleton } from "babylonjs/Bones/skeleton";
  75363. import { Observable } from "babylonjs/Misc/observable";
  75364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  75365. import { Texture } from "babylonjs/Materials/Textures/texture";
  75366. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  75367. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  75368. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  75369. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  75370. /**
  75371. * Defines the list of states available for a task inside a AssetsManager
  75372. */
  75373. export enum AssetTaskState {
  75374. /**
  75375. * Initialization
  75376. */
  75377. INIT = 0,
  75378. /**
  75379. * Running
  75380. */
  75381. RUNNING = 1,
  75382. /**
  75383. * Done
  75384. */
  75385. DONE = 2,
  75386. /**
  75387. * Error
  75388. */
  75389. ERROR = 3
  75390. }
  75391. /**
  75392. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  75393. */
  75394. export abstract class AbstractAssetTask {
  75395. /**
  75396. * Task name
  75397. */ name: string;
  75398. /**
  75399. * Callback called when the task is successful
  75400. */
  75401. onSuccess: (task: any) => void;
  75402. /**
  75403. * Callback called when the task is not successful
  75404. */
  75405. onError: (task: any, message?: string, exception?: any) => void;
  75406. /**
  75407. * Creates a new AssetsManager
  75408. * @param name defines the name of the task
  75409. */
  75410. constructor(
  75411. /**
  75412. * Task name
  75413. */ name: string);
  75414. private _isCompleted;
  75415. private _taskState;
  75416. private _errorObject;
  75417. /**
  75418. * Get if the task is completed
  75419. */
  75420. get isCompleted(): boolean;
  75421. /**
  75422. * Gets the current state of the task
  75423. */
  75424. get taskState(): AssetTaskState;
  75425. /**
  75426. * Gets the current error object (if task is in error)
  75427. */
  75428. get errorObject(): {
  75429. message?: string;
  75430. exception?: any;
  75431. };
  75432. /**
  75433. * Internal only
  75434. * @hidden
  75435. */
  75436. _setErrorObject(message?: string, exception?: any): void;
  75437. /**
  75438. * Execute the current task
  75439. * @param scene defines the scene where you want your assets to be loaded
  75440. * @param onSuccess is a callback called when the task is successfully executed
  75441. * @param onError is a callback called if an error occurs
  75442. */
  75443. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75444. /**
  75445. * Execute the current task
  75446. * @param scene defines the scene where you want your assets to be loaded
  75447. * @param onSuccess is a callback called when the task is successfully executed
  75448. * @param onError is a callback called if an error occurs
  75449. */
  75450. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75451. /**
  75452. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  75453. * This can be used with failed tasks that have the reason for failure fixed.
  75454. */
  75455. reset(): void;
  75456. private onErrorCallback;
  75457. private onDoneCallback;
  75458. }
  75459. /**
  75460. * Define the interface used by progress events raised during assets loading
  75461. */
  75462. export interface IAssetsProgressEvent {
  75463. /**
  75464. * Defines the number of remaining tasks to process
  75465. */
  75466. remainingCount: number;
  75467. /**
  75468. * Defines the total number of tasks
  75469. */
  75470. totalCount: number;
  75471. /**
  75472. * Defines the task that was just processed
  75473. */
  75474. task: AbstractAssetTask;
  75475. }
  75476. /**
  75477. * Class used to share progress information about assets loading
  75478. */
  75479. export class AssetsProgressEvent implements IAssetsProgressEvent {
  75480. /**
  75481. * Defines the number of remaining tasks to process
  75482. */
  75483. remainingCount: number;
  75484. /**
  75485. * Defines the total number of tasks
  75486. */
  75487. totalCount: number;
  75488. /**
  75489. * Defines the task that was just processed
  75490. */
  75491. task: AbstractAssetTask;
  75492. /**
  75493. * Creates a AssetsProgressEvent
  75494. * @param remainingCount defines the number of remaining tasks to process
  75495. * @param totalCount defines the total number of tasks
  75496. * @param task defines the task that was just processed
  75497. */
  75498. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  75499. }
  75500. /**
  75501. * Define a task used by AssetsManager to load meshes
  75502. */
  75503. export class MeshAssetTask extends AbstractAssetTask {
  75504. /**
  75505. * Defines the name of the task
  75506. */
  75507. name: string;
  75508. /**
  75509. * Defines the list of mesh's names you want to load
  75510. */
  75511. meshesNames: any;
  75512. /**
  75513. * Defines the root url to use as a base to load your meshes and associated resources
  75514. */
  75515. rootUrl: string;
  75516. /**
  75517. * Defines the filename or File of the scene to load from
  75518. */
  75519. sceneFilename: string | File;
  75520. /**
  75521. * Gets the list of loaded meshes
  75522. */
  75523. loadedMeshes: Array<AbstractMesh>;
  75524. /**
  75525. * Gets the list of loaded particle systems
  75526. */
  75527. loadedParticleSystems: Array<IParticleSystem>;
  75528. /**
  75529. * Gets the list of loaded skeletons
  75530. */
  75531. loadedSkeletons: Array<Skeleton>;
  75532. /**
  75533. * Gets the list of loaded animation groups
  75534. */
  75535. loadedAnimationGroups: Array<AnimationGroup>;
  75536. /**
  75537. * Callback called when the task is successful
  75538. */
  75539. onSuccess: (task: MeshAssetTask) => void;
  75540. /**
  75541. * Callback called when the task is successful
  75542. */
  75543. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  75544. /**
  75545. * Creates a new MeshAssetTask
  75546. * @param name defines the name of the task
  75547. * @param meshesNames defines the list of mesh's names you want to load
  75548. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  75549. * @param sceneFilename defines the filename or File of the scene to load from
  75550. */
  75551. constructor(
  75552. /**
  75553. * Defines the name of the task
  75554. */
  75555. name: string,
  75556. /**
  75557. * Defines the list of mesh's names you want to load
  75558. */
  75559. meshesNames: any,
  75560. /**
  75561. * Defines the root url to use as a base to load your meshes and associated resources
  75562. */
  75563. rootUrl: string,
  75564. /**
  75565. * Defines the filename or File of the scene to load from
  75566. */
  75567. sceneFilename: string | File);
  75568. /**
  75569. * Execute the current task
  75570. * @param scene defines the scene where you want your assets to be loaded
  75571. * @param onSuccess is a callback called when the task is successfully executed
  75572. * @param onError is a callback called if an error occurs
  75573. */
  75574. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75575. }
  75576. /**
  75577. * Define a task used by AssetsManager to load text content
  75578. */
  75579. export class TextFileAssetTask extends AbstractAssetTask {
  75580. /**
  75581. * Defines the name of the task
  75582. */
  75583. name: string;
  75584. /**
  75585. * Defines the location of the file to load
  75586. */
  75587. url: string;
  75588. /**
  75589. * Gets the loaded text string
  75590. */
  75591. text: string;
  75592. /**
  75593. * Callback called when the task is successful
  75594. */
  75595. onSuccess: (task: TextFileAssetTask) => void;
  75596. /**
  75597. * Callback called when the task is successful
  75598. */
  75599. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  75600. /**
  75601. * Creates a new TextFileAssetTask object
  75602. * @param name defines the name of the task
  75603. * @param url defines the location of the file to load
  75604. */
  75605. constructor(
  75606. /**
  75607. * Defines the name of the task
  75608. */
  75609. name: string,
  75610. /**
  75611. * Defines the location of the file to load
  75612. */
  75613. url: string);
  75614. /**
  75615. * Execute the current task
  75616. * @param scene defines the scene where you want your assets to be loaded
  75617. * @param onSuccess is a callback called when the task is successfully executed
  75618. * @param onError is a callback called if an error occurs
  75619. */
  75620. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75621. }
  75622. /**
  75623. * Define a task used by AssetsManager to load binary data
  75624. */
  75625. export class BinaryFileAssetTask extends AbstractAssetTask {
  75626. /**
  75627. * Defines the name of the task
  75628. */
  75629. name: string;
  75630. /**
  75631. * Defines the location of the file to load
  75632. */
  75633. url: string;
  75634. /**
  75635. * Gets the lodaded data (as an array buffer)
  75636. */
  75637. data: ArrayBuffer;
  75638. /**
  75639. * Callback called when the task is successful
  75640. */
  75641. onSuccess: (task: BinaryFileAssetTask) => void;
  75642. /**
  75643. * Callback called when the task is successful
  75644. */
  75645. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  75646. /**
  75647. * Creates a new BinaryFileAssetTask object
  75648. * @param name defines the name of the new task
  75649. * @param url defines the location of the file to load
  75650. */
  75651. constructor(
  75652. /**
  75653. * Defines the name of the task
  75654. */
  75655. name: string,
  75656. /**
  75657. * Defines the location of the file to load
  75658. */
  75659. url: string);
  75660. /**
  75661. * Execute the current task
  75662. * @param scene defines the scene where you want your assets to be loaded
  75663. * @param onSuccess is a callback called when the task is successfully executed
  75664. * @param onError is a callback called if an error occurs
  75665. */
  75666. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75667. }
  75668. /**
  75669. * Define a task used by AssetsManager to load images
  75670. */
  75671. export class ImageAssetTask extends AbstractAssetTask {
  75672. /**
  75673. * Defines the name of the task
  75674. */
  75675. name: string;
  75676. /**
  75677. * Defines the location of the image to load
  75678. */
  75679. url: string;
  75680. /**
  75681. * Gets the loaded images
  75682. */
  75683. image: HTMLImageElement;
  75684. /**
  75685. * Callback called when the task is successful
  75686. */
  75687. onSuccess: (task: ImageAssetTask) => void;
  75688. /**
  75689. * Callback called when the task is successful
  75690. */
  75691. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  75692. /**
  75693. * Creates a new ImageAssetTask
  75694. * @param name defines the name of the task
  75695. * @param url defines the location of the image to load
  75696. */
  75697. constructor(
  75698. /**
  75699. * Defines the name of the task
  75700. */
  75701. name: string,
  75702. /**
  75703. * Defines the location of the image to load
  75704. */
  75705. url: string);
  75706. /**
  75707. * Execute the current task
  75708. * @param scene defines the scene where you want your assets to be loaded
  75709. * @param onSuccess is a callback called when the task is successfully executed
  75710. * @param onError is a callback called if an error occurs
  75711. */
  75712. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75713. }
  75714. /**
  75715. * Defines the interface used by texture loading tasks
  75716. */
  75717. export interface ITextureAssetTask<TEX extends BaseTexture> {
  75718. /**
  75719. * Gets the loaded texture
  75720. */
  75721. texture: TEX;
  75722. }
  75723. /**
  75724. * Define a task used by AssetsManager to load 2D textures
  75725. */
  75726. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  75727. /**
  75728. * Defines the name of the task
  75729. */
  75730. name: string;
  75731. /**
  75732. * Defines the location of the file to load
  75733. */
  75734. url: string;
  75735. /**
  75736. * Defines if mipmap should not be generated (default is false)
  75737. */
  75738. noMipmap?: boolean | undefined;
  75739. /**
  75740. * Defines if texture must be inverted on Y axis (default is true)
  75741. */
  75742. invertY: boolean;
  75743. /**
  75744. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75745. */
  75746. samplingMode: number;
  75747. /**
  75748. * Gets the loaded texture
  75749. */
  75750. texture: Texture;
  75751. /**
  75752. * Callback called when the task is successful
  75753. */
  75754. onSuccess: (task: TextureAssetTask) => void;
  75755. /**
  75756. * Callback called when the task is successful
  75757. */
  75758. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  75759. /**
  75760. * Creates a new TextureAssetTask object
  75761. * @param name defines the name of the task
  75762. * @param url defines the location of the file to load
  75763. * @param noMipmap defines if mipmap should not be generated (default is false)
  75764. * @param invertY defines if texture must be inverted on Y axis (default is true)
  75765. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75766. */
  75767. constructor(
  75768. /**
  75769. * Defines the name of the task
  75770. */
  75771. name: string,
  75772. /**
  75773. * Defines the location of the file to load
  75774. */
  75775. url: string,
  75776. /**
  75777. * Defines if mipmap should not be generated (default is false)
  75778. */
  75779. noMipmap?: boolean | undefined,
  75780. /**
  75781. * Defines if texture must be inverted on Y axis (default is true)
  75782. */
  75783. invertY?: boolean,
  75784. /**
  75785. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75786. */
  75787. samplingMode?: number);
  75788. /**
  75789. * Execute the current task
  75790. * @param scene defines the scene where you want your assets to be loaded
  75791. * @param onSuccess is a callback called when the task is successfully executed
  75792. * @param onError is a callback called if an error occurs
  75793. */
  75794. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75795. }
  75796. /**
  75797. * Define a task used by AssetsManager to load cube textures
  75798. */
  75799. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  75800. /**
  75801. * Defines the name of the task
  75802. */
  75803. name: string;
  75804. /**
  75805. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75806. */
  75807. url: string;
  75808. /**
  75809. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75810. */
  75811. extensions?: string[] | undefined;
  75812. /**
  75813. * Defines if mipmaps should not be generated (default is false)
  75814. */
  75815. noMipmap?: boolean | undefined;
  75816. /**
  75817. * Defines the explicit list of files (undefined by default)
  75818. */
  75819. files?: string[] | undefined;
  75820. /**
  75821. * Gets the loaded texture
  75822. */
  75823. texture: CubeTexture;
  75824. /**
  75825. * Callback called when the task is successful
  75826. */
  75827. onSuccess: (task: CubeTextureAssetTask) => void;
  75828. /**
  75829. * Callback called when the task is successful
  75830. */
  75831. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  75832. /**
  75833. * Creates a new CubeTextureAssetTask
  75834. * @param name defines the name of the task
  75835. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75836. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75837. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75838. * @param files defines the explicit list of files (undefined by default)
  75839. */
  75840. constructor(
  75841. /**
  75842. * Defines the name of the task
  75843. */
  75844. name: string,
  75845. /**
  75846. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75847. */
  75848. url: string,
  75849. /**
  75850. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75851. */
  75852. extensions?: string[] | undefined,
  75853. /**
  75854. * Defines if mipmaps should not be generated (default is false)
  75855. */
  75856. noMipmap?: boolean | undefined,
  75857. /**
  75858. * Defines the explicit list of files (undefined by default)
  75859. */
  75860. files?: string[] | undefined);
  75861. /**
  75862. * Execute the current task
  75863. * @param scene defines the scene where you want your assets to be loaded
  75864. * @param onSuccess is a callback called when the task is successfully executed
  75865. * @param onError is a callback called if an error occurs
  75866. */
  75867. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75868. }
  75869. /**
  75870. * Define a task used by AssetsManager to load HDR cube textures
  75871. */
  75872. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  75873. /**
  75874. * Defines the name of the task
  75875. */
  75876. name: string;
  75877. /**
  75878. * Defines the location of the file to load
  75879. */
  75880. url: string;
  75881. /**
  75882. * Defines the desired size (the more it increases the longer the generation will be)
  75883. */
  75884. size: number;
  75885. /**
  75886. * Defines if mipmaps should not be generated (default is false)
  75887. */
  75888. noMipmap: boolean;
  75889. /**
  75890. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75891. */
  75892. generateHarmonics: boolean;
  75893. /**
  75894. * 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)
  75895. */
  75896. gammaSpace: boolean;
  75897. /**
  75898. * Internal Use Only
  75899. */
  75900. reserved: boolean;
  75901. /**
  75902. * Gets the loaded texture
  75903. */
  75904. texture: HDRCubeTexture;
  75905. /**
  75906. * Callback called when the task is successful
  75907. */
  75908. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  75909. /**
  75910. * Callback called when the task is successful
  75911. */
  75912. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  75913. /**
  75914. * Creates a new HDRCubeTextureAssetTask object
  75915. * @param name defines the name of the task
  75916. * @param url defines the location of the file to load
  75917. * @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.
  75918. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75919. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75920. * @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)
  75921. * @param reserved Internal use only
  75922. */
  75923. constructor(
  75924. /**
  75925. * Defines the name of the task
  75926. */
  75927. name: string,
  75928. /**
  75929. * Defines the location of the file to load
  75930. */
  75931. url: string,
  75932. /**
  75933. * Defines the desired size (the more it increases the longer the generation will be)
  75934. */
  75935. size: number,
  75936. /**
  75937. * Defines if mipmaps should not be generated (default is false)
  75938. */
  75939. noMipmap?: boolean,
  75940. /**
  75941. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75942. */
  75943. generateHarmonics?: boolean,
  75944. /**
  75945. * 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)
  75946. */
  75947. gammaSpace?: boolean,
  75948. /**
  75949. * Internal Use Only
  75950. */
  75951. reserved?: boolean);
  75952. /**
  75953. * Execute the current task
  75954. * @param scene defines the scene where you want your assets to be loaded
  75955. * @param onSuccess is a callback called when the task is successfully executed
  75956. * @param onError is a callback called if an error occurs
  75957. */
  75958. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75959. }
  75960. /**
  75961. * Define a task used by AssetsManager to load Equirectangular cube textures
  75962. */
  75963. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  75964. /**
  75965. * Defines the name of the task
  75966. */
  75967. name: string;
  75968. /**
  75969. * Defines the location of the file to load
  75970. */
  75971. url: string;
  75972. /**
  75973. * Defines the desired size (the more it increases the longer the generation will be)
  75974. */
  75975. size: number;
  75976. /**
  75977. * Defines if mipmaps should not be generated (default is false)
  75978. */
  75979. noMipmap: boolean;
  75980. /**
  75981. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75982. * but the standard material would require them in Gamma space) (default is true)
  75983. */
  75984. gammaSpace: boolean;
  75985. /**
  75986. * Gets the loaded texture
  75987. */
  75988. texture: EquiRectangularCubeTexture;
  75989. /**
  75990. * Callback called when the task is successful
  75991. */
  75992. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  75993. /**
  75994. * Callback called when the task is successful
  75995. */
  75996. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  75997. /**
  75998. * Creates a new EquiRectangularCubeTextureAssetTask object
  75999. * @param name defines the name of the task
  76000. * @param url defines the location of the file to load
  76001. * @param size defines the desired size (the more it increases the longer the generation will be)
  76002. * If the size is omitted this implies you are using a preprocessed cubemap.
  76003. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76004. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76005. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76006. * (default is true)
  76007. */
  76008. constructor(
  76009. /**
  76010. * Defines the name of the task
  76011. */
  76012. name: string,
  76013. /**
  76014. * Defines the location of the file to load
  76015. */
  76016. url: string,
  76017. /**
  76018. * Defines the desired size (the more it increases the longer the generation will be)
  76019. */
  76020. size: number,
  76021. /**
  76022. * Defines if mipmaps should not be generated (default is false)
  76023. */
  76024. noMipmap?: boolean,
  76025. /**
  76026. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76027. * but the standard material would require them in Gamma space) (default is true)
  76028. */
  76029. gammaSpace?: boolean);
  76030. /**
  76031. * Execute the current task
  76032. * @param scene defines the scene where you want your assets to be loaded
  76033. * @param onSuccess is a callback called when the task is successfully executed
  76034. * @param onError is a callback called if an error occurs
  76035. */
  76036. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76037. }
  76038. /**
  76039. * This class can be used to easily import assets into a scene
  76040. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76041. */
  76042. export class AssetsManager {
  76043. private _scene;
  76044. private _isLoading;
  76045. protected _tasks: AbstractAssetTask[];
  76046. protected _waitingTasksCount: number;
  76047. protected _totalTasksCount: number;
  76048. /**
  76049. * Callback called when all tasks are processed
  76050. */
  76051. onFinish: (tasks: AbstractAssetTask[]) => void;
  76052. /**
  76053. * Callback called when a task is successful
  76054. */
  76055. onTaskSuccess: (task: AbstractAssetTask) => void;
  76056. /**
  76057. * Callback called when a task had an error
  76058. */
  76059. onTaskError: (task: AbstractAssetTask) => void;
  76060. /**
  76061. * Callback called when a task is done (whatever the result is)
  76062. */
  76063. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76064. /**
  76065. * Observable called when all tasks are processed
  76066. */
  76067. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76068. /**
  76069. * Observable called when a task had an error
  76070. */
  76071. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76072. /**
  76073. * Observable called when all tasks were executed
  76074. */
  76075. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76076. /**
  76077. * Observable called when a task is done (whatever the result is)
  76078. */
  76079. onProgressObservable: Observable<IAssetsProgressEvent>;
  76080. /**
  76081. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76082. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76083. */
  76084. useDefaultLoadingScreen: boolean;
  76085. /**
  76086. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76087. * when all assets have been downloaded.
  76088. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76089. */
  76090. autoHideLoadingUI: boolean;
  76091. /**
  76092. * Creates a new AssetsManager
  76093. * @param scene defines the scene to work on
  76094. */
  76095. constructor(scene: Scene);
  76096. /**
  76097. * Add a MeshAssetTask to the list of active tasks
  76098. * @param taskName defines the name of the new task
  76099. * @param meshesNames defines the name of meshes to load
  76100. * @param rootUrl defines the root url to use to locate files
  76101. * @param sceneFilename defines the filename of the scene file
  76102. * @returns a new MeshAssetTask object
  76103. */
  76104. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76105. /**
  76106. * Add a TextFileAssetTask to the list of active tasks
  76107. * @param taskName defines the name of the new task
  76108. * @param url defines the url of the file to load
  76109. * @returns a new TextFileAssetTask object
  76110. */
  76111. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76112. /**
  76113. * Add a BinaryFileAssetTask to the list of active tasks
  76114. * @param taskName defines the name of the new task
  76115. * @param url defines the url of the file to load
  76116. * @returns a new BinaryFileAssetTask object
  76117. */
  76118. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76119. /**
  76120. * Add a ImageAssetTask to the list of active tasks
  76121. * @param taskName defines the name of the new task
  76122. * @param url defines the url of the file to load
  76123. * @returns a new ImageAssetTask object
  76124. */
  76125. addImageTask(taskName: string, url: string): ImageAssetTask;
  76126. /**
  76127. * Add a TextureAssetTask to the list of active tasks
  76128. * @param taskName defines the name of the new task
  76129. * @param url defines the url of the file to load
  76130. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76131. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76132. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76133. * @returns a new TextureAssetTask object
  76134. */
  76135. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76136. /**
  76137. * Add a CubeTextureAssetTask to the list of active tasks
  76138. * @param taskName defines the name of the new task
  76139. * @param url defines the url of the file to load
  76140. * @param extensions defines the extension to use to load the cube map (can be null)
  76141. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76142. * @param files defines the list of files to load (can be null)
  76143. * @returns a new CubeTextureAssetTask object
  76144. */
  76145. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76146. /**
  76147. *
  76148. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76149. * @param taskName defines the name of the new task
  76150. * @param url defines the url of the file to load
  76151. * @param size defines the size you want for the cubemap (can be null)
  76152. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76153. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76154. * @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)
  76155. * @param reserved Internal use only
  76156. * @returns a new HDRCubeTextureAssetTask object
  76157. */
  76158. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76159. /**
  76160. *
  76161. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76162. * @param taskName defines the name of the new task
  76163. * @param url defines the url of the file to load
  76164. * @param size defines the size you want for the cubemap (can be null)
  76165. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76166. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76167. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76168. * @returns a new EquiRectangularCubeTextureAssetTask object
  76169. */
  76170. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76171. /**
  76172. * Remove a task from the assets manager.
  76173. * @param task the task to remove
  76174. */
  76175. removeTask(task: AbstractAssetTask): void;
  76176. private _decreaseWaitingTasksCount;
  76177. private _runTask;
  76178. /**
  76179. * Reset the AssetsManager and remove all tasks
  76180. * @return the current instance of the AssetsManager
  76181. */
  76182. reset(): AssetsManager;
  76183. /**
  76184. * Start the loading process
  76185. * @return the current instance of the AssetsManager
  76186. */
  76187. load(): AssetsManager;
  76188. /**
  76189. * Start the loading process as an async operation
  76190. * @return a promise returning the list of failed tasks
  76191. */
  76192. loadAsync(): Promise<void>;
  76193. }
  76194. }
  76195. declare module "babylonjs/Misc/deferred" {
  76196. /**
  76197. * Wrapper class for promise with external resolve and reject.
  76198. */
  76199. export class Deferred<T> {
  76200. /**
  76201. * The promise associated with this deferred object.
  76202. */
  76203. readonly promise: Promise<T>;
  76204. private _resolve;
  76205. private _reject;
  76206. /**
  76207. * The resolve method of the promise associated with this deferred object.
  76208. */
  76209. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76210. /**
  76211. * The reject method of the promise associated with this deferred object.
  76212. */
  76213. get reject(): (reason?: any) => void;
  76214. /**
  76215. * Constructor for this deferred object.
  76216. */
  76217. constructor();
  76218. }
  76219. }
  76220. declare module "babylonjs/Misc/meshExploder" {
  76221. import { Mesh } from "babylonjs/Meshes/mesh";
  76222. /**
  76223. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  76224. */
  76225. export class MeshExploder {
  76226. private _centerMesh;
  76227. private _meshes;
  76228. private _meshesOrigins;
  76229. private _toCenterVectors;
  76230. private _scaledDirection;
  76231. private _newPosition;
  76232. private _centerPosition;
  76233. /**
  76234. * Explodes meshes from a center mesh.
  76235. * @param meshes The meshes to explode.
  76236. * @param centerMesh The mesh to be center of explosion.
  76237. */
  76238. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  76239. private _setCenterMesh;
  76240. /**
  76241. * Get class name
  76242. * @returns "MeshExploder"
  76243. */
  76244. getClassName(): string;
  76245. /**
  76246. * "Exploded meshes"
  76247. * @returns Array of meshes with the centerMesh at index 0.
  76248. */
  76249. getMeshes(): Array<Mesh>;
  76250. /**
  76251. * Explodes meshes giving a specific direction
  76252. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  76253. */
  76254. explode(direction?: number): void;
  76255. }
  76256. }
  76257. declare module "babylonjs/Misc/filesInput" {
  76258. import { Engine } from "babylonjs/Engines/engine";
  76259. import { Scene } from "babylonjs/scene";
  76260. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  76261. import { Nullable } from "babylonjs/types";
  76262. /**
  76263. * Class used to help managing file picking and drag'n'drop
  76264. */
  76265. export class FilesInput {
  76266. /**
  76267. * List of files ready to be loaded
  76268. */
  76269. static get FilesToLoad(): {
  76270. [key: string]: File;
  76271. };
  76272. /**
  76273. * Callback called when a file is processed
  76274. */
  76275. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  76276. private _engine;
  76277. private _currentScene;
  76278. private _sceneLoadedCallback;
  76279. private _progressCallback;
  76280. private _additionalRenderLoopLogicCallback;
  76281. private _textureLoadingCallback;
  76282. private _startingProcessingFilesCallback;
  76283. private _onReloadCallback;
  76284. private _errorCallback;
  76285. private _elementToMonitor;
  76286. private _sceneFileToLoad;
  76287. private _filesToLoad;
  76288. /**
  76289. * Creates a new FilesInput
  76290. * @param engine defines the rendering engine
  76291. * @param scene defines the hosting scene
  76292. * @param sceneLoadedCallback callback called when scene is loaded
  76293. * @param progressCallback callback called to track progress
  76294. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  76295. * @param textureLoadingCallback callback called when a texture is loading
  76296. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  76297. * @param onReloadCallback callback called when a reload is requested
  76298. * @param errorCallback callback call if an error occurs
  76299. */
  76300. 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>);
  76301. private _dragEnterHandler;
  76302. private _dragOverHandler;
  76303. private _dropHandler;
  76304. /**
  76305. * Calls this function to listen to drag'n'drop events on a specific DOM element
  76306. * @param elementToMonitor defines the DOM element to track
  76307. */
  76308. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  76309. /** Gets the current list of files to load */
  76310. get filesToLoad(): File[];
  76311. /**
  76312. * Release all associated resources
  76313. */
  76314. dispose(): void;
  76315. private renderFunction;
  76316. private drag;
  76317. private drop;
  76318. private _traverseFolder;
  76319. private _processFiles;
  76320. /**
  76321. * Load files from a drop event
  76322. * @param event defines the drop event to use as source
  76323. */
  76324. loadFiles(event: any): void;
  76325. private _processReload;
  76326. /**
  76327. * Reload the current scene from the loaded files
  76328. */
  76329. reload(): void;
  76330. }
  76331. }
  76332. declare module "babylonjs/Misc/HighDynamicRange/index" {
  76333. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  76334. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  76335. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  76336. }
  76337. declare module "babylonjs/Misc/sceneOptimizer" {
  76338. import { Scene, IDisposable } from "babylonjs/scene";
  76339. import { Observable } from "babylonjs/Misc/observable";
  76340. /**
  76341. * Defines the root class used to create scene optimization to use with SceneOptimizer
  76342. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76343. */
  76344. export class SceneOptimization {
  76345. /**
  76346. * Defines the priority of this optimization (0 by default which means first in the list)
  76347. */
  76348. priority: number;
  76349. /**
  76350. * Gets a string describing the action executed by the current optimization
  76351. * @returns description string
  76352. */
  76353. getDescription(): string;
  76354. /**
  76355. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76356. * @param scene defines the current scene where to apply this optimization
  76357. * @param optimizer defines the current optimizer
  76358. * @returns true if everything that can be done was applied
  76359. */
  76360. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76361. /**
  76362. * Creates the SceneOptimization object
  76363. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76364. * @param desc defines the description associated with the optimization
  76365. */
  76366. constructor(
  76367. /**
  76368. * Defines the priority of this optimization (0 by default which means first in the list)
  76369. */
  76370. priority?: number);
  76371. }
  76372. /**
  76373. * Defines an optimization used to reduce the size of render target textures
  76374. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76375. */
  76376. export class TextureOptimization extends SceneOptimization {
  76377. /**
  76378. * Defines the priority of this optimization (0 by default which means first in the list)
  76379. */
  76380. priority: number;
  76381. /**
  76382. * 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
  76383. */
  76384. maximumSize: number;
  76385. /**
  76386. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76387. */
  76388. step: number;
  76389. /**
  76390. * Gets a string describing the action executed by the current optimization
  76391. * @returns description string
  76392. */
  76393. getDescription(): string;
  76394. /**
  76395. * Creates the TextureOptimization object
  76396. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76397. * @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
  76398. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76399. */
  76400. constructor(
  76401. /**
  76402. * Defines the priority of this optimization (0 by default which means first in the list)
  76403. */
  76404. priority?: number,
  76405. /**
  76406. * 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
  76407. */
  76408. maximumSize?: number,
  76409. /**
  76410. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76411. */
  76412. step?: number);
  76413. /**
  76414. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76415. * @param scene defines the current scene where to apply this optimization
  76416. * @param optimizer defines the current optimizer
  76417. * @returns true if everything that can be done was applied
  76418. */
  76419. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76420. }
  76421. /**
  76422. * Defines an optimization used to increase or decrease the rendering resolution
  76423. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76424. */
  76425. export class HardwareScalingOptimization extends SceneOptimization {
  76426. /**
  76427. * Defines the priority of this optimization (0 by default which means first in the list)
  76428. */
  76429. priority: number;
  76430. /**
  76431. * Defines the maximum scale to use (2 by default)
  76432. */
  76433. maximumScale: number;
  76434. /**
  76435. * Defines the step to use between two passes (0.5 by default)
  76436. */
  76437. step: number;
  76438. private _currentScale;
  76439. private _directionOffset;
  76440. /**
  76441. * Gets a string describing the action executed by the current optimization
  76442. * @return description string
  76443. */
  76444. getDescription(): string;
  76445. /**
  76446. * Creates the HardwareScalingOptimization object
  76447. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76448. * @param maximumScale defines the maximum scale to use (2 by default)
  76449. * @param step defines the step to use between two passes (0.5 by default)
  76450. */
  76451. constructor(
  76452. /**
  76453. * Defines the priority of this optimization (0 by default which means first in the list)
  76454. */
  76455. priority?: number,
  76456. /**
  76457. * Defines the maximum scale to use (2 by default)
  76458. */
  76459. maximumScale?: number,
  76460. /**
  76461. * Defines the step to use between two passes (0.5 by default)
  76462. */
  76463. step?: number);
  76464. /**
  76465. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76466. * @param scene defines the current scene where to apply this optimization
  76467. * @param optimizer defines the current optimizer
  76468. * @returns true if everything that can be done was applied
  76469. */
  76470. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76471. }
  76472. /**
  76473. * Defines an optimization used to remove shadows
  76474. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76475. */
  76476. export class ShadowsOptimization extends SceneOptimization {
  76477. /**
  76478. * Gets a string describing the action executed by the current optimization
  76479. * @return description string
  76480. */
  76481. getDescription(): string;
  76482. /**
  76483. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76484. * @param scene defines the current scene where to apply this optimization
  76485. * @param optimizer defines the current optimizer
  76486. * @returns true if everything that can be done was applied
  76487. */
  76488. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76489. }
  76490. /**
  76491. * Defines an optimization used to turn post-processes off
  76492. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76493. */
  76494. export class PostProcessesOptimization extends SceneOptimization {
  76495. /**
  76496. * Gets a string describing the action executed by the current optimization
  76497. * @return description string
  76498. */
  76499. getDescription(): string;
  76500. /**
  76501. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76502. * @param scene defines the current scene where to apply this optimization
  76503. * @param optimizer defines the current optimizer
  76504. * @returns true if everything that can be done was applied
  76505. */
  76506. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76507. }
  76508. /**
  76509. * Defines an optimization used to turn lens flares off
  76510. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76511. */
  76512. export class LensFlaresOptimization extends SceneOptimization {
  76513. /**
  76514. * Gets a string describing the action executed by the current optimization
  76515. * @return description string
  76516. */
  76517. getDescription(): string;
  76518. /**
  76519. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76520. * @param scene defines the current scene where to apply this optimization
  76521. * @param optimizer defines the current optimizer
  76522. * @returns true if everything that can be done was applied
  76523. */
  76524. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76525. }
  76526. /**
  76527. * Defines an optimization based on user defined callback.
  76528. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76529. */
  76530. export class CustomOptimization extends SceneOptimization {
  76531. /**
  76532. * Callback called to apply the custom optimization.
  76533. */
  76534. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  76535. /**
  76536. * Callback called to get custom description
  76537. */
  76538. onGetDescription: () => string;
  76539. /**
  76540. * Gets a string describing the action executed by the current optimization
  76541. * @returns description string
  76542. */
  76543. getDescription(): string;
  76544. /**
  76545. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76546. * @param scene defines the current scene where to apply this optimization
  76547. * @param optimizer defines the current optimizer
  76548. * @returns true if everything that can be done was applied
  76549. */
  76550. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76551. }
  76552. /**
  76553. * Defines an optimization used to turn particles off
  76554. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76555. */
  76556. export class ParticlesOptimization extends SceneOptimization {
  76557. /**
  76558. * Gets a string describing the action executed by the current optimization
  76559. * @return description string
  76560. */
  76561. getDescription(): string;
  76562. /**
  76563. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76564. * @param scene defines the current scene where to apply this optimization
  76565. * @param optimizer defines the current optimizer
  76566. * @returns true if everything that can be done was applied
  76567. */
  76568. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76569. }
  76570. /**
  76571. * Defines an optimization used to turn render targets off
  76572. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76573. */
  76574. export class RenderTargetsOptimization extends SceneOptimization {
  76575. /**
  76576. * Gets a string describing the action executed by the current optimization
  76577. * @return description string
  76578. */
  76579. getDescription(): string;
  76580. /**
  76581. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76582. * @param scene defines the current scene where to apply this optimization
  76583. * @param optimizer defines the current optimizer
  76584. * @returns true if everything that can be done was applied
  76585. */
  76586. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76587. }
  76588. /**
  76589. * Defines an optimization used to merge meshes with compatible materials
  76590. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76591. */
  76592. export class MergeMeshesOptimization extends SceneOptimization {
  76593. private static _UpdateSelectionTree;
  76594. /**
  76595. * Gets or sets a boolean which defines if optimization octree has to be updated
  76596. */
  76597. static get UpdateSelectionTree(): boolean;
  76598. /**
  76599. * Gets or sets a boolean which defines if optimization octree has to be updated
  76600. */
  76601. static set UpdateSelectionTree(value: boolean);
  76602. /**
  76603. * Gets a string describing the action executed by the current optimization
  76604. * @return description string
  76605. */
  76606. getDescription(): string;
  76607. private _canBeMerged;
  76608. /**
  76609. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76610. * @param scene defines the current scene where to apply this optimization
  76611. * @param optimizer defines the current optimizer
  76612. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  76613. * @returns true if everything that can be done was applied
  76614. */
  76615. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  76616. }
  76617. /**
  76618. * Defines a list of options used by SceneOptimizer
  76619. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76620. */
  76621. export class SceneOptimizerOptions {
  76622. /**
  76623. * Defines the target frame rate to reach (60 by default)
  76624. */
  76625. targetFrameRate: number;
  76626. /**
  76627. * Defines the interval between two checkes (2000ms by default)
  76628. */
  76629. trackerDuration: number;
  76630. /**
  76631. * Gets the list of optimizations to apply
  76632. */
  76633. optimizations: SceneOptimization[];
  76634. /**
  76635. * Creates a new list of options used by SceneOptimizer
  76636. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  76637. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  76638. */
  76639. constructor(
  76640. /**
  76641. * Defines the target frame rate to reach (60 by default)
  76642. */
  76643. targetFrameRate?: number,
  76644. /**
  76645. * Defines the interval between two checkes (2000ms by default)
  76646. */
  76647. trackerDuration?: number);
  76648. /**
  76649. * Add a new optimization
  76650. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  76651. * @returns the current SceneOptimizerOptions
  76652. */
  76653. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  76654. /**
  76655. * Add a new custom optimization
  76656. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  76657. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  76658. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76659. * @returns the current SceneOptimizerOptions
  76660. */
  76661. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  76662. /**
  76663. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  76664. * @param targetFrameRate defines the target frame rate (60 by default)
  76665. * @returns a SceneOptimizerOptions object
  76666. */
  76667. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76668. /**
  76669. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  76670. * @param targetFrameRate defines the target frame rate (60 by default)
  76671. * @returns a SceneOptimizerOptions object
  76672. */
  76673. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76674. /**
  76675. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  76676. * @param targetFrameRate defines the target frame rate (60 by default)
  76677. * @returns a SceneOptimizerOptions object
  76678. */
  76679. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76680. }
  76681. /**
  76682. * Class used to run optimizations in order to reach a target frame rate
  76683. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76684. */
  76685. export class SceneOptimizer implements IDisposable {
  76686. private _isRunning;
  76687. private _options;
  76688. private _scene;
  76689. private _currentPriorityLevel;
  76690. private _targetFrameRate;
  76691. private _trackerDuration;
  76692. private _currentFrameRate;
  76693. private _sceneDisposeObserver;
  76694. private _improvementMode;
  76695. /**
  76696. * Defines an observable called when the optimizer reaches the target frame rate
  76697. */
  76698. onSuccessObservable: Observable<SceneOptimizer>;
  76699. /**
  76700. * Defines an observable called when the optimizer enables an optimization
  76701. */
  76702. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  76703. /**
  76704. * Defines an observable called when the optimizer is not able to reach the target frame rate
  76705. */
  76706. onFailureObservable: Observable<SceneOptimizer>;
  76707. /**
  76708. * Gets a boolean indicating if the optimizer is in improvement mode
  76709. */
  76710. get isInImprovementMode(): boolean;
  76711. /**
  76712. * Gets the current priority level (0 at start)
  76713. */
  76714. get currentPriorityLevel(): number;
  76715. /**
  76716. * Gets the current frame rate checked by the SceneOptimizer
  76717. */
  76718. get currentFrameRate(): number;
  76719. /**
  76720. * Gets or sets the current target frame rate (60 by default)
  76721. */
  76722. get targetFrameRate(): number;
  76723. /**
  76724. * Gets or sets the current target frame rate (60 by default)
  76725. */
  76726. set targetFrameRate(value: number);
  76727. /**
  76728. * Gets or sets the current interval between two checks (every 2000ms by default)
  76729. */
  76730. get trackerDuration(): number;
  76731. /**
  76732. * Gets or sets the current interval between two checks (every 2000ms by default)
  76733. */
  76734. set trackerDuration(value: number);
  76735. /**
  76736. * Gets the list of active optimizations
  76737. */
  76738. get optimizations(): SceneOptimization[];
  76739. /**
  76740. * Creates a new SceneOptimizer
  76741. * @param scene defines the scene to work on
  76742. * @param options defines the options to use with the SceneOptimizer
  76743. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  76744. * @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)
  76745. */
  76746. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  76747. /**
  76748. * Stops the current optimizer
  76749. */
  76750. stop(): void;
  76751. /**
  76752. * Reset the optimizer to initial step (current priority level = 0)
  76753. */
  76754. reset(): void;
  76755. /**
  76756. * Start the optimizer. By default it will try to reach a specific framerate
  76757. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  76758. */
  76759. start(): void;
  76760. private _checkCurrentState;
  76761. /**
  76762. * Release all resources
  76763. */
  76764. dispose(): void;
  76765. /**
  76766. * Helper function to create a SceneOptimizer with one single line of code
  76767. * @param scene defines the scene to work on
  76768. * @param options defines the options to use with the SceneOptimizer
  76769. * @param onSuccess defines a callback to call on success
  76770. * @param onFailure defines a callback to call on failure
  76771. * @returns the new SceneOptimizer object
  76772. */
  76773. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  76774. }
  76775. }
  76776. declare module "babylonjs/Misc/sceneSerializer" {
  76777. import { Scene } from "babylonjs/scene";
  76778. /**
  76779. * Class used to serialize a scene into a string
  76780. */
  76781. export class SceneSerializer {
  76782. /**
  76783. * Clear cache used by a previous serialization
  76784. */
  76785. static ClearCache(): void;
  76786. /**
  76787. * Serialize a scene into a JSON compatible object
  76788. * @param scene defines the scene to serialize
  76789. * @returns a JSON compatible object
  76790. */
  76791. static Serialize(scene: Scene): any;
  76792. /**
  76793. * Serialize a mesh into a JSON compatible object
  76794. * @param toSerialize defines the mesh to serialize
  76795. * @param withParents defines if parents must be serialized as well
  76796. * @param withChildren defines if children must be serialized as well
  76797. * @returns a JSON compatible object
  76798. */
  76799. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  76800. }
  76801. }
  76802. declare module "babylonjs/Misc/textureTools" {
  76803. import { Texture } from "babylonjs/Materials/Textures/texture";
  76804. /**
  76805. * Class used to host texture specific utilities
  76806. */
  76807. export class TextureTools {
  76808. /**
  76809. * Uses the GPU to create a copy texture rescaled at a given size
  76810. * @param texture Texture to copy from
  76811. * @param width defines the desired width
  76812. * @param height defines the desired height
  76813. * @param useBilinearMode defines if bilinear mode has to be used
  76814. * @return the generated texture
  76815. */
  76816. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  76817. }
  76818. }
  76819. declare module "babylonjs/Misc/videoRecorder" {
  76820. import { Nullable } from "babylonjs/types";
  76821. import { Engine } from "babylonjs/Engines/engine";
  76822. /**
  76823. * This represents the different options available for the video capture.
  76824. */
  76825. export interface VideoRecorderOptions {
  76826. /** Defines the mime type of the video. */
  76827. mimeType: string;
  76828. /** Defines the FPS the video should be recorded at. */
  76829. fps: number;
  76830. /** Defines the chunk size for the recording data. */
  76831. recordChunckSize: number;
  76832. /** The audio tracks to attach to the recording. */
  76833. audioTracks?: MediaStreamTrack[];
  76834. }
  76835. /**
  76836. * This can help with recording videos from BabylonJS.
  76837. * This is based on the available WebRTC functionalities of the browser.
  76838. *
  76839. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  76840. */
  76841. export class VideoRecorder {
  76842. private static readonly _defaultOptions;
  76843. /**
  76844. * Returns whether or not the VideoRecorder is available in your browser.
  76845. * @param engine Defines the Babylon Engine.
  76846. * @returns true if supported otherwise false.
  76847. */
  76848. static IsSupported(engine: Engine): boolean;
  76849. private readonly _options;
  76850. private _canvas;
  76851. private _mediaRecorder;
  76852. private _recordedChunks;
  76853. private _fileName;
  76854. private _resolve;
  76855. private _reject;
  76856. /**
  76857. * True when a recording is already in progress.
  76858. */
  76859. get isRecording(): boolean;
  76860. /**
  76861. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  76862. * @param engine Defines the BabylonJS Engine you wish to record.
  76863. * @param options Defines options that can be used to customize the capture.
  76864. */
  76865. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  76866. /**
  76867. * Stops the current recording before the default capture timeout passed in the startRecording function.
  76868. */
  76869. stopRecording(): void;
  76870. /**
  76871. * Starts recording the canvas for a max duration specified in parameters.
  76872. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  76873. * If null no automatic download will start and you can rely on the promise to get the data back.
  76874. * @param maxDuration Defines the maximum recording time in seconds.
  76875. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  76876. * @return A promise callback at the end of the recording with the video data in Blob.
  76877. */
  76878. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  76879. /**
  76880. * Releases internal resources used during the recording.
  76881. */
  76882. dispose(): void;
  76883. private _handleDataAvailable;
  76884. private _handleError;
  76885. private _handleStop;
  76886. }
  76887. }
  76888. declare module "babylonjs/Misc/screenshotTools" {
  76889. import { Camera } from "babylonjs/Cameras/camera";
  76890. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  76891. import { Engine } from "babylonjs/Engines/engine";
  76892. /**
  76893. * Class containing a set of static utilities functions for screenshots
  76894. */
  76895. export class ScreenshotTools {
  76896. /**
  76897. * Captures a screenshot of the current rendering
  76898. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76899. * @param engine defines the rendering engine
  76900. * @param camera defines the source camera
  76901. * @param size This parameter can be set to a single number or to an object with the
  76902. * following (optional) properties: precision, width, height. If a single number is passed,
  76903. * it will be used for both width and height. If an object is passed, the screenshot size
  76904. * will be derived from the parameters. The precision property is a multiplier allowing
  76905. * rendering at a higher or lower resolution
  76906. * @param successCallback defines the callback receives a single parameter which contains the
  76907. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76908. * src parameter of an <img> to display it
  76909. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76910. * Check your browser for supported MIME types
  76911. */
  76912. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  76913. /**
  76914. * Captures a screenshot of the current rendering
  76915. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76916. * @param engine defines the rendering engine
  76917. * @param camera defines the source camera
  76918. * @param size This parameter can be set to a single number or to an object with the
  76919. * following (optional) properties: precision, width, height. If a single number is passed,
  76920. * it will be used for both width and height. If an object is passed, the screenshot size
  76921. * will be derived from the parameters. The precision property is a multiplier allowing
  76922. * rendering at a higher or lower resolution
  76923. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76924. * Check your browser for supported MIME types
  76925. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76926. * to the src parameter of an <img> to display it
  76927. */
  76928. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  76929. /**
  76930. * Generates an image screenshot from the specified camera.
  76931. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76932. * @param engine The engine to use for rendering
  76933. * @param camera The camera to use for rendering
  76934. * @param size This parameter can be set to a single number or to an object with the
  76935. * following (optional) properties: precision, width, height. If a single number is passed,
  76936. * it will be used for both width and height. If an object is passed, the screenshot size
  76937. * will be derived from the parameters. The precision property is a multiplier allowing
  76938. * rendering at a higher or lower resolution
  76939. * @param successCallback The callback receives a single parameter which contains the
  76940. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76941. * src parameter of an <img> to display it
  76942. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76943. * Check your browser for supported MIME types
  76944. * @param samples Texture samples (default: 1)
  76945. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76946. * @param fileName A name for for the downloaded file.
  76947. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76948. */
  76949. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  76950. /**
  76951. * Generates an image screenshot from the specified camera.
  76952. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76953. * @param engine The engine to use for rendering
  76954. * @param camera The camera to use for rendering
  76955. * @param size This parameter can be set to a single number or to an object with the
  76956. * following (optional) properties: precision, width, height. If a single number is passed,
  76957. * it will be used for both width and height. If an object is passed, the screenshot size
  76958. * will be derived from the parameters. The precision property is a multiplier allowing
  76959. * rendering at a higher or lower resolution
  76960. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76961. * Check your browser for supported MIME types
  76962. * @param samples Texture samples (default: 1)
  76963. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76964. * @param fileName A name for for the downloaded file.
  76965. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76966. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76967. * to the src parameter of an <img> to display it
  76968. */
  76969. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  76970. /**
  76971. * Gets height and width for screenshot size
  76972. * @private
  76973. */
  76974. private static _getScreenshotSize;
  76975. }
  76976. }
  76977. declare module "babylonjs/Misc/dataReader" {
  76978. /**
  76979. * Interface for a data buffer
  76980. */
  76981. export interface IDataBuffer {
  76982. /**
  76983. * Reads bytes from the data buffer.
  76984. * @param byteOffset The byte offset to read
  76985. * @param byteLength The byte length to read
  76986. * @returns A promise that resolves when the bytes are read
  76987. */
  76988. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  76989. /**
  76990. * The byte length of the buffer.
  76991. */
  76992. readonly byteLength: number;
  76993. }
  76994. /**
  76995. * Utility class for reading from a data buffer
  76996. */
  76997. export class DataReader {
  76998. /**
  76999. * The data buffer associated with this data reader.
  77000. */
  77001. readonly buffer: IDataBuffer;
  77002. /**
  77003. * The current byte offset from the beginning of the data buffer.
  77004. */
  77005. byteOffset: number;
  77006. private _dataView;
  77007. private _dataByteOffset;
  77008. /**
  77009. * Constructor
  77010. * @param buffer The buffer to read
  77011. */
  77012. constructor(buffer: IDataBuffer);
  77013. /**
  77014. * Loads the given byte length.
  77015. * @param byteLength The byte length to load
  77016. * @returns A promise that resolves when the load is complete
  77017. */
  77018. loadAsync(byteLength: number): Promise<void>;
  77019. /**
  77020. * Read a unsigned 32-bit integer from the currently loaded data range.
  77021. * @returns The 32-bit integer read
  77022. */
  77023. readUint32(): number;
  77024. /**
  77025. * Read a byte array from the currently loaded data range.
  77026. * @param byteLength The byte length to read
  77027. * @returns The byte array read
  77028. */
  77029. readUint8Array(byteLength: number): Uint8Array;
  77030. /**
  77031. * Read a string from the currently loaded data range.
  77032. * @param byteLength The byte length to read
  77033. * @returns The string read
  77034. */
  77035. readString(byteLength: number): string;
  77036. /**
  77037. * Skips the given byte length the currently loaded data range.
  77038. * @param byteLength The byte length to skip
  77039. */
  77040. skipBytes(byteLength: number): void;
  77041. }
  77042. }
  77043. declare module "babylonjs/Misc/dataStorage" {
  77044. /**
  77045. * Class for storing data to local storage if available or in-memory storage otherwise
  77046. */
  77047. export class DataStorage {
  77048. private static _Storage;
  77049. private static _GetStorage;
  77050. /**
  77051. * Reads a string from the data storage
  77052. * @param key The key to read
  77053. * @param defaultValue The value if the key doesn't exist
  77054. * @returns The string value
  77055. */
  77056. static ReadString(key: string, defaultValue: string): string;
  77057. /**
  77058. * Writes a string to the data storage
  77059. * @param key The key to write
  77060. * @param value The value to write
  77061. */
  77062. static WriteString(key: string, value: string): void;
  77063. /**
  77064. * Reads a boolean from the data storage
  77065. * @param key The key to read
  77066. * @param defaultValue The value if the key doesn't exist
  77067. * @returns The boolean value
  77068. */
  77069. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77070. /**
  77071. * Writes a boolean to the data storage
  77072. * @param key The key to write
  77073. * @param value The value to write
  77074. */
  77075. static WriteBoolean(key: string, value: boolean): void;
  77076. /**
  77077. * Reads a number from the data storage
  77078. * @param key The key to read
  77079. * @param defaultValue The value if the key doesn't exist
  77080. * @returns The number value
  77081. */
  77082. static ReadNumber(key: string, defaultValue: number): number;
  77083. /**
  77084. * Writes a number to the data storage
  77085. * @param key The key to write
  77086. * @param value The value to write
  77087. */
  77088. static WriteNumber(key: string, value: number): void;
  77089. }
  77090. }
  77091. declare module "babylonjs/Misc/index" {
  77092. export * from "babylonjs/Misc/andOrNotEvaluator";
  77093. export * from "babylonjs/Misc/assetsManager";
  77094. export * from "babylonjs/Misc/basis";
  77095. export * from "babylonjs/Misc/dds";
  77096. export * from "babylonjs/Misc/decorators";
  77097. export * from "babylonjs/Misc/deferred";
  77098. export * from "babylonjs/Misc/environmentTextureTools";
  77099. export * from "babylonjs/Misc/meshExploder";
  77100. export * from "babylonjs/Misc/filesInput";
  77101. export * from "babylonjs/Misc/HighDynamicRange/index";
  77102. export * from "babylonjs/Misc/khronosTextureContainer";
  77103. export * from "babylonjs/Misc/observable";
  77104. export * from "babylonjs/Misc/performanceMonitor";
  77105. export * from "babylonjs/Misc/promise";
  77106. export * from "babylonjs/Misc/sceneOptimizer";
  77107. export * from "babylonjs/Misc/sceneSerializer";
  77108. export * from "babylonjs/Misc/smartArray";
  77109. export * from "babylonjs/Misc/stringDictionary";
  77110. export * from "babylonjs/Misc/tags";
  77111. export * from "babylonjs/Misc/textureTools";
  77112. export * from "babylonjs/Misc/tga";
  77113. export * from "babylonjs/Misc/tools";
  77114. export * from "babylonjs/Misc/videoRecorder";
  77115. export * from "babylonjs/Misc/virtualJoystick";
  77116. export * from "babylonjs/Misc/workerPool";
  77117. export * from "babylonjs/Misc/logger";
  77118. export * from "babylonjs/Misc/typeStore";
  77119. export * from "babylonjs/Misc/filesInputStore";
  77120. export * from "babylonjs/Misc/deepCopier";
  77121. export * from "babylonjs/Misc/pivotTools";
  77122. export * from "babylonjs/Misc/precisionDate";
  77123. export * from "babylonjs/Misc/screenshotTools";
  77124. export * from "babylonjs/Misc/typeStore";
  77125. export * from "babylonjs/Misc/webRequest";
  77126. export * from "babylonjs/Misc/iInspectable";
  77127. export * from "babylonjs/Misc/brdfTextureTools";
  77128. export * from "babylonjs/Misc/rgbdTextureTools";
  77129. export * from "babylonjs/Misc/gradients";
  77130. export * from "babylonjs/Misc/perfCounter";
  77131. export * from "babylonjs/Misc/fileRequest";
  77132. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77133. export * from "babylonjs/Misc/retryStrategy";
  77134. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77135. export * from "babylonjs/Misc/canvasGenerator";
  77136. export * from "babylonjs/Misc/fileTools";
  77137. export * from "babylonjs/Misc/stringTools";
  77138. export * from "babylonjs/Misc/dataReader";
  77139. export * from "babylonjs/Misc/minMaxReducer";
  77140. export * from "babylonjs/Misc/depthReducer";
  77141. export * from "babylonjs/Misc/dataStorage";
  77142. }
  77143. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77144. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77145. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77146. import { Observable } from "babylonjs/Misc/observable";
  77147. import { Matrix } from "babylonjs/Maths/math.vector";
  77148. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77149. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77150. /**
  77151. * An interface for all Hit test features
  77152. */
  77153. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77154. /**
  77155. * Triggered when new babylon (transformed) hit test results are available
  77156. */
  77157. onHitTestResultObservable: Observable<T[]>;
  77158. }
  77159. /**
  77160. * Options used for hit testing
  77161. */
  77162. export interface IWebXRLegacyHitTestOptions {
  77163. /**
  77164. * Only test when user interacted with the scene. Default - hit test every frame
  77165. */
  77166. testOnPointerDownOnly?: boolean;
  77167. /**
  77168. * The node to use to transform the local results to world coordinates
  77169. */
  77170. worldParentNode?: TransformNode;
  77171. }
  77172. /**
  77173. * Interface defining the babylon result of raycasting/hit-test
  77174. */
  77175. export interface IWebXRLegacyHitResult {
  77176. /**
  77177. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77178. */
  77179. transformationMatrix: Matrix;
  77180. /**
  77181. * The native hit test result
  77182. */
  77183. xrHitResult: XRHitResult | XRHitTestResult;
  77184. }
  77185. /**
  77186. * The currently-working hit-test module.
  77187. * Hit test (or Ray-casting) is used to interact with the real world.
  77188. * For further information read here - https://github.com/immersive-web/hit-test
  77189. */
  77190. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  77191. /**
  77192. * options to use when constructing this feature
  77193. */
  77194. readonly options: IWebXRLegacyHitTestOptions;
  77195. private _direction;
  77196. private _mat;
  77197. private _onSelectEnabled;
  77198. private _origin;
  77199. /**
  77200. * The module's name
  77201. */
  77202. static readonly Name: string;
  77203. /**
  77204. * The (Babylon) version of this module.
  77205. * This is an integer representing the implementation version.
  77206. * This number does not correspond to the WebXR specs version
  77207. */
  77208. static readonly Version: number;
  77209. /**
  77210. * Populated with the last native XR Hit Results
  77211. */
  77212. lastNativeXRHitResults: XRHitResult[];
  77213. /**
  77214. * Triggered when new babylon (transformed) hit test results are available
  77215. */
  77216. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  77217. /**
  77218. * Creates a new instance of the (legacy version) hit test feature
  77219. * @param _xrSessionManager an instance of WebXRSessionManager
  77220. * @param options options to use when constructing this feature
  77221. */
  77222. constructor(_xrSessionManager: WebXRSessionManager,
  77223. /**
  77224. * options to use when constructing this feature
  77225. */
  77226. options?: IWebXRLegacyHitTestOptions);
  77227. /**
  77228. * execute a hit test with an XR Ray
  77229. *
  77230. * @param xrSession a native xrSession that will execute this hit test
  77231. * @param xrRay the ray (position and direction) to use for ray-casting
  77232. * @param referenceSpace native XR reference space to use for the hit-test
  77233. * @param filter filter function that will filter the results
  77234. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77235. */
  77236. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  77237. /**
  77238. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  77239. * @param event the (select) event to use to select with
  77240. * @param referenceSpace the reference space to use for this hit test
  77241. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77242. */
  77243. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77244. /**
  77245. * attach this feature
  77246. * Will usually be called by the features manager
  77247. *
  77248. * @returns true if successful.
  77249. */
  77250. attach(): boolean;
  77251. /**
  77252. * detach this feature.
  77253. * Will usually be called by the features manager
  77254. *
  77255. * @returns true if successful.
  77256. */
  77257. detach(): boolean;
  77258. /**
  77259. * Dispose this feature and all of the resources attached
  77260. */
  77261. dispose(): void;
  77262. protected _onXRFrame(frame: XRFrame): void;
  77263. private _onHitTestResults;
  77264. private _onSelect;
  77265. }
  77266. }
  77267. declare module "babylonjs/XR/features/WebXRHitTest" {
  77268. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77269. import { Observable } from "babylonjs/Misc/observable";
  77270. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77271. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77272. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  77273. /**
  77274. * Options used for hit testing (version 2)
  77275. */
  77276. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  77277. /**
  77278. * Do not create a permanent hit test. Will usually be used when only
  77279. * transient inputs are needed.
  77280. */
  77281. disablePermanentHitTest?: boolean;
  77282. /**
  77283. * Enable transient (for example touch-based) hit test inspections
  77284. */
  77285. enableTransientHitTest?: boolean;
  77286. /**
  77287. * Offset ray for the permanent hit test
  77288. */
  77289. offsetRay?: Vector3;
  77290. /**
  77291. * Offset ray for the transient hit test
  77292. */
  77293. transientOffsetRay?: Vector3;
  77294. /**
  77295. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  77296. */
  77297. useReferenceSpace?: boolean;
  77298. }
  77299. /**
  77300. * Interface defining the babylon result of hit-test
  77301. */
  77302. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  77303. /**
  77304. * The input source that generated this hit test (if transient)
  77305. */
  77306. inputSource?: XRInputSource;
  77307. /**
  77308. * Is this a transient hit test
  77309. */
  77310. isTransient?: boolean;
  77311. /**
  77312. * Position of the hit test result
  77313. */
  77314. position: Vector3;
  77315. /**
  77316. * Rotation of the hit test result
  77317. */
  77318. rotationQuaternion: Quaternion;
  77319. /**
  77320. * The native hit test result
  77321. */
  77322. xrHitResult: XRHitTestResult;
  77323. }
  77324. /**
  77325. * The currently-working hit-test module.
  77326. * Hit test (or Ray-casting) is used to interact with the real world.
  77327. * For further information read here - https://github.com/immersive-web/hit-test
  77328. *
  77329. * Tested on chrome (mobile) 80.
  77330. */
  77331. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  77332. /**
  77333. * options to use when constructing this feature
  77334. */
  77335. readonly options: IWebXRHitTestOptions;
  77336. private _tmpMat;
  77337. private _tmpPos;
  77338. private _tmpQuat;
  77339. private _transientXrHitTestSource;
  77340. private _xrHitTestSource;
  77341. private initHitTestSource;
  77342. /**
  77343. * The module's name
  77344. */
  77345. static readonly Name: string;
  77346. /**
  77347. * The (Babylon) version of this module.
  77348. * This is an integer representing the implementation version.
  77349. * This number does not correspond to the WebXR specs version
  77350. */
  77351. static readonly Version: number;
  77352. /**
  77353. * When set to true, each hit test will have its own position/rotation objects
  77354. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  77355. * the developers will clone them or copy them as they see fit.
  77356. */
  77357. autoCloneTransformation: boolean;
  77358. /**
  77359. * Triggered when new babylon (transformed) hit test results are available
  77360. */
  77361. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  77362. /**
  77363. * Use this to temporarily pause hit test checks.
  77364. */
  77365. paused: boolean;
  77366. /**
  77367. * Creates a new instance of the hit test feature
  77368. * @param _xrSessionManager an instance of WebXRSessionManager
  77369. * @param options options to use when constructing this feature
  77370. */
  77371. constructor(_xrSessionManager: WebXRSessionManager,
  77372. /**
  77373. * options to use when constructing this feature
  77374. */
  77375. options?: IWebXRHitTestOptions);
  77376. /**
  77377. * attach this feature
  77378. * Will usually be called by the features manager
  77379. *
  77380. * @returns true if successful.
  77381. */
  77382. attach(): boolean;
  77383. /**
  77384. * detach this feature.
  77385. * Will usually be called by the features manager
  77386. *
  77387. * @returns true if successful.
  77388. */
  77389. detach(): boolean;
  77390. /**
  77391. * Dispose this feature and all of the resources attached
  77392. */
  77393. dispose(): void;
  77394. protected _onXRFrame(frame: XRFrame): void;
  77395. private _processWebXRHitTestResult;
  77396. }
  77397. }
  77398. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  77399. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77400. import { Observable } from "babylonjs/Misc/observable";
  77401. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77402. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77403. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77404. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  77405. /**
  77406. * Configuration options of the anchor system
  77407. */
  77408. export interface IWebXRAnchorSystemOptions {
  77409. /**
  77410. * a node that will be used to convert local to world coordinates
  77411. */
  77412. worldParentNode?: TransformNode;
  77413. /**
  77414. * If set to true a reference of the created anchors will be kept until the next session starts
  77415. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  77416. */
  77417. doNotRemoveAnchorsOnSessionEnded?: boolean;
  77418. }
  77419. /**
  77420. * A babylon container for an XR Anchor
  77421. */
  77422. export interface IWebXRAnchor {
  77423. /**
  77424. * A babylon-assigned ID for this anchor
  77425. */
  77426. id: number;
  77427. /**
  77428. * Transformation matrix to apply to an object attached to this anchor
  77429. */
  77430. transformationMatrix: Matrix;
  77431. /**
  77432. * The native anchor object
  77433. */
  77434. xrAnchor: XRAnchor;
  77435. /**
  77436. * if defined, this object will be constantly updated by the anchor's position and rotation
  77437. */
  77438. attachedNode?: TransformNode;
  77439. }
  77440. /**
  77441. * An implementation of the anchor system for WebXR.
  77442. * For further information see https://github.com/immersive-web/anchors/
  77443. */
  77444. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  77445. private _options;
  77446. private _lastFrameDetected;
  77447. private _trackedAnchors;
  77448. private _referenceSpaceForFrameAnchors;
  77449. private _futureAnchors;
  77450. /**
  77451. * The module's name
  77452. */
  77453. static readonly Name: string;
  77454. /**
  77455. * The (Babylon) version of this module.
  77456. * This is an integer representing the implementation version.
  77457. * This number does not correspond to the WebXR specs version
  77458. */
  77459. static readonly Version: number;
  77460. /**
  77461. * Observers registered here will be executed when a new anchor was added to the session
  77462. */
  77463. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  77464. /**
  77465. * Observers registered here will be executed when an anchor was removed from the session
  77466. */
  77467. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  77468. /**
  77469. * Observers registered here will be executed when an existing anchor updates
  77470. * This can execute N times every frame
  77471. */
  77472. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  77473. /**
  77474. * Set the reference space to use for anchor creation, when not using a hit test.
  77475. * Will default to the session's reference space if not defined
  77476. */
  77477. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  77478. /**
  77479. * constructs a new anchor system
  77480. * @param _xrSessionManager an instance of WebXRSessionManager
  77481. * @param _options configuration object for this feature
  77482. */
  77483. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  77484. private _tmpVector;
  77485. private _tmpQuaternion;
  77486. private _populateTmpTransformation;
  77487. /**
  77488. * Create a new anchor point using a hit test result at a specific point in the scene
  77489. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77490. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77491. *
  77492. * @param hitTestResult The hit test result to use for this anchor creation
  77493. * @param position an optional position offset for this anchor
  77494. * @param rotationQuaternion an optional rotation offset for this anchor
  77495. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77496. */
  77497. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  77498. /**
  77499. * Add a new anchor at a specific position and rotation
  77500. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  77501. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  77502. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77503. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77504. *
  77505. * @param position the position in which to add an anchor
  77506. * @param rotationQuaternion an optional rotation for the anchor transformation
  77507. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  77508. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77509. */
  77510. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  77511. /**
  77512. * detach this feature.
  77513. * Will usually be called by the features manager
  77514. *
  77515. * @returns true if successful.
  77516. */
  77517. detach(): boolean;
  77518. /**
  77519. * Dispose this feature and all of the resources attached
  77520. */
  77521. dispose(): void;
  77522. protected _onXRFrame(frame: XRFrame): void;
  77523. /**
  77524. * avoiding using Array.find for global support.
  77525. * @param xrAnchor the plane to find in the array
  77526. */
  77527. private _findIndexInAnchorArray;
  77528. private _updateAnchorWithXRFrame;
  77529. private _createAnchorAtTransformation;
  77530. }
  77531. }
  77532. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  77533. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77534. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77535. import { Observable } from "babylonjs/Misc/observable";
  77536. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  77537. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77538. /**
  77539. * Options used in the plane detector module
  77540. */
  77541. export interface IWebXRPlaneDetectorOptions {
  77542. /**
  77543. * The node to use to transform the local results to world coordinates
  77544. */
  77545. worldParentNode?: TransformNode;
  77546. /**
  77547. * If set to true a reference of the created planes will be kept until the next session starts
  77548. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  77549. */
  77550. doNotRemovePlanesOnSessionEnded?: boolean;
  77551. }
  77552. /**
  77553. * A babylon interface for a WebXR plane.
  77554. * A Plane is actually a polygon, built from N points in space
  77555. *
  77556. * Supported in chrome 79, not supported in canary 81 ATM
  77557. */
  77558. export interface IWebXRPlane {
  77559. /**
  77560. * a babylon-assigned ID for this polygon
  77561. */
  77562. id: number;
  77563. /**
  77564. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  77565. */
  77566. polygonDefinition: Array<Vector3>;
  77567. /**
  77568. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  77569. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  77570. */
  77571. transformationMatrix: Matrix;
  77572. /**
  77573. * the native xr-plane object
  77574. */
  77575. xrPlane: XRPlane;
  77576. }
  77577. /**
  77578. * The plane detector is used to detect planes in the real world when in AR
  77579. * For more information see https://github.com/immersive-web/real-world-geometry/
  77580. */
  77581. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  77582. private _options;
  77583. private _detectedPlanes;
  77584. private _enabled;
  77585. private _lastFrameDetected;
  77586. /**
  77587. * The module's name
  77588. */
  77589. static readonly Name: string;
  77590. /**
  77591. * The (Babylon) version of this module.
  77592. * This is an integer representing the implementation version.
  77593. * This number does not correspond to the WebXR specs version
  77594. */
  77595. static readonly Version: number;
  77596. /**
  77597. * Observers registered here will be executed when a new plane was added to the session
  77598. */
  77599. onPlaneAddedObservable: Observable<IWebXRPlane>;
  77600. /**
  77601. * Observers registered here will be executed when a plane is no longer detected in the session
  77602. */
  77603. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  77604. /**
  77605. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  77606. * This can execute N times every frame
  77607. */
  77608. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  77609. /**
  77610. * construct a new Plane Detector
  77611. * @param _xrSessionManager an instance of xr Session manager
  77612. * @param _options configuration to use when constructing this feature
  77613. */
  77614. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  77615. /**
  77616. * detach this feature.
  77617. * Will usually be called by the features manager
  77618. *
  77619. * @returns true if successful.
  77620. */
  77621. detach(): boolean;
  77622. /**
  77623. * Dispose this feature and all of the resources attached
  77624. */
  77625. dispose(): void;
  77626. protected _onXRFrame(frame: XRFrame): void;
  77627. private _init;
  77628. private _updatePlaneWithXRPlane;
  77629. /**
  77630. * avoiding using Array.find for global support.
  77631. * @param xrPlane the plane to find in the array
  77632. */
  77633. private findIndexInPlaneArray;
  77634. }
  77635. }
  77636. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  77637. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77639. import { Observable } from "babylonjs/Misc/observable";
  77640. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77641. /**
  77642. * Options interface for the background remover plugin
  77643. */
  77644. export interface IWebXRBackgroundRemoverOptions {
  77645. /**
  77646. * Further background meshes to disable when entering AR
  77647. */
  77648. backgroundMeshes?: AbstractMesh[];
  77649. /**
  77650. * flags to configure the removal of the environment helper.
  77651. * If not set, the entire background will be removed. If set, flags should be set as well.
  77652. */
  77653. environmentHelperRemovalFlags?: {
  77654. /**
  77655. * Should the skybox be removed (default false)
  77656. */
  77657. skyBox?: boolean;
  77658. /**
  77659. * Should the ground be removed (default false)
  77660. */
  77661. ground?: boolean;
  77662. };
  77663. /**
  77664. * don't disable the environment helper
  77665. */
  77666. ignoreEnvironmentHelper?: boolean;
  77667. }
  77668. /**
  77669. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  77670. */
  77671. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  77672. /**
  77673. * read-only options to be used in this module
  77674. */
  77675. readonly options: IWebXRBackgroundRemoverOptions;
  77676. /**
  77677. * The module's name
  77678. */
  77679. static readonly Name: string;
  77680. /**
  77681. * The (Babylon) version of this module.
  77682. * This is an integer representing the implementation version.
  77683. * This number does not correspond to the WebXR specs version
  77684. */
  77685. static readonly Version: number;
  77686. /**
  77687. * registered observers will be triggered when the background state changes
  77688. */
  77689. onBackgroundStateChangedObservable: Observable<boolean>;
  77690. /**
  77691. * constructs a new background remover module
  77692. * @param _xrSessionManager the session manager for this module
  77693. * @param options read-only options to be used in this module
  77694. */
  77695. constructor(_xrSessionManager: WebXRSessionManager,
  77696. /**
  77697. * read-only options to be used in this module
  77698. */
  77699. options?: IWebXRBackgroundRemoverOptions);
  77700. /**
  77701. * attach this feature
  77702. * Will usually be called by the features manager
  77703. *
  77704. * @returns true if successful.
  77705. */
  77706. attach(): boolean;
  77707. /**
  77708. * detach this feature.
  77709. * Will usually be called by the features manager
  77710. *
  77711. * @returns true if successful.
  77712. */
  77713. detach(): boolean;
  77714. /**
  77715. * Dispose this feature and all of the resources attached
  77716. */
  77717. dispose(): void;
  77718. protected _onXRFrame(_xrFrame: XRFrame): void;
  77719. private _setBackgroundState;
  77720. }
  77721. }
  77722. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  77723. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77724. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  77725. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77726. import { WebXRInput } from "babylonjs/XR/webXRInput";
  77727. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77728. import { Nullable } from "babylonjs/types";
  77729. /**
  77730. * Options for the controller physics feature
  77731. */
  77732. export class IWebXRControllerPhysicsOptions {
  77733. /**
  77734. * Should the headset get its own impostor
  77735. */
  77736. enableHeadsetImpostor?: boolean;
  77737. /**
  77738. * Optional parameters for the headset impostor
  77739. */
  77740. headsetImpostorParams?: {
  77741. /**
  77742. * The type of impostor to create. Default is sphere
  77743. */
  77744. impostorType: number;
  77745. /**
  77746. * the size of the impostor. Defaults to 10cm
  77747. */
  77748. impostorSize?: number | {
  77749. width: number;
  77750. height: number;
  77751. depth: number;
  77752. };
  77753. /**
  77754. * Friction definitions
  77755. */
  77756. friction?: number;
  77757. /**
  77758. * Restitution
  77759. */
  77760. restitution?: number;
  77761. };
  77762. /**
  77763. * The physics properties of the future impostors
  77764. */
  77765. physicsProperties?: {
  77766. /**
  77767. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  77768. * Note that this requires a physics engine that supports mesh impostors!
  77769. */
  77770. useControllerMesh?: boolean;
  77771. /**
  77772. * The type of impostor to create. Default is sphere
  77773. */
  77774. impostorType?: number;
  77775. /**
  77776. * the size of the impostor. Defaults to 10cm
  77777. */
  77778. impostorSize?: number | {
  77779. width: number;
  77780. height: number;
  77781. depth: number;
  77782. };
  77783. /**
  77784. * Friction definitions
  77785. */
  77786. friction?: number;
  77787. /**
  77788. * Restitution
  77789. */
  77790. restitution?: number;
  77791. };
  77792. /**
  77793. * the xr input to use with this pointer selection
  77794. */
  77795. xrInput: WebXRInput;
  77796. }
  77797. /**
  77798. * Add physics impostor to your webxr controllers,
  77799. * including naive calculation of their linear and angular velocity
  77800. */
  77801. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  77802. private readonly _options;
  77803. private _attachController;
  77804. private _controllers;
  77805. private _debugMode;
  77806. private _delta;
  77807. private _headsetImpostor?;
  77808. private _headsetMesh?;
  77809. private _lastTimestamp;
  77810. private _tmpQuaternion;
  77811. private _tmpVector;
  77812. /**
  77813. * The module's name
  77814. */
  77815. static readonly Name: string;
  77816. /**
  77817. * The (Babylon) version of this module.
  77818. * This is an integer representing the implementation version.
  77819. * This number does not correspond to the webxr specs version
  77820. */
  77821. static readonly Version: number;
  77822. /**
  77823. * Construct a new Controller Physics Feature
  77824. * @param _xrSessionManager the corresponding xr session manager
  77825. * @param _options options to create this feature with
  77826. */
  77827. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  77828. /**
  77829. * @hidden
  77830. * enable debugging - will show console outputs and the impostor mesh
  77831. */
  77832. _enablePhysicsDebug(): void;
  77833. /**
  77834. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  77835. * @param xrController the controller to add
  77836. */
  77837. addController(xrController: WebXRInputSource): void;
  77838. /**
  77839. * attach this feature
  77840. * Will usually be called by the features manager
  77841. *
  77842. * @returns true if successful.
  77843. */
  77844. attach(): boolean;
  77845. /**
  77846. * detach this feature.
  77847. * Will usually be called by the features manager
  77848. *
  77849. * @returns true if successful.
  77850. */
  77851. detach(): boolean;
  77852. /**
  77853. * Get the headset impostor, if enabled
  77854. * @returns the impostor
  77855. */
  77856. getHeadsetImpostor(): PhysicsImpostor | undefined;
  77857. /**
  77858. * Get the physics impostor of a specific controller.
  77859. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  77860. * @param controller the controller or the controller id of which to get the impostor
  77861. * @returns the impostor or null
  77862. */
  77863. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  77864. /**
  77865. * Update the physics properties provided in the constructor
  77866. * @param newProperties the new properties object
  77867. */
  77868. setPhysicsProperties(newProperties: {
  77869. impostorType?: number;
  77870. impostorSize?: number | {
  77871. width: number;
  77872. height: number;
  77873. depth: number;
  77874. };
  77875. friction?: number;
  77876. restitution?: number;
  77877. }): void;
  77878. protected _onXRFrame(_xrFrame: any): void;
  77879. private _detachController;
  77880. }
  77881. }
  77882. declare module "babylonjs/XR/features/index" {
  77883. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  77884. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  77885. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  77886. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  77887. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  77888. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  77889. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  77890. export * from "babylonjs/XR/features/WebXRHitTest";
  77891. }
  77892. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  77893. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77895. import { Scene } from "babylonjs/scene";
  77896. /**
  77897. * The motion controller class for all microsoft mixed reality controllers
  77898. */
  77899. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77900. protected readonly _mapping: {
  77901. defaultButton: {
  77902. valueNodeName: string;
  77903. unpressedNodeName: string;
  77904. pressedNodeName: string;
  77905. };
  77906. defaultAxis: {
  77907. valueNodeName: string;
  77908. minNodeName: string;
  77909. maxNodeName: string;
  77910. };
  77911. buttons: {
  77912. "xr-standard-trigger": {
  77913. rootNodeName: string;
  77914. componentProperty: string;
  77915. states: string[];
  77916. };
  77917. "xr-standard-squeeze": {
  77918. rootNodeName: string;
  77919. componentProperty: string;
  77920. states: string[];
  77921. };
  77922. "xr-standard-touchpad": {
  77923. rootNodeName: string;
  77924. labelAnchorNodeName: string;
  77925. touchPointNodeName: string;
  77926. };
  77927. "xr-standard-thumbstick": {
  77928. rootNodeName: string;
  77929. componentProperty: string;
  77930. states: string[];
  77931. };
  77932. };
  77933. axes: {
  77934. "xr-standard-touchpad": {
  77935. "x-axis": {
  77936. rootNodeName: string;
  77937. };
  77938. "y-axis": {
  77939. rootNodeName: string;
  77940. };
  77941. };
  77942. "xr-standard-thumbstick": {
  77943. "x-axis": {
  77944. rootNodeName: string;
  77945. };
  77946. "y-axis": {
  77947. rootNodeName: string;
  77948. };
  77949. };
  77950. };
  77951. };
  77952. /**
  77953. * The base url used to load the left and right controller models
  77954. */
  77955. static MODEL_BASE_URL: string;
  77956. /**
  77957. * The name of the left controller model file
  77958. */
  77959. static MODEL_LEFT_FILENAME: string;
  77960. /**
  77961. * The name of the right controller model file
  77962. */
  77963. static MODEL_RIGHT_FILENAME: string;
  77964. profileId: string;
  77965. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77966. protected _getFilenameAndPath(): {
  77967. filename: string;
  77968. path: string;
  77969. };
  77970. protected _getModelLoadingConstraints(): boolean;
  77971. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77972. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77973. protected _updateModel(): void;
  77974. }
  77975. }
  77976. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  77977. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77979. import { Scene } from "babylonjs/scene";
  77980. /**
  77981. * The motion controller class for oculus touch (quest, rift).
  77982. * This class supports legacy mapping as well the standard xr mapping
  77983. */
  77984. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77985. private _forceLegacyControllers;
  77986. private _modelRootNode;
  77987. /**
  77988. * The base url used to load the left and right controller models
  77989. */
  77990. static MODEL_BASE_URL: string;
  77991. /**
  77992. * The name of the left controller model file
  77993. */
  77994. static MODEL_LEFT_FILENAME: string;
  77995. /**
  77996. * The name of the right controller model file
  77997. */
  77998. static MODEL_RIGHT_FILENAME: string;
  77999. /**
  78000. * Base Url for the Quest controller model.
  78001. */
  78002. static QUEST_MODEL_BASE_URL: string;
  78003. profileId: string;
  78004. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  78005. protected _getFilenameAndPath(): {
  78006. filename: string;
  78007. path: string;
  78008. };
  78009. protected _getModelLoadingConstraints(): boolean;
  78010. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78011. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78012. protected _updateModel(): void;
  78013. /**
  78014. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78015. * between the touch and touch 2.
  78016. */
  78017. private _isQuest;
  78018. }
  78019. }
  78020. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78021. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78022. import { Scene } from "babylonjs/scene";
  78023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78024. /**
  78025. * The motion controller class for the standard HTC-Vive controllers
  78026. */
  78027. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78028. private _modelRootNode;
  78029. /**
  78030. * The base url used to load the left and right controller models
  78031. */
  78032. static MODEL_BASE_URL: string;
  78033. /**
  78034. * File name for the controller model.
  78035. */
  78036. static MODEL_FILENAME: string;
  78037. profileId: string;
  78038. /**
  78039. * Create a new Vive motion controller object
  78040. * @param scene the scene to use to create this controller
  78041. * @param gamepadObject the corresponding gamepad object
  78042. * @param handedness the handedness of the controller
  78043. */
  78044. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78045. protected _getFilenameAndPath(): {
  78046. filename: string;
  78047. path: string;
  78048. };
  78049. protected _getModelLoadingConstraints(): boolean;
  78050. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78051. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78052. protected _updateModel(): void;
  78053. }
  78054. }
  78055. declare module "babylonjs/XR/motionController/index" {
  78056. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78057. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78058. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78059. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78060. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78061. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78062. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78063. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78064. }
  78065. declare module "babylonjs/XR/index" {
  78066. export * from "babylonjs/XR/webXRCamera";
  78067. export * from "babylonjs/XR/webXREnterExitUI";
  78068. export * from "babylonjs/XR/webXRExperienceHelper";
  78069. export * from "babylonjs/XR/webXRInput";
  78070. export * from "babylonjs/XR/webXRInputSource";
  78071. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78072. export * from "babylonjs/XR/webXRTypes";
  78073. export * from "babylonjs/XR/webXRSessionManager";
  78074. export * from "babylonjs/XR/webXRDefaultExperience";
  78075. export * from "babylonjs/XR/webXRFeaturesManager";
  78076. export * from "babylonjs/XR/features/index";
  78077. export * from "babylonjs/XR/motionController/index";
  78078. }
  78079. declare module "babylonjs/index" {
  78080. export * from "babylonjs/abstractScene";
  78081. export * from "babylonjs/Actions/index";
  78082. export * from "babylonjs/Animations/index";
  78083. export * from "babylonjs/assetContainer";
  78084. export * from "babylonjs/Audio/index";
  78085. export * from "babylonjs/Behaviors/index";
  78086. export * from "babylonjs/Bones/index";
  78087. export * from "babylonjs/Cameras/index";
  78088. export * from "babylonjs/Collisions/index";
  78089. export * from "babylonjs/Culling/index";
  78090. export * from "babylonjs/Debug/index";
  78091. export * from "babylonjs/DeviceInput/index";
  78092. export * from "babylonjs/Engines/index";
  78093. export * from "babylonjs/Events/index";
  78094. export * from "babylonjs/Gamepads/index";
  78095. export * from "babylonjs/Gizmos/index";
  78096. export * from "babylonjs/Helpers/index";
  78097. export * from "babylonjs/Instrumentation/index";
  78098. export * from "babylonjs/Layers/index";
  78099. export * from "babylonjs/LensFlares/index";
  78100. export * from "babylonjs/Lights/index";
  78101. export * from "babylonjs/Loading/index";
  78102. export * from "babylonjs/Materials/index";
  78103. export * from "babylonjs/Maths/index";
  78104. export * from "babylonjs/Meshes/index";
  78105. export * from "babylonjs/Morph/index";
  78106. export * from "babylonjs/Navigation/index";
  78107. export * from "babylonjs/node";
  78108. export * from "babylonjs/Offline/index";
  78109. export * from "babylonjs/Particles/index";
  78110. export * from "babylonjs/Physics/index";
  78111. export * from "babylonjs/PostProcesses/index";
  78112. export * from "babylonjs/Probes/index";
  78113. export * from "babylonjs/Rendering/index";
  78114. export * from "babylonjs/scene";
  78115. export * from "babylonjs/sceneComponent";
  78116. export * from "babylonjs/Sprites/index";
  78117. export * from "babylonjs/States/index";
  78118. export * from "babylonjs/Misc/index";
  78119. export * from "babylonjs/XR/index";
  78120. export * from "babylonjs/types";
  78121. }
  78122. declare module "babylonjs/Animations/pathCursor" {
  78123. import { Vector3 } from "babylonjs/Maths/math.vector";
  78124. import { Path2 } from "babylonjs/Maths/math.path";
  78125. /**
  78126. * A cursor which tracks a point on a path
  78127. */
  78128. export class PathCursor {
  78129. private path;
  78130. /**
  78131. * Stores path cursor callbacks for when an onchange event is triggered
  78132. */
  78133. private _onchange;
  78134. /**
  78135. * The value of the path cursor
  78136. */
  78137. value: number;
  78138. /**
  78139. * The animation array of the path cursor
  78140. */
  78141. animations: Animation[];
  78142. /**
  78143. * Initializes the path cursor
  78144. * @param path The path to track
  78145. */
  78146. constructor(path: Path2);
  78147. /**
  78148. * Gets the cursor point on the path
  78149. * @returns A point on the path cursor at the cursor location
  78150. */
  78151. getPoint(): Vector3;
  78152. /**
  78153. * Moves the cursor ahead by the step amount
  78154. * @param step The amount to move the cursor forward
  78155. * @returns This path cursor
  78156. */
  78157. moveAhead(step?: number): PathCursor;
  78158. /**
  78159. * Moves the cursor behind by the step amount
  78160. * @param step The amount to move the cursor back
  78161. * @returns This path cursor
  78162. */
  78163. moveBack(step?: number): PathCursor;
  78164. /**
  78165. * Moves the cursor by the step amount
  78166. * If the step amount is greater than one, an exception is thrown
  78167. * @param step The amount to move the cursor
  78168. * @returns This path cursor
  78169. */
  78170. move(step: number): PathCursor;
  78171. /**
  78172. * Ensures that the value is limited between zero and one
  78173. * @returns This path cursor
  78174. */
  78175. private ensureLimits;
  78176. /**
  78177. * Runs onchange callbacks on change (used by the animation engine)
  78178. * @returns This path cursor
  78179. */
  78180. private raiseOnChange;
  78181. /**
  78182. * Executes a function on change
  78183. * @param f A path cursor onchange callback
  78184. * @returns This path cursor
  78185. */
  78186. onchange(f: (cursor: PathCursor) => void): PathCursor;
  78187. }
  78188. }
  78189. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  78190. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  78191. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  78192. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  78193. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  78194. }
  78195. declare module "babylonjs/Engines/Processors/Expressions/index" {
  78196. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  78197. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  78198. }
  78199. declare module "babylonjs/Engines/Processors/index" {
  78200. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  78201. export * from "babylonjs/Engines/Processors/Expressions/index";
  78202. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  78203. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  78204. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  78205. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  78206. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  78207. export * from "babylonjs/Engines/Processors/shaderProcessor";
  78208. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  78209. }
  78210. declare module "babylonjs/Legacy/legacy" {
  78211. import * as Babylon from "babylonjs/index";
  78212. export * from "babylonjs/index";
  78213. }
  78214. declare module "babylonjs/Shaders/blur.fragment" {
  78215. /** @hidden */
  78216. export var blurPixelShader: {
  78217. name: string;
  78218. shader: string;
  78219. };
  78220. }
  78221. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  78222. /** @hidden */
  78223. export var pointCloudVertexDeclaration: {
  78224. name: string;
  78225. shader: string;
  78226. };
  78227. }
  78228. declare module "babylonjs" {
  78229. export * from "babylonjs/Legacy/legacy";
  78230. }
  78231. declare module BABYLON {
  78232. /** Alias type for value that can be null */
  78233. export type Nullable<T> = T | null;
  78234. /**
  78235. * Alias type for number that are floats
  78236. * @ignorenaming
  78237. */
  78238. export type float = number;
  78239. /**
  78240. * Alias type for number that are doubles.
  78241. * @ignorenaming
  78242. */
  78243. export type double = number;
  78244. /**
  78245. * Alias type for number that are integer
  78246. * @ignorenaming
  78247. */
  78248. export type int = number;
  78249. /** Alias type for number array or Float32Array */
  78250. export type FloatArray = number[] | Float32Array;
  78251. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  78252. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  78253. /**
  78254. * Alias for types that can be used by a Buffer or VertexBuffer.
  78255. */
  78256. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  78257. /**
  78258. * Alias type for primitive types
  78259. * @ignorenaming
  78260. */
  78261. type Primitive = undefined | null | boolean | string | number | Function;
  78262. /**
  78263. * Type modifier to make all the properties of an object Readonly
  78264. */
  78265. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  78266. /**
  78267. * Type modifier to make all the properties of an object Readonly recursively
  78268. */
  78269. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  78270. /**
  78271. * Type modifier to make object properties readonly.
  78272. */
  78273. export type DeepImmutableObject<T> = {
  78274. readonly [K in keyof T]: DeepImmutable<T[K]>;
  78275. };
  78276. /** @hidden */
  78277. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  78278. }
  78279. }
  78280. declare module BABYLON {
  78281. /**
  78282. * A class serves as a medium between the observable and its observers
  78283. */
  78284. export class EventState {
  78285. /**
  78286. * Create a new EventState
  78287. * @param mask defines the mask associated with this state
  78288. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78289. * @param target defines the original target of the state
  78290. * @param currentTarget defines the current target of the state
  78291. */
  78292. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  78293. /**
  78294. * Initialize the current event state
  78295. * @param mask defines the mask associated with this state
  78296. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78297. * @param target defines the original target of the state
  78298. * @param currentTarget defines the current target of the state
  78299. * @returns the current event state
  78300. */
  78301. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  78302. /**
  78303. * An Observer can set this property to true to prevent subsequent observers of being notified
  78304. */
  78305. skipNextObservers: boolean;
  78306. /**
  78307. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78308. */
  78309. mask: number;
  78310. /**
  78311. * The object that originally notified the event
  78312. */
  78313. target?: any;
  78314. /**
  78315. * The current object in the bubbling phase
  78316. */
  78317. currentTarget?: any;
  78318. /**
  78319. * This will be populated with the return value of the last function that was executed.
  78320. * If it is the first function in the callback chain it will be the event data.
  78321. */
  78322. lastReturnValue?: any;
  78323. }
  78324. /**
  78325. * Represent an Observer registered to a given Observable object.
  78326. */
  78327. export class Observer<T> {
  78328. /**
  78329. * Defines the callback to call when the observer is notified
  78330. */
  78331. callback: (eventData: T, eventState: EventState) => void;
  78332. /**
  78333. * Defines the mask of the observer (used to filter notifications)
  78334. */
  78335. mask: number;
  78336. /**
  78337. * Defines the current scope used to restore the JS context
  78338. */
  78339. scope: any;
  78340. /** @hidden */
  78341. _willBeUnregistered: boolean;
  78342. /**
  78343. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  78344. */
  78345. unregisterOnNextCall: boolean;
  78346. /**
  78347. * Creates a new observer
  78348. * @param callback defines the callback to call when the observer is notified
  78349. * @param mask defines the mask of the observer (used to filter notifications)
  78350. * @param scope defines the current scope used to restore the JS context
  78351. */
  78352. constructor(
  78353. /**
  78354. * Defines the callback to call when the observer is notified
  78355. */
  78356. callback: (eventData: T, eventState: EventState) => void,
  78357. /**
  78358. * Defines the mask of the observer (used to filter notifications)
  78359. */
  78360. mask: number,
  78361. /**
  78362. * Defines the current scope used to restore the JS context
  78363. */
  78364. scope?: any);
  78365. }
  78366. /**
  78367. * Represent a list of observers registered to multiple Observables object.
  78368. */
  78369. export class MultiObserver<T> {
  78370. private _observers;
  78371. private _observables;
  78372. /**
  78373. * Release associated resources
  78374. */
  78375. dispose(): void;
  78376. /**
  78377. * Raise a callback when one of the observable will notify
  78378. * @param observables defines a list of observables to watch
  78379. * @param callback defines the callback to call on notification
  78380. * @param mask defines the mask used to filter notifications
  78381. * @param scope defines the current scope used to restore the JS context
  78382. * @returns the new MultiObserver
  78383. */
  78384. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  78385. }
  78386. /**
  78387. * The Observable class is a simple implementation of the Observable pattern.
  78388. *
  78389. * 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.
  78390. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  78391. * 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).
  78392. * 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.
  78393. */
  78394. export class Observable<T> {
  78395. private _observers;
  78396. private _eventState;
  78397. private _onObserverAdded;
  78398. /**
  78399. * Gets the list of observers
  78400. */
  78401. get observers(): Array<Observer<T>>;
  78402. /**
  78403. * Creates a new observable
  78404. * @param onObserverAdded defines a callback to call when a new observer is added
  78405. */
  78406. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  78407. /**
  78408. * Create a new Observer with the specified callback
  78409. * @param callback the callback that will be executed for that Observer
  78410. * @param mask the mask used to filter observers
  78411. * @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.
  78412. * @param scope optional scope for the callback to be called from
  78413. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  78414. * @returns the new observer created for the callback
  78415. */
  78416. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  78417. /**
  78418. * Create a new Observer with the specified callback and unregisters after the next notification
  78419. * @param callback the callback that will be executed for that Observer
  78420. * @returns the new observer created for the callback
  78421. */
  78422. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  78423. /**
  78424. * Remove an Observer from the Observable object
  78425. * @param observer the instance of the Observer to remove
  78426. * @returns false if it doesn't belong to this Observable
  78427. */
  78428. remove(observer: Nullable<Observer<T>>): boolean;
  78429. /**
  78430. * Remove a callback from the Observable object
  78431. * @param callback the callback to remove
  78432. * @param scope optional scope. If used only the callbacks with this scope will be removed
  78433. * @returns false if it doesn't belong to this Observable
  78434. */
  78435. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  78436. private _deferUnregister;
  78437. private _remove;
  78438. /**
  78439. * Moves the observable to the top of the observer list making it get called first when notified
  78440. * @param observer the observer to move
  78441. */
  78442. makeObserverTopPriority(observer: Observer<T>): void;
  78443. /**
  78444. * Moves the observable to the bottom of the observer list making it get called last when notified
  78445. * @param observer the observer to move
  78446. */
  78447. makeObserverBottomPriority(observer: Observer<T>): void;
  78448. /**
  78449. * Notify all Observers by calling their respective callback with the given data
  78450. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  78451. * @param eventData defines the data to send to all observers
  78452. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  78453. * @param target defines the original target of the state
  78454. * @param currentTarget defines the current target of the state
  78455. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  78456. */
  78457. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  78458. /**
  78459. * Calling this will execute each callback, expecting it to be a promise or return a value.
  78460. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  78461. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  78462. * and it is crucial that all callbacks will be executed.
  78463. * The order of the callbacks is kept, callbacks are not executed parallel.
  78464. *
  78465. * @param eventData The data to be sent to each callback
  78466. * @param mask is used to filter observers defaults to -1
  78467. * @param target defines the callback target (see EventState)
  78468. * @param currentTarget defines he current object in the bubbling phase
  78469. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  78470. */
  78471. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  78472. /**
  78473. * Notify a specific observer
  78474. * @param observer defines the observer to notify
  78475. * @param eventData defines the data to be sent to each callback
  78476. * @param mask is used to filter observers defaults to -1
  78477. */
  78478. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  78479. /**
  78480. * Gets a boolean indicating if the observable has at least one observer
  78481. * @returns true is the Observable has at least one Observer registered
  78482. */
  78483. hasObservers(): boolean;
  78484. /**
  78485. * Clear the list of observers
  78486. */
  78487. clear(): void;
  78488. /**
  78489. * Clone the current observable
  78490. * @returns a new observable
  78491. */
  78492. clone(): Observable<T>;
  78493. /**
  78494. * Does this observable handles observer registered with a given mask
  78495. * @param mask defines the mask to be tested
  78496. * @return whether or not one observer registered with the given mask is handeled
  78497. **/
  78498. hasSpecificMask(mask?: number): boolean;
  78499. }
  78500. }
  78501. declare module BABYLON {
  78502. /**
  78503. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  78504. * Babylon.js
  78505. */
  78506. export class DomManagement {
  78507. /**
  78508. * Checks if the window object exists
  78509. * @returns true if the window object exists
  78510. */
  78511. static IsWindowObjectExist(): boolean;
  78512. /**
  78513. * Checks if the navigator object exists
  78514. * @returns true if the navigator object exists
  78515. */
  78516. static IsNavigatorAvailable(): boolean;
  78517. /**
  78518. * Check if the document object exists
  78519. * @returns true if the document object exists
  78520. */
  78521. static IsDocumentAvailable(): boolean;
  78522. /**
  78523. * Extracts text content from a DOM element hierarchy
  78524. * @param element defines the root element
  78525. * @returns a string
  78526. */
  78527. static GetDOMTextContent(element: HTMLElement): string;
  78528. }
  78529. }
  78530. declare module BABYLON {
  78531. /**
  78532. * Logger used througouht the application to allow configuration of
  78533. * the log level required for the messages.
  78534. */
  78535. export class Logger {
  78536. /**
  78537. * No log
  78538. */
  78539. static readonly NoneLogLevel: number;
  78540. /**
  78541. * Only message logs
  78542. */
  78543. static readonly MessageLogLevel: number;
  78544. /**
  78545. * Only warning logs
  78546. */
  78547. static readonly WarningLogLevel: number;
  78548. /**
  78549. * Only error logs
  78550. */
  78551. static readonly ErrorLogLevel: number;
  78552. /**
  78553. * All logs
  78554. */
  78555. static readonly AllLogLevel: number;
  78556. private static _LogCache;
  78557. /**
  78558. * Gets a value indicating the number of loading errors
  78559. * @ignorenaming
  78560. */
  78561. static errorsCount: number;
  78562. /**
  78563. * Callback called when a new log is added
  78564. */
  78565. static OnNewCacheEntry: (entry: string) => void;
  78566. private static _AddLogEntry;
  78567. private static _FormatMessage;
  78568. private static _LogDisabled;
  78569. private static _LogEnabled;
  78570. private static _WarnDisabled;
  78571. private static _WarnEnabled;
  78572. private static _ErrorDisabled;
  78573. private static _ErrorEnabled;
  78574. /**
  78575. * Log a message to the console
  78576. */
  78577. static Log: (message: string) => void;
  78578. /**
  78579. * Write a warning message to the console
  78580. */
  78581. static Warn: (message: string) => void;
  78582. /**
  78583. * Write an error message to the console
  78584. */
  78585. static Error: (message: string) => void;
  78586. /**
  78587. * Gets current log cache (list of logs)
  78588. */
  78589. static get LogCache(): string;
  78590. /**
  78591. * Clears the log cache
  78592. */
  78593. static ClearLogCache(): void;
  78594. /**
  78595. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  78596. */
  78597. static set LogLevels(level: number);
  78598. }
  78599. }
  78600. declare module BABYLON {
  78601. /** @hidden */
  78602. export class _TypeStore {
  78603. /** @hidden */
  78604. static RegisteredTypes: {
  78605. [key: string]: Object;
  78606. };
  78607. /** @hidden */
  78608. static GetClass(fqdn: string): any;
  78609. }
  78610. }
  78611. declare module BABYLON {
  78612. /**
  78613. * Helper to manipulate strings
  78614. */
  78615. export class StringTools {
  78616. /**
  78617. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  78618. * @param str Source string
  78619. * @param suffix Suffix to search for in the source string
  78620. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78621. */
  78622. static EndsWith(str: string, suffix: string): boolean;
  78623. /**
  78624. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  78625. * @param str Source string
  78626. * @param suffix Suffix to search for in the source string
  78627. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78628. */
  78629. static StartsWith(str: string, suffix: string): boolean;
  78630. /**
  78631. * Decodes a buffer into a string
  78632. * @param buffer The buffer to decode
  78633. * @returns The decoded string
  78634. */
  78635. static Decode(buffer: Uint8Array | Uint16Array): string;
  78636. /**
  78637. * Encode a buffer to a base64 string
  78638. * @param buffer defines the buffer to encode
  78639. * @returns the encoded string
  78640. */
  78641. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  78642. /**
  78643. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  78644. * @param num the number to convert and pad
  78645. * @param length the expected length of the string
  78646. * @returns the padded string
  78647. */
  78648. static PadNumber(num: number, length: number): string;
  78649. }
  78650. }
  78651. declare module BABYLON {
  78652. /**
  78653. * Class containing a set of static utilities functions for deep copy.
  78654. */
  78655. export class DeepCopier {
  78656. /**
  78657. * Tries to copy an object by duplicating every property
  78658. * @param source defines the source object
  78659. * @param destination defines the target object
  78660. * @param doNotCopyList defines a list of properties to avoid
  78661. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  78662. */
  78663. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  78664. }
  78665. }
  78666. declare module BABYLON {
  78667. /**
  78668. * Class containing a set of static utilities functions for precision date
  78669. */
  78670. export class PrecisionDate {
  78671. /**
  78672. * Gets either window.performance.now() if supported or Date.now() else
  78673. */
  78674. static get Now(): number;
  78675. }
  78676. }
  78677. declare module BABYLON {
  78678. /** @hidden */
  78679. export class _DevTools {
  78680. static WarnImport(name: string): string;
  78681. }
  78682. }
  78683. declare module BABYLON {
  78684. /**
  78685. * Interface used to define the mechanism to get data from the network
  78686. */
  78687. export interface IWebRequest {
  78688. /**
  78689. * Returns client's response url
  78690. */
  78691. responseURL: string;
  78692. /**
  78693. * Returns client's status
  78694. */
  78695. status: number;
  78696. /**
  78697. * Returns client's status as a text
  78698. */
  78699. statusText: string;
  78700. }
  78701. }
  78702. declare module BABYLON {
  78703. /**
  78704. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  78705. */
  78706. export class WebRequest implements IWebRequest {
  78707. private _xhr;
  78708. /**
  78709. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  78710. * i.e. when loading files, where the server/service expects an Authorization header
  78711. */
  78712. static CustomRequestHeaders: {
  78713. [key: string]: string;
  78714. };
  78715. /**
  78716. * Add callback functions in this array to update all the requests before they get sent to the network
  78717. */
  78718. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  78719. private _injectCustomRequestHeaders;
  78720. /**
  78721. * Gets or sets a function to be called when loading progress changes
  78722. */
  78723. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  78724. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  78725. /**
  78726. * Returns client's state
  78727. */
  78728. get readyState(): number;
  78729. /**
  78730. * Returns client's status
  78731. */
  78732. get status(): number;
  78733. /**
  78734. * Returns client's status as a text
  78735. */
  78736. get statusText(): string;
  78737. /**
  78738. * Returns client's response
  78739. */
  78740. get response(): any;
  78741. /**
  78742. * Returns client's response url
  78743. */
  78744. get responseURL(): string;
  78745. /**
  78746. * Returns client's response as text
  78747. */
  78748. get responseText(): string;
  78749. /**
  78750. * Gets or sets the expected response type
  78751. */
  78752. get responseType(): XMLHttpRequestResponseType;
  78753. set responseType(value: XMLHttpRequestResponseType);
  78754. /** @hidden */
  78755. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  78756. /** @hidden */
  78757. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  78758. /**
  78759. * Cancels any network activity
  78760. */
  78761. abort(): void;
  78762. /**
  78763. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  78764. * @param body defines an optional request body
  78765. */
  78766. send(body?: Document | BodyInit | null): void;
  78767. /**
  78768. * Sets the request method, request URL
  78769. * @param method defines the method to use (GET, POST, etc..)
  78770. * @param url defines the url to connect with
  78771. */
  78772. open(method: string, url: string): void;
  78773. /**
  78774. * Sets the value of a request header.
  78775. * @param name The name of the header whose value is to be set
  78776. * @param value The value to set as the body of the header
  78777. */
  78778. setRequestHeader(name: string, value: string): void;
  78779. /**
  78780. * Get the string containing the text of a particular header's value.
  78781. * @param name The name of the header
  78782. * @returns The string containing the text of the given header name
  78783. */
  78784. getResponseHeader(name: string): Nullable<string>;
  78785. }
  78786. }
  78787. declare module BABYLON {
  78788. /**
  78789. * File request interface
  78790. */
  78791. export interface IFileRequest {
  78792. /**
  78793. * Raised when the request is complete (success or error).
  78794. */
  78795. onCompleteObservable: Observable<IFileRequest>;
  78796. /**
  78797. * Aborts the request for a file.
  78798. */
  78799. abort: () => void;
  78800. }
  78801. }
  78802. declare module BABYLON {
  78803. /**
  78804. * Define options used to create a render target texture
  78805. */
  78806. export class RenderTargetCreationOptions {
  78807. /**
  78808. * Specifies is mipmaps must be generated
  78809. */
  78810. generateMipMaps?: boolean;
  78811. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  78812. generateDepthBuffer?: boolean;
  78813. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  78814. generateStencilBuffer?: boolean;
  78815. /** Defines texture type (int by default) */
  78816. type?: number;
  78817. /** Defines sampling mode (trilinear by default) */
  78818. samplingMode?: number;
  78819. /** Defines format (RGBA by default) */
  78820. format?: number;
  78821. }
  78822. }
  78823. declare module BABYLON {
  78824. /** Defines the cross module used constants to avoid circular dependncies */
  78825. export class Constants {
  78826. /** Defines that alpha blending is disabled */
  78827. static readonly ALPHA_DISABLE: number;
  78828. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  78829. static readonly ALPHA_ADD: number;
  78830. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  78831. static readonly ALPHA_COMBINE: number;
  78832. /** Defines that alpha blending is DEST - SRC * DEST */
  78833. static readonly ALPHA_SUBTRACT: number;
  78834. /** Defines that alpha blending is SRC * DEST */
  78835. static readonly ALPHA_MULTIPLY: number;
  78836. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  78837. static readonly ALPHA_MAXIMIZED: number;
  78838. /** Defines that alpha blending is SRC + DEST */
  78839. static readonly ALPHA_ONEONE: number;
  78840. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  78841. static readonly ALPHA_PREMULTIPLIED: number;
  78842. /**
  78843. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  78844. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  78845. */
  78846. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  78847. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  78848. static readonly ALPHA_INTERPOLATE: number;
  78849. /**
  78850. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  78851. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  78852. */
  78853. static readonly ALPHA_SCREENMODE: number;
  78854. /**
  78855. * Defines that alpha blending is SRC + DST
  78856. * Alpha will be set to SRC ALPHA + DST ALPHA
  78857. */
  78858. static readonly ALPHA_ONEONE_ONEONE: number;
  78859. /**
  78860. * Defines that alpha blending is SRC * DST ALPHA + DST
  78861. * Alpha will be set to 0
  78862. */
  78863. static readonly ALPHA_ALPHATOCOLOR: number;
  78864. /**
  78865. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78866. */
  78867. static readonly ALPHA_REVERSEONEMINUS: number;
  78868. /**
  78869. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  78870. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  78871. */
  78872. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  78873. /**
  78874. * Defines that alpha blending is SRC + DST
  78875. * Alpha will be set to SRC ALPHA
  78876. */
  78877. static readonly ALPHA_ONEONE_ONEZERO: number;
  78878. /**
  78879. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78880. * Alpha will be set to DST ALPHA
  78881. */
  78882. static readonly ALPHA_EXCLUSION: number;
  78883. /** Defines that alpha blending equation a SUM */
  78884. static readonly ALPHA_EQUATION_ADD: number;
  78885. /** Defines that alpha blending equation a SUBSTRACTION */
  78886. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  78887. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  78888. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  78889. /** Defines that alpha blending equation a MAX operation */
  78890. static readonly ALPHA_EQUATION_MAX: number;
  78891. /** Defines that alpha blending equation a MIN operation */
  78892. static readonly ALPHA_EQUATION_MIN: number;
  78893. /**
  78894. * Defines that alpha blending equation a DARKEN operation:
  78895. * It takes the min of the src and sums the alpha channels.
  78896. */
  78897. static readonly ALPHA_EQUATION_DARKEN: number;
  78898. /** Defines that the ressource is not delayed*/
  78899. static readonly DELAYLOADSTATE_NONE: number;
  78900. /** Defines that the ressource was successfully delay loaded */
  78901. static readonly DELAYLOADSTATE_LOADED: number;
  78902. /** Defines that the ressource is currently delay loading */
  78903. static readonly DELAYLOADSTATE_LOADING: number;
  78904. /** Defines that the ressource is delayed and has not started loading */
  78905. static readonly DELAYLOADSTATE_NOTLOADED: number;
  78906. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  78907. static readonly NEVER: number;
  78908. /** 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 */
  78909. static readonly ALWAYS: number;
  78910. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  78911. static readonly LESS: number;
  78912. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  78913. static readonly EQUAL: number;
  78914. /** 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 */
  78915. static readonly LEQUAL: number;
  78916. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  78917. static readonly GREATER: number;
  78918. /** 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 */
  78919. static readonly GEQUAL: number;
  78920. /** 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 */
  78921. static readonly NOTEQUAL: number;
  78922. /** Passed to stencilOperation to specify that stencil value must be kept */
  78923. static readonly KEEP: number;
  78924. /** Passed to stencilOperation to specify that stencil value must be replaced */
  78925. static readonly REPLACE: number;
  78926. /** Passed to stencilOperation to specify that stencil value must be incremented */
  78927. static readonly INCR: number;
  78928. /** Passed to stencilOperation to specify that stencil value must be decremented */
  78929. static readonly DECR: number;
  78930. /** Passed to stencilOperation to specify that stencil value must be inverted */
  78931. static readonly INVERT: number;
  78932. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  78933. static readonly INCR_WRAP: number;
  78934. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  78935. static readonly DECR_WRAP: number;
  78936. /** Texture is not repeating outside of 0..1 UVs */
  78937. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  78938. /** Texture is repeating outside of 0..1 UVs */
  78939. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  78940. /** Texture is repeating and mirrored */
  78941. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  78942. /** ALPHA */
  78943. static readonly TEXTUREFORMAT_ALPHA: number;
  78944. /** LUMINANCE */
  78945. static readonly TEXTUREFORMAT_LUMINANCE: number;
  78946. /** LUMINANCE_ALPHA */
  78947. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  78948. /** RGB */
  78949. static readonly TEXTUREFORMAT_RGB: number;
  78950. /** RGBA */
  78951. static readonly TEXTUREFORMAT_RGBA: number;
  78952. /** RED */
  78953. static readonly TEXTUREFORMAT_RED: number;
  78954. /** RED (2nd reference) */
  78955. static readonly TEXTUREFORMAT_R: number;
  78956. /** RG */
  78957. static readonly TEXTUREFORMAT_RG: number;
  78958. /** RED_INTEGER */
  78959. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  78960. /** RED_INTEGER (2nd reference) */
  78961. static readonly TEXTUREFORMAT_R_INTEGER: number;
  78962. /** RG_INTEGER */
  78963. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  78964. /** RGB_INTEGER */
  78965. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  78966. /** RGBA_INTEGER */
  78967. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  78968. /** UNSIGNED_BYTE */
  78969. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  78970. /** UNSIGNED_BYTE (2nd reference) */
  78971. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  78972. /** FLOAT */
  78973. static readonly TEXTURETYPE_FLOAT: number;
  78974. /** HALF_FLOAT */
  78975. static readonly TEXTURETYPE_HALF_FLOAT: number;
  78976. /** BYTE */
  78977. static readonly TEXTURETYPE_BYTE: number;
  78978. /** SHORT */
  78979. static readonly TEXTURETYPE_SHORT: number;
  78980. /** UNSIGNED_SHORT */
  78981. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  78982. /** INT */
  78983. static readonly TEXTURETYPE_INT: number;
  78984. /** UNSIGNED_INT */
  78985. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  78986. /** UNSIGNED_SHORT_4_4_4_4 */
  78987. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  78988. /** UNSIGNED_SHORT_5_5_5_1 */
  78989. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  78990. /** UNSIGNED_SHORT_5_6_5 */
  78991. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  78992. /** UNSIGNED_INT_2_10_10_10_REV */
  78993. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  78994. /** UNSIGNED_INT_24_8 */
  78995. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  78996. /** UNSIGNED_INT_10F_11F_11F_REV */
  78997. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  78998. /** UNSIGNED_INT_5_9_9_9_REV */
  78999. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  79000. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  79001. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  79002. /** nearest is mag = nearest and min = nearest and no mip */
  79003. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  79004. /** mag = nearest and min = nearest and mip = none */
  79005. static readonly TEXTURE_NEAREST_NEAREST: number;
  79006. /** Bilinear is mag = linear and min = linear and no mip */
  79007. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79008. /** mag = linear and min = linear and mip = none */
  79009. static readonly TEXTURE_LINEAR_LINEAR: number;
  79010. /** Trilinear is mag = linear and min = linear and mip = linear */
  79011. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79012. /** Trilinear is mag = linear and min = linear and mip = linear */
  79013. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79014. /** mag = nearest and min = nearest and mip = nearest */
  79015. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79016. /** mag = nearest and min = linear and mip = nearest */
  79017. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79018. /** mag = nearest and min = linear and mip = linear */
  79019. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79020. /** mag = nearest and min = linear and mip = none */
  79021. static readonly TEXTURE_NEAREST_LINEAR: number;
  79022. /** nearest is mag = nearest and min = nearest and mip = linear */
  79023. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79024. /** mag = linear and min = nearest and mip = nearest */
  79025. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79026. /** mag = linear and min = nearest and mip = linear */
  79027. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79028. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79029. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79030. /** mag = linear and min = nearest and mip = none */
  79031. static readonly TEXTURE_LINEAR_NEAREST: number;
  79032. /** Explicit coordinates mode */
  79033. static readonly TEXTURE_EXPLICIT_MODE: number;
  79034. /** Spherical coordinates mode */
  79035. static readonly TEXTURE_SPHERICAL_MODE: number;
  79036. /** Planar coordinates mode */
  79037. static readonly TEXTURE_PLANAR_MODE: number;
  79038. /** Cubic coordinates mode */
  79039. static readonly TEXTURE_CUBIC_MODE: number;
  79040. /** Projection coordinates mode */
  79041. static readonly TEXTURE_PROJECTION_MODE: number;
  79042. /** Skybox coordinates mode */
  79043. static readonly TEXTURE_SKYBOX_MODE: number;
  79044. /** Inverse Cubic coordinates mode */
  79045. static readonly TEXTURE_INVCUBIC_MODE: number;
  79046. /** Equirectangular coordinates mode */
  79047. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79048. /** Equirectangular Fixed coordinates mode */
  79049. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79050. /** Equirectangular Fixed Mirrored coordinates mode */
  79051. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79052. /** Offline (baking) quality for texture filtering */
  79053. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79054. /** High quality for texture filtering */
  79055. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79056. /** Medium quality for texture filtering */
  79057. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79058. /** Low quality for texture filtering */
  79059. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79060. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79061. static readonly SCALEMODE_FLOOR: number;
  79062. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79063. static readonly SCALEMODE_NEAREST: number;
  79064. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79065. static readonly SCALEMODE_CEILING: number;
  79066. /**
  79067. * The dirty texture flag value
  79068. */
  79069. static readonly MATERIAL_TextureDirtyFlag: number;
  79070. /**
  79071. * The dirty light flag value
  79072. */
  79073. static readonly MATERIAL_LightDirtyFlag: number;
  79074. /**
  79075. * The dirty fresnel flag value
  79076. */
  79077. static readonly MATERIAL_FresnelDirtyFlag: number;
  79078. /**
  79079. * The dirty attribute flag value
  79080. */
  79081. static readonly MATERIAL_AttributesDirtyFlag: number;
  79082. /**
  79083. * The dirty misc flag value
  79084. */
  79085. static readonly MATERIAL_MiscDirtyFlag: number;
  79086. /**
  79087. * The all dirty flag value
  79088. */
  79089. static readonly MATERIAL_AllDirtyFlag: number;
  79090. /**
  79091. * Returns the triangle fill mode
  79092. */
  79093. static readonly MATERIAL_TriangleFillMode: number;
  79094. /**
  79095. * Returns the wireframe mode
  79096. */
  79097. static readonly MATERIAL_WireFrameFillMode: number;
  79098. /**
  79099. * Returns the point fill mode
  79100. */
  79101. static readonly MATERIAL_PointFillMode: number;
  79102. /**
  79103. * Returns the point list draw mode
  79104. */
  79105. static readonly MATERIAL_PointListDrawMode: number;
  79106. /**
  79107. * Returns the line list draw mode
  79108. */
  79109. static readonly MATERIAL_LineListDrawMode: number;
  79110. /**
  79111. * Returns the line loop draw mode
  79112. */
  79113. static readonly MATERIAL_LineLoopDrawMode: number;
  79114. /**
  79115. * Returns the line strip draw mode
  79116. */
  79117. static readonly MATERIAL_LineStripDrawMode: number;
  79118. /**
  79119. * Returns the triangle strip draw mode
  79120. */
  79121. static readonly MATERIAL_TriangleStripDrawMode: number;
  79122. /**
  79123. * Returns the triangle fan draw mode
  79124. */
  79125. static readonly MATERIAL_TriangleFanDrawMode: number;
  79126. /**
  79127. * Stores the clock-wise side orientation
  79128. */
  79129. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79130. /**
  79131. * Stores the counter clock-wise side orientation
  79132. */
  79133. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79134. /**
  79135. * Nothing
  79136. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79137. */
  79138. static readonly ACTION_NothingTrigger: number;
  79139. /**
  79140. * On pick
  79141. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79142. */
  79143. static readonly ACTION_OnPickTrigger: number;
  79144. /**
  79145. * On left pick
  79146. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79147. */
  79148. static readonly ACTION_OnLeftPickTrigger: number;
  79149. /**
  79150. * On right pick
  79151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79152. */
  79153. static readonly ACTION_OnRightPickTrigger: number;
  79154. /**
  79155. * On center pick
  79156. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79157. */
  79158. static readonly ACTION_OnCenterPickTrigger: number;
  79159. /**
  79160. * On pick down
  79161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79162. */
  79163. static readonly ACTION_OnPickDownTrigger: number;
  79164. /**
  79165. * On double pick
  79166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79167. */
  79168. static readonly ACTION_OnDoublePickTrigger: number;
  79169. /**
  79170. * On pick up
  79171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79172. */
  79173. static readonly ACTION_OnPickUpTrigger: number;
  79174. /**
  79175. * On pick out.
  79176. * This trigger will only be raised if you also declared a OnPickDown
  79177. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79178. */
  79179. static readonly ACTION_OnPickOutTrigger: number;
  79180. /**
  79181. * On long press
  79182. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79183. */
  79184. static readonly ACTION_OnLongPressTrigger: number;
  79185. /**
  79186. * On pointer over
  79187. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79188. */
  79189. static readonly ACTION_OnPointerOverTrigger: number;
  79190. /**
  79191. * On pointer out
  79192. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79193. */
  79194. static readonly ACTION_OnPointerOutTrigger: number;
  79195. /**
  79196. * On every frame
  79197. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79198. */
  79199. static readonly ACTION_OnEveryFrameTrigger: number;
  79200. /**
  79201. * On intersection enter
  79202. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79203. */
  79204. static readonly ACTION_OnIntersectionEnterTrigger: number;
  79205. /**
  79206. * On intersection exit
  79207. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79208. */
  79209. static readonly ACTION_OnIntersectionExitTrigger: number;
  79210. /**
  79211. * On key down
  79212. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79213. */
  79214. static readonly ACTION_OnKeyDownTrigger: number;
  79215. /**
  79216. * On key up
  79217. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79218. */
  79219. static readonly ACTION_OnKeyUpTrigger: number;
  79220. /**
  79221. * Billboard mode will only apply to Y axis
  79222. */
  79223. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  79224. /**
  79225. * Billboard mode will apply to all axes
  79226. */
  79227. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  79228. /**
  79229. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79230. */
  79231. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  79232. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79233. * Test order :
  79234. * Is the bounding sphere outside the frustum ?
  79235. * If not, are the bounding box vertices outside the frustum ?
  79236. * It not, then the cullable object is in the frustum.
  79237. */
  79238. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  79239. /** Culling strategy : Bounding Sphere Only.
  79240. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79241. * It's also less accurate than the standard because some not visible objects can still be selected.
  79242. * Test : is the bounding sphere outside the frustum ?
  79243. * If not, then the cullable object is in the frustum.
  79244. */
  79245. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79246. /** Culling strategy : Optimistic Inclusion.
  79247. * This in an inclusion test first, then the standard exclusion test.
  79248. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79249. * 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.
  79250. * Anyway, it's as accurate as the standard strategy.
  79251. * Test :
  79252. * Is the cullable object bounding sphere center in the frustum ?
  79253. * If not, apply the default culling strategy.
  79254. */
  79255. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79256. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79257. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79258. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79259. * 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.
  79260. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79261. * Test :
  79262. * Is the cullable object bounding sphere center in the frustum ?
  79263. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79264. */
  79265. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79266. /**
  79267. * No logging while loading
  79268. */
  79269. static readonly SCENELOADER_NO_LOGGING: number;
  79270. /**
  79271. * Minimal logging while loading
  79272. */
  79273. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  79274. /**
  79275. * Summary logging while loading
  79276. */
  79277. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  79278. /**
  79279. * Detailled logging while loading
  79280. */
  79281. static readonly SCENELOADER_DETAILED_LOGGING: number;
  79282. }
  79283. }
  79284. declare module BABYLON {
  79285. /**
  79286. * This represents the required contract to create a new type of texture loader.
  79287. */
  79288. export interface IInternalTextureLoader {
  79289. /**
  79290. * Defines wether the loader supports cascade loading the different faces.
  79291. */
  79292. supportCascades: boolean;
  79293. /**
  79294. * This returns if the loader support the current file information.
  79295. * @param extension defines the file extension of the file being loaded
  79296. * @param mimeType defines the optional mime type of the file being loaded
  79297. * @returns true if the loader can load the specified file
  79298. */
  79299. canLoad(extension: string, mimeType?: string): boolean;
  79300. /**
  79301. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  79302. * @param data contains the texture data
  79303. * @param texture defines the BabylonJS internal texture
  79304. * @param createPolynomials will be true if polynomials have been requested
  79305. * @param onLoad defines the callback to trigger once the texture is ready
  79306. * @param onError defines the callback to trigger in case of error
  79307. */
  79308. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  79309. /**
  79310. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  79311. * @param data contains the texture data
  79312. * @param texture defines the BabylonJS internal texture
  79313. * @param callback defines the method to call once ready to upload
  79314. */
  79315. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  79316. }
  79317. }
  79318. declare module BABYLON {
  79319. /**
  79320. * Class used to store and describe the pipeline context associated with an effect
  79321. */
  79322. export interface IPipelineContext {
  79323. /**
  79324. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  79325. */
  79326. isAsync: boolean;
  79327. /**
  79328. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  79329. */
  79330. isReady: boolean;
  79331. /** @hidden */
  79332. _getVertexShaderCode(): string | null;
  79333. /** @hidden */
  79334. _getFragmentShaderCode(): string | null;
  79335. /** @hidden */
  79336. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  79337. }
  79338. }
  79339. declare module BABYLON {
  79340. /**
  79341. * Class used to store gfx data (like WebGLBuffer)
  79342. */
  79343. export class DataBuffer {
  79344. /**
  79345. * Gets or sets the number of objects referencing this buffer
  79346. */
  79347. references: number;
  79348. /** Gets or sets the size of the underlying buffer */
  79349. capacity: number;
  79350. /**
  79351. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  79352. */
  79353. is32Bits: boolean;
  79354. /**
  79355. * Gets the underlying buffer
  79356. */
  79357. get underlyingResource(): any;
  79358. }
  79359. }
  79360. declare module BABYLON {
  79361. /** @hidden */
  79362. export interface IShaderProcessor {
  79363. attributeProcessor?: (attribute: string) => string;
  79364. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  79365. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  79366. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  79367. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  79368. lineProcessor?: (line: string, isFragment: boolean) => string;
  79369. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79370. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79371. }
  79372. }
  79373. declare module BABYLON {
  79374. /** @hidden */
  79375. export interface ProcessingOptions {
  79376. defines: string[];
  79377. indexParameters: any;
  79378. isFragment: boolean;
  79379. shouldUseHighPrecisionShader: boolean;
  79380. supportsUniformBuffers: boolean;
  79381. shadersRepository: string;
  79382. includesShadersStore: {
  79383. [key: string]: string;
  79384. };
  79385. processor?: IShaderProcessor;
  79386. version: string;
  79387. platformName: string;
  79388. lookForClosingBracketForUniformBuffer?: boolean;
  79389. }
  79390. }
  79391. declare module BABYLON {
  79392. /** @hidden */
  79393. export class ShaderCodeNode {
  79394. line: string;
  79395. children: ShaderCodeNode[];
  79396. additionalDefineKey?: string;
  79397. additionalDefineValue?: string;
  79398. isValid(preprocessors: {
  79399. [key: string]: string;
  79400. }): boolean;
  79401. process(preprocessors: {
  79402. [key: string]: string;
  79403. }, options: ProcessingOptions): string;
  79404. }
  79405. }
  79406. declare module BABYLON {
  79407. /** @hidden */
  79408. export class ShaderCodeCursor {
  79409. private _lines;
  79410. lineIndex: number;
  79411. get currentLine(): string;
  79412. get canRead(): boolean;
  79413. set lines(value: string[]);
  79414. }
  79415. }
  79416. declare module BABYLON {
  79417. /** @hidden */
  79418. export class ShaderCodeConditionNode extends ShaderCodeNode {
  79419. process(preprocessors: {
  79420. [key: string]: string;
  79421. }, options: ProcessingOptions): string;
  79422. }
  79423. }
  79424. declare module BABYLON {
  79425. /** @hidden */
  79426. export class ShaderDefineExpression {
  79427. isTrue(preprocessors: {
  79428. [key: string]: string;
  79429. }): boolean;
  79430. private static _OperatorPriority;
  79431. private static _Stack;
  79432. static postfixToInfix(postfix: string[]): string;
  79433. static infixToPostfix(infix: string): string[];
  79434. }
  79435. }
  79436. declare module BABYLON {
  79437. /** @hidden */
  79438. export class ShaderCodeTestNode extends ShaderCodeNode {
  79439. testExpression: ShaderDefineExpression;
  79440. isValid(preprocessors: {
  79441. [key: string]: string;
  79442. }): boolean;
  79443. }
  79444. }
  79445. declare module BABYLON {
  79446. /** @hidden */
  79447. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  79448. define: string;
  79449. not: boolean;
  79450. constructor(define: string, not?: boolean);
  79451. isTrue(preprocessors: {
  79452. [key: string]: string;
  79453. }): boolean;
  79454. }
  79455. }
  79456. declare module BABYLON {
  79457. /** @hidden */
  79458. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  79459. leftOperand: ShaderDefineExpression;
  79460. rightOperand: ShaderDefineExpression;
  79461. isTrue(preprocessors: {
  79462. [key: string]: string;
  79463. }): boolean;
  79464. }
  79465. }
  79466. declare module BABYLON {
  79467. /** @hidden */
  79468. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  79469. leftOperand: ShaderDefineExpression;
  79470. rightOperand: ShaderDefineExpression;
  79471. isTrue(preprocessors: {
  79472. [key: string]: string;
  79473. }): boolean;
  79474. }
  79475. }
  79476. declare module BABYLON {
  79477. /** @hidden */
  79478. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  79479. define: string;
  79480. operand: string;
  79481. testValue: string;
  79482. constructor(define: string, operand: string, testValue: string);
  79483. isTrue(preprocessors: {
  79484. [key: string]: string;
  79485. }): boolean;
  79486. }
  79487. }
  79488. declare module BABYLON {
  79489. /**
  79490. * Class used to enable access to offline support
  79491. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  79492. */
  79493. export interface IOfflineProvider {
  79494. /**
  79495. * Gets a boolean indicating if scene must be saved in the database
  79496. */
  79497. enableSceneOffline: boolean;
  79498. /**
  79499. * Gets a boolean indicating if textures must be saved in the database
  79500. */
  79501. enableTexturesOffline: boolean;
  79502. /**
  79503. * Open the offline support and make it available
  79504. * @param successCallback defines the callback to call on success
  79505. * @param errorCallback defines the callback to call on error
  79506. */
  79507. open(successCallback: () => void, errorCallback: () => void): void;
  79508. /**
  79509. * Loads an image from the offline support
  79510. * @param url defines the url to load from
  79511. * @param image defines the target DOM image
  79512. */
  79513. loadImage(url: string, image: HTMLImageElement): void;
  79514. /**
  79515. * Loads a file from offline support
  79516. * @param url defines the URL to load from
  79517. * @param sceneLoaded defines a callback to call on success
  79518. * @param progressCallBack defines a callback to call when progress changed
  79519. * @param errorCallback defines a callback to call on error
  79520. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  79521. */
  79522. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  79523. }
  79524. }
  79525. declare module BABYLON {
  79526. /**
  79527. * Class used to help managing file picking and drag'n'drop
  79528. * File Storage
  79529. */
  79530. export class FilesInputStore {
  79531. /**
  79532. * List of files ready to be loaded
  79533. */
  79534. static FilesToLoad: {
  79535. [key: string]: File;
  79536. };
  79537. }
  79538. }
  79539. declare module BABYLON {
  79540. /**
  79541. * Class used to define a retry strategy when error happens while loading assets
  79542. */
  79543. export class RetryStrategy {
  79544. /**
  79545. * Function used to defines an exponential back off strategy
  79546. * @param maxRetries defines the maximum number of retries (3 by default)
  79547. * @param baseInterval defines the interval between retries
  79548. * @returns the strategy function to use
  79549. */
  79550. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  79551. }
  79552. }
  79553. declare module BABYLON {
  79554. /**
  79555. * @ignore
  79556. * Application error to support additional information when loading a file
  79557. */
  79558. export abstract class BaseError extends Error {
  79559. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  79560. }
  79561. }
  79562. declare module BABYLON {
  79563. /** @ignore */
  79564. export class LoadFileError extends BaseError {
  79565. request?: WebRequest;
  79566. file?: File;
  79567. /**
  79568. * Creates a new LoadFileError
  79569. * @param message defines the message of the error
  79570. * @param request defines the optional web request
  79571. * @param file defines the optional file
  79572. */
  79573. constructor(message: string, object?: WebRequest | File);
  79574. }
  79575. /** @ignore */
  79576. export class RequestFileError extends BaseError {
  79577. request: WebRequest;
  79578. /**
  79579. * Creates a new LoadFileError
  79580. * @param message defines the message of the error
  79581. * @param request defines the optional web request
  79582. */
  79583. constructor(message: string, request: WebRequest);
  79584. }
  79585. /** @ignore */
  79586. export class ReadFileError extends BaseError {
  79587. file: File;
  79588. /**
  79589. * Creates a new ReadFileError
  79590. * @param message defines the message of the error
  79591. * @param file defines the optional file
  79592. */
  79593. constructor(message: string, file: File);
  79594. }
  79595. /**
  79596. * @hidden
  79597. */
  79598. export class FileTools {
  79599. /**
  79600. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  79601. */
  79602. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  79603. /**
  79604. * Gets or sets the base URL to use to load assets
  79605. */
  79606. static BaseUrl: string;
  79607. /**
  79608. * Default behaviour for cors in the application.
  79609. * It can be a string if the expected behavior is identical in the entire app.
  79610. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  79611. */
  79612. static CorsBehavior: string | ((url: string | string[]) => string);
  79613. /**
  79614. * Gets or sets a function used to pre-process url before using them to load assets
  79615. */
  79616. static PreprocessUrl: (url: string) => string;
  79617. /**
  79618. * Removes unwanted characters from an url
  79619. * @param url defines the url to clean
  79620. * @returns the cleaned url
  79621. */
  79622. private static _CleanUrl;
  79623. /**
  79624. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  79625. * @param url define the url we are trying
  79626. * @param element define the dom element where to configure the cors policy
  79627. */
  79628. static SetCorsBehavior(url: string | string[], element: {
  79629. crossOrigin: string | null;
  79630. }): void;
  79631. /**
  79632. * Loads an image as an HTMLImageElement.
  79633. * @param input url string, ArrayBuffer, or Blob to load
  79634. * @param onLoad callback called when the image successfully loads
  79635. * @param onError callback called when the image fails to load
  79636. * @param offlineProvider offline provider for caching
  79637. * @param mimeType optional mime type
  79638. * @returns the HTMLImageElement of the loaded image
  79639. */
  79640. 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>;
  79641. /**
  79642. * Reads a file from a File object
  79643. * @param file defines the file to load
  79644. * @param onSuccess defines the callback to call when data is loaded
  79645. * @param onProgress defines the callback to call during loading process
  79646. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  79647. * @param onError defines the callback to call when an error occurs
  79648. * @returns a file request object
  79649. */
  79650. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  79651. /**
  79652. * Loads a file from a url
  79653. * @param url url to load
  79654. * @param onSuccess callback called when the file successfully loads
  79655. * @param onProgress callback called while file is loading (if the server supports this mode)
  79656. * @param offlineProvider defines the offline provider for caching
  79657. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79658. * @param onError callback called when the file fails to load
  79659. * @returns a file request object
  79660. */
  79661. 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;
  79662. /**
  79663. * Loads a file
  79664. * @param url url to load
  79665. * @param onSuccess callback called when the file successfully loads
  79666. * @param onProgress callback called while file is loading (if the server supports this mode)
  79667. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79668. * @param onError callback called when the file fails to load
  79669. * @param onOpened callback called when the web request is opened
  79670. * @returns a file request object
  79671. */
  79672. 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;
  79673. /**
  79674. * Checks if the loaded document was accessed via `file:`-Protocol.
  79675. * @returns boolean
  79676. */
  79677. static IsFileURL(): boolean;
  79678. }
  79679. }
  79680. declare module BABYLON {
  79681. /** @hidden */
  79682. export class ShaderProcessor {
  79683. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  79684. private static _ProcessPrecision;
  79685. private static _ExtractOperation;
  79686. private static _BuildSubExpression;
  79687. private static _BuildExpression;
  79688. private static _MoveCursorWithinIf;
  79689. private static _MoveCursor;
  79690. private static _EvaluatePreProcessors;
  79691. private static _PreparePreProcessors;
  79692. private static _ProcessShaderConversion;
  79693. private static _ProcessIncludes;
  79694. /**
  79695. * Loads a file from a url
  79696. * @param url url to load
  79697. * @param onSuccess callback called when the file successfully loads
  79698. * @param onProgress callback called while file is loading (if the server supports this mode)
  79699. * @param offlineProvider defines the offline provider for caching
  79700. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79701. * @param onError callback called when the file fails to load
  79702. * @returns a file request object
  79703. * @hidden
  79704. */
  79705. 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;
  79706. }
  79707. }
  79708. declare module BABYLON {
  79709. /**
  79710. * @hidden
  79711. */
  79712. export interface IColor4Like {
  79713. r: float;
  79714. g: float;
  79715. b: float;
  79716. a: float;
  79717. }
  79718. /**
  79719. * @hidden
  79720. */
  79721. export interface IColor3Like {
  79722. r: float;
  79723. g: float;
  79724. b: float;
  79725. }
  79726. /**
  79727. * @hidden
  79728. */
  79729. export interface IVector4Like {
  79730. x: float;
  79731. y: float;
  79732. z: float;
  79733. w: float;
  79734. }
  79735. /**
  79736. * @hidden
  79737. */
  79738. export interface IVector3Like {
  79739. x: float;
  79740. y: float;
  79741. z: float;
  79742. }
  79743. /**
  79744. * @hidden
  79745. */
  79746. export interface IVector2Like {
  79747. x: float;
  79748. y: float;
  79749. }
  79750. /**
  79751. * @hidden
  79752. */
  79753. export interface IMatrixLike {
  79754. toArray(): DeepImmutable<Float32Array>;
  79755. updateFlag: int;
  79756. }
  79757. /**
  79758. * @hidden
  79759. */
  79760. export interface IViewportLike {
  79761. x: float;
  79762. y: float;
  79763. width: float;
  79764. height: float;
  79765. }
  79766. /**
  79767. * @hidden
  79768. */
  79769. export interface IPlaneLike {
  79770. normal: IVector3Like;
  79771. d: float;
  79772. normalize(): void;
  79773. }
  79774. }
  79775. declare module BABYLON {
  79776. /**
  79777. * Interface used to define common properties for effect fallbacks
  79778. */
  79779. export interface IEffectFallbacks {
  79780. /**
  79781. * Removes the defines that should be removed when falling back.
  79782. * @param currentDefines defines the current define statements for the shader.
  79783. * @param effect defines the current effect we try to compile
  79784. * @returns The resulting defines with defines of the current rank removed.
  79785. */
  79786. reduce(currentDefines: string, effect: Effect): string;
  79787. /**
  79788. * Removes the fallback from the bound mesh.
  79789. */
  79790. unBindMesh(): void;
  79791. /**
  79792. * Checks to see if more fallbacks are still availible.
  79793. */
  79794. hasMoreFallbacks: boolean;
  79795. }
  79796. }
  79797. declare module BABYLON {
  79798. /**
  79799. * Class used to evalaute queries containing `and` and `or` operators
  79800. */
  79801. export class AndOrNotEvaluator {
  79802. /**
  79803. * Evaluate a query
  79804. * @param query defines the query to evaluate
  79805. * @param evaluateCallback defines the callback used to filter result
  79806. * @returns true if the query matches
  79807. */
  79808. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  79809. private static _HandleParenthesisContent;
  79810. private static _SimplifyNegation;
  79811. }
  79812. }
  79813. declare module BABYLON {
  79814. /**
  79815. * Class used to store custom tags
  79816. */
  79817. export class Tags {
  79818. /**
  79819. * Adds support for tags on the given object
  79820. * @param obj defines the object to use
  79821. */
  79822. static EnableFor(obj: any): void;
  79823. /**
  79824. * Removes tags support
  79825. * @param obj defines the object to use
  79826. */
  79827. static DisableFor(obj: any): void;
  79828. /**
  79829. * Gets a boolean indicating if the given object has tags
  79830. * @param obj defines the object to use
  79831. * @returns a boolean
  79832. */
  79833. static HasTags(obj: any): boolean;
  79834. /**
  79835. * Gets the tags available on a given object
  79836. * @param obj defines the object to use
  79837. * @param asString defines if the tags must be returned as a string instead of an array of strings
  79838. * @returns the tags
  79839. */
  79840. static GetTags(obj: any, asString?: boolean): any;
  79841. /**
  79842. * Adds tags to an object
  79843. * @param obj defines the object to use
  79844. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  79845. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  79846. */
  79847. static AddTagsTo(obj: any, tagsString: string): void;
  79848. /**
  79849. * @hidden
  79850. */
  79851. static _AddTagTo(obj: any, tag: string): void;
  79852. /**
  79853. * Removes specific tags from a specific object
  79854. * @param obj defines the object to use
  79855. * @param tagsString defines the tags to remove
  79856. */
  79857. static RemoveTagsFrom(obj: any, tagsString: string): void;
  79858. /**
  79859. * @hidden
  79860. */
  79861. static _RemoveTagFrom(obj: any, tag: string): void;
  79862. /**
  79863. * Defines if tags hosted on an object match a given query
  79864. * @param obj defines the object to use
  79865. * @param tagsQuery defines the tag query
  79866. * @returns a boolean
  79867. */
  79868. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  79869. }
  79870. }
  79871. declare module BABYLON {
  79872. /**
  79873. * Scalar computation library
  79874. */
  79875. export class Scalar {
  79876. /**
  79877. * Two pi constants convenient for computation.
  79878. */
  79879. static TwoPi: number;
  79880. /**
  79881. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79882. * @param a number
  79883. * @param b number
  79884. * @param epsilon (default = 1.401298E-45)
  79885. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79886. */
  79887. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  79888. /**
  79889. * Returns a string : the upper case translation of the number i to hexadecimal.
  79890. * @param i number
  79891. * @returns the upper case translation of the number i to hexadecimal.
  79892. */
  79893. static ToHex(i: number): string;
  79894. /**
  79895. * Returns -1 if value is negative and +1 is value is positive.
  79896. * @param value the value
  79897. * @returns the value itself if it's equal to zero.
  79898. */
  79899. static Sign(value: number): number;
  79900. /**
  79901. * Returns the value itself if it's between min and max.
  79902. * Returns min if the value is lower than min.
  79903. * Returns max if the value is greater than max.
  79904. * @param value the value to clmap
  79905. * @param min the min value to clamp to (default: 0)
  79906. * @param max the max value to clamp to (default: 1)
  79907. * @returns the clamped value
  79908. */
  79909. static Clamp(value: number, min?: number, max?: number): number;
  79910. /**
  79911. * the log2 of value.
  79912. * @param value the value to compute log2 of
  79913. * @returns the log2 of value.
  79914. */
  79915. static Log2(value: number): number;
  79916. /**
  79917. * Loops the value, so that it is never larger than length and never smaller than 0.
  79918. *
  79919. * This is similar to the modulo operator but it works with floating point numbers.
  79920. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  79921. * With t = 5 and length = 2.5, the result would be 0.0.
  79922. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  79923. * @param value the value
  79924. * @param length the length
  79925. * @returns the looped value
  79926. */
  79927. static Repeat(value: number, length: number): number;
  79928. /**
  79929. * Normalize the value between 0.0 and 1.0 using min and max values
  79930. * @param value value to normalize
  79931. * @param min max to normalize between
  79932. * @param max min to normalize between
  79933. * @returns the normalized value
  79934. */
  79935. static Normalize(value: number, min: number, max: number): number;
  79936. /**
  79937. * Denormalize the value from 0.0 and 1.0 using min and max values
  79938. * @param normalized value to denormalize
  79939. * @param min max to denormalize between
  79940. * @param max min to denormalize between
  79941. * @returns the denormalized value
  79942. */
  79943. static Denormalize(normalized: number, min: number, max: number): number;
  79944. /**
  79945. * Calculates the shortest difference between two given angles given in degrees.
  79946. * @param current current angle in degrees
  79947. * @param target target angle in degrees
  79948. * @returns the delta
  79949. */
  79950. static DeltaAngle(current: number, target: number): number;
  79951. /**
  79952. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  79953. * @param tx value
  79954. * @param length length
  79955. * @returns The returned value will move back and forth between 0 and length
  79956. */
  79957. static PingPong(tx: number, length: number): number;
  79958. /**
  79959. * Interpolates between min and max with smoothing at the limits.
  79960. *
  79961. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  79962. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  79963. * @param from from
  79964. * @param to to
  79965. * @param tx value
  79966. * @returns the smooth stepped value
  79967. */
  79968. static SmoothStep(from: number, to: number, tx: number): number;
  79969. /**
  79970. * Moves a value current towards target.
  79971. *
  79972. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  79973. * Negative values of maxDelta pushes the value away from target.
  79974. * @param current current value
  79975. * @param target target value
  79976. * @param maxDelta max distance to move
  79977. * @returns resulting value
  79978. */
  79979. static MoveTowards(current: number, target: number, maxDelta: number): number;
  79980. /**
  79981. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79982. *
  79983. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  79984. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  79985. * @param current current value
  79986. * @param target target value
  79987. * @param maxDelta max distance to move
  79988. * @returns resulting angle
  79989. */
  79990. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  79991. /**
  79992. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  79993. * @param start start value
  79994. * @param end target value
  79995. * @param amount amount to lerp between
  79996. * @returns the lerped value
  79997. */
  79998. static Lerp(start: number, end: number, amount: number): number;
  79999. /**
  80000. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80001. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  80002. * @param start start value
  80003. * @param end target value
  80004. * @param amount amount to lerp between
  80005. * @returns the lerped value
  80006. */
  80007. static LerpAngle(start: number, end: number, amount: number): number;
  80008. /**
  80009. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80010. * @param a start value
  80011. * @param b target value
  80012. * @param value value between a and b
  80013. * @returns the inverseLerp value
  80014. */
  80015. static InverseLerp(a: number, b: number, value: number): number;
  80016. /**
  80017. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80018. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80019. * @param value1 spline value
  80020. * @param tangent1 spline value
  80021. * @param value2 spline value
  80022. * @param tangent2 spline value
  80023. * @param amount input value
  80024. * @returns hermite result
  80025. */
  80026. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80027. /**
  80028. * Returns a random float number between and min and max values
  80029. * @param min min value of random
  80030. * @param max max value of random
  80031. * @returns random value
  80032. */
  80033. static RandomRange(min: number, max: number): number;
  80034. /**
  80035. * This function returns percentage of a number in a given range.
  80036. *
  80037. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80038. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80039. * @param number to convert to percentage
  80040. * @param min min range
  80041. * @param max max range
  80042. * @returns the percentage
  80043. */
  80044. static RangeToPercent(number: number, min: number, max: number): number;
  80045. /**
  80046. * This function returns number that corresponds to the percentage in a given range.
  80047. *
  80048. * PercentToRange(0.34,0,100) will return 34.
  80049. * @param percent to convert to number
  80050. * @param min min range
  80051. * @param max max range
  80052. * @returns the number
  80053. */
  80054. static PercentToRange(percent: number, min: number, max: number): number;
  80055. /**
  80056. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80057. * @param angle The angle to normalize in radian.
  80058. * @return The converted angle.
  80059. */
  80060. static NormalizeRadians(angle: number): number;
  80061. }
  80062. }
  80063. declare module BABYLON {
  80064. /**
  80065. * Constant used to convert a value to gamma space
  80066. * @ignorenaming
  80067. */
  80068. export const ToGammaSpace: number;
  80069. /**
  80070. * Constant used to convert a value to linear space
  80071. * @ignorenaming
  80072. */
  80073. export const ToLinearSpace = 2.2;
  80074. /**
  80075. * Constant used to define the minimal number value in Babylon.js
  80076. * @ignorenaming
  80077. */
  80078. let Epsilon: number;
  80079. }
  80080. declare module BABYLON {
  80081. /**
  80082. * Class used to represent a viewport on screen
  80083. */
  80084. export class Viewport {
  80085. /** viewport left coordinate */
  80086. x: number;
  80087. /** viewport top coordinate */
  80088. y: number;
  80089. /**viewport width */
  80090. width: number;
  80091. /** viewport height */
  80092. height: number;
  80093. /**
  80094. * Creates a Viewport object located at (x, y) and sized (width, height)
  80095. * @param x defines viewport left coordinate
  80096. * @param y defines viewport top coordinate
  80097. * @param width defines the viewport width
  80098. * @param height defines the viewport height
  80099. */
  80100. constructor(
  80101. /** viewport left coordinate */
  80102. x: number,
  80103. /** viewport top coordinate */
  80104. y: number,
  80105. /**viewport width */
  80106. width: number,
  80107. /** viewport height */
  80108. height: number);
  80109. /**
  80110. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80111. * @param renderWidth defines the rendering width
  80112. * @param renderHeight defines the rendering height
  80113. * @returns a new Viewport
  80114. */
  80115. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80116. /**
  80117. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80118. * @param renderWidth defines the rendering width
  80119. * @param renderHeight defines the rendering height
  80120. * @param ref defines the target viewport
  80121. * @returns the current viewport
  80122. */
  80123. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80124. /**
  80125. * Returns a new Viewport copied from the current one
  80126. * @returns a new Viewport
  80127. */
  80128. clone(): Viewport;
  80129. }
  80130. }
  80131. declare module BABYLON {
  80132. /**
  80133. * Class containing a set of static utilities functions for arrays.
  80134. */
  80135. export class ArrayTools {
  80136. /**
  80137. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80138. * @param size the number of element to construct and put in the array
  80139. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80140. * @returns a new array filled with new objects
  80141. */
  80142. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80143. }
  80144. }
  80145. declare module BABYLON {
  80146. /**
  80147. * Represents a plane by the equation ax + by + cz + d = 0
  80148. */
  80149. export class Plane {
  80150. private static _TmpMatrix;
  80151. /**
  80152. * Normal of the plane (a,b,c)
  80153. */
  80154. normal: Vector3;
  80155. /**
  80156. * d component of the plane
  80157. */
  80158. d: number;
  80159. /**
  80160. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80161. * @param a a component of the plane
  80162. * @param b b component of the plane
  80163. * @param c c component of the plane
  80164. * @param d d component of the plane
  80165. */
  80166. constructor(a: number, b: number, c: number, d: number);
  80167. /**
  80168. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80169. */
  80170. asArray(): number[];
  80171. /**
  80172. * @returns a new plane copied from the current Plane.
  80173. */
  80174. clone(): Plane;
  80175. /**
  80176. * @returns the string "Plane".
  80177. */
  80178. getClassName(): string;
  80179. /**
  80180. * @returns the Plane hash code.
  80181. */
  80182. getHashCode(): number;
  80183. /**
  80184. * Normalize the current Plane in place.
  80185. * @returns the updated Plane.
  80186. */
  80187. normalize(): Plane;
  80188. /**
  80189. * Applies a transformation the plane and returns the result
  80190. * @param transformation the transformation matrix to be applied to the plane
  80191. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80192. */
  80193. transform(transformation: DeepImmutable<Matrix>): Plane;
  80194. /**
  80195. * Compute the dot product between the point and the plane normal
  80196. * @param point point to calculate the dot product with
  80197. * @returns the dot product (float) of the point coordinates and the plane normal.
  80198. */
  80199. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80200. /**
  80201. * Updates the current Plane from the plane defined by the three given points.
  80202. * @param point1 one of the points used to contruct the plane
  80203. * @param point2 one of the points used to contruct the plane
  80204. * @param point3 one of the points used to contruct the plane
  80205. * @returns the updated Plane.
  80206. */
  80207. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80208. /**
  80209. * Checks if the plane is facing a given direction
  80210. * @param direction the direction to check if the plane is facing
  80211. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80212. * @returns True is the vector "direction" is the same side than the plane normal.
  80213. */
  80214. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80215. /**
  80216. * Calculates the distance to a point
  80217. * @param point point to calculate distance to
  80218. * @returns the signed distance (float) from the given point to the Plane.
  80219. */
  80220. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80221. /**
  80222. * Creates a plane from an array
  80223. * @param array the array to create a plane from
  80224. * @returns a new Plane from the given array.
  80225. */
  80226. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80227. /**
  80228. * Creates a plane from three points
  80229. * @param point1 point used to create the plane
  80230. * @param point2 point used to create the plane
  80231. * @param point3 point used to create the plane
  80232. * @returns a new Plane defined by the three given points.
  80233. */
  80234. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80235. /**
  80236. * Creates a plane from an origin point and a normal
  80237. * @param origin origin of the plane to be constructed
  80238. * @param normal normal of the plane to be constructed
  80239. * @returns a new Plane the normal vector to this plane at the given origin point.
  80240. * Note : the vector "normal" is updated because normalized.
  80241. */
  80242. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  80243. /**
  80244. * Calculates the distance from a plane and a point
  80245. * @param origin origin of the plane to be constructed
  80246. * @param normal normal of the plane to be constructed
  80247. * @param point point to calculate distance to
  80248. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80249. */
  80250. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80251. }
  80252. }
  80253. declare module BABYLON {
  80254. /**
  80255. * Class representing a vector containing 2 coordinates
  80256. */
  80257. export class Vector2 {
  80258. /** defines the first coordinate */
  80259. x: number;
  80260. /** defines the second coordinate */
  80261. y: number;
  80262. /**
  80263. * Creates a new Vector2 from the given x and y coordinates
  80264. * @param x defines the first coordinate
  80265. * @param y defines the second coordinate
  80266. */
  80267. constructor(
  80268. /** defines the first coordinate */
  80269. x?: number,
  80270. /** defines the second coordinate */
  80271. y?: number);
  80272. /**
  80273. * Gets a string with the Vector2 coordinates
  80274. * @returns a string with the Vector2 coordinates
  80275. */
  80276. toString(): string;
  80277. /**
  80278. * Gets class name
  80279. * @returns the string "Vector2"
  80280. */
  80281. getClassName(): string;
  80282. /**
  80283. * Gets current vector hash code
  80284. * @returns the Vector2 hash code as a number
  80285. */
  80286. getHashCode(): number;
  80287. /**
  80288. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  80289. * @param array defines the source array
  80290. * @param index defines the offset in source array
  80291. * @returns the current Vector2
  80292. */
  80293. toArray(array: FloatArray, index?: number): Vector2;
  80294. /**
  80295. * Copy the current vector to an array
  80296. * @returns a new array with 2 elements: the Vector2 coordinates.
  80297. */
  80298. asArray(): number[];
  80299. /**
  80300. * Sets the Vector2 coordinates with the given Vector2 coordinates
  80301. * @param source defines the source Vector2
  80302. * @returns the current updated Vector2
  80303. */
  80304. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  80305. /**
  80306. * Sets the Vector2 coordinates with the given floats
  80307. * @param x defines the first coordinate
  80308. * @param y defines the second coordinate
  80309. * @returns the current updated Vector2
  80310. */
  80311. copyFromFloats(x: number, y: number): Vector2;
  80312. /**
  80313. * Sets the Vector2 coordinates with the given floats
  80314. * @param x defines the first coordinate
  80315. * @param y defines the second coordinate
  80316. * @returns the current updated Vector2
  80317. */
  80318. set(x: number, y: number): Vector2;
  80319. /**
  80320. * Add another vector with the current one
  80321. * @param otherVector defines the other vector
  80322. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  80323. */
  80324. add(otherVector: DeepImmutable<Vector2>): Vector2;
  80325. /**
  80326. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  80327. * @param otherVector defines the other vector
  80328. * @param result defines the target vector
  80329. * @returns the unmodified current Vector2
  80330. */
  80331. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80332. /**
  80333. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  80334. * @param otherVector defines the other vector
  80335. * @returns the current updated Vector2
  80336. */
  80337. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80338. /**
  80339. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  80340. * @param otherVector defines the other vector
  80341. * @returns a new Vector2
  80342. */
  80343. addVector3(otherVector: Vector3): Vector2;
  80344. /**
  80345. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  80346. * @param otherVector defines the other vector
  80347. * @returns a new Vector2
  80348. */
  80349. subtract(otherVector: Vector2): Vector2;
  80350. /**
  80351. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  80352. * @param otherVector defines the other vector
  80353. * @param result defines the target vector
  80354. * @returns the unmodified current Vector2
  80355. */
  80356. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80357. /**
  80358. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  80359. * @param otherVector defines the other vector
  80360. * @returns the current updated Vector2
  80361. */
  80362. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80363. /**
  80364. * Multiplies in place the current Vector2 coordinates by the given ones
  80365. * @param otherVector defines the other vector
  80366. * @returns the current updated Vector2
  80367. */
  80368. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80369. /**
  80370. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  80371. * @param otherVector defines the other vector
  80372. * @returns a new Vector2
  80373. */
  80374. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  80375. /**
  80376. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  80377. * @param otherVector defines the other vector
  80378. * @param result defines the target vector
  80379. * @returns the unmodified current Vector2
  80380. */
  80381. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80382. /**
  80383. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  80384. * @param x defines the first coordinate
  80385. * @param y defines the second coordinate
  80386. * @returns a new Vector2
  80387. */
  80388. multiplyByFloats(x: number, y: number): Vector2;
  80389. /**
  80390. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  80391. * @param otherVector defines the other vector
  80392. * @returns a new Vector2
  80393. */
  80394. divide(otherVector: Vector2): Vector2;
  80395. /**
  80396. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  80397. * @param otherVector defines the other vector
  80398. * @param result defines the target vector
  80399. * @returns the unmodified current Vector2
  80400. */
  80401. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80402. /**
  80403. * Divides the current Vector2 coordinates by the given ones
  80404. * @param otherVector defines the other vector
  80405. * @returns the current updated Vector2
  80406. */
  80407. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80408. /**
  80409. * Gets a new Vector2 with current Vector2 negated coordinates
  80410. * @returns a new Vector2
  80411. */
  80412. negate(): Vector2;
  80413. /**
  80414. * Negate this vector in place
  80415. * @returns this
  80416. */
  80417. negateInPlace(): Vector2;
  80418. /**
  80419. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  80420. * @param result defines the Vector3 object where to store the result
  80421. * @returns the current Vector2
  80422. */
  80423. negateToRef(result: Vector2): Vector2;
  80424. /**
  80425. * Multiply the Vector2 coordinates by scale
  80426. * @param scale defines the scaling factor
  80427. * @returns the current updated Vector2
  80428. */
  80429. scaleInPlace(scale: number): Vector2;
  80430. /**
  80431. * Returns a new Vector2 scaled by "scale" from the current Vector2
  80432. * @param scale defines the scaling factor
  80433. * @returns a new Vector2
  80434. */
  80435. scale(scale: number): Vector2;
  80436. /**
  80437. * Scale the current Vector2 values by a factor to a given Vector2
  80438. * @param scale defines the scale factor
  80439. * @param result defines the Vector2 object where to store the result
  80440. * @returns the unmodified current Vector2
  80441. */
  80442. scaleToRef(scale: number, result: Vector2): Vector2;
  80443. /**
  80444. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  80445. * @param scale defines the scale factor
  80446. * @param result defines the Vector2 object where to store the result
  80447. * @returns the unmodified current Vector2
  80448. */
  80449. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  80450. /**
  80451. * Gets a boolean if two vectors are equals
  80452. * @param otherVector defines the other vector
  80453. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  80454. */
  80455. equals(otherVector: DeepImmutable<Vector2>): boolean;
  80456. /**
  80457. * Gets a boolean if two vectors are equals (using an epsilon value)
  80458. * @param otherVector defines the other vector
  80459. * @param epsilon defines the minimal distance to consider equality
  80460. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  80461. */
  80462. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  80463. /**
  80464. * Gets a new Vector2 from current Vector2 floored values
  80465. * @returns a new Vector2
  80466. */
  80467. floor(): Vector2;
  80468. /**
  80469. * Gets a new Vector2 from current Vector2 floored values
  80470. * @returns a new Vector2
  80471. */
  80472. fract(): Vector2;
  80473. /**
  80474. * Gets the length of the vector
  80475. * @returns the vector length (float)
  80476. */
  80477. length(): number;
  80478. /**
  80479. * Gets the vector squared length
  80480. * @returns the vector squared length (float)
  80481. */
  80482. lengthSquared(): number;
  80483. /**
  80484. * Normalize the vector
  80485. * @returns the current updated Vector2
  80486. */
  80487. normalize(): Vector2;
  80488. /**
  80489. * Gets a new Vector2 copied from the Vector2
  80490. * @returns a new Vector2
  80491. */
  80492. clone(): Vector2;
  80493. /**
  80494. * Gets a new Vector2(0, 0)
  80495. * @returns a new Vector2
  80496. */
  80497. static Zero(): Vector2;
  80498. /**
  80499. * Gets a new Vector2(1, 1)
  80500. * @returns a new Vector2
  80501. */
  80502. static One(): Vector2;
  80503. /**
  80504. * Gets a new Vector2 set from the given index element of the given array
  80505. * @param array defines the data source
  80506. * @param offset defines the offset in the data source
  80507. * @returns a new Vector2
  80508. */
  80509. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  80510. /**
  80511. * Sets "result" from the given index element of the given array
  80512. * @param array defines the data source
  80513. * @param offset defines the offset in the data source
  80514. * @param result defines the target vector
  80515. */
  80516. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  80517. /**
  80518. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  80519. * @param value1 defines 1st point of control
  80520. * @param value2 defines 2nd point of control
  80521. * @param value3 defines 3rd point of control
  80522. * @param value4 defines 4th point of control
  80523. * @param amount defines the interpolation factor
  80524. * @returns a new Vector2
  80525. */
  80526. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  80527. /**
  80528. * 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".
  80529. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  80530. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  80531. * @param value defines the value to clamp
  80532. * @param min defines the lower limit
  80533. * @param max defines the upper limit
  80534. * @returns a new Vector2
  80535. */
  80536. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  80537. /**
  80538. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  80539. * @param value1 defines the 1st control point
  80540. * @param tangent1 defines the outgoing tangent
  80541. * @param value2 defines the 2nd control point
  80542. * @param tangent2 defines the incoming tangent
  80543. * @param amount defines the interpolation factor
  80544. * @returns a new Vector2
  80545. */
  80546. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  80547. /**
  80548. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  80549. * @param start defines the start vector
  80550. * @param end defines the end vector
  80551. * @param amount defines the interpolation factor
  80552. * @returns a new Vector2
  80553. */
  80554. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  80555. /**
  80556. * Gets the dot product of the vector "left" and the vector "right"
  80557. * @param left defines first vector
  80558. * @param right defines second vector
  80559. * @returns the dot product (float)
  80560. */
  80561. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  80562. /**
  80563. * Returns a new Vector2 equal to the normalized given vector
  80564. * @param vector defines the vector to normalize
  80565. * @returns a new Vector2
  80566. */
  80567. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  80568. /**
  80569. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  80570. * @param left defines 1st vector
  80571. * @param right defines 2nd vector
  80572. * @returns a new Vector2
  80573. */
  80574. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80575. /**
  80576. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  80577. * @param left defines 1st vector
  80578. * @param right defines 2nd vector
  80579. * @returns a new Vector2
  80580. */
  80581. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80582. /**
  80583. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  80584. * @param vector defines the vector to transform
  80585. * @param transformation defines the matrix to apply
  80586. * @returns a new Vector2
  80587. */
  80588. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  80589. /**
  80590. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  80591. * @param vector defines the vector to transform
  80592. * @param transformation defines the matrix to apply
  80593. * @param result defines the target vector
  80594. */
  80595. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  80596. /**
  80597. * Determines if a given vector is included in a triangle
  80598. * @param p defines the vector to test
  80599. * @param p0 defines 1st triangle point
  80600. * @param p1 defines 2nd triangle point
  80601. * @param p2 defines 3rd triangle point
  80602. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  80603. */
  80604. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  80605. /**
  80606. * Gets the distance between the vectors "value1" and "value2"
  80607. * @param value1 defines first vector
  80608. * @param value2 defines second vector
  80609. * @returns the distance between vectors
  80610. */
  80611. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80612. /**
  80613. * Returns the squared distance between the vectors "value1" and "value2"
  80614. * @param value1 defines first vector
  80615. * @param value2 defines second vector
  80616. * @returns the squared distance between vectors
  80617. */
  80618. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80619. /**
  80620. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  80621. * @param value1 defines first vector
  80622. * @param value2 defines second vector
  80623. * @returns a new Vector2
  80624. */
  80625. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  80626. /**
  80627. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  80628. * @param p defines the middle point
  80629. * @param segA defines one point of the segment
  80630. * @param segB defines the other point of the segment
  80631. * @returns the shortest distance
  80632. */
  80633. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  80634. }
  80635. /**
  80636. * Class used to store (x,y,z) vector representation
  80637. * A Vector3 is the main object used in 3D geometry
  80638. * It can represent etiher the coordinates of a point the space, either a direction
  80639. * Reminder: js uses a left handed forward facing system
  80640. */
  80641. export class Vector3 {
  80642. private static _UpReadOnly;
  80643. private static _ZeroReadOnly;
  80644. /** @hidden */
  80645. _x: number;
  80646. /** @hidden */
  80647. _y: number;
  80648. /** @hidden */
  80649. _z: number;
  80650. /** @hidden */
  80651. _isDirty: boolean;
  80652. /** Gets or sets the x coordinate */
  80653. get x(): number;
  80654. set x(value: number);
  80655. /** Gets or sets the y coordinate */
  80656. get y(): number;
  80657. set y(value: number);
  80658. /** Gets or sets the z coordinate */
  80659. get z(): number;
  80660. set z(value: number);
  80661. /**
  80662. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  80663. * @param x defines the first coordinates (on X axis)
  80664. * @param y defines the second coordinates (on Y axis)
  80665. * @param z defines the third coordinates (on Z axis)
  80666. */
  80667. constructor(x?: number, y?: number, z?: number);
  80668. /**
  80669. * Creates a string representation of the Vector3
  80670. * @returns a string with the Vector3 coordinates.
  80671. */
  80672. toString(): string;
  80673. /**
  80674. * Gets the class name
  80675. * @returns the string "Vector3"
  80676. */
  80677. getClassName(): string;
  80678. /**
  80679. * Creates the Vector3 hash code
  80680. * @returns a number which tends to be unique between Vector3 instances
  80681. */
  80682. getHashCode(): number;
  80683. /**
  80684. * Creates an array containing three elements : the coordinates of the Vector3
  80685. * @returns a new array of numbers
  80686. */
  80687. asArray(): number[];
  80688. /**
  80689. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  80690. * @param array defines the destination array
  80691. * @param index defines the offset in the destination array
  80692. * @returns the current Vector3
  80693. */
  80694. toArray(array: FloatArray, index?: number): Vector3;
  80695. /**
  80696. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  80697. * @returns a new Quaternion object, computed from the Vector3 coordinates
  80698. */
  80699. toQuaternion(): Quaternion;
  80700. /**
  80701. * Adds the given vector to the current Vector3
  80702. * @param otherVector defines the second operand
  80703. * @returns the current updated Vector3
  80704. */
  80705. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80706. /**
  80707. * Adds the given coordinates to the current Vector3
  80708. * @param x defines the x coordinate of the operand
  80709. * @param y defines the y coordinate of the operand
  80710. * @param z defines the z coordinate of the operand
  80711. * @returns the current updated Vector3
  80712. */
  80713. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80714. /**
  80715. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  80716. * @param otherVector defines the second operand
  80717. * @returns the resulting Vector3
  80718. */
  80719. add(otherVector: DeepImmutable<Vector3>): Vector3;
  80720. /**
  80721. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  80722. * @param otherVector defines the second operand
  80723. * @param result defines the Vector3 object where to store the result
  80724. * @returns the current Vector3
  80725. */
  80726. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80727. /**
  80728. * Subtract the given vector from the current Vector3
  80729. * @param otherVector defines the second operand
  80730. * @returns the current updated Vector3
  80731. */
  80732. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80733. /**
  80734. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  80735. * @param otherVector defines the second operand
  80736. * @returns the resulting Vector3
  80737. */
  80738. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  80739. /**
  80740. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  80741. * @param otherVector defines the second operand
  80742. * @param result defines the Vector3 object where to store the result
  80743. * @returns the current Vector3
  80744. */
  80745. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80746. /**
  80747. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  80748. * @param x defines the x coordinate of the operand
  80749. * @param y defines the y coordinate of the operand
  80750. * @param z defines the z coordinate of the operand
  80751. * @returns the resulting Vector3
  80752. */
  80753. subtractFromFloats(x: number, y: number, z: number): Vector3;
  80754. /**
  80755. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  80756. * @param x defines the x coordinate of the operand
  80757. * @param y defines the y coordinate of the operand
  80758. * @param z defines the z coordinate of the operand
  80759. * @param result defines the Vector3 object where to store the result
  80760. * @returns the current Vector3
  80761. */
  80762. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  80763. /**
  80764. * Gets a new Vector3 set with the current Vector3 negated coordinates
  80765. * @returns a new Vector3
  80766. */
  80767. negate(): Vector3;
  80768. /**
  80769. * Negate this vector in place
  80770. * @returns this
  80771. */
  80772. negateInPlace(): Vector3;
  80773. /**
  80774. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  80775. * @param result defines the Vector3 object where to store the result
  80776. * @returns the current Vector3
  80777. */
  80778. negateToRef(result: Vector3): Vector3;
  80779. /**
  80780. * Multiplies the Vector3 coordinates by the float "scale"
  80781. * @param scale defines the multiplier factor
  80782. * @returns the current updated Vector3
  80783. */
  80784. scaleInPlace(scale: number): Vector3;
  80785. /**
  80786. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  80787. * @param scale defines the multiplier factor
  80788. * @returns a new Vector3
  80789. */
  80790. scale(scale: number): Vector3;
  80791. /**
  80792. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  80793. * @param scale defines the multiplier factor
  80794. * @param result defines the Vector3 object where to store the result
  80795. * @returns the current Vector3
  80796. */
  80797. scaleToRef(scale: number, result: Vector3): Vector3;
  80798. /**
  80799. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  80800. * @param scale defines the scale factor
  80801. * @param result defines the Vector3 object where to store the result
  80802. * @returns the unmodified current Vector3
  80803. */
  80804. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  80805. /**
  80806. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80807. * @param origin defines the origin of the projection ray
  80808. * @param plane defines the plane to project to
  80809. * @returns the projected vector3
  80810. */
  80811. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  80812. /**
  80813. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80814. * @param origin defines the origin of the projection ray
  80815. * @param plane defines the plane to project to
  80816. * @param result defines the Vector3 where to store the result
  80817. */
  80818. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  80819. /**
  80820. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  80821. * @param otherVector defines the second operand
  80822. * @returns true if both vectors are equals
  80823. */
  80824. equals(otherVector: DeepImmutable<Vector3>): boolean;
  80825. /**
  80826. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  80827. * @param otherVector defines the second operand
  80828. * @param epsilon defines the minimal distance to define values as equals
  80829. * @returns true if both vectors are distant less than epsilon
  80830. */
  80831. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  80832. /**
  80833. * Returns true if the current Vector3 coordinates equals the given floats
  80834. * @param x defines the x coordinate of the operand
  80835. * @param y defines the y coordinate of the operand
  80836. * @param z defines the z coordinate of the operand
  80837. * @returns true if both vectors are equals
  80838. */
  80839. equalsToFloats(x: number, y: number, z: number): boolean;
  80840. /**
  80841. * Multiplies the current Vector3 coordinates by the given ones
  80842. * @param otherVector defines the second operand
  80843. * @returns the current updated Vector3
  80844. */
  80845. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80846. /**
  80847. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  80848. * @param otherVector defines the second operand
  80849. * @returns the new Vector3
  80850. */
  80851. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  80852. /**
  80853. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  80854. * @param otherVector defines the second operand
  80855. * @param result defines the Vector3 object where to store the result
  80856. * @returns the current Vector3
  80857. */
  80858. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80859. /**
  80860. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  80861. * @param x defines the x coordinate of the operand
  80862. * @param y defines the y coordinate of the operand
  80863. * @param z defines the z coordinate of the operand
  80864. * @returns the new Vector3
  80865. */
  80866. multiplyByFloats(x: number, y: number, z: number): Vector3;
  80867. /**
  80868. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  80869. * @param otherVector defines the second operand
  80870. * @returns the new Vector3
  80871. */
  80872. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  80873. /**
  80874. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  80875. * @param otherVector defines the second operand
  80876. * @param result defines the Vector3 object where to store the result
  80877. * @returns the current Vector3
  80878. */
  80879. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80880. /**
  80881. * Divides the current Vector3 coordinates by the given ones.
  80882. * @param otherVector defines the second operand
  80883. * @returns the current updated Vector3
  80884. */
  80885. divideInPlace(otherVector: Vector3): Vector3;
  80886. /**
  80887. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  80888. * @param other defines the second operand
  80889. * @returns the current updated Vector3
  80890. */
  80891. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80892. /**
  80893. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  80894. * @param other defines the second operand
  80895. * @returns the current updated Vector3
  80896. */
  80897. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80898. /**
  80899. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  80900. * @param x defines the x coordinate of the operand
  80901. * @param y defines the y coordinate of the operand
  80902. * @param z defines the z coordinate of the operand
  80903. * @returns the current updated Vector3
  80904. */
  80905. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80906. /**
  80907. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  80908. * @param x defines the x coordinate of the operand
  80909. * @param y defines the y coordinate of the operand
  80910. * @param z defines the z coordinate of the operand
  80911. * @returns the current updated Vector3
  80912. */
  80913. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80914. /**
  80915. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  80916. * Check if is non uniform within a certain amount of decimal places to account for this
  80917. * @param epsilon the amount the values can differ
  80918. * @returns if the the vector is non uniform to a certain number of decimal places
  80919. */
  80920. isNonUniformWithinEpsilon(epsilon: number): boolean;
  80921. /**
  80922. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  80923. */
  80924. get isNonUniform(): boolean;
  80925. /**
  80926. * Gets a new Vector3 from current Vector3 floored values
  80927. * @returns a new Vector3
  80928. */
  80929. floor(): Vector3;
  80930. /**
  80931. * Gets a new Vector3 from current Vector3 floored values
  80932. * @returns a new Vector3
  80933. */
  80934. fract(): Vector3;
  80935. /**
  80936. * Gets the length of the Vector3
  80937. * @returns the length of the Vector3
  80938. */
  80939. length(): number;
  80940. /**
  80941. * Gets the squared length of the Vector3
  80942. * @returns squared length of the Vector3
  80943. */
  80944. lengthSquared(): number;
  80945. /**
  80946. * Normalize the current Vector3.
  80947. * Please note that this is an in place operation.
  80948. * @returns the current updated Vector3
  80949. */
  80950. normalize(): Vector3;
  80951. /**
  80952. * Reorders the x y z properties of the vector in place
  80953. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  80954. * @returns the current updated vector
  80955. */
  80956. reorderInPlace(order: string): this;
  80957. /**
  80958. * Rotates the vector around 0,0,0 by a quaternion
  80959. * @param quaternion the rotation quaternion
  80960. * @param result vector to store the result
  80961. * @returns the resulting vector
  80962. */
  80963. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  80964. /**
  80965. * Rotates a vector around a given point
  80966. * @param quaternion the rotation quaternion
  80967. * @param point the point to rotate around
  80968. * @param result vector to store the result
  80969. * @returns the resulting vector
  80970. */
  80971. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  80972. /**
  80973. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  80974. * The cross product is then orthogonal to both current and "other"
  80975. * @param other defines the right operand
  80976. * @returns the cross product
  80977. */
  80978. cross(other: Vector3): Vector3;
  80979. /**
  80980. * Normalize the current Vector3 with the given input length.
  80981. * Please note that this is an in place operation.
  80982. * @param len the length of the vector
  80983. * @returns the current updated Vector3
  80984. */
  80985. normalizeFromLength(len: number): Vector3;
  80986. /**
  80987. * Normalize the current Vector3 to a new vector
  80988. * @returns the new Vector3
  80989. */
  80990. normalizeToNew(): Vector3;
  80991. /**
  80992. * Normalize the current Vector3 to the reference
  80993. * @param reference define the Vector3 to update
  80994. * @returns the updated Vector3
  80995. */
  80996. normalizeToRef(reference: Vector3): Vector3;
  80997. /**
  80998. * Creates a new Vector3 copied from the current Vector3
  80999. * @returns the new Vector3
  81000. */
  81001. clone(): Vector3;
  81002. /**
  81003. * Copies the given vector coordinates to the current Vector3 ones
  81004. * @param source defines the source Vector3
  81005. * @returns the current updated Vector3
  81006. */
  81007. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81008. /**
  81009. * Copies the given floats to the current Vector3 coordinates
  81010. * @param x defines the x coordinate of the operand
  81011. * @param y defines the y coordinate of the operand
  81012. * @param z defines the z coordinate of the operand
  81013. * @returns the current updated Vector3
  81014. */
  81015. copyFromFloats(x: number, y: number, z: number): Vector3;
  81016. /**
  81017. * Copies the given floats to the current Vector3 coordinates
  81018. * @param x defines the x coordinate of the operand
  81019. * @param y defines the y coordinate of the operand
  81020. * @param z defines the z coordinate of the operand
  81021. * @returns the current updated Vector3
  81022. */
  81023. set(x: number, y: number, z: number): Vector3;
  81024. /**
  81025. * Copies the given float to the current Vector3 coordinates
  81026. * @param v defines the x, y and z coordinates of the operand
  81027. * @returns the current updated Vector3
  81028. */
  81029. setAll(v: number): Vector3;
  81030. /**
  81031. * Get the clip factor between two vectors
  81032. * @param vector0 defines the first operand
  81033. * @param vector1 defines the second operand
  81034. * @param axis defines the axis to use
  81035. * @param size defines the size along the axis
  81036. * @returns the clip factor
  81037. */
  81038. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81039. /**
  81040. * Get angle between two vectors
  81041. * @param vector0 angle between vector0 and vector1
  81042. * @param vector1 angle between vector0 and vector1
  81043. * @param normal direction of the normal
  81044. * @return the angle between vector0 and vector1
  81045. */
  81046. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81047. /**
  81048. * Returns a new Vector3 set from the index "offset" of the given array
  81049. * @param array defines the source array
  81050. * @param offset defines the offset in the source array
  81051. * @returns the new Vector3
  81052. */
  81053. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81054. /**
  81055. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81056. * @param array defines the source array
  81057. * @param offset defines the offset in the source array
  81058. * @returns the new Vector3
  81059. * @deprecated Please use FromArray instead.
  81060. */
  81061. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81062. /**
  81063. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81064. * @param array defines the source array
  81065. * @param offset defines the offset in the source array
  81066. * @param result defines the Vector3 where to store the result
  81067. */
  81068. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81069. /**
  81070. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81071. * @param array defines the source array
  81072. * @param offset defines the offset in the source array
  81073. * @param result defines the Vector3 where to store the result
  81074. * @deprecated Please use FromArrayToRef instead.
  81075. */
  81076. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81077. /**
  81078. * Sets the given vector "result" with the given floats.
  81079. * @param x defines the x coordinate of the source
  81080. * @param y defines the y coordinate of the source
  81081. * @param z defines the z coordinate of the source
  81082. * @param result defines the Vector3 where to store the result
  81083. */
  81084. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81085. /**
  81086. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81087. * @returns a new empty Vector3
  81088. */
  81089. static Zero(): Vector3;
  81090. /**
  81091. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81092. * @returns a new unit Vector3
  81093. */
  81094. static One(): Vector3;
  81095. /**
  81096. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81097. * @returns a new up Vector3
  81098. */
  81099. static Up(): Vector3;
  81100. /**
  81101. * Gets a up Vector3 that must not be updated
  81102. */
  81103. static get UpReadOnly(): DeepImmutable<Vector3>;
  81104. /**
  81105. * Gets a zero Vector3 that must not be updated
  81106. */
  81107. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81108. /**
  81109. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81110. * @returns a new down Vector3
  81111. */
  81112. static Down(): Vector3;
  81113. /**
  81114. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81115. * @param rightHandedSystem is the scene right-handed (negative z)
  81116. * @returns a new forward Vector3
  81117. */
  81118. static Forward(rightHandedSystem?: boolean): Vector3;
  81119. /**
  81120. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81121. * @param rightHandedSystem is the scene right-handed (negative-z)
  81122. * @returns a new forward Vector3
  81123. */
  81124. static Backward(rightHandedSystem?: boolean): Vector3;
  81125. /**
  81126. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81127. * @returns a new right Vector3
  81128. */
  81129. static Right(): Vector3;
  81130. /**
  81131. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81132. * @returns a new left Vector3
  81133. */
  81134. static Left(): Vector3;
  81135. /**
  81136. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  81137. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81138. * @param vector defines the Vector3 to transform
  81139. * @param transformation defines the transformation matrix
  81140. * @returns the transformed Vector3
  81141. */
  81142. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81143. /**
  81144. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  81145. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81146. * @param vector defines the Vector3 to transform
  81147. * @param transformation defines the transformation matrix
  81148. * @param result defines the Vector3 where to store the result
  81149. */
  81150. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81151. /**
  81152. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  81153. * This method computes tranformed coordinates only, not transformed direction vectors
  81154. * @param x define the x coordinate of the source vector
  81155. * @param y define the y coordinate of the source vector
  81156. * @param z define the z coordinate of the source vector
  81157. * @param transformation defines the transformation matrix
  81158. * @param result defines the Vector3 where to store the result
  81159. */
  81160. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81161. /**
  81162. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  81163. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81164. * @param vector defines the Vector3 to transform
  81165. * @param transformation defines the transformation matrix
  81166. * @returns the new Vector3
  81167. */
  81168. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81169. /**
  81170. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  81171. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81172. * @param vector defines the Vector3 to transform
  81173. * @param transformation defines the transformation matrix
  81174. * @param result defines the Vector3 where to store the result
  81175. */
  81176. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81177. /**
  81178. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  81179. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81180. * @param x define the x coordinate of the source vector
  81181. * @param y define the y coordinate of the source vector
  81182. * @param z define the z coordinate of the source vector
  81183. * @param transformation defines the transformation matrix
  81184. * @param result defines the Vector3 where to store the result
  81185. */
  81186. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81187. /**
  81188. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  81189. * @param value1 defines the first control point
  81190. * @param value2 defines the second control point
  81191. * @param value3 defines the third control point
  81192. * @param value4 defines the fourth control point
  81193. * @param amount defines the amount on the spline to use
  81194. * @returns the new Vector3
  81195. */
  81196. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  81197. /**
  81198. * 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"
  81199. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81200. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81201. * @param value defines the current value
  81202. * @param min defines the lower range value
  81203. * @param max defines the upper range value
  81204. * @returns the new Vector3
  81205. */
  81206. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  81207. /**
  81208. * 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"
  81209. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81210. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81211. * @param value defines the current value
  81212. * @param min defines the lower range value
  81213. * @param max defines the upper range value
  81214. * @param result defines the Vector3 where to store the result
  81215. */
  81216. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  81217. /**
  81218. * Checks if a given vector is inside a specific range
  81219. * @param v defines the vector to test
  81220. * @param min defines the minimum range
  81221. * @param max defines the maximum range
  81222. */
  81223. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  81224. /**
  81225. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  81226. * @param value1 defines the first control point
  81227. * @param tangent1 defines the first tangent vector
  81228. * @param value2 defines the second control point
  81229. * @param tangent2 defines the second tangent vector
  81230. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  81231. * @returns the new Vector3
  81232. */
  81233. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  81234. /**
  81235. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  81236. * @param start defines the start value
  81237. * @param end defines the end value
  81238. * @param amount max defines amount between both (between 0 and 1)
  81239. * @returns the new Vector3
  81240. */
  81241. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  81242. /**
  81243. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  81244. * @param start defines the start value
  81245. * @param end defines the end value
  81246. * @param amount max defines amount between both (between 0 and 1)
  81247. * @param result defines the Vector3 where to store the result
  81248. */
  81249. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  81250. /**
  81251. * Returns the dot product (float) between the vectors "left" and "right"
  81252. * @param left defines the left operand
  81253. * @param right defines the right operand
  81254. * @returns the dot product
  81255. */
  81256. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  81257. /**
  81258. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  81259. * The cross product is then orthogonal to both "left" and "right"
  81260. * @param left defines the left operand
  81261. * @param right defines the right operand
  81262. * @returns the cross product
  81263. */
  81264. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81265. /**
  81266. * Sets the given vector "result" with the cross product of "left" and "right"
  81267. * The cross product is then orthogonal to both "left" and "right"
  81268. * @param left defines the left operand
  81269. * @param right defines the right operand
  81270. * @param result defines the Vector3 where to store the result
  81271. */
  81272. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  81273. /**
  81274. * Returns a new Vector3 as the normalization of the given vector
  81275. * @param vector defines the Vector3 to normalize
  81276. * @returns the new Vector3
  81277. */
  81278. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  81279. /**
  81280. * Sets the given vector "result" with the normalization of the given first vector
  81281. * @param vector defines the Vector3 to normalize
  81282. * @param result defines the Vector3 where to store the result
  81283. */
  81284. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  81285. /**
  81286. * Project a Vector3 onto screen space
  81287. * @param vector defines the Vector3 to project
  81288. * @param world defines the world matrix to use
  81289. * @param transform defines the transform (view x projection) matrix to use
  81290. * @param viewport defines the screen viewport to use
  81291. * @returns the new Vector3
  81292. */
  81293. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  81294. /** @hidden */
  81295. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  81296. /**
  81297. * Unproject from screen space to object space
  81298. * @param source defines the screen space Vector3 to use
  81299. * @param viewportWidth defines the current width of the viewport
  81300. * @param viewportHeight defines the current height of the viewport
  81301. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81302. * @param transform defines the transform (view x projection) matrix to use
  81303. * @returns the new Vector3
  81304. */
  81305. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  81306. /**
  81307. * Unproject from screen space to object space
  81308. * @param source defines the screen space Vector3 to use
  81309. * @param viewportWidth defines the current width of the viewport
  81310. * @param viewportHeight defines the current height of the viewport
  81311. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81312. * @param view defines the view matrix to use
  81313. * @param projection defines the projection matrix to use
  81314. * @returns the new Vector3
  81315. */
  81316. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  81317. /**
  81318. * Unproject from screen space to object space
  81319. * @param source defines the screen space Vector3 to use
  81320. * @param viewportWidth defines the current width of the viewport
  81321. * @param viewportHeight defines the current height of the viewport
  81322. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81323. * @param view defines the view matrix to use
  81324. * @param projection defines the projection matrix to use
  81325. * @param result defines the Vector3 where to store the result
  81326. */
  81327. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81328. /**
  81329. * Unproject from screen space to object space
  81330. * @param sourceX defines the screen space x coordinate to use
  81331. * @param sourceY defines the screen space y coordinate to use
  81332. * @param sourceZ defines the screen space z coordinate to use
  81333. * @param viewportWidth defines the current width of the viewport
  81334. * @param viewportHeight defines the current height of the viewport
  81335. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81336. * @param view defines the view matrix to use
  81337. * @param projection defines the projection matrix to use
  81338. * @param result defines the Vector3 where to store the result
  81339. */
  81340. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81341. /**
  81342. * Gets the minimal coordinate values between two Vector3
  81343. * @param left defines the first operand
  81344. * @param right defines the second operand
  81345. * @returns the new Vector3
  81346. */
  81347. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81348. /**
  81349. * Gets the maximal coordinate values between two Vector3
  81350. * @param left defines the first operand
  81351. * @param right defines the second operand
  81352. * @returns the new Vector3
  81353. */
  81354. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81355. /**
  81356. * Returns the distance between the vectors "value1" and "value2"
  81357. * @param value1 defines the first operand
  81358. * @param value2 defines the second operand
  81359. * @returns the distance
  81360. */
  81361. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81362. /**
  81363. * Returns the squared distance between the vectors "value1" and "value2"
  81364. * @param value1 defines the first operand
  81365. * @param value2 defines the second operand
  81366. * @returns the squared distance
  81367. */
  81368. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81369. /**
  81370. * Returns a new Vector3 located at the center between "value1" and "value2"
  81371. * @param value1 defines the first operand
  81372. * @param value2 defines the second operand
  81373. * @returns the new Vector3
  81374. */
  81375. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  81376. /**
  81377. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  81378. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  81379. * to something in order to rotate it from its local system to the given target system
  81380. * Note: axis1, axis2 and axis3 are normalized during this operation
  81381. * @param axis1 defines the first axis
  81382. * @param axis2 defines the second axis
  81383. * @param axis3 defines the third axis
  81384. * @returns a new Vector3
  81385. */
  81386. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  81387. /**
  81388. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  81389. * @param axis1 defines the first axis
  81390. * @param axis2 defines the second axis
  81391. * @param axis3 defines the third axis
  81392. * @param ref defines the Vector3 where to store the result
  81393. */
  81394. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  81395. }
  81396. /**
  81397. * Vector4 class created for EulerAngle class conversion to Quaternion
  81398. */
  81399. export class Vector4 {
  81400. /** x value of the vector */
  81401. x: number;
  81402. /** y value of the vector */
  81403. y: number;
  81404. /** z value of the vector */
  81405. z: number;
  81406. /** w value of the vector */
  81407. w: number;
  81408. /**
  81409. * Creates a Vector4 object from the given floats.
  81410. * @param x x value of the vector
  81411. * @param y y value of the vector
  81412. * @param z z value of the vector
  81413. * @param w w value of the vector
  81414. */
  81415. constructor(
  81416. /** x value of the vector */
  81417. x: number,
  81418. /** y value of the vector */
  81419. y: number,
  81420. /** z value of the vector */
  81421. z: number,
  81422. /** w value of the vector */
  81423. w: number);
  81424. /**
  81425. * Returns the string with the Vector4 coordinates.
  81426. * @returns a string containing all the vector values
  81427. */
  81428. toString(): string;
  81429. /**
  81430. * Returns the string "Vector4".
  81431. * @returns "Vector4"
  81432. */
  81433. getClassName(): string;
  81434. /**
  81435. * Returns the Vector4 hash code.
  81436. * @returns a unique hash code
  81437. */
  81438. getHashCode(): number;
  81439. /**
  81440. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  81441. * @returns the resulting array
  81442. */
  81443. asArray(): number[];
  81444. /**
  81445. * Populates the given array from the given index with the Vector4 coordinates.
  81446. * @param array array to populate
  81447. * @param index index of the array to start at (default: 0)
  81448. * @returns the Vector4.
  81449. */
  81450. toArray(array: FloatArray, index?: number): Vector4;
  81451. /**
  81452. * Adds the given vector to the current Vector4.
  81453. * @param otherVector the vector to add
  81454. * @returns the updated Vector4.
  81455. */
  81456. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81457. /**
  81458. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  81459. * @param otherVector the vector to add
  81460. * @returns the resulting vector
  81461. */
  81462. add(otherVector: DeepImmutable<Vector4>): Vector4;
  81463. /**
  81464. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  81465. * @param otherVector the vector to add
  81466. * @param result the vector to store the result
  81467. * @returns the current Vector4.
  81468. */
  81469. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81470. /**
  81471. * Subtract in place the given vector from the current Vector4.
  81472. * @param otherVector the vector to subtract
  81473. * @returns the updated Vector4.
  81474. */
  81475. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81476. /**
  81477. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  81478. * @param otherVector the vector to add
  81479. * @returns the new vector with the result
  81480. */
  81481. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  81482. /**
  81483. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  81484. * @param otherVector the vector to subtract
  81485. * @param result the vector to store the result
  81486. * @returns the current Vector4.
  81487. */
  81488. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81489. /**
  81490. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81491. */
  81492. /**
  81493. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81494. * @param x value to subtract
  81495. * @param y value to subtract
  81496. * @param z value to subtract
  81497. * @param w value to subtract
  81498. * @returns new vector containing the result
  81499. */
  81500. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81501. /**
  81502. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81503. * @param x value to subtract
  81504. * @param y value to subtract
  81505. * @param z value to subtract
  81506. * @param w value to subtract
  81507. * @param result the vector to store the result in
  81508. * @returns the current Vector4.
  81509. */
  81510. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  81511. /**
  81512. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  81513. * @returns a new vector with the negated values
  81514. */
  81515. negate(): Vector4;
  81516. /**
  81517. * Negate this vector in place
  81518. * @returns this
  81519. */
  81520. negateInPlace(): Vector4;
  81521. /**
  81522. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  81523. * @param result defines the Vector3 object where to store the result
  81524. * @returns the current Vector4
  81525. */
  81526. negateToRef(result: Vector4): Vector4;
  81527. /**
  81528. * Multiplies the current Vector4 coordinates by scale (float).
  81529. * @param scale the number to scale with
  81530. * @returns the updated Vector4.
  81531. */
  81532. scaleInPlace(scale: number): Vector4;
  81533. /**
  81534. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  81535. * @param scale the number to scale with
  81536. * @returns a new vector with the result
  81537. */
  81538. scale(scale: number): Vector4;
  81539. /**
  81540. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  81541. * @param scale the number to scale with
  81542. * @param result a vector to store the result in
  81543. * @returns the current Vector4.
  81544. */
  81545. scaleToRef(scale: number, result: Vector4): Vector4;
  81546. /**
  81547. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  81548. * @param scale defines the scale factor
  81549. * @param result defines the Vector4 object where to store the result
  81550. * @returns the unmodified current Vector4
  81551. */
  81552. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  81553. /**
  81554. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  81555. * @param otherVector the vector to compare against
  81556. * @returns true if they are equal
  81557. */
  81558. equals(otherVector: DeepImmutable<Vector4>): boolean;
  81559. /**
  81560. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  81561. * @param otherVector vector to compare against
  81562. * @param epsilon (Default: very small number)
  81563. * @returns true if they are equal
  81564. */
  81565. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  81566. /**
  81567. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  81568. * @param x x value to compare against
  81569. * @param y y value to compare against
  81570. * @param z z value to compare against
  81571. * @param w w value to compare against
  81572. * @returns true if equal
  81573. */
  81574. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  81575. /**
  81576. * Multiplies in place the current Vector4 by the given one.
  81577. * @param otherVector vector to multiple with
  81578. * @returns the updated Vector4.
  81579. */
  81580. multiplyInPlace(otherVector: Vector4): Vector4;
  81581. /**
  81582. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  81583. * @param otherVector vector to multiple with
  81584. * @returns resulting new vector
  81585. */
  81586. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  81587. /**
  81588. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  81589. * @param otherVector vector to multiple with
  81590. * @param result vector to store the result
  81591. * @returns the current Vector4.
  81592. */
  81593. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81594. /**
  81595. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  81596. * @param x x value multiply with
  81597. * @param y y value multiply with
  81598. * @param z z value multiply with
  81599. * @param w w value multiply with
  81600. * @returns resulting new vector
  81601. */
  81602. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  81603. /**
  81604. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  81605. * @param otherVector vector to devide with
  81606. * @returns resulting new vector
  81607. */
  81608. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  81609. /**
  81610. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  81611. * @param otherVector vector to devide with
  81612. * @param result vector to store the result
  81613. * @returns the current Vector4.
  81614. */
  81615. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81616. /**
  81617. * Divides the current Vector3 coordinates by the given ones.
  81618. * @param otherVector vector to devide with
  81619. * @returns the updated Vector3.
  81620. */
  81621. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81622. /**
  81623. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  81624. * @param other defines the second operand
  81625. * @returns the current updated Vector4
  81626. */
  81627. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81628. /**
  81629. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  81630. * @param other defines the second operand
  81631. * @returns the current updated Vector4
  81632. */
  81633. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81634. /**
  81635. * Gets a new Vector4 from current Vector4 floored values
  81636. * @returns a new Vector4
  81637. */
  81638. floor(): Vector4;
  81639. /**
  81640. * Gets a new Vector4 from current Vector3 floored values
  81641. * @returns a new Vector4
  81642. */
  81643. fract(): Vector4;
  81644. /**
  81645. * Returns the Vector4 length (float).
  81646. * @returns the length
  81647. */
  81648. length(): number;
  81649. /**
  81650. * Returns the Vector4 squared length (float).
  81651. * @returns the length squared
  81652. */
  81653. lengthSquared(): number;
  81654. /**
  81655. * Normalizes in place the Vector4.
  81656. * @returns the updated Vector4.
  81657. */
  81658. normalize(): Vector4;
  81659. /**
  81660. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  81661. * @returns this converted to a new vector3
  81662. */
  81663. toVector3(): Vector3;
  81664. /**
  81665. * Returns a new Vector4 copied from the current one.
  81666. * @returns the new cloned vector
  81667. */
  81668. clone(): Vector4;
  81669. /**
  81670. * Updates the current Vector4 with the given one coordinates.
  81671. * @param source the source vector to copy from
  81672. * @returns the updated Vector4.
  81673. */
  81674. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  81675. /**
  81676. * Updates the current Vector4 coordinates with the given floats.
  81677. * @param x float to copy from
  81678. * @param y float to copy from
  81679. * @param z float to copy from
  81680. * @param w float to copy from
  81681. * @returns the updated Vector4.
  81682. */
  81683. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81684. /**
  81685. * Updates the current Vector4 coordinates with the given floats.
  81686. * @param x float to set from
  81687. * @param y float to set from
  81688. * @param z float to set from
  81689. * @param w float to set from
  81690. * @returns the updated Vector4.
  81691. */
  81692. set(x: number, y: number, z: number, w: number): Vector4;
  81693. /**
  81694. * Copies the given float to the current Vector3 coordinates
  81695. * @param v defines the x, y, z and w coordinates of the operand
  81696. * @returns the current updated Vector3
  81697. */
  81698. setAll(v: number): Vector4;
  81699. /**
  81700. * Returns a new Vector4 set from the starting index of the given array.
  81701. * @param array the array to pull values from
  81702. * @param offset the offset into the array to start at
  81703. * @returns the new vector
  81704. */
  81705. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  81706. /**
  81707. * Updates the given vector "result" from the starting index of the given array.
  81708. * @param array the array to pull values from
  81709. * @param offset the offset into the array to start at
  81710. * @param result the vector to store the result in
  81711. */
  81712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  81713. /**
  81714. * Updates the given vector "result" from the starting index of the given Float32Array.
  81715. * @param array the array to pull values from
  81716. * @param offset the offset into the array to start at
  81717. * @param result the vector to store the result in
  81718. */
  81719. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  81720. /**
  81721. * Updates the given vector "result" coordinates from the given floats.
  81722. * @param x float to set from
  81723. * @param y float to set from
  81724. * @param z float to set from
  81725. * @param w float to set from
  81726. * @param result the vector to the floats in
  81727. */
  81728. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  81729. /**
  81730. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  81731. * @returns the new vector
  81732. */
  81733. static Zero(): Vector4;
  81734. /**
  81735. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  81736. * @returns the new vector
  81737. */
  81738. static One(): Vector4;
  81739. /**
  81740. * Returns a new normalized Vector4 from the given one.
  81741. * @param vector the vector to normalize
  81742. * @returns the vector
  81743. */
  81744. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  81745. /**
  81746. * Updates the given vector "result" from the normalization of the given one.
  81747. * @param vector the vector to normalize
  81748. * @param result the vector to store the result in
  81749. */
  81750. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  81751. /**
  81752. * Returns a vector with the minimum values from the left and right vectors
  81753. * @param left left vector to minimize
  81754. * @param right right vector to minimize
  81755. * @returns a new vector with the minimum of the left and right vector values
  81756. */
  81757. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81758. /**
  81759. * Returns a vector with the maximum values from the left and right vectors
  81760. * @param left left vector to maximize
  81761. * @param right right vector to maximize
  81762. * @returns a new vector with the maximum of the left and right vector values
  81763. */
  81764. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81765. /**
  81766. * Returns the distance (float) between the vectors "value1" and "value2".
  81767. * @param value1 value to calulate the distance between
  81768. * @param value2 value to calulate the distance between
  81769. * @return the distance between the two vectors
  81770. */
  81771. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81772. /**
  81773. * Returns the squared distance (float) between the vectors "value1" and "value2".
  81774. * @param value1 value to calulate the distance between
  81775. * @param value2 value to calulate the distance between
  81776. * @return the distance between the two vectors squared
  81777. */
  81778. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81779. /**
  81780. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  81781. * @param value1 value to calulate the center between
  81782. * @param value2 value to calulate the center between
  81783. * @return the center between the two vectors
  81784. */
  81785. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  81786. /**
  81787. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  81788. * This methods computes transformed normalized direction vectors only.
  81789. * @param vector the vector to transform
  81790. * @param transformation the transformation matrix to apply
  81791. * @returns the new vector
  81792. */
  81793. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  81794. /**
  81795. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  81796. * This methods computes transformed normalized direction vectors only.
  81797. * @param vector the vector to transform
  81798. * @param transformation the transformation matrix to apply
  81799. * @param result the vector to store the result in
  81800. */
  81801. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81802. /**
  81803. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  81804. * This methods computes transformed normalized direction vectors only.
  81805. * @param x value to transform
  81806. * @param y value to transform
  81807. * @param z value to transform
  81808. * @param w value to transform
  81809. * @param transformation the transformation matrix to apply
  81810. * @param result the vector to store the results in
  81811. */
  81812. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81813. /**
  81814. * Creates a new Vector4 from a Vector3
  81815. * @param source defines the source data
  81816. * @param w defines the 4th component (default is 0)
  81817. * @returns a new Vector4
  81818. */
  81819. static FromVector3(source: Vector3, w?: number): Vector4;
  81820. }
  81821. /**
  81822. * Class used to store quaternion data
  81823. * @see https://en.wikipedia.org/wiki/Quaternion
  81824. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  81825. */
  81826. export class Quaternion {
  81827. /** @hidden */
  81828. _x: number;
  81829. /** @hidden */
  81830. _y: number;
  81831. /** @hidden */
  81832. _z: number;
  81833. /** @hidden */
  81834. _w: number;
  81835. /** @hidden */
  81836. _isDirty: boolean;
  81837. /** Gets or sets the x coordinate */
  81838. get x(): number;
  81839. set x(value: number);
  81840. /** Gets or sets the y coordinate */
  81841. get y(): number;
  81842. set y(value: number);
  81843. /** Gets or sets the z coordinate */
  81844. get z(): number;
  81845. set z(value: number);
  81846. /** Gets or sets the w coordinate */
  81847. get w(): number;
  81848. set w(value: number);
  81849. /**
  81850. * Creates a new Quaternion from the given floats
  81851. * @param x defines the first component (0 by default)
  81852. * @param y defines the second component (0 by default)
  81853. * @param z defines the third component (0 by default)
  81854. * @param w defines the fourth component (1.0 by default)
  81855. */
  81856. constructor(x?: number, y?: number, z?: number, w?: number);
  81857. /**
  81858. * Gets a string representation for the current quaternion
  81859. * @returns a string with the Quaternion coordinates
  81860. */
  81861. toString(): string;
  81862. /**
  81863. * Gets the class name of the quaternion
  81864. * @returns the string "Quaternion"
  81865. */
  81866. getClassName(): string;
  81867. /**
  81868. * Gets a hash code for this quaternion
  81869. * @returns the quaternion hash code
  81870. */
  81871. getHashCode(): number;
  81872. /**
  81873. * Copy the quaternion to an array
  81874. * @returns a new array populated with 4 elements from the quaternion coordinates
  81875. */
  81876. asArray(): number[];
  81877. /**
  81878. * Check if two quaternions are equals
  81879. * @param otherQuaternion defines the second operand
  81880. * @return true if the current quaternion and the given one coordinates are strictly equals
  81881. */
  81882. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  81883. /**
  81884. * Gets a boolean if two quaternions are equals (using an epsilon value)
  81885. * @param otherQuaternion defines the other quaternion
  81886. * @param epsilon defines the minimal distance to consider equality
  81887. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  81888. */
  81889. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  81890. /**
  81891. * Clone the current quaternion
  81892. * @returns a new quaternion copied from the current one
  81893. */
  81894. clone(): Quaternion;
  81895. /**
  81896. * Copy a quaternion to the current one
  81897. * @param other defines the other quaternion
  81898. * @returns the updated current quaternion
  81899. */
  81900. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  81901. /**
  81902. * Updates the current quaternion with the given float coordinates
  81903. * @param x defines the x coordinate
  81904. * @param y defines the y coordinate
  81905. * @param z defines the z coordinate
  81906. * @param w defines the w coordinate
  81907. * @returns the updated current quaternion
  81908. */
  81909. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  81910. /**
  81911. * Updates the current quaternion from the given float coordinates
  81912. * @param x defines the x coordinate
  81913. * @param y defines the y coordinate
  81914. * @param z defines the z coordinate
  81915. * @param w defines the w coordinate
  81916. * @returns the updated current quaternion
  81917. */
  81918. set(x: number, y: number, z: number, w: number): Quaternion;
  81919. /**
  81920. * Adds two quaternions
  81921. * @param other defines the second operand
  81922. * @returns a new quaternion as the addition result of the given one and the current quaternion
  81923. */
  81924. add(other: DeepImmutable<Quaternion>): Quaternion;
  81925. /**
  81926. * Add a quaternion to the current one
  81927. * @param other defines the quaternion to add
  81928. * @returns the current quaternion
  81929. */
  81930. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  81931. /**
  81932. * Subtract two quaternions
  81933. * @param other defines the second operand
  81934. * @returns a new quaternion as the subtraction result of the given one from the current one
  81935. */
  81936. subtract(other: Quaternion): Quaternion;
  81937. /**
  81938. * Multiplies the current quaternion by a scale factor
  81939. * @param value defines the scale factor
  81940. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  81941. */
  81942. scale(value: number): Quaternion;
  81943. /**
  81944. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  81945. * @param scale defines the scale factor
  81946. * @param result defines the Quaternion object where to store the result
  81947. * @returns the unmodified current quaternion
  81948. */
  81949. scaleToRef(scale: number, result: Quaternion): Quaternion;
  81950. /**
  81951. * Multiplies in place the current quaternion by a scale factor
  81952. * @param value defines the scale factor
  81953. * @returns the current modified quaternion
  81954. */
  81955. scaleInPlace(value: number): Quaternion;
  81956. /**
  81957. * Scale the current quaternion values by a factor and add the result to a given quaternion
  81958. * @param scale defines the scale factor
  81959. * @param result defines the Quaternion object where to store the result
  81960. * @returns the unmodified current quaternion
  81961. */
  81962. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  81963. /**
  81964. * Multiplies two quaternions
  81965. * @param q1 defines the second operand
  81966. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  81967. */
  81968. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  81969. /**
  81970. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  81971. * @param q1 defines the second operand
  81972. * @param result defines the target quaternion
  81973. * @returns the current quaternion
  81974. */
  81975. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  81976. /**
  81977. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  81978. * @param q1 defines the second operand
  81979. * @returns the currentupdated quaternion
  81980. */
  81981. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  81982. /**
  81983. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  81984. * @param ref defines the target quaternion
  81985. * @returns the current quaternion
  81986. */
  81987. conjugateToRef(ref: Quaternion): Quaternion;
  81988. /**
  81989. * Conjugates in place (1-q) the current quaternion
  81990. * @returns the current updated quaternion
  81991. */
  81992. conjugateInPlace(): Quaternion;
  81993. /**
  81994. * Conjugates in place (1-q) the current quaternion
  81995. * @returns a new quaternion
  81996. */
  81997. conjugate(): Quaternion;
  81998. /**
  81999. * Gets length of current quaternion
  82000. * @returns the quaternion length (float)
  82001. */
  82002. length(): number;
  82003. /**
  82004. * Normalize in place the current quaternion
  82005. * @returns the current updated quaternion
  82006. */
  82007. normalize(): Quaternion;
  82008. /**
  82009. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82010. * @param order is a reserved parameter and is ignore for now
  82011. * @returns a new Vector3 containing the Euler angles
  82012. */
  82013. toEulerAngles(order?: string): Vector3;
  82014. /**
  82015. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82016. * @param result defines the vector which will be filled with the Euler angles
  82017. * @param order is a reserved parameter and is ignore for now
  82018. * @returns the current unchanged quaternion
  82019. */
  82020. toEulerAnglesToRef(result: Vector3): Quaternion;
  82021. /**
  82022. * Updates the given rotation matrix with the current quaternion values
  82023. * @param result defines the target matrix
  82024. * @returns the current unchanged quaternion
  82025. */
  82026. toRotationMatrix(result: Matrix): Quaternion;
  82027. /**
  82028. * Updates the current quaternion from the given rotation matrix values
  82029. * @param matrix defines the source matrix
  82030. * @returns the current updated quaternion
  82031. */
  82032. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82033. /**
  82034. * Creates a new quaternion from a rotation matrix
  82035. * @param matrix defines the source matrix
  82036. * @returns a new quaternion created from the given rotation matrix values
  82037. */
  82038. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82039. /**
  82040. * Updates the given quaternion with the given rotation matrix values
  82041. * @param matrix defines the source matrix
  82042. * @param result defines the target quaternion
  82043. */
  82044. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82045. /**
  82046. * Returns the dot product (float) between the quaternions "left" and "right"
  82047. * @param left defines the left operand
  82048. * @param right defines the right operand
  82049. * @returns the dot product
  82050. */
  82051. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82052. /**
  82053. * Checks if the two quaternions are close to each other
  82054. * @param quat0 defines the first quaternion to check
  82055. * @param quat1 defines the second quaternion to check
  82056. * @returns true if the two quaternions are close to each other
  82057. */
  82058. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82059. /**
  82060. * Creates an empty quaternion
  82061. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82062. */
  82063. static Zero(): Quaternion;
  82064. /**
  82065. * Inverse a given quaternion
  82066. * @param q defines the source quaternion
  82067. * @returns a new quaternion as the inverted current quaternion
  82068. */
  82069. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82070. /**
  82071. * Inverse a given quaternion
  82072. * @param q defines the source quaternion
  82073. * @param result the quaternion the result will be stored in
  82074. * @returns the result quaternion
  82075. */
  82076. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82077. /**
  82078. * Creates an identity quaternion
  82079. * @returns the identity quaternion
  82080. */
  82081. static Identity(): Quaternion;
  82082. /**
  82083. * Gets a boolean indicating if the given quaternion is identity
  82084. * @param quaternion defines the quaternion to check
  82085. * @returns true if the quaternion is identity
  82086. */
  82087. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82088. /**
  82089. * Creates a quaternion from a rotation around an axis
  82090. * @param axis defines the axis to use
  82091. * @param angle defines the angle to use
  82092. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82093. */
  82094. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82095. /**
  82096. * Creates a rotation around an axis and stores it into the given quaternion
  82097. * @param axis defines the axis to use
  82098. * @param angle defines the angle to use
  82099. * @param result defines the target quaternion
  82100. * @returns the target quaternion
  82101. */
  82102. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82103. /**
  82104. * Creates a new quaternion from data stored into an array
  82105. * @param array defines the data source
  82106. * @param offset defines the offset in the source array where the data starts
  82107. * @returns a new quaternion
  82108. */
  82109. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82110. /**
  82111. * Updates the given quaternion "result" from the starting index of the given array.
  82112. * @param array the array to pull values from
  82113. * @param offset the offset into the array to start at
  82114. * @param result the quaternion to store the result in
  82115. */
  82116. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82117. /**
  82118. * Create a quaternion from Euler rotation angles
  82119. * @param x Pitch
  82120. * @param y Yaw
  82121. * @param z Roll
  82122. * @returns the new Quaternion
  82123. */
  82124. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82125. /**
  82126. * Updates a quaternion from Euler rotation angles
  82127. * @param x Pitch
  82128. * @param y Yaw
  82129. * @param z Roll
  82130. * @param result the quaternion to store the result
  82131. * @returns the updated quaternion
  82132. */
  82133. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  82134. /**
  82135. * Create a quaternion from Euler rotation vector
  82136. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82137. * @returns the new Quaternion
  82138. */
  82139. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  82140. /**
  82141. * Updates a quaternion from Euler rotation vector
  82142. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82143. * @param result the quaternion to store the result
  82144. * @returns the updated quaternion
  82145. */
  82146. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  82147. /**
  82148. * Creates a new quaternion from the given Euler float angles (y, x, z)
  82149. * @param yaw defines the rotation around Y axis
  82150. * @param pitch defines the rotation around X axis
  82151. * @param roll defines the rotation around Z axis
  82152. * @returns the new quaternion
  82153. */
  82154. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  82155. /**
  82156. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  82157. * @param yaw defines the rotation around Y axis
  82158. * @param pitch defines the rotation around X axis
  82159. * @param roll defines the rotation around Z axis
  82160. * @param result defines the target quaternion
  82161. */
  82162. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  82163. /**
  82164. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  82165. * @param alpha defines the rotation around first axis
  82166. * @param beta defines the rotation around second axis
  82167. * @param gamma defines the rotation around third axis
  82168. * @returns the new quaternion
  82169. */
  82170. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  82171. /**
  82172. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  82173. * @param alpha defines the rotation around first axis
  82174. * @param beta defines the rotation around second axis
  82175. * @param gamma defines the rotation around third axis
  82176. * @param result defines the target quaternion
  82177. */
  82178. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  82179. /**
  82180. * 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)
  82181. * @param axis1 defines the first axis
  82182. * @param axis2 defines the second axis
  82183. * @param axis3 defines the third axis
  82184. * @returns the new quaternion
  82185. */
  82186. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  82187. /**
  82188. * 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
  82189. * @param axis1 defines the first axis
  82190. * @param axis2 defines the second axis
  82191. * @param axis3 defines the third axis
  82192. * @param ref defines the target quaternion
  82193. */
  82194. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  82195. /**
  82196. * Interpolates between two quaternions
  82197. * @param left defines first quaternion
  82198. * @param right defines second quaternion
  82199. * @param amount defines the gradient to use
  82200. * @returns the new interpolated quaternion
  82201. */
  82202. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82203. /**
  82204. * Interpolates between two quaternions and stores it into a target quaternion
  82205. * @param left defines first quaternion
  82206. * @param right defines second quaternion
  82207. * @param amount defines the gradient to use
  82208. * @param result defines the target quaternion
  82209. */
  82210. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  82211. /**
  82212. * Interpolate between two quaternions using Hermite interpolation
  82213. * @param value1 defines first quaternion
  82214. * @param tangent1 defines the incoming tangent
  82215. * @param value2 defines second quaternion
  82216. * @param tangent2 defines the outgoing tangent
  82217. * @param amount defines the target quaternion
  82218. * @returns the new interpolated quaternion
  82219. */
  82220. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82221. }
  82222. /**
  82223. * Class used to store matrix data (4x4)
  82224. */
  82225. export class Matrix {
  82226. private static _updateFlagSeed;
  82227. private static _identityReadOnly;
  82228. private _isIdentity;
  82229. private _isIdentityDirty;
  82230. private _isIdentity3x2;
  82231. private _isIdentity3x2Dirty;
  82232. /**
  82233. * Gets the update flag of the matrix which is an unique number for the matrix.
  82234. * It will be incremented every time the matrix data change.
  82235. * You can use it to speed the comparison between two versions of the same matrix.
  82236. */
  82237. updateFlag: number;
  82238. private readonly _m;
  82239. /**
  82240. * Gets the internal data of the matrix
  82241. */
  82242. get m(): DeepImmutable<Float32Array>;
  82243. /** @hidden */
  82244. _markAsUpdated(): void;
  82245. /** @hidden */
  82246. private _updateIdentityStatus;
  82247. /**
  82248. * Creates an empty matrix (filled with zeros)
  82249. */
  82250. constructor();
  82251. /**
  82252. * Check if the current matrix is identity
  82253. * @returns true is the matrix is the identity matrix
  82254. */
  82255. isIdentity(): boolean;
  82256. /**
  82257. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  82258. * @returns true is the matrix is the identity matrix
  82259. */
  82260. isIdentityAs3x2(): boolean;
  82261. /**
  82262. * Gets the determinant of the matrix
  82263. * @returns the matrix determinant
  82264. */
  82265. determinant(): number;
  82266. /**
  82267. * Returns the matrix as a Float32Array
  82268. * @returns the matrix underlying array
  82269. */
  82270. toArray(): DeepImmutable<Float32Array>;
  82271. /**
  82272. * Returns the matrix as a Float32Array
  82273. * @returns the matrix underlying array.
  82274. */
  82275. asArray(): DeepImmutable<Float32Array>;
  82276. /**
  82277. * Inverts the current matrix in place
  82278. * @returns the current inverted matrix
  82279. */
  82280. invert(): Matrix;
  82281. /**
  82282. * Sets all the matrix elements to zero
  82283. * @returns the current matrix
  82284. */
  82285. reset(): Matrix;
  82286. /**
  82287. * Adds the current matrix with a second one
  82288. * @param other defines the matrix to add
  82289. * @returns a new matrix as the addition of the current matrix and the given one
  82290. */
  82291. add(other: DeepImmutable<Matrix>): Matrix;
  82292. /**
  82293. * Sets the given matrix "result" to the addition of the current matrix and the given one
  82294. * @param other defines the matrix to add
  82295. * @param result defines the target matrix
  82296. * @returns the current matrix
  82297. */
  82298. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82299. /**
  82300. * Adds in place the given matrix to the current matrix
  82301. * @param other defines the second operand
  82302. * @returns the current updated matrix
  82303. */
  82304. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  82305. /**
  82306. * Sets the given matrix to the current inverted Matrix
  82307. * @param other defines the target matrix
  82308. * @returns the unmodified current matrix
  82309. */
  82310. invertToRef(other: Matrix): Matrix;
  82311. /**
  82312. * add a value at the specified position in the current Matrix
  82313. * @param index the index of the value within the matrix. between 0 and 15.
  82314. * @param value the value to be added
  82315. * @returns the current updated matrix
  82316. */
  82317. addAtIndex(index: number, value: number): Matrix;
  82318. /**
  82319. * mutiply the specified position in the current Matrix by a value
  82320. * @param index the index of the value within the matrix. between 0 and 15.
  82321. * @param value the value to be added
  82322. * @returns the current updated matrix
  82323. */
  82324. multiplyAtIndex(index: number, value: number): Matrix;
  82325. /**
  82326. * Inserts the translation vector (using 3 floats) in the current matrix
  82327. * @param x defines the 1st component of the translation
  82328. * @param y defines the 2nd component of the translation
  82329. * @param z defines the 3rd component of the translation
  82330. * @returns the current updated matrix
  82331. */
  82332. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82333. /**
  82334. * Adds the translation vector (using 3 floats) in the current matrix
  82335. * @param x defines the 1st component of the translation
  82336. * @param y defines the 2nd component of the translation
  82337. * @param z defines the 3rd component of the translation
  82338. * @returns the current updated matrix
  82339. */
  82340. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82341. /**
  82342. * Inserts the translation vector in the current matrix
  82343. * @param vector3 defines the translation to insert
  82344. * @returns the current updated matrix
  82345. */
  82346. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  82347. /**
  82348. * Gets the translation value of the current matrix
  82349. * @returns a new Vector3 as the extracted translation from the matrix
  82350. */
  82351. getTranslation(): Vector3;
  82352. /**
  82353. * Fill a Vector3 with the extracted translation from the matrix
  82354. * @param result defines the Vector3 where to store the translation
  82355. * @returns the current matrix
  82356. */
  82357. getTranslationToRef(result: Vector3): Matrix;
  82358. /**
  82359. * Remove rotation and scaling part from the matrix
  82360. * @returns the updated matrix
  82361. */
  82362. removeRotationAndScaling(): Matrix;
  82363. /**
  82364. * Multiply two matrices
  82365. * @param other defines the second operand
  82366. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  82367. */
  82368. multiply(other: DeepImmutable<Matrix>): Matrix;
  82369. /**
  82370. * Copy the current matrix from the given one
  82371. * @param other defines the source matrix
  82372. * @returns the current updated matrix
  82373. */
  82374. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  82375. /**
  82376. * Populates the given array from the starting index with the current matrix values
  82377. * @param array defines the target array
  82378. * @param offset defines the offset in the target array where to start storing values
  82379. * @returns the current matrix
  82380. */
  82381. copyToArray(array: Float32Array, offset?: number): Matrix;
  82382. /**
  82383. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  82384. * @param other defines the second operand
  82385. * @param result defines the matrix where to store the multiplication
  82386. * @returns the current matrix
  82387. */
  82388. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82389. /**
  82390. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  82391. * @param other defines the second operand
  82392. * @param result defines the array where to store the multiplication
  82393. * @param offset defines the offset in the target array where to start storing values
  82394. * @returns the current matrix
  82395. */
  82396. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  82397. /**
  82398. * Check equality between this matrix and a second one
  82399. * @param value defines the second matrix to compare
  82400. * @returns true is the current matrix and the given one values are strictly equal
  82401. */
  82402. equals(value: DeepImmutable<Matrix>): boolean;
  82403. /**
  82404. * Clone the current matrix
  82405. * @returns a new matrix from the current matrix
  82406. */
  82407. clone(): Matrix;
  82408. /**
  82409. * Returns the name of the current matrix class
  82410. * @returns the string "Matrix"
  82411. */
  82412. getClassName(): string;
  82413. /**
  82414. * Gets the hash code of the current matrix
  82415. * @returns the hash code
  82416. */
  82417. getHashCode(): number;
  82418. /**
  82419. * Decomposes the current Matrix into a translation, rotation and scaling components
  82420. * @param scale defines the scale vector3 given as a reference to update
  82421. * @param rotation defines the rotation quaternion given as a reference to update
  82422. * @param translation defines the translation vector3 given as a reference to update
  82423. * @returns true if operation was successful
  82424. */
  82425. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  82426. /**
  82427. * Gets specific row of the matrix
  82428. * @param index defines the number of the row to get
  82429. * @returns the index-th row of the current matrix as a new Vector4
  82430. */
  82431. getRow(index: number): Nullable<Vector4>;
  82432. /**
  82433. * Sets the index-th row of the current matrix to the vector4 values
  82434. * @param index defines the number of the row to set
  82435. * @param row defines the target vector4
  82436. * @returns the updated current matrix
  82437. */
  82438. setRow(index: number, row: Vector4): Matrix;
  82439. /**
  82440. * Compute the transpose of the matrix
  82441. * @returns the new transposed matrix
  82442. */
  82443. transpose(): Matrix;
  82444. /**
  82445. * Compute the transpose of the matrix and store it in a given matrix
  82446. * @param result defines the target matrix
  82447. * @returns the current matrix
  82448. */
  82449. transposeToRef(result: Matrix): Matrix;
  82450. /**
  82451. * Sets the index-th row of the current matrix with the given 4 x float values
  82452. * @param index defines the row index
  82453. * @param x defines the x component to set
  82454. * @param y defines the y component to set
  82455. * @param z defines the z component to set
  82456. * @param w defines the w component to set
  82457. * @returns the updated current matrix
  82458. */
  82459. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  82460. /**
  82461. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  82462. * @param scale defines the scale factor
  82463. * @returns a new matrix
  82464. */
  82465. scale(scale: number): Matrix;
  82466. /**
  82467. * Scale the current matrix values by a factor to a given result matrix
  82468. * @param scale defines the scale factor
  82469. * @param result defines the matrix to store the result
  82470. * @returns the current matrix
  82471. */
  82472. scaleToRef(scale: number, result: Matrix): Matrix;
  82473. /**
  82474. * Scale the current matrix values by a factor and add the result to a given matrix
  82475. * @param scale defines the scale factor
  82476. * @param result defines the Matrix to store the result
  82477. * @returns the current matrix
  82478. */
  82479. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  82480. /**
  82481. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  82482. * @param ref matrix to store the result
  82483. */
  82484. toNormalMatrix(ref: Matrix): void;
  82485. /**
  82486. * Gets only rotation part of the current matrix
  82487. * @returns a new matrix sets to the extracted rotation matrix from the current one
  82488. */
  82489. getRotationMatrix(): Matrix;
  82490. /**
  82491. * Extracts the rotation matrix from the current one and sets it as the given "result"
  82492. * @param result defines the target matrix to store data to
  82493. * @returns the current matrix
  82494. */
  82495. getRotationMatrixToRef(result: Matrix): Matrix;
  82496. /**
  82497. * Toggles model matrix from being right handed to left handed in place and vice versa
  82498. */
  82499. toggleModelMatrixHandInPlace(): void;
  82500. /**
  82501. * Toggles projection matrix from being right handed to left handed in place and vice versa
  82502. */
  82503. toggleProjectionMatrixHandInPlace(): void;
  82504. /**
  82505. * Creates a matrix from an array
  82506. * @param array defines the source array
  82507. * @param offset defines an offset in the source array
  82508. * @returns a new Matrix set from the starting index of the given array
  82509. */
  82510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  82511. /**
  82512. * Copy the content of an array into a given matrix
  82513. * @param array defines the source array
  82514. * @param offset defines an offset in the source array
  82515. * @param result defines the target matrix
  82516. */
  82517. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  82518. /**
  82519. * Stores an array into a matrix after having multiplied each component by a given factor
  82520. * @param array defines the source array
  82521. * @param offset defines the offset in the source array
  82522. * @param scale defines the scaling factor
  82523. * @param result defines the target matrix
  82524. */
  82525. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  82526. /**
  82527. * Gets an identity matrix that must not be updated
  82528. */
  82529. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  82530. /**
  82531. * Stores a list of values (16) inside a given matrix
  82532. * @param initialM11 defines 1st value of 1st row
  82533. * @param initialM12 defines 2nd value of 1st row
  82534. * @param initialM13 defines 3rd value of 1st row
  82535. * @param initialM14 defines 4th value of 1st row
  82536. * @param initialM21 defines 1st value of 2nd row
  82537. * @param initialM22 defines 2nd value of 2nd row
  82538. * @param initialM23 defines 3rd value of 2nd row
  82539. * @param initialM24 defines 4th value of 2nd row
  82540. * @param initialM31 defines 1st value of 3rd row
  82541. * @param initialM32 defines 2nd value of 3rd row
  82542. * @param initialM33 defines 3rd value of 3rd row
  82543. * @param initialM34 defines 4th value of 3rd row
  82544. * @param initialM41 defines 1st value of 4th row
  82545. * @param initialM42 defines 2nd value of 4th row
  82546. * @param initialM43 defines 3rd value of 4th row
  82547. * @param initialM44 defines 4th value of 4th row
  82548. * @param result defines the target matrix
  82549. */
  82550. 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;
  82551. /**
  82552. * Creates new matrix from a list of values (16)
  82553. * @param initialM11 defines 1st value of 1st row
  82554. * @param initialM12 defines 2nd value of 1st row
  82555. * @param initialM13 defines 3rd value of 1st row
  82556. * @param initialM14 defines 4th value of 1st row
  82557. * @param initialM21 defines 1st value of 2nd row
  82558. * @param initialM22 defines 2nd value of 2nd row
  82559. * @param initialM23 defines 3rd value of 2nd row
  82560. * @param initialM24 defines 4th value of 2nd row
  82561. * @param initialM31 defines 1st value of 3rd row
  82562. * @param initialM32 defines 2nd value of 3rd row
  82563. * @param initialM33 defines 3rd value of 3rd row
  82564. * @param initialM34 defines 4th value of 3rd row
  82565. * @param initialM41 defines 1st value of 4th row
  82566. * @param initialM42 defines 2nd value of 4th row
  82567. * @param initialM43 defines 3rd value of 4th row
  82568. * @param initialM44 defines 4th value of 4th row
  82569. * @returns the new matrix
  82570. */
  82571. 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;
  82572. /**
  82573. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82574. * @param scale defines the scale vector3
  82575. * @param rotation defines the rotation quaternion
  82576. * @param translation defines the translation vector3
  82577. * @returns a new matrix
  82578. */
  82579. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  82580. /**
  82581. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82582. * @param scale defines the scale vector3
  82583. * @param rotation defines the rotation quaternion
  82584. * @param translation defines the translation vector3
  82585. * @param result defines the target matrix
  82586. */
  82587. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  82588. /**
  82589. * Creates a new identity matrix
  82590. * @returns a new identity matrix
  82591. */
  82592. static Identity(): Matrix;
  82593. /**
  82594. * Creates a new identity matrix and stores the result in a given matrix
  82595. * @param result defines the target matrix
  82596. */
  82597. static IdentityToRef(result: Matrix): void;
  82598. /**
  82599. * Creates a new zero matrix
  82600. * @returns a new zero matrix
  82601. */
  82602. static Zero(): Matrix;
  82603. /**
  82604. * Creates a new rotation matrix for "angle" radians around the X axis
  82605. * @param angle defines the angle (in radians) to use
  82606. * @return the new matrix
  82607. */
  82608. static RotationX(angle: number): Matrix;
  82609. /**
  82610. * Creates a new matrix as the invert of a given matrix
  82611. * @param source defines the source matrix
  82612. * @returns the new matrix
  82613. */
  82614. static Invert(source: DeepImmutable<Matrix>): Matrix;
  82615. /**
  82616. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  82617. * @param angle defines the angle (in radians) to use
  82618. * @param result defines the target matrix
  82619. */
  82620. static RotationXToRef(angle: number, result: Matrix): void;
  82621. /**
  82622. * Creates a new rotation matrix for "angle" radians around the Y axis
  82623. * @param angle defines the angle (in radians) to use
  82624. * @return the new matrix
  82625. */
  82626. static RotationY(angle: number): Matrix;
  82627. /**
  82628. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  82629. * @param angle defines the angle (in radians) to use
  82630. * @param result defines the target matrix
  82631. */
  82632. static RotationYToRef(angle: number, result: Matrix): void;
  82633. /**
  82634. * Creates a new rotation matrix for "angle" radians around the Z axis
  82635. * @param angle defines the angle (in radians) to use
  82636. * @return the new matrix
  82637. */
  82638. static RotationZ(angle: number): Matrix;
  82639. /**
  82640. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  82641. * @param angle defines the angle (in radians) to use
  82642. * @param result defines the target matrix
  82643. */
  82644. static RotationZToRef(angle: number, result: Matrix): void;
  82645. /**
  82646. * Creates a new rotation matrix for "angle" radians around the given axis
  82647. * @param axis defines the axis to use
  82648. * @param angle defines the angle (in radians) to use
  82649. * @return the new matrix
  82650. */
  82651. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  82652. /**
  82653. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  82654. * @param axis defines the axis to use
  82655. * @param angle defines the angle (in radians) to use
  82656. * @param result defines the target matrix
  82657. */
  82658. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  82659. /**
  82660. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  82661. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  82662. * @param from defines the vector to align
  82663. * @param to defines the vector to align to
  82664. * @param result defines the target matrix
  82665. */
  82666. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  82667. /**
  82668. * Creates a rotation matrix
  82669. * @param yaw defines the yaw angle in radians (Y axis)
  82670. * @param pitch defines the pitch angle in radians (X axis)
  82671. * @param roll defines the roll angle in radians (X axis)
  82672. * @returns the new rotation matrix
  82673. */
  82674. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  82675. /**
  82676. * Creates a rotation matrix and stores it in a given matrix
  82677. * @param yaw defines the yaw angle in radians (Y axis)
  82678. * @param pitch defines the pitch angle in radians (X axis)
  82679. * @param roll defines the roll angle in radians (X axis)
  82680. * @param result defines the target matrix
  82681. */
  82682. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  82683. /**
  82684. * Creates a scaling matrix
  82685. * @param x defines the scale factor on X axis
  82686. * @param y defines the scale factor on Y axis
  82687. * @param z defines the scale factor on Z axis
  82688. * @returns the new matrix
  82689. */
  82690. static Scaling(x: number, y: number, z: number): Matrix;
  82691. /**
  82692. * Creates a scaling matrix and stores it in a given matrix
  82693. * @param x defines the scale factor on X axis
  82694. * @param y defines the scale factor on Y axis
  82695. * @param z defines the scale factor on Z axis
  82696. * @param result defines the target matrix
  82697. */
  82698. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  82699. /**
  82700. * Creates a translation matrix
  82701. * @param x defines the translation on X axis
  82702. * @param y defines the translation on Y axis
  82703. * @param z defines the translationon Z axis
  82704. * @returns the new matrix
  82705. */
  82706. static Translation(x: number, y: number, z: number): Matrix;
  82707. /**
  82708. * Creates a translation matrix and stores it in a given matrix
  82709. * @param x defines the translation on X axis
  82710. * @param y defines the translation on Y axis
  82711. * @param z defines the translationon Z axis
  82712. * @param result defines the target matrix
  82713. */
  82714. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  82715. /**
  82716. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82717. * @param startValue defines the start value
  82718. * @param endValue defines the end value
  82719. * @param gradient defines the gradient factor
  82720. * @returns the new matrix
  82721. */
  82722. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82723. /**
  82724. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82725. * @param startValue defines the start value
  82726. * @param endValue defines the end value
  82727. * @param gradient defines the gradient factor
  82728. * @param result defines the Matrix object where to store data
  82729. */
  82730. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82731. /**
  82732. * Builds a new matrix whose values are computed by:
  82733. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82734. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82735. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82736. * @param startValue defines the first matrix
  82737. * @param endValue defines the second matrix
  82738. * @param gradient defines the gradient between the two matrices
  82739. * @returns the new matrix
  82740. */
  82741. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82742. /**
  82743. * Update a matrix to values which are computed by:
  82744. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82745. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82746. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82747. * @param startValue defines the first matrix
  82748. * @param endValue defines the second matrix
  82749. * @param gradient defines the gradient between the two matrices
  82750. * @param result defines the target matrix
  82751. */
  82752. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82753. /**
  82754. * 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"
  82755. * This function works in left handed mode
  82756. * @param eye defines the final position of the entity
  82757. * @param target defines where the entity should look at
  82758. * @param up defines the up vector for the entity
  82759. * @returns the new matrix
  82760. */
  82761. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82762. /**
  82763. * 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".
  82764. * This function works in left handed mode
  82765. * @param eye defines the final position of the entity
  82766. * @param target defines where the entity should look at
  82767. * @param up defines the up vector for the entity
  82768. * @param result defines the target matrix
  82769. */
  82770. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82771. /**
  82772. * 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"
  82773. * This function works in right handed mode
  82774. * @param eye defines the final position of the entity
  82775. * @param target defines where the entity should look at
  82776. * @param up defines the up vector for the entity
  82777. * @returns the new matrix
  82778. */
  82779. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82780. /**
  82781. * 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".
  82782. * This function works in right handed mode
  82783. * @param eye defines the final position of the entity
  82784. * @param target defines where the entity should look at
  82785. * @param up defines the up vector for the entity
  82786. * @param result defines the target matrix
  82787. */
  82788. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82789. /**
  82790. * Create a left-handed orthographic projection matrix
  82791. * @param width defines the viewport width
  82792. * @param height defines the viewport height
  82793. * @param znear defines the near clip plane
  82794. * @param zfar defines the far clip plane
  82795. * @returns a new matrix as a left-handed orthographic projection matrix
  82796. */
  82797. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82798. /**
  82799. * Store a left-handed orthographic projection to a given matrix
  82800. * @param width defines the viewport width
  82801. * @param height defines the viewport height
  82802. * @param znear defines the near clip plane
  82803. * @param zfar defines the far clip plane
  82804. * @param result defines the target matrix
  82805. */
  82806. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  82807. /**
  82808. * Create a left-handed orthographic projection matrix
  82809. * @param left defines the viewport left coordinate
  82810. * @param right defines the viewport right coordinate
  82811. * @param bottom defines the viewport bottom coordinate
  82812. * @param top defines the viewport top coordinate
  82813. * @param znear defines the near clip plane
  82814. * @param zfar defines the far clip plane
  82815. * @returns a new matrix as a left-handed orthographic projection matrix
  82816. */
  82817. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82818. /**
  82819. * Stores a left-handed orthographic projection into a given matrix
  82820. * @param left defines the viewport left coordinate
  82821. * @param right defines the viewport right coordinate
  82822. * @param bottom defines the viewport bottom coordinate
  82823. * @param top defines the viewport top coordinate
  82824. * @param znear defines the near clip plane
  82825. * @param zfar defines the far clip plane
  82826. * @param result defines the target matrix
  82827. */
  82828. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82829. /**
  82830. * Creates a right-handed orthographic projection matrix
  82831. * @param left defines the viewport left coordinate
  82832. * @param right defines the viewport right coordinate
  82833. * @param bottom defines the viewport bottom coordinate
  82834. * @param top defines the viewport top coordinate
  82835. * @param znear defines the near clip plane
  82836. * @param zfar defines the far clip plane
  82837. * @returns a new matrix as a right-handed orthographic projection matrix
  82838. */
  82839. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82840. /**
  82841. * Stores a right-handed orthographic projection into a given matrix
  82842. * @param left defines the viewport left coordinate
  82843. * @param right defines the viewport right coordinate
  82844. * @param bottom defines the viewport bottom coordinate
  82845. * @param top defines the viewport top coordinate
  82846. * @param znear defines the near clip plane
  82847. * @param zfar defines the far clip plane
  82848. * @param result defines the target matrix
  82849. */
  82850. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82851. /**
  82852. * Creates a left-handed perspective projection matrix
  82853. * @param width defines the viewport width
  82854. * @param height defines the viewport height
  82855. * @param znear defines the near clip plane
  82856. * @param zfar defines the far clip plane
  82857. * @returns a new matrix as a left-handed perspective projection matrix
  82858. */
  82859. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82860. /**
  82861. * Creates a left-handed perspective projection matrix
  82862. * @param fov defines the horizontal field of view
  82863. * @param aspect defines the aspect ratio
  82864. * @param znear defines the near clip plane
  82865. * @param zfar defines the far clip plane
  82866. * @returns a new matrix as a left-handed perspective projection matrix
  82867. */
  82868. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82869. /**
  82870. * Stores a left-handed perspective projection into a given matrix
  82871. * @param fov defines the horizontal field of view
  82872. * @param aspect defines the aspect ratio
  82873. * @param znear defines the near clip plane
  82874. * @param zfar defines the far clip plane
  82875. * @param result defines the target matrix
  82876. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82877. */
  82878. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82879. /**
  82880. * Stores a left-handed perspective projection into a given matrix with depth reversed
  82881. * @param fov defines the horizontal field of view
  82882. * @param aspect defines the aspect ratio
  82883. * @param znear defines the near clip plane
  82884. * @param zfar not used as infinity is used as far clip
  82885. * @param result defines the target matrix
  82886. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82887. */
  82888. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82889. /**
  82890. * Creates a right-handed perspective projection matrix
  82891. * @param fov defines the horizontal field of view
  82892. * @param aspect defines the aspect ratio
  82893. * @param znear defines the near clip plane
  82894. * @param zfar defines the far clip plane
  82895. * @returns a new matrix as a right-handed perspective projection matrix
  82896. */
  82897. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82898. /**
  82899. * Stores a right-handed perspective projection into a given matrix
  82900. * @param fov defines the horizontal field of view
  82901. * @param aspect defines the aspect ratio
  82902. * @param znear defines the near clip plane
  82903. * @param zfar defines the far clip plane
  82904. * @param result defines the target matrix
  82905. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82906. */
  82907. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82908. /**
  82909. * Stores a right-handed perspective projection into a given matrix
  82910. * @param fov defines the horizontal field of view
  82911. * @param aspect defines the aspect ratio
  82912. * @param znear defines the near clip plane
  82913. * @param zfar not used as infinity is used as far clip
  82914. * @param result defines the target matrix
  82915. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82916. */
  82917. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82918. /**
  82919. * Stores a perspective projection for WebVR info a given matrix
  82920. * @param fov defines the field of view
  82921. * @param znear defines the near clip plane
  82922. * @param zfar defines the far clip plane
  82923. * @param result defines the target matrix
  82924. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  82925. */
  82926. static PerspectiveFovWebVRToRef(fov: {
  82927. upDegrees: number;
  82928. downDegrees: number;
  82929. leftDegrees: number;
  82930. rightDegrees: number;
  82931. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  82932. /**
  82933. * Computes a complete transformation matrix
  82934. * @param viewport defines the viewport to use
  82935. * @param world defines the world matrix
  82936. * @param view defines the view matrix
  82937. * @param projection defines the projection matrix
  82938. * @param zmin defines the near clip plane
  82939. * @param zmax defines the far clip plane
  82940. * @returns the transformation matrix
  82941. */
  82942. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  82943. /**
  82944. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  82945. * @param matrix defines the matrix to use
  82946. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  82947. */
  82948. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  82949. /**
  82950. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  82951. * @param matrix defines the matrix to use
  82952. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  82953. */
  82954. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  82955. /**
  82956. * Compute the transpose of a given matrix
  82957. * @param matrix defines the matrix to transpose
  82958. * @returns the new matrix
  82959. */
  82960. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  82961. /**
  82962. * Compute the transpose of a matrix and store it in a target matrix
  82963. * @param matrix defines the matrix to transpose
  82964. * @param result defines the target matrix
  82965. */
  82966. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  82967. /**
  82968. * Computes a reflection matrix from a plane
  82969. * @param plane defines the reflection plane
  82970. * @returns a new matrix
  82971. */
  82972. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  82973. /**
  82974. * Computes a reflection matrix from a plane
  82975. * @param plane defines the reflection plane
  82976. * @param result defines the target matrix
  82977. */
  82978. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  82979. /**
  82980. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  82981. * @param xaxis defines the value of the 1st axis
  82982. * @param yaxis defines the value of the 2nd axis
  82983. * @param zaxis defines the value of the 3rd axis
  82984. * @param result defines the target matrix
  82985. */
  82986. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  82987. /**
  82988. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  82989. * @param quat defines the quaternion to use
  82990. * @param result defines the target matrix
  82991. */
  82992. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  82993. }
  82994. /**
  82995. * @hidden
  82996. */
  82997. export class TmpVectors {
  82998. static Vector2: Vector2[];
  82999. static Vector3: Vector3[];
  83000. static Vector4: Vector4[];
  83001. static Quaternion: Quaternion[];
  83002. static Matrix: Matrix[];
  83003. }
  83004. }
  83005. declare module BABYLON {
  83006. /**
  83007. * Defines potential orientation for back face culling
  83008. */
  83009. export enum Orientation {
  83010. /**
  83011. * Clockwise
  83012. */
  83013. CW = 0,
  83014. /** Counter clockwise */
  83015. CCW = 1
  83016. }
  83017. /** Class used to represent a Bezier curve */
  83018. export class BezierCurve {
  83019. /**
  83020. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83021. * @param t defines the time
  83022. * @param x1 defines the left coordinate on X axis
  83023. * @param y1 defines the left coordinate on Y axis
  83024. * @param x2 defines the right coordinate on X axis
  83025. * @param y2 defines the right coordinate on Y axis
  83026. * @returns the interpolated value
  83027. */
  83028. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83029. }
  83030. /**
  83031. * Defines angle representation
  83032. */
  83033. export class Angle {
  83034. private _radians;
  83035. /**
  83036. * Creates an Angle object of "radians" radians (float).
  83037. * @param radians the angle in radians
  83038. */
  83039. constructor(radians: number);
  83040. /**
  83041. * Get value in degrees
  83042. * @returns the Angle value in degrees (float)
  83043. */
  83044. degrees(): number;
  83045. /**
  83046. * Get value in radians
  83047. * @returns the Angle value in radians (float)
  83048. */
  83049. radians(): number;
  83050. /**
  83051. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  83052. * @param a defines first vector
  83053. * @param b defines second vector
  83054. * @returns a new Angle
  83055. */
  83056. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83057. /**
  83058. * Gets a new Angle object from the given float in radians
  83059. * @param radians defines the angle value in radians
  83060. * @returns a new Angle
  83061. */
  83062. static FromRadians(radians: number): Angle;
  83063. /**
  83064. * Gets a new Angle object from the given float in degrees
  83065. * @param degrees defines the angle value in degrees
  83066. * @returns a new Angle
  83067. */
  83068. static FromDegrees(degrees: number): Angle;
  83069. }
  83070. /**
  83071. * This represents an arc in a 2d space.
  83072. */
  83073. export class Arc2 {
  83074. /** Defines the start point of the arc */
  83075. startPoint: Vector2;
  83076. /** Defines the mid point of the arc */
  83077. midPoint: Vector2;
  83078. /** Defines the end point of the arc */
  83079. endPoint: Vector2;
  83080. /**
  83081. * Defines the center point of the arc.
  83082. */
  83083. centerPoint: Vector2;
  83084. /**
  83085. * Defines the radius of the arc.
  83086. */
  83087. radius: number;
  83088. /**
  83089. * Defines the angle of the arc (from mid point to end point).
  83090. */
  83091. angle: Angle;
  83092. /**
  83093. * Defines the start angle of the arc (from start point to middle point).
  83094. */
  83095. startAngle: Angle;
  83096. /**
  83097. * Defines the orientation of the arc (clock wise/counter clock wise).
  83098. */
  83099. orientation: Orientation;
  83100. /**
  83101. * Creates an Arc object from the three given points : start, middle and end.
  83102. * @param startPoint Defines the start point of the arc
  83103. * @param midPoint Defines the midlle point of the arc
  83104. * @param endPoint Defines the end point of the arc
  83105. */
  83106. constructor(
  83107. /** Defines the start point of the arc */
  83108. startPoint: Vector2,
  83109. /** Defines the mid point of the arc */
  83110. midPoint: Vector2,
  83111. /** Defines the end point of the arc */
  83112. endPoint: Vector2);
  83113. }
  83114. /**
  83115. * Represents a 2D path made up of multiple 2D points
  83116. */
  83117. export class Path2 {
  83118. private _points;
  83119. private _length;
  83120. /**
  83121. * If the path start and end point are the same
  83122. */
  83123. closed: boolean;
  83124. /**
  83125. * Creates a Path2 object from the starting 2D coordinates x and y.
  83126. * @param x the starting points x value
  83127. * @param y the starting points y value
  83128. */
  83129. constructor(x: number, y: number);
  83130. /**
  83131. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  83132. * @param x the added points x value
  83133. * @param y the added points y value
  83134. * @returns the updated Path2.
  83135. */
  83136. addLineTo(x: number, y: number): Path2;
  83137. /**
  83138. * 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.
  83139. * @param midX middle point x value
  83140. * @param midY middle point y value
  83141. * @param endX end point x value
  83142. * @param endY end point y value
  83143. * @param numberOfSegments (default: 36)
  83144. * @returns the updated Path2.
  83145. */
  83146. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  83147. /**
  83148. * Closes the Path2.
  83149. * @returns the Path2.
  83150. */
  83151. close(): Path2;
  83152. /**
  83153. * Gets the sum of the distance between each sequential point in the path
  83154. * @returns the Path2 total length (float).
  83155. */
  83156. length(): number;
  83157. /**
  83158. * Gets the points which construct the path
  83159. * @returns the Path2 internal array of points.
  83160. */
  83161. getPoints(): Vector2[];
  83162. /**
  83163. * Retreives the point at the distance aways from the starting point
  83164. * @param normalizedLengthPosition the length along the path to retreive the point from
  83165. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  83166. */
  83167. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  83168. /**
  83169. * Creates a new path starting from an x and y position
  83170. * @param x starting x value
  83171. * @param y starting y value
  83172. * @returns a new Path2 starting at the coordinates (x, y).
  83173. */
  83174. static StartingAt(x: number, y: number): Path2;
  83175. }
  83176. /**
  83177. * Represents a 3D path made up of multiple 3D points
  83178. */
  83179. export class Path3D {
  83180. /**
  83181. * an array of Vector3, the curve axis of the Path3D
  83182. */
  83183. path: Vector3[];
  83184. private _curve;
  83185. private _distances;
  83186. private _tangents;
  83187. private _normals;
  83188. private _binormals;
  83189. private _raw;
  83190. private _alignTangentsWithPath;
  83191. private readonly _pointAtData;
  83192. /**
  83193. * new Path3D(path, normal, raw)
  83194. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  83195. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  83196. * @param path an array of Vector3, the curve axis of the Path3D
  83197. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  83198. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  83199. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  83200. */
  83201. constructor(
  83202. /**
  83203. * an array of Vector3, the curve axis of the Path3D
  83204. */
  83205. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  83206. /**
  83207. * Returns the Path3D array of successive Vector3 designing its curve.
  83208. * @returns the Path3D array of successive Vector3 designing its curve.
  83209. */
  83210. getCurve(): Vector3[];
  83211. /**
  83212. * Returns the Path3D array of successive Vector3 designing its curve.
  83213. * @returns the Path3D array of successive Vector3 designing its curve.
  83214. */
  83215. getPoints(): Vector3[];
  83216. /**
  83217. * @returns the computed length (float) of the path.
  83218. */
  83219. length(): number;
  83220. /**
  83221. * Returns an array populated with tangent vectors on each Path3D curve point.
  83222. * @returns an array populated with tangent vectors on each Path3D curve point.
  83223. */
  83224. getTangents(): Vector3[];
  83225. /**
  83226. * Returns an array populated with normal vectors on each Path3D curve point.
  83227. * @returns an array populated with normal vectors on each Path3D curve point.
  83228. */
  83229. getNormals(): Vector3[];
  83230. /**
  83231. * Returns an array populated with binormal vectors on each Path3D curve point.
  83232. * @returns an array populated with binormal vectors on each Path3D curve point.
  83233. */
  83234. getBinormals(): Vector3[];
  83235. /**
  83236. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  83237. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  83238. */
  83239. getDistances(): number[];
  83240. /**
  83241. * Returns an interpolated point along this path
  83242. * @param position the position of the point along this path, from 0.0 to 1.0
  83243. * @returns a new Vector3 as the point
  83244. */
  83245. getPointAt(position: number): Vector3;
  83246. /**
  83247. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83248. * @param position the position of the point along this path, from 0.0 to 1.0
  83249. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  83250. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  83251. */
  83252. getTangentAt(position: number, interpolated?: boolean): Vector3;
  83253. /**
  83254. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83255. * @param position the position of the point along this path, from 0.0 to 1.0
  83256. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  83257. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  83258. */
  83259. getNormalAt(position: number, interpolated?: boolean): Vector3;
  83260. /**
  83261. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  83262. * @param position the position of the point along this path, from 0.0 to 1.0
  83263. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  83264. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  83265. */
  83266. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  83267. /**
  83268. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  83269. * @param position the position of the point along this path, from 0.0 to 1.0
  83270. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  83271. */
  83272. getDistanceAt(position: number): number;
  83273. /**
  83274. * Returns the array index of the previous point of an interpolated point along this path
  83275. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83276. * @returns the array index
  83277. */
  83278. getPreviousPointIndexAt(position: number): number;
  83279. /**
  83280. * 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)
  83281. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83282. * @returns the sub position
  83283. */
  83284. getSubPositionAt(position: number): number;
  83285. /**
  83286. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  83287. * @param target the vector of which to get the closest position to
  83288. * @returns the position of the closest virtual point on this path to the target vector
  83289. */
  83290. getClosestPositionTo(target: Vector3): number;
  83291. /**
  83292. * Returns a sub path (slice) of this path
  83293. * @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
  83294. * @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
  83295. * @returns a sub path (slice) of this path
  83296. */
  83297. slice(start?: number, end?: number): Path3D;
  83298. /**
  83299. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  83300. * @param path path which all values are copied into the curves points
  83301. * @param firstNormal which should be projected onto the curve
  83302. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  83303. * @returns the same object updated.
  83304. */
  83305. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  83306. private _compute;
  83307. private _getFirstNonNullVector;
  83308. private _getLastNonNullVector;
  83309. private _normalVector;
  83310. /**
  83311. * Updates the point at data for an interpolated point along this curve
  83312. * @param position the position of the point along this curve, from 0.0 to 1.0
  83313. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  83314. * @returns the (updated) point at data
  83315. */
  83316. private _updatePointAtData;
  83317. /**
  83318. * Updates the point at data from the specified parameters
  83319. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  83320. * @param point the interpolated point
  83321. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  83322. */
  83323. private _setPointAtData;
  83324. /**
  83325. * Updates the point at interpolation matrix for the tangents, normals and binormals
  83326. */
  83327. private _updateInterpolationMatrix;
  83328. }
  83329. /**
  83330. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83331. * A Curve3 is designed from a series of successive Vector3.
  83332. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  83333. */
  83334. export class Curve3 {
  83335. private _points;
  83336. private _length;
  83337. /**
  83338. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  83339. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  83340. * @param v1 (Vector3) the control point
  83341. * @param v2 (Vector3) the end point of the Quadratic Bezier
  83342. * @param nbPoints (integer) the wanted number of points in the curve
  83343. * @returns the created Curve3
  83344. */
  83345. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83346. /**
  83347. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  83348. * @param v0 (Vector3) the origin point of the Cubic Bezier
  83349. * @param v1 (Vector3) the first control point
  83350. * @param v2 (Vector3) the second control point
  83351. * @param v3 (Vector3) the end point of the Cubic Bezier
  83352. * @param nbPoints (integer) the wanted number of points in the curve
  83353. * @returns the created Curve3
  83354. */
  83355. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83356. /**
  83357. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  83358. * @param p1 (Vector3) the origin point of the Hermite Spline
  83359. * @param t1 (Vector3) the tangent vector at the origin point
  83360. * @param p2 (Vector3) the end point of the Hermite Spline
  83361. * @param t2 (Vector3) the tangent vector at the end point
  83362. * @param nbPoints (integer) the wanted number of points in the curve
  83363. * @returns the created Curve3
  83364. */
  83365. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83366. /**
  83367. * Returns a Curve3 object along a CatmullRom Spline curve :
  83368. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  83369. * @param nbPoints (integer) the wanted number of points between each curve control points
  83370. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  83371. * @returns the created Curve3
  83372. */
  83373. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  83374. /**
  83375. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83376. * A Curve3 is designed from a series of successive Vector3.
  83377. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  83378. * @param points points which make up the curve
  83379. */
  83380. constructor(points: Vector3[]);
  83381. /**
  83382. * @returns the Curve3 stored array of successive Vector3
  83383. */
  83384. getPoints(): Vector3[];
  83385. /**
  83386. * @returns the computed length (float) of the curve.
  83387. */
  83388. length(): number;
  83389. /**
  83390. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  83391. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  83392. * curveA and curveB keep unchanged.
  83393. * @param curve the curve to continue from this curve
  83394. * @returns the newly constructed curve
  83395. */
  83396. continue(curve: DeepImmutable<Curve3>): Curve3;
  83397. private _computeLength;
  83398. }
  83399. }
  83400. declare module BABYLON {
  83401. /**
  83402. * This represents the main contract an easing function should follow.
  83403. * Easing functions are used throughout the animation system.
  83404. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83405. */
  83406. export interface IEasingFunction {
  83407. /**
  83408. * Given an input gradient between 0 and 1, this returns the corrseponding value
  83409. * of the easing function.
  83410. * The link below provides some of the most common examples of easing functions.
  83411. * @see https://easings.net/
  83412. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83413. * @returns the corresponding value on the curve defined by the easing function
  83414. */
  83415. ease(gradient: number): number;
  83416. }
  83417. /**
  83418. * Base class used for every default easing function.
  83419. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83420. */
  83421. export class EasingFunction implements IEasingFunction {
  83422. /**
  83423. * Interpolation follows the mathematical formula associated with the easing function.
  83424. */
  83425. static readonly EASINGMODE_EASEIN: number;
  83426. /**
  83427. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  83428. */
  83429. static readonly EASINGMODE_EASEOUT: number;
  83430. /**
  83431. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  83432. */
  83433. static readonly EASINGMODE_EASEINOUT: number;
  83434. private _easingMode;
  83435. /**
  83436. * Sets the easing mode of the current function.
  83437. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  83438. */
  83439. setEasingMode(easingMode: number): void;
  83440. /**
  83441. * Gets the current easing mode.
  83442. * @returns the easing mode
  83443. */
  83444. getEasingMode(): number;
  83445. /**
  83446. * @hidden
  83447. */
  83448. easeInCore(gradient: number): number;
  83449. /**
  83450. * Given an input gradient between 0 and 1, this returns the corresponding value
  83451. * of the easing function.
  83452. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83453. * @returns the corresponding value on the curve defined by the easing function
  83454. */
  83455. ease(gradient: number): number;
  83456. }
  83457. /**
  83458. * Easing function with a circle shape (see link below).
  83459. * @see https://easings.net/#easeInCirc
  83460. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83461. */
  83462. export class CircleEase extends EasingFunction implements IEasingFunction {
  83463. /** @hidden */
  83464. easeInCore(gradient: number): number;
  83465. }
  83466. /**
  83467. * Easing function with a ease back shape (see link below).
  83468. * @see https://easings.net/#easeInBack
  83469. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83470. */
  83471. export class BackEase extends EasingFunction implements IEasingFunction {
  83472. /** Defines the amplitude of the function */
  83473. amplitude: number;
  83474. /**
  83475. * Instantiates a back ease easing
  83476. * @see https://easings.net/#easeInBack
  83477. * @param amplitude Defines the amplitude of the function
  83478. */
  83479. constructor(
  83480. /** Defines the amplitude of the function */
  83481. amplitude?: number);
  83482. /** @hidden */
  83483. easeInCore(gradient: number): number;
  83484. }
  83485. /**
  83486. * Easing function with a bouncing shape (see link below).
  83487. * @see https://easings.net/#easeInBounce
  83488. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83489. */
  83490. export class BounceEase extends EasingFunction implements IEasingFunction {
  83491. /** Defines the number of bounces */
  83492. bounces: number;
  83493. /** Defines the amplitude of the bounce */
  83494. bounciness: number;
  83495. /**
  83496. * Instantiates a bounce easing
  83497. * @see https://easings.net/#easeInBounce
  83498. * @param bounces Defines the number of bounces
  83499. * @param bounciness Defines the amplitude of the bounce
  83500. */
  83501. constructor(
  83502. /** Defines the number of bounces */
  83503. bounces?: number,
  83504. /** Defines the amplitude of the bounce */
  83505. bounciness?: number);
  83506. /** @hidden */
  83507. easeInCore(gradient: number): number;
  83508. }
  83509. /**
  83510. * Easing function with a power of 3 shape (see link below).
  83511. * @see https://easings.net/#easeInCubic
  83512. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83513. */
  83514. export class CubicEase extends EasingFunction implements IEasingFunction {
  83515. /** @hidden */
  83516. easeInCore(gradient: number): number;
  83517. }
  83518. /**
  83519. * Easing function with an elastic shape (see link below).
  83520. * @see https://easings.net/#easeInElastic
  83521. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83522. */
  83523. export class ElasticEase extends EasingFunction implements IEasingFunction {
  83524. /** Defines the number of oscillations*/
  83525. oscillations: number;
  83526. /** Defines the amplitude of the oscillations*/
  83527. springiness: number;
  83528. /**
  83529. * Instantiates an elastic easing function
  83530. * @see https://easings.net/#easeInElastic
  83531. * @param oscillations Defines the number of oscillations
  83532. * @param springiness Defines the amplitude of the oscillations
  83533. */
  83534. constructor(
  83535. /** Defines the number of oscillations*/
  83536. oscillations?: number,
  83537. /** Defines the amplitude of the oscillations*/
  83538. springiness?: number);
  83539. /** @hidden */
  83540. easeInCore(gradient: number): number;
  83541. }
  83542. /**
  83543. * Easing function with an exponential shape (see link below).
  83544. * @see https://easings.net/#easeInExpo
  83545. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83546. */
  83547. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  83548. /** Defines the exponent of the function */
  83549. exponent: number;
  83550. /**
  83551. * Instantiates an exponential easing function
  83552. * @see https://easings.net/#easeInExpo
  83553. * @param exponent Defines the exponent of the function
  83554. */
  83555. constructor(
  83556. /** Defines the exponent of the function */
  83557. exponent?: number);
  83558. /** @hidden */
  83559. easeInCore(gradient: number): number;
  83560. }
  83561. /**
  83562. * Easing function with a power shape (see link below).
  83563. * @see https://easings.net/#easeInQuad
  83564. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83565. */
  83566. export class PowerEase extends EasingFunction implements IEasingFunction {
  83567. /** Defines the power of the function */
  83568. power: number;
  83569. /**
  83570. * Instantiates an power base easing function
  83571. * @see https://easings.net/#easeInQuad
  83572. * @param power Defines the power of the function
  83573. */
  83574. constructor(
  83575. /** Defines the power of the function */
  83576. power?: number);
  83577. /** @hidden */
  83578. easeInCore(gradient: number): number;
  83579. }
  83580. /**
  83581. * Easing function with a power of 2 shape (see link below).
  83582. * @see https://easings.net/#easeInQuad
  83583. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83584. */
  83585. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  83586. /** @hidden */
  83587. easeInCore(gradient: number): number;
  83588. }
  83589. /**
  83590. * Easing function with a power of 4 shape (see link below).
  83591. * @see https://easings.net/#easeInQuart
  83592. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83593. */
  83594. export class QuarticEase extends EasingFunction implements IEasingFunction {
  83595. /** @hidden */
  83596. easeInCore(gradient: number): number;
  83597. }
  83598. /**
  83599. * Easing function with a power of 5 shape (see link below).
  83600. * @see https://easings.net/#easeInQuint
  83601. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83602. */
  83603. export class QuinticEase extends EasingFunction implements IEasingFunction {
  83604. /** @hidden */
  83605. easeInCore(gradient: number): number;
  83606. }
  83607. /**
  83608. * Easing function with a sin shape (see link below).
  83609. * @see https://easings.net/#easeInSine
  83610. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83611. */
  83612. export class SineEase extends EasingFunction implements IEasingFunction {
  83613. /** @hidden */
  83614. easeInCore(gradient: number): number;
  83615. }
  83616. /**
  83617. * Easing function with a bezier shape (see link below).
  83618. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83619. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83620. */
  83621. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  83622. /** Defines the x component of the start tangent in the bezier curve */
  83623. x1: number;
  83624. /** Defines the y component of the start tangent in the bezier curve */
  83625. y1: number;
  83626. /** Defines the x component of the end tangent in the bezier curve */
  83627. x2: number;
  83628. /** Defines the y component of the end tangent in the bezier curve */
  83629. y2: number;
  83630. /**
  83631. * Instantiates a bezier function
  83632. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83633. * @param x1 Defines the x component of the start tangent in the bezier curve
  83634. * @param y1 Defines the y component of the start tangent in the bezier curve
  83635. * @param x2 Defines the x component of the end tangent in the bezier curve
  83636. * @param y2 Defines the y component of the end tangent in the bezier curve
  83637. */
  83638. constructor(
  83639. /** Defines the x component of the start tangent in the bezier curve */
  83640. x1?: number,
  83641. /** Defines the y component of the start tangent in the bezier curve */
  83642. y1?: number,
  83643. /** Defines the x component of the end tangent in the bezier curve */
  83644. x2?: number,
  83645. /** Defines the y component of the end tangent in the bezier curve */
  83646. y2?: number);
  83647. /** @hidden */
  83648. easeInCore(gradient: number): number;
  83649. }
  83650. }
  83651. declare module BABYLON {
  83652. /**
  83653. * Class used to hold a RBG color
  83654. */
  83655. export class Color3 {
  83656. /**
  83657. * Defines the red component (between 0 and 1, default is 0)
  83658. */
  83659. r: number;
  83660. /**
  83661. * Defines the green component (between 0 and 1, default is 0)
  83662. */
  83663. g: number;
  83664. /**
  83665. * Defines the blue component (between 0 and 1, default is 0)
  83666. */
  83667. b: number;
  83668. /**
  83669. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  83670. * @param r defines the red component (between 0 and 1, default is 0)
  83671. * @param g defines the green component (between 0 and 1, default is 0)
  83672. * @param b defines the blue component (between 0 and 1, default is 0)
  83673. */
  83674. constructor(
  83675. /**
  83676. * Defines the red component (between 0 and 1, default is 0)
  83677. */
  83678. r?: number,
  83679. /**
  83680. * Defines the green component (between 0 and 1, default is 0)
  83681. */
  83682. g?: number,
  83683. /**
  83684. * Defines the blue component (between 0 and 1, default is 0)
  83685. */
  83686. b?: number);
  83687. /**
  83688. * Creates a string with the Color3 current values
  83689. * @returns the string representation of the Color3 object
  83690. */
  83691. toString(): string;
  83692. /**
  83693. * Returns the string "Color3"
  83694. * @returns "Color3"
  83695. */
  83696. getClassName(): string;
  83697. /**
  83698. * Compute the Color3 hash code
  83699. * @returns an unique number that can be used to hash Color3 objects
  83700. */
  83701. getHashCode(): number;
  83702. /**
  83703. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  83704. * @param array defines the array where to store the r,g,b components
  83705. * @param index defines an optional index in the target array to define where to start storing values
  83706. * @returns the current Color3 object
  83707. */
  83708. toArray(array: FloatArray, index?: number): Color3;
  83709. /**
  83710. * Returns a new Color4 object from the current Color3 and the given alpha
  83711. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  83712. * @returns a new Color4 object
  83713. */
  83714. toColor4(alpha?: number): Color4;
  83715. /**
  83716. * Returns a new array populated with 3 numeric elements : red, green and blue values
  83717. * @returns the new array
  83718. */
  83719. asArray(): number[];
  83720. /**
  83721. * Returns the luminance value
  83722. * @returns a float value
  83723. */
  83724. toLuminance(): number;
  83725. /**
  83726. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  83727. * @param otherColor defines the second operand
  83728. * @returns the new Color3 object
  83729. */
  83730. multiply(otherColor: DeepImmutable<Color3>): Color3;
  83731. /**
  83732. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  83733. * @param otherColor defines the second operand
  83734. * @param result defines the Color3 object where to store the result
  83735. * @returns the current Color3
  83736. */
  83737. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83738. /**
  83739. * Determines equality between Color3 objects
  83740. * @param otherColor defines the second operand
  83741. * @returns true if the rgb values are equal to the given ones
  83742. */
  83743. equals(otherColor: DeepImmutable<Color3>): boolean;
  83744. /**
  83745. * Determines equality between the current Color3 object and a set of r,b,g values
  83746. * @param r defines the red component to check
  83747. * @param g defines the green component to check
  83748. * @param b defines the blue component to check
  83749. * @returns true if the rgb values are equal to the given ones
  83750. */
  83751. equalsFloats(r: number, g: number, b: number): boolean;
  83752. /**
  83753. * Multiplies in place each rgb value by scale
  83754. * @param scale defines the scaling factor
  83755. * @returns the updated Color3
  83756. */
  83757. scale(scale: number): Color3;
  83758. /**
  83759. * Multiplies the rgb values by scale and stores the result into "result"
  83760. * @param scale defines the scaling factor
  83761. * @param result defines the Color3 object where to store the result
  83762. * @returns the unmodified current Color3
  83763. */
  83764. scaleToRef(scale: number, result: Color3): Color3;
  83765. /**
  83766. * Scale the current Color3 values by a factor and add the result to a given Color3
  83767. * @param scale defines the scale factor
  83768. * @param result defines color to store the result into
  83769. * @returns the unmodified current Color3
  83770. */
  83771. scaleAndAddToRef(scale: number, result: Color3): Color3;
  83772. /**
  83773. * Clamps the rgb values by the min and max values and stores the result into "result"
  83774. * @param min defines minimum clamping value (default is 0)
  83775. * @param max defines maximum clamping value (default is 1)
  83776. * @param result defines color to store the result into
  83777. * @returns the original Color3
  83778. */
  83779. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  83780. /**
  83781. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  83782. * @param otherColor defines the second operand
  83783. * @returns the new Color3
  83784. */
  83785. add(otherColor: DeepImmutable<Color3>): Color3;
  83786. /**
  83787. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  83788. * @param otherColor defines the second operand
  83789. * @param result defines Color3 object to store the result into
  83790. * @returns the unmodified current Color3
  83791. */
  83792. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83793. /**
  83794. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  83795. * @param otherColor defines the second operand
  83796. * @returns the new Color3
  83797. */
  83798. subtract(otherColor: DeepImmutable<Color3>): Color3;
  83799. /**
  83800. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  83801. * @param otherColor defines the second operand
  83802. * @param result defines Color3 object to store the result into
  83803. * @returns the unmodified current Color3
  83804. */
  83805. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83806. /**
  83807. * Copy the current object
  83808. * @returns a new Color3 copied the current one
  83809. */
  83810. clone(): Color3;
  83811. /**
  83812. * Copies the rgb values from the source in the current Color3
  83813. * @param source defines the source Color3 object
  83814. * @returns the updated Color3 object
  83815. */
  83816. copyFrom(source: DeepImmutable<Color3>): Color3;
  83817. /**
  83818. * Updates the Color3 rgb values from the given floats
  83819. * @param r defines the red component to read from
  83820. * @param g defines the green component to read from
  83821. * @param b defines the blue component to read from
  83822. * @returns the current Color3 object
  83823. */
  83824. copyFromFloats(r: number, g: number, b: number): Color3;
  83825. /**
  83826. * Updates the Color3 rgb values from the given floats
  83827. * @param r defines the red component to read from
  83828. * @param g defines the green component to read from
  83829. * @param b defines the blue component to read from
  83830. * @returns the current Color3 object
  83831. */
  83832. set(r: number, g: number, b: number): Color3;
  83833. /**
  83834. * Compute the Color3 hexadecimal code as a string
  83835. * @returns a string containing the hexadecimal representation of the Color3 object
  83836. */
  83837. toHexString(): string;
  83838. /**
  83839. * Computes a new Color3 converted from the current one to linear space
  83840. * @returns a new Color3 object
  83841. */
  83842. toLinearSpace(): Color3;
  83843. /**
  83844. * Converts current color in rgb space to HSV values
  83845. * @returns a new color3 representing the HSV values
  83846. */
  83847. toHSV(): Color3;
  83848. /**
  83849. * Converts current color in rgb space to HSV values
  83850. * @param result defines the Color3 where to store the HSV values
  83851. */
  83852. toHSVToRef(result: Color3): void;
  83853. /**
  83854. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  83855. * @param convertedColor defines the Color3 object where to store the linear space version
  83856. * @returns the unmodified Color3
  83857. */
  83858. toLinearSpaceToRef(convertedColor: Color3): Color3;
  83859. /**
  83860. * Computes a new Color3 converted from the current one to gamma space
  83861. * @returns a new Color3 object
  83862. */
  83863. toGammaSpace(): Color3;
  83864. /**
  83865. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  83866. * @param convertedColor defines the Color3 object where to store the gamma space version
  83867. * @returns the unmodified Color3
  83868. */
  83869. toGammaSpaceToRef(convertedColor: Color3): Color3;
  83870. private static _BlackReadOnly;
  83871. /**
  83872. * Convert Hue, saturation and value to a Color3 (RGB)
  83873. * @param hue defines the hue
  83874. * @param saturation defines the saturation
  83875. * @param value defines the value
  83876. * @param result defines the Color3 where to store the RGB values
  83877. */
  83878. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  83879. /**
  83880. * Creates a new Color3 from the string containing valid hexadecimal values
  83881. * @param hex defines a string containing valid hexadecimal values
  83882. * @returns a new Color3 object
  83883. */
  83884. static FromHexString(hex: string): Color3;
  83885. /**
  83886. * Creates a new Color3 from the starting index of the given array
  83887. * @param array defines the source array
  83888. * @param offset defines an offset in the source array
  83889. * @returns a new Color3 object
  83890. */
  83891. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  83892. /**
  83893. * Creates a new Color3 from integer values (< 256)
  83894. * @param r defines the red component to read from (value between 0 and 255)
  83895. * @param g defines the green component to read from (value between 0 and 255)
  83896. * @param b defines the blue component to read from (value between 0 and 255)
  83897. * @returns a new Color3 object
  83898. */
  83899. static FromInts(r: number, g: number, b: number): Color3;
  83900. /**
  83901. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83902. * @param start defines the start Color3 value
  83903. * @param end defines the end Color3 value
  83904. * @param amount defines the gradient value between start and end
  83905. * @returns a new Color3 object
  83906. */
  83907. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  83908. /**
  83909. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83910. * @param left defines the start value
  83911. * @param right defines the end value
  83912. * @param amount defines the gradient factor
  83913. * @param result defines the Color3 object where to store the result
  83914. */
  83915. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  83916. /**
  83917. * Returns a Color3 value containing a red color
  83918. * @returns a new Color3 object
  83919. */
  83920. static Red(): Color3;
  83921. /**
  83922. * Returns a Color3 value containing a green color
  83923. * @returns a new Color3 object
  83924. */
  83925. static Green(): Color3;
  83926. /**
  83927. * Returns a Color3 value containing a blue color
  83928. * @returns a new Color3 object
  83929. */
  83930. static Blue(): Color3;
  83931. /**
  83932. * Returns a Color3 value containing a black color
  83933. * @returns a new Color3 object
  83934. */
  83935. static Black(): Color3;
  83936. /**
  83937. * Gets a Color3 value containing a black color that must not be updated
  83938. */
  83939. static get BlackReadOnly(): DeepImmutable<Color3>;
  83940. /**
  83941. * Returns a Color3 value containing a white color
  83942. * @returns a new Color3 object
  83943. */
  83944. static White(): Color3;
  83945. /**
  83946. * Returns a Color3 value containing a purple color
  83947. * @returns a new Color3 object
  83948. */
  83949. static Purple(): Color3;
  83950. /**
  83951. * Returns a Color3 value containing a magenta color
  83952. * @returns a new Color3 object
  83953. */
  83954. static Magenta(): Color3;
  83955. /**
  83956. * Returns a Color3 value containing a yellow color
  83957. * @returns a new Color3 object
  83958. */
  83959. static Yellow(): Color3;
  83960. /**
  83961. * Returns a Color3 value containing a gray color
  83962. * @returns a new Color3 object
  83963. */
  83964. static Gray(): Color3;
  83965. /**
  83966. * Returns a Color3 value containing a teal color
  83967. * @returns a new Color3 object
  83968. */
  83969. static Teal(): Color3;
  83970. /**
  83971. * Returns a Color3 value containing a random color
  83972. * @returns a new Color3 object
  83973. */
  83974. static Random(): Color3;
  83975. }
  83976. /**
  83977. * Class used to hold a RBGA color
  83978. */
  83979. export class Color4 {
  83980. /**
  83981. * Defines the red component (between 0 and 1, default is 0)
  83982. */
  83983. r: number;
  83984. /**
  83985. * Defines the green component (between 0 and 1, default is 0)
  83986. */
  83987. g: number;
  83988. /**
  83989. * Defines the blue component (between 0 and 1, default is 0)
  83990. */
  83991. b: number;
  83992. /**
  83993. * Defines the alpha component (between 0 and 1, default is 1)
  83994. */
  83995. a: number;
  83996. /**
  83997. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  83998. * @param r defines the red component (between 0 and 1, default is 0)
  83999. * @param g defines the green component (between 0 and 1, default is 0)
  84000. * @param b defines the blue component (between 0 and 1, default is 0)
  84001. * @param a defines the alpha component (between 0 and 1, default is 1)
  84002. */
  84003. constructor(
  84004. /**
  84005. * Defines the red component (between 0 and 1, default is 0)
  84006. */
  84007. r?: number,
  84008. /**
  84009. * Defines the green component (between 0 and 1, default is 0)
  84010. */
  84011. g?: number,
  84012. /**
  84013. * Defines the blue component (between 0 and 1, default is 0)
  84014. */
  84015. b?: number,
  84016. /**
  84017. * Defines the alpha component (between 0 and 1, default is 1)
  84018. */
  84019. a?: number);
  84020. /**
  84021. * Adds in place the given Color4 values to the current Color4 object
  84022. * @param right defines the second operand
  84023. * @returns the current updated Color4 object
  84024. */
  84025. addInPlace(right: DeepImmutable<Color4>): Color4;
  84026. /**
  84027. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84028. * @returns the new array
  84029. */
  84030. asArray(): number[];
  84031. /**
  84032. * Stores from the starting index in the given array the Color4 successive values
  84033. * @param array defines the array where to store the r,g,b components
  84034. * @param index defines an optional index in the target array to define where to start storing values
  84035. * @returns the current Color4 object
  84036. */
  84037. toArray(array: number[], index?: number): Color4;
  84038. /**
  84039. * Determines equality between Color4 objects
  84040. * @param otherColor defines the second operand
  84041. * @returns true if the rgba values are equal to the given ones
  84042. */
  84043. equals(otherColor: DeepImmutable<Color4>): boolean;
  84044. /**
  84045. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84046. * @param right defines the second operand
  84047. * @returns a new Color4 object
  84048. */
  84049. add(right: DeepImmutable<Color4>): Color4;
  84050. /**
  84051. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84052. * @param right defines the second operand
  84053. * @returns a new Color4 object
  84054. */
  84055. subtract(right: DeepImmutable<Color4>): Color4;
  84056. /**
  84057. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84058. * @param right defines the second operand
  84059. * @param result defines the Color4 object where to store the result
  84060. * @returns the current Color4 object
  84061. */
  84062. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84063. /**
  84064. * Creates a new Color4 with the current Color4 values multiplied by scale
  84065. * @param scale defines the scaling factor to apply
  84066. * @returns a new Color4 object
  84067. */
  84068. scale(scale: number): Color4;
  84069. /**
  84070. * Multiplies the current Color4 values by scale and stores the result in "result"
  84071. * @param scale defines the scaling factor to apply
  84072. * @param result defines the Color4 object where to store the result
  84073. * @returns the current unmodified Color4
  84074. */
  84075. scaleToRef(scale: number, result: Color4): Color4;
  84076. /**
  84077. * Scale the current Color4 values by a factor and add the result to a given Color4
  84078. * @param scale defines the scale factor
  84079. * @param result defines the Color4 object where to store the result
  84080. * @returns the unmodified current Color4
  84081. */
  84082. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84083. /**
  84084. * Clamps the rgb values by the min and max values and stores the result into "result"
  84085. * @param min defines minimum clamping value (default is 0)
  84086. * @param max defines maximum clamping value (default is 1)
  84087. * @param result defines color to store the result into.
  84088. * @returns the cuurent Color4
  84089. */
  84090. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84091. /**
  84092. * Multipy an Color4 value by another and return a new Color4 object
  84093. * @param color defines the Color4 value to multiply by
  84094. * @returns a new Color4 object
  84095. */
  84096. multiply(color: Color4): Color4;
  84097. /**
  84098. * Multipy a Color4 value by another and push the result in a reference value
  84099. * @param color defines the Color4 value to multiply by
  84100. * @param result defines the Color4 to fill the result in
  84101. * @returns the result Color4
  84102. */
  84103. multiplyToRef(color: Color4, result: Color4): Color4;
  84104. /**
  84105. * Creates a string with the Color4 current values
  84106. * @returns the string representation of the Color4 object
  84107. */
  84108. toString(): string;
  84109. /**
  84110. * Returns the string "Color4"
  84111. * @returns "Color4"
  84112. */
  84113. getClassName(): string;
  84114. /**
  84115. * Compute the Color4 hash code
  84116. * @returns an unique number that can be used to hash Color4 objects
  84117. */
  84118. getHashCode(): number;
  84119. /**
  84120. * Creates a new Color4 copied from the current one
  84121. * @returns a new Color4 object
  84122. */
  84123. clone(): Color4;
  84124. /**
  84125. * Copies the given Color4 values into the current one
  84126. * @param source defines the source Color4 object
  84127. * @returns the current updated Color4 object
  84128. */
  84129. copyFrom(source: Color4): Color4;
  84130. /**
  84131. * Copies the given float values into the current one
  84132. * @param r defines the red component to read from
  84133. * @param g defines the green component to read from
  84134. * @param b defines the blue component to read from
  84135. * @param a defines the alpha component to read from
  84136. * @returns the current updated Color4 object
  84137. */
  84138. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  84139. /**
  84140. * Copies the given float values into the current one
  84141. * @param r defines the red component to read from
  84142. * @param g defines the green component to read from
  84143. * @param b defines the blue component to read from
  84144. * @param a defines the alpha component to read from
  84145. * @returns the current updated Color4 object
  84146. */
  84147. set(r: number, g: number, b: number, a: number): Color4;
  84148. /**
  84149. * Compute the Color4 hexadecimal code as a string
  84150. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  84151. * @returns a string containing the hexadecimal representation of the Color4 object
  84152. */
  84153. toHexString(returnAsColor3?: boolean): string;
  84154. /**
  84155. * Computes a new Color4 converted from the current one to linear space
  84156. * @returns a new Color4 object
  84157. */
  84158. toLinearSpace(): Color4;
  84159. /**
  84160. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  84161. * @param convertedColor defines the Color4 object where to store the linear space version
  84162. * @returns the unmodified Color4
  84163. */
  84164. toLinearSpaceToRef(convertedColor: Color4): Color4;
  84165. /**
  84166. * Computes a new Color4 converted from the current one to gamma space
  84167. * @returns a new Color4 object
  84168. */
  84169. toGammaSpace(): Color4;
  84170. /**
  84171. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  84172. * @param convertedColor defines the Color4 object where to store the gamma space version
  84173. * @returns the unmodified Color4
  84174. */
  84175. toGammaSpaceToRef(convertedColor: Color4): Color4;
  84176. /**
  84177. * Creates a new Color4 from the string containing valid hexadecimal values
  84178. * @param hex defines a string containing valid hexadecimal values
  84179. * @returns a new Color4 object
  84180. */
  84181. static FromHexString(hex: string): Color4;
  84182. /**
  84183. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84184. * @param left defines the start value
  84185. * @param right defines the end value
  84186. * @param amount defines the gradient factor
  84187. * @returns a new Color4 object
  84188. */
  84189. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  84190. /**
  84191. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84192. * @param left defines the start value
  84193. * @param right defines the end value
  84194. * @param amount defines the gradient factor
  84195. * @param result defines the Color4 object where to store data
  84196. */
  84197. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  84198. /**
  84199. * Creates a new Color4 from a Color3 and an alpha value
  84200. * @param color3 defines the source Color3 to read from
  84201. * @param alpha defines the alpha component (1.0 by default)
  84202. * @returns a new Color4 object
  84203. */
  84204. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  84205. /**
  84206. * Creates a new Color4 from the starting index element of the given array
  84207. * @param array defines the source array to read from
  84208. * @param offset defines the offset in the source array
  84209. * @returns a new Color4 object
  84210. */
  84211. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84212. /**
  84213. * Creates a new Color3 from integer values (< 256)
  84214. * @param r defines the red component to read from (value between 0 and 255)
  84215. * @param g defines the green component to read from (value between 0 and 255)
  84216. * @param b defines the blue component to read from (value between 0 and 255)
  84217. * @param a defines the alpha component to read from (value between 0 and 255)
  84218. * @returns a new Color3 object
  84219. */
  84220. static FromInts(r: number, g: number, b: number, a: number): Color4;
  84221. /**
  84222. * Check the content of a given array and convert it to an array containing RGBA data
  84223. * If the original array was already containing count * 4 values then it is returned directly
  84224. * @param colors defines the array to check
  84225. * @param count defines the number of RGBA data to expect
  84226. * @returns an array containing count * 4 values (RGBA)
  84227. */
  84228. static CheckColors4(colors: number[], count: number): number[];
  84229. }
  84230. /**
  84231. * @hidden
  84232. */
  84233. export class TmpColors {
  84234. static Color3: Color3[];
  84235. static Color4: Color4[];
  84236. }
  84237. }
  84238. declare module BABYLON {
  84239. /**
  84240. * Defines an interface which represents an animation key frame
  84241. */
  84242. export interface IAnimationKey {
  84243. /**
  84244. * Frame of the key frame
  84245. */
  84246. frame: number;
  84247. /**
  84248. * Value at the specifies key frame
  84249. */
  84250. value: any;
  84251. /**
  84252. * The input tangent for the cubic hermite spline
  84253. */
  84254. inTangent?: any;
  84255. /**
  84256. * The output tangent for the cubic hermite spline
  84257. */
  84258. outTangent?: any;
  84259. /**
  84260. * The animation interpolation type
  84261. */
  84262. interpolation?: AnimationKeyInterpolation;
  84263. }
  84264. /**
  84265. * Enum for the animation key frame interpolation type
  84266. */
  84267. export enum AnimationKeyInterpolation {
  84268. /**
  84269. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  84270. */
  84271. STEP = 1
  84272. }
  84273. }
  84274. declare module BABYLON {
  84275. /**
  84276. * Represents the range of an animation
  84277. */
  84278. export class AnimationRange {
  84279. /**The name of the animation range**/
  84280. name: string;
  84281. /**The starting frame of the animation */
  84282. from: number;
  84283. /**The ending frame of the animation*/
  84284. to: number;
  84285. /**
  84286. * Initializes the range of an animation
  84287. * @param name The name of the animation range
  84288. * @param from The starting frame of the animation
  84289. * @param to The ending frame of the animation
  84290. */
  84291. constructor(
  84292. /**The name of the animation range**/
  84293. name: string,
  84294. /**The starting frame of the animation */
  84295. from: number,
  84296. /**The ending frame of the animation*/
  84297. to: number);
  84298. /**
  84299. * Makes a copy of the animation range
  84300. * @returns A copy of the animation range
  84301. */
  84302. clone(): AnimationRange;
  84303. }
  84304. }
  84305. declare module BABYLON {
  84306. /**
  84307. * Composed of a frame, and an action function
  84308. */
  84309. export class AnimationEvent {
  84310. /** The frame for which the event is triggered **/
  84311. frame: number;
  84312. /** The event to perform when triggered **/
  84313. action: (currentFrame: number) => void;
  84314. /** Specifies if the event should be triggered only once**/
  84315. onlyOnce?: boolean | undefined;
  84316. /**
  84317. * Specifies if the animation event is done
  84318. */
  84319. isDone: boolean;
  84320. /**
  84321. * Initializes the animation event
  84322. * @param frame The frame for which the event is triggered
  84323. * @param action The event to perform when triggered
  84324. * @param onlyOnce Specifies if the event should be triggered only once
  84325. */
  84326. constructor(
  84327. /** The frame for which the event is triggered **/
  84328. frame: number,
  84329. /** The event to perform when triggered **/
  84330. action: (currentFrame: number) => void,
  84331. /** Specifies if the event should be triggered only once**/
  84332. onlyOnce?: boolean | undefined);
  84333. /** @hidden */
  84334. _clone(): AnimationEvent;
  84335. }
  84336. }
  84337. declare module BABYLON {
  84338. /**
  84339. * Interface used to define a behavior
  84340. */
  84341. export interface Behavior<T> {
  84342. /** gets or sets behavior's name */
  84343. name: string;
  84344. /**
  84345. * Function called when the behavior needs to be initialized (after attaching it to a target)
  84346. */
  84347. init(): void;
  84348. /**
  84349. * Called when the behavior is attached to a target
  84350. * @param target defines the target where the behavior is attached to
  84351. */
  84352. attach(target: T): void;
  84353. /**
  84354. * Called when the behavior is detached from its target
  84355. */
  84356. detach(): void;
  84357. }
  84358. /**
  84359. * Interface implemented by classes supporting behaviors
  84360. */
  84361. export interface IBehaviorAware<T> {
  84362. /**
  84363. * Attach a behavior
  84364. * @param behavior defines the behavior to attach
  84365. * @returns the current host
  84366. */
  84367. addBehavior(behavior: Behavior<T>): T;
  84368. /**
  84369. * Remove a behavior from the current object
  84370. * @param behavior defines the behavior to detach
  84371. * @returns the current host
  84372. */
  84373. removeBehavior(behavior: Behavior<T>): T;
  84374. /**
  84375. * Gets a behavior using its name to search
  84376. * @param name defines the name to search
  84377. * @returns the behavior or null if not found
  84378. */
  84379. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  84380. }
  84381. }
  84382. declare module BABYLON {
  84383. /**
  84384. * Defines an array and its length.
  84385. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  84386. */
  84387. export interface ISmartArrayLike<T> {
  84388. /**
  84389. * The data of the array.
  84390. */
  84391. data: Array<T>;
  84392. /**
  84393. * The active length of the array.
  84394. */
  84395. length: number;
  84396. }
  84397. /**
  84398. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84399. */
  84400. export class SmartArray<T> implements ISmartArrayLike<T> {
  84401. /**
  84402. * The full set of data from the array.
  84403. */
  84404. data: Array<T>;
  84405. /**
  84406. * The active length of the array.
  84407. */
  84408. length: number;
  84409. protected _id: number;
  84410. /**
  84411. * Instantiates a Smart Array.
  84412. * @param capacity defines the default capacity of the array.
  84413. */
  84414. constructor(capacity: number);
  84415. /**
  84416. * Pushes a value at the end of the active data.
  84417. * @param value defines the object to push in the array.
  84418. */
  84419. push(value: T): void;
  84420. /**
  84421. * Iterates over the active data and apply the lambda to them.
  84422. * @param func defines the action to apply on each value.
  84423. */
  84424. forEach(func: (content: T) => void): void;
  84425. /**
  84426. * Sorts the full sets of data.
  84427. * @param compareFn defines the comparison function to apply.
  84428. */
  84429. sort(compareFn: (a: T, b: T) => number): void;
  84430. /**
  84431. * Resets the active data to an empty array.
  84432. */
  84433. reset(): void;
  84434. /**
  84435. * Releases all the data from the array as well as the array.
  84436. */
  84437. dispose(): void;
  84438. /**
  84439. * Concats the active data with a given array.
  84440. * @param array defines the data to concatenate with.
  84441. */
  84442. concat(array: any): void;
  84443. /**
  84444. * Returns the position of a value in the active data.
  84445. * @param value defines the value to find the index for
  84446. * @returns the index if found in the active data otherwise -1
  84447. */
  84448. indexOf(value: T): number;
  84449. /**
  84450. * Returns whether an element is part of the active data.
  84451. * @param value defines the value to look for
  84452. * @returns true if found in the active data otherwise false
  84453. */
  84454. contains(value: T): boolean;
  84455. private static _GlobalId;
  84456. }
  84457. /**
  84458. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84459. * The data in this array can only be present once
  84460. */
  84461. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  84462. private _duplicateId;
  84463. /**
  84464. * Pushes a value at the end of the active data.
  84465. * THIS DOES NOT PREVENT DUPPLICATE DATA
  84466. * @param value defines the object to push in the array.
  84467. */
  84468. push(value: T): void;
  84469. /**
  84470. * Pushes a value at the end of the active data.
  84471. * If the data is already present, it won t be added again
  84472. * @param value defines the object to push in the array.
  84473. * @returns true if added false if it was already present
  84474. */
  84475. pushNoDuplicate(value: T): boolean;
  84476. /**
  84477. * Resets the active data to an empty array.
  84478. */
  84479. reset(): void;
  84480. /**
  84481. * Concats the active data with a given array.
  84482. * This ensures no dupplicate will be present in the result.
  84483. * @param array defines the data to concatenate with.
  84484. */
  84485. concatWithNoDuplicate(array: any): void;
  84486. }
  84487. }
  84488. declare module BABYLON {
  84489. /**
  84490. * @ignore
  84491. * This is a list of all the different input types that are available in the application.
  84492. * Fo instance: ArcRotateCameraGamepadInput...
  84493. */
  84494. export var CameraInputTypes: {};
  84495. /**
  84496. * This is the contract to implement in order to create a new input class.
  84497. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  84498. */
  84499. export interface ICameraInput<TCamera extends Camera> {
  84500. /**
  84501. * Defines the camera the input is attached to.
  84502. */
  84503. camera: Nullable<TCamera>;
  84504. /**
  84505. * Gets the class name of the current intput.
  84506. * @returns the class name
  84507. */
  84508. getClassName(): string;
  84509. /**
  84510. * Get the friendly name associated with the input class.
  84511. * @returns the input friendly name
  84512. */
  84513. getSimpleName(): string;
  84514. /**
  84515. * Attach the input controls to a specific dom element to get the input from.
  84516. * @param element Defines the element the controls should be listened from
  84517. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84518. */
  84519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84520. /**
  84521. * Detach the current controls from the specified dom element.
  84522. * @param element Defines the element to stop listening the inputs from
  84523. */
  84524. detachControl(element: Nullable<HTMLElement>): void;
  84525. /**
  84526. * Update the current camera state depending on the inputs that have been used this frame.
  84527. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84528. */
  84529. checkInputs?: () => void;
  84530. }
  84531. /**
  84532. * Represents a map of input types to input instance or input index to input instance.
  84533. */
  84534. export interface CameraInputsMap<TCamera extends Camera> {
  84535. /**
  84536. * Accessor to the input by input type.
  84537. */
  84538. [name: string]: ICameraInput<TCamera>;
  84539. /**
  84540. * Accessor to the input by input index.
  84541. */
  84542. [idx: number]: ICameraInput<TCamera>;
  84543. }
  84544. /**
  84545. * This represents the input manager used within a camera.
  84546. * It helps dealing with all the different kind of input attached to a camera.
  84547. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84548. */
  84549. export class CameraInputsManager<TCamera extends Camera> {
  84550. /**
  84551. * Defines the list of inputs attahed to the camera.
  84552. */
  84553. attached: CameraInputsMap<TCamera>;
  84554. /**
  84555. * Defines the dom element the camera is collecting inputs from.
  84556. * This is null if the controls have not been attached.
  84557. */
  84558. attachedElement: Nullable<HTMLElement>;
  84559. /**
  84560. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84561. */
  84562. noPreventDefault: boolean;
  84563. /**
  84564. * Defined the camera the input manager belongs to.
  84565. */
  84566. camera: TCamera;
  84567. /**
  84568. * Update the current camera state depending on the inputs that have been used this frame.
  84569. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84570. */
  84571. checkInputs: () => void;
  84572. /**
  84573. * Instantiate a new Camera Input Manager.
  84574. * @param camera Defines the camera the input manager blongs to
  84575. */
  84576. constructor(camera: TCamera);
  84577. /**
  84578. * Add an input method to a camera
  84579. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84580. * @param input camera input method
  84581. */
  84582. add(input: ICameraInput<TCamera>): void;
  84583. /**
  84584. * Remove a specific input method from a camera
  84585. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  84586. * @param inputToRemove camera input method
  84587. */
  84588. remove(inputToRemove: ICameraInput<TCamera>): void;
  84589. /**
  84590. * Remove a specific input type from a camera
  84591. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  84592. * @param inputType the type of the input to remove
  84593. */
  84594. removeByType(inputType: string): void;
  84595. private _addCheckInputs;
  84596. /**
  84597. * Attach the input controls to the currently attached dom element to listen the events from.
  84598. * @param input Defines the input to attach
  84599. */
  84600. attachInput(input: ICameraInput<TCamera>): void;
  84601. /**
  84602. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  84603. * @param element Defines the dom element to collect the events from
  84604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84605. */
  84606. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  84607. /**
  84608. * Detach the current manager inputs controls from a specific dom element.
  84609. * @param element Defines the dom element to collect the events from
  84610. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  84611. */
  84612. detachElement(element: HTMLElement, disconnect?: boolean): void;
  84613. /**
  84614. * Rebuild the dynamic inputCheck function from the current list of
  84615. * defined inputs in the manager.
  84616. */
  84617. rebuildInputCheck(): void;
  84618. /**
  84619. * Remove all attached input methods from a camera
  84620. */
  84621. clear(): void;
  84622. /**
  84623. * Serialize the current input manager attached to a camera.
  84624. * This ensures than once parsed,
  84625. * the input associated to the camera will be identical to the current ones
  84626. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  84627. */
  84628. serialize(serializedCamera: any): void;
  84629. /**
  84630. * Parses an input manager serialized JSON to restore the previous list of inputs
  84631. * and states associated to a camera.
  84632. * @param parsedCamera Defines the JSON to parse
  84633. */
  84634. parse(parsedCamera: any): void;
  84635. }
  84636. }
  84637. declare module BABYLON {
  84638. /**
  84639. * Class used to store data that will be store in GPU memory
  84640. */
  84641. export class Buffer {
  84642. private _engine;
  84643. private _buffer;
  84644. /** @hidden */
  84645. _data: Nullable<DataArray>;
  84646. private _updatable;
  84647. private _instanced;
  84648. private _divisor;
  84649. /**
  84650. * Gets the byte stride.
  84651. */
  84652. readonly byteStride: number;
  84653. /**
  84654. * Constructor
  84655. * @param engine the engine
  84656. * @param data the data to use for this buffer
  84657. * @param updatable whether the data is updatable
  84658. * @param stride the stride (optional)
  84659. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84660. * @param instanced whether the buffer is instanced (optional)
  84661. * @param useBytes set to true if the stride in in bytes (optional)
  84662. * @param divisor sets an optional divisor for instances (1 by default)
  84663. */
  84664. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  84665. /**
  84666. * Create a new VertexBuffer based on the current buffer
  84667. * @param kind defines the vertex buffer kind (position, normal, etc.)
  84668. * @param offset defines offset in the buffer (0 by default)
  84669. * @param size defines the size in floats of attributes (position is 3 for instance)
  84670. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  84671. * @param instanced defines if the vertex buffer contains indexed data
  84672. * @param useBytes defines if the offset and stride are in bytes *
  84673. * @param divisor sets an optional divisor for instances (1 by default)
  84674. * @returns the new vertex buffer
  84675. */
  84676. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  84677. /**
  84678. * Gets a boolean indicating if the Buffer is updatable?
  84679. * @returns true if the buffer is updatable
  84680. */
  84681. isUpdatable(): boolean;
  84682. /**
  84683. * Gets current buffer's data
  84684. * @returns a DataArray or null
  84685. */
  84686. getData(): Nullable<DataArray>;
  84687. /**
  84688. * Gets underlying native buffer
  84689. * @returns underlying native buffer
  84690. */
  84691. getBuffer(): Nullable<DataBuffer>;
  84692. /**
  84693. * Gets the stride in float32 units (i.e. byte stride / 4).
  84694. * May not be an integer if the byte stride is not divisible by 4.
  84695. * @returns the stride in float32 units
  84696. * @deprecated Please use byteStride instead.
  84697. */
  84698. getStrideSize(): number;
  84699. /**
  84700. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84701. * @param data defines the data to store
  84702. */
  84703. create(data?: Nullable<DataArray>): void;
  84704. /** @hidden */
  84705. _rebuild(): void;
  84706. /**
  84707. * Update current buffer data
  84708. * @param data defines the data to store
  84709. */
  84710. update(data: DataArray): void;
  84711. /**
  84712. * Updates the data directly.
  84713. * @param data the new data
  84714. * @param offset the new offset
  84715. * @param vertexCount the vertex count (optional)
  84716. * @param useBytes set to true if the offset is in bytes
  84717. */
  84718. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  84719. /**
  84720. * Release all resources
  84721. */
  84722. dispose(): void;
  84723. }
  84724. /**
  84725. * Specialized buffer used to store vertex data
  84726. */
  84727. export class VertexBuffer {
  84728. /** @hidden */
  84729. _buffer: Buffer;
  84730. private _kind;
  84731. private _size;
  84732. private _ownsBuffer;
  84733. private _instanced;
  84734. private _instanceDivisor;
  84735. /**
  84736. * The byte type.
  84737. */
  84738. static readonly BYTE: number;
  84739. /**
  84740. * The unsigned byte type.
  84741. */
  84742. static readonly UNSIGNED_BYTE: number;
  84743. /**
  84744. * The short type.
  84745. */
  84746. static readonly SHORT: number;
  84747. /**
  84748. * The unsigned short type.
  84749. */
  84750. static readonly UNSIGNED_SHORT: number;
  84751. /**
  84752. * The integer type.
  84753. */
  84754. static readonly INT: number;
  84755. /**
  84756. * The unsigned integer type.
  84757. */
  84758. static readonly UNSIGNED_INT: number;
  84759. /**
  84760. * The float type.
  84761. */
  84762. static readonly FLOAT: number;
  84763. /**
  84764. * Gets or sets the instance divisor when in instanced mode
  84765. */
  84766. get instanceDivisor(): number;
  84767. set instanceDivisor(value: number);
  84768. /**
  84769. * Gets the byte stride.
  84770. */
  84771. readonly byteStride: number;
  84772. /**
  84773. * Gets the byte offset.
  84774. */
  84775. readonly byteOffset: number;
  84776. /**
  84777. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  84778. */
  84779. readonly normalized: boolean;
  84780. /**
  84781. * Gets the data type of each component in the array.
  84782. */
  84783. readonly type: number;
  84784. /**
  84785. * Constructor
  84786. * @param engine the engine
  84787. * @param data the data to use for this vertex buffer
  84788. * @param kind the vertex buffer kind
  84789. * @param updatable whether the data is updatable
  84790. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84791. * @param stride the stride (optional)
  84792. * @param instanced whether the buffer is instanced (optional)
  84793. * @param offset the offset of the data (optional)
  84794. * @param size the number of components (optional)
  84795. * @param type the type of the component (optional)
  84796. * @param normalized whether the data contains normalized data (optional)
  84797. * @param useBytes set to true if stride and offset are in bytes (optional)
  84798. * @param divisor defines the instance divisor to use (1 by default)
  84799. */
  84800. 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);
  84801. /** @hidden */
  84802. _rebuild(): void;
  84803. /**
  84804. * Returns the kind of the VertexBuffer (string)
  84805. * @returns a string
  84806. */
  84807. getKind(): string;
  84808. /**
  84809. * Gets a boolean indicating if the VertexBuffer is updatable?
  84810. * @returns true if the buffer is updatable
  84811. */
  84812. isUpdatable(): boolean;
  84813. /**
  84814. * Gets current buffer's data
  84815. * @returns a DataArray or null
  84816. */
  84817. getData(): Nullable<DataArray>;
  84818. /**
  84819. * Gets underlying native buffer
  84820. * @returns underlying native buffer
  84821. */
  84822. getBuffer(): Nullable<DataBuffer>;
  84823. /**
  84824. * Gets the stride in float32 units (i.e. byte stride / 4).
  84825. * May not be an integer if the byte stride is not divisible by 4.
  84826. * @returns the stride in float32 units
  84827. * @deprecated Please use byteStride instead.
  84828. */
  84829. getStrideSize(): number;
  84830. /**
  84831. * Returns the offset as a multiple of the type byte length.
  84832. * @returns the offset in bytes
  84833. * @deprecated Please use byteOffset instead.
  84834. */
  84835. getOffset(): number;
  84836. /**
  84837. * Returns the number of components per vertex attribute (integer)
  84838. * @returns the size in float
  84839. */
  84840. getSize(): number;
  84841. /**
  84842. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84843. * @returns true if this buffer is instanced
  84844. */
  84845. getIsInstanced(): boolean;
  84846. /**
  84847. * Returns the instancing divisor, zero for non-instanced (integer).
  84848. * @returns a number
  84849. */
  84850. getInstanceDivisor(): number;
  84851. /**
  84852. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84853. * @param data defines the data to store
  84854. */
  84855. create(data?: DataArray): void;
  84856. /**
  84857. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  84858. * This function will create a new buffer if the current one is not updatable
  84859. * @param data defines the data to store
  84860. */
  84861. update(data: DataArray): void;
  84862. /**
  84863. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  84864. * Returns the directly updated WebGLBuffer.
  84865. * @param data the new data
  84866. * @param offset the new offset
  84867. * @param useBytes set to true if the offset is in bytes
  84868. */
  84869. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  84870. /**
  84871. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  84872. */
  84873. dispose(): void;
  84874. /**
  84875. * Enumerates each value of this vertex buffer as numbers.
  84876. * @param count the number of values to enumerate
  84877. * @param callback the callback function called for each value
  84878. */
  84879. forEach(count: number, callback: (value: number, index: number) => void): void;
  84880. /**
  84881. * Positions
  84882. */
  84883. static readonly PositionKind: string;
  84884. /**
  84885. * Normals
  84886. */
  84887. static readonly NormalKind: string;
  84888. /**
  84889. * Tangents
  84890. */
  84891. static readonly TangentKind: string;
  84892. /**
  84893. * Texture coordinates
  84894. */
  84895. static readonly UVKind: string;
  84896. /**
  84897. * Texture coordinates 2
  84898. */
  84899. static readonly UV2Kind: string;
  84900. /**
  84901. * Texture coordinates 3
  84902. */
  84903. static readonly UV3Kind: string;
  84904. /**
  84905. * Texture coordinates 4
  84906. */
  84907. static readonly UV4Kind: string;
  84908. /**
  84909. * Texture coordinates 5
  84910. */
  84911. static readonly UV5Kind: string;
  84912. /**
  84913. * Texture coordinates 6
  84914. */
  84915. static readonly UV6Kind: string;
  84916. /**
  84917. * Colors
  84918. */
  84919. static readonly ColorKind: string;
  84920. /**
  84921. * Matrix indices (for bones)
  84922. */
  84923. static readonly MatricesIndicesKind: string;
  84924. /**
  84925. * Matrix weights (for bones)
  84926. */
  84927. static readonly MatricesWeightsKind: string;
  84928. /**
  84929. * Additional matrix indices (for bones)
  84930. */
  84931. static readonly MatricesIndicesExtraKind: string;
  84932. /**
  84933. * Additional matrix weights (for bones)
  84934. */
  84935. static readonly MatricesWeightsExtraKind: string;
  84936. /**
  84937. * Deduces the stride given a kind.
  84938. * @param kind The kind string to deduce
  84939. * @returns The deduced stride
  84940. */
  84941. static DeduceStride(kind: string): number;
  84942. /**
  84943. * Gets the byte length of the given type.
  84944. * @param type the type
  84945. * @returns the number of bytes
  84946. */
  84947. static GetTypeByteLength(type: number): number;
  84948. /**
  84949. * Enumerates each value of the given parameters as numbers.
  84950. * @param data the data to enumerate
  84951. * @param byteOffset the byte offset of the data
  84952. * @param byteStride the byte stride of the data
  84953. * @param componentCount the number of components per element
  84954. * @param componentType the type of the component
  84955. * @param count the number of values to enumerate
  84956. * @param normalized whether the data is normalized
  84957. * @param callback the callback function called for each value
  84958. */
  84959. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  84960. private static _GetFloatValue;
  84961. }
  84962. }
  84963. declare module BABYLON {
  84964. /**
  84965. * @hidden
  84966. */
  84967. export class IntersectionInfo {
  84968. bu: Nullable<number>;
  84969. bv: Nullable<number>;
  84970. distance: number;
  84971. faceId: number;
  84972. subMeshId: number;
  84973. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  84974. }
  84975. }
  84976. declare module BABYLON {
  84977. /**
  84978. * Class used to store bounding sphere information
  84979. */
  84980. export class BoundingSphere {
  84981. /**
  84982. * Gets the center of the bounding sphere in local space
  84983. */
  84984. readonly center: Vector3;
  84985. /**
  84986. * Radius of the bounding sphere in local space
  84987. */
  84988. radius: number;
  84989. /**
  84990. * Gets the center of the bounding sphere in world space
  84991. */
  84992. readonly centerWorld: Vector3;
  84993. /**
  84994. * Radius of the bounding sphere in world space
  84995. */
  84996. radiusWorld: number;
  84997. /**
  84998. * Gets the minimum vector in local space
  84999. */
  85000. readonly minimum: Vector3;
  85001. /**
  85002. * Gets the maximum vector in local space
  85003. */
  85004. readonly maximum: Vector3;
  85005. private _worldMatrix;
  85006. private static readonly TmpVector3;
  85007. /**
  85008. * Creates a new bounding sphere
  85009. * @param min defines the minimum vector (in local space)
  85010. * @param max defines the maximum vector (in local space)
  85011. * @param worldMatrix defines the new world matrix
  85012. */
  85013. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85014. /**
  85015. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85016. * @param min defines the new minimum vector (in local space)
  85017. * @param max defines the new maximum vector (in local space)
  85018. * @param worldMatrix defines the new world matrix
  85019. */
  85020. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85021. /**
  85022. * Scale the current bounding sphere by applying a scale factor
  85023. * @param factor defines the scale factor to apply
  85024. * @returns the current bounding box
  85025. */
  85026. scale(factor: number): BoundingSphere;
  85027. /**
  85028. * Gets the world matrix of the bounding box
  85029. * @returns a matrix
  85030. */
  85031. getWorldMatrix(): DeepImmutable<Matrix>;
  85032. /** @hidden */
  85033. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85034. /**
  85035. * Tests if the bounding sphere is intersecting the frustum planes
  85036. * @param frustumPlanes defines the frustum planes to test
  85037. * @returns true if there is an intersection
  85038. */
  85039. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85040. /**
  85041. * Tests if the bounding sphere center is in between the frustum planes.
  85042. * Used for optimistic fast inclusion.
  85043. * @param frustumPlanes defines the frustum planes to test
  85044. * @returns true if the sphere center is in between the frustum planes
  85045. */
  85046. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85047. /**
  85048. * Tests if a point is inside the bounding sphere
  85049. * @param point defines the point to test
  85050. * @returns true if the point is inside the bounding sphere
  85051. */
  85052. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85053. /**
  85054. * Checks if two sphere intersct
  85055. * @param sphere0 sphere 0
  85056. * @param sphere1 sphere 1
  85057. * @returns true if the speres intersect
  85058. */
  85059. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85060. }
  85061. }
  85062. declare module BABYLON {
  85063. /**
  85064. * Class used to store bounding box information
  85065. */
  85066. export class BoundingBox implements ICullable {
  85067. /**
  85068. * Gets the 8 vectors representing the bounding box in local space
  85069. */
  85070. readonly vectors: Vector3[];
  85071. /**
  85072. * Gets the center of the bounding box in local space
  85073. */
  85074. readonly center: Vector3;
  85075. /**
  85076. * Gets the center of the bounding box in world space
  85077. */
  85078. readonly centerWorld: Vector3;
  85079. /**
  85080. * Gets the extend size in local space
  85081. */
  85082. readonly extendSize: Vector3;
  85083. /**
  85084. * Gets the extend size in world space
  85085. */
  85086. readonly extendSizeWorld: Vector3;
  85087. /**
  85088. * Gets the OBB (object bounding box) directions
  85089. */
  85090. readonly directions: Vector3[];
  85091. /**
  85092. * Gets the 8 vectors representing the bounding box in world space
  85093. */
  85094. readonly vectorsWorld: Vector3[];
  85095. /**
  85096. * Gets the minimum vector in world space
  85097. */
  85098. readonly minimumWorld: Vector3;
  85099. /**
  85100. * Gets the maximum vector in world space
  85101. */
  85102. readonly maximumWorld: Vector3;
  85103. /**
  85104. * Gets the minimum vector in local space
  85105. */
  85106. readonly minimum: Vector3;
  85107. /**
  85108. * Gets the maximum vector in local space
  85109. */
  85110. readonly maximum: Vector3;
  85111. private _worldMatrix;
  85112. private static readonly TmpVector3;
  85113. /**
  85114. * @hidden
  85115. */
  85116. _tag: number;
  85117. /**
  85118. * Creates a new bounding box
  85119. * @param min defines the minimum vector (in local space)
  85120. * @param max defines the maximum vector (in local space)
  85121. * @param worldMatrix defines the new world matrix
  85122. */
  85123. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85124. /**
  85125. * Recreates the entire bounding box from scratch as if we call the constructor in place
  85126. * @param min defines the new minimum vector (in local space)
  85127. * @param max defines the new maximum vector (in local space)
  85128. * @param worldMatrix defines the new world matrix
  85129. */
  85130. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85131. /**
  85132. * Scale the current bounding box by applying a scale factor
  85133. * @param factor defines the scale factor to apply
  85134. * @returns the current bounding box
  85135. */
  85136. scale(factor: number): BoundingBox;
  85137. /**
  85138. * Gets the world matrix of the bounding box
  85139. * @returns a matrix
  85140. */
  85141. getWorldMatrix(): DeepImmutable<Matrix>;
  85142. /** @hidden */
  85143. _update(world: DeepImmutable<Matrix>): void;
  85144. /**
  85145. * Tests if the bounding box is intersecting the frustum planes
  85146. * @param frustumPlanes defines the frustum planes to test
  85147. * @returns true if there is an intersection
  85148. */
  85149. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85150. /**
  85151. * Tests if the bounding box is entirely inside the frustum planes
  85152. * @param frustumPlanes defines the frustum planes to test
  85153. * @returns true if there is an inclusion
  85154. */
  85155. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85156. /**
  85157. * Tests if a point is inside the bounding box
  85158. * @param point defines the point to test
  85159. * @returns true if the point is inside the bounding box
  85160. */
  85161. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85162. /**
  85163. * Tests if the bounding box intersects with a bounding sphere
  85164. * @param sphere defines the sphere to test
  85165. * @returns true if there is an intersection
  85166. */
  85167. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  85168. /**
  85169. * Tests if the bounding box intersects with a box defined by a min and max vectors
  85170. * @param min defines the min vector to use
  85171. * @param max defines the max vector to use
  85172. * @returns true if there is an intersection
  85173. */
  85174. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  85175. /**
  85176. * Tests if two bounding boxes are intersections
  85177. * @param box0 defines the first box to test
  85178. * @param box1 defines the second box to test
  85179. * @returns true if there is an intersection
  85180. */
  85181. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  85182. /**
  85183. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  85184. * @param minPoint defines the minimum vector of the bounding box
  85185. * @param maxPoint defines the maximum vector of the bounding box
  85186. * @param sphereCenter defines the sphere center
  85187. * @param sphereRadius defines the sphere radius
  85188. * @returns true if there is an intersection
  85189. */
  85190. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  85191. /**
  85192. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  85193. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85194. * @param frustumPlanes defines the frustum planes to test
  85195. * @return true if there is an inclusion
  85196. */
  85197. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85198. /**
  85199. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  85200. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85201. * @param frustumPlanes defines the frustum planes to test
  85202. * @return true if there is an intersection
  85203. */
  85204. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85205. }
  85206. }
  85207. declare module BABYLON {
  85208. /** @hidden */
  85209. export class Collider {
  85210. /** Define if a collision was found */
  85211. collisionFound: boolean;
  85212. /**
  85213. * Define last intersection point in local space
  85214. */
  85215. intersectionPoint: Vector3;
  85216. /**
  85217. * Define last collided mesh
  85218. */
  85219. collidedMesh: Nullable<AbstractMesh>;
  85220. private _collisionPoint;
  85221. private _planeIntersectionPoint;
  85222. private _tempVector;
  85223. private _tempVector2;
  85224. private _tempVector3;
  85225. private _tempVector4;
  85226. private _edge;
  85227. private _baseToVertex;
  85228. private _destinationPoint;
  85229. private _slidePlaneNormal;
  85230. private _displacementVector;
  85231. /** @hidden */
  85232. _radius: Vector3;
  85233. /** @hidden */
  85234. _retry: number;
  85235. private _velocity;
  85236. private _basePoint;
  85237. private _epsilon;
  85238. /** @hidden */
  85239. _velocityWorldLength: number;
  85240. /** @hidden */
  85241. _basePointWorld: Vector3;
  85242. private _velocityWorld;
  85243. private _normalizedVelocity;
  85244. /** @hidden */
  85245. _initialVelocity: Vector3;
  85246. /** @hidden */
  85247. _initialPosition: Vector3;
  85248. private _nearestDistance;
  85249. private _collisionMask;
  85250. get collisionMask(): number;
  85251. set collisionMask(mask: number);
  85252. /**
  85253. * Gets the plane normal used to compute the sliding response (in local space)
  85254. */
  85255. get slidePlaneNormal(): Vector3;
  85256. /** @hidden */
  85257. _initialize(source: Vector3, dir: Vector3, e: number): void;
  85258. /** @hidden */
  85259. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  85260. /** @hidden */
  85261. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  85262. /** @hidden */
  85263. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85264. /** @hidden */
  85265. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85266. /** @hidden */
  85267. _getResponse(pos: Vector3, vel: Vector3): void;
  85268. }
  85269. }
  85270. declare module BABYLON {
  85271. /**
  85272. * Interface for cullable objects
  85273. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  85274. */
  85275. export interface ICullable {
  85276. /**
  85277. * Checks if the object or part of the object is in the frustum
  85278. * @param frustumPlanes Camera near/planes
  85279. * @returns true if the object is in frustum otherwise false
  85280. */
  85281. isInFrustum(frustumPlanes: Plane[]): boolean;
  85282. /**
  85283. * Checks if a cullable object (mesh...) is in the camera frustum
  85284. * Unlike isInFrustum this cheks the full bounding box
  85285. * @param frustumPlanes Camera near/planes
  85286. * @returns true if the object is in frustum otherwise false
  85287. */
  85288. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85289. }
  85290. /**
  85291. * Info for a bounding data of a mesh
  85292. */
  85293. export class BoundingInfo implements ICullable {
  85294. /**
  85295. * Bounding box for the mesh
  85296. */
  85297. readonly boundingBox: BoundingBox;
  85298. /**
  85299. * Bounding sphere for the mesh
  85300. */
  85301. readonly boundingSphere: BoundingSphere;
  85302. private _isLocked;
  85303. private static readonly TmpVector3;
  85304. /**
  85305. * Constructs bounding info
  85306. * @param minimum min vector of the bounding box/sphere
  85307. * @param maximum max vector of the bounding box/sphere
  85308. * @param worldMatrix defines the new world matrix
  85309. */
  85310. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85311. /**
  85312. * Recreates the entire bounding info from scratch as if we call the constructor in place
  85313. * @param min defines the new minimum vector (in local space)
  85314. * @param max defines the new maximum vector (in local space)
  85315. * @param worldMatrix defines the new world matrix
  85316. */
  85317. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85318. /**
  85319. * min vector of the bounding box/sphere
  85320. */
  85321. get minimum(): Vector3;
  85322. /**
  85323. * max vector of the bounding box/sphere
  85324. */
  85325. get maximum(): Vector3;
  85326. /**
  85327. * If the info is locked and won't be updated to avoid perf overhead
  85328. */
  85329. get isLocked(): boolean;
  85330. set isLocked(value: boolean);
  85331. /**
  85332. * Updates the bounding sphere and box
  85333. * @param world world matrix to be used to update
  85334. */
  85335. update(world: DeepImmutable<Matrix>): void;
  85336. /**
  85337. * Recreate the bounding info to be centered around a specific point given a specific extend.
  85338. * @param center New center of the bounding info
  85339. * @param extend New extend of the bounding info
  85340. * @returns the current bounding info
  85341. */
  85342. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  85343. /**
  85344. * Scale the current bounding info by applying a scale factor
  85345. * @param factor defines the scale factor to apply
  85346. * @returns the current bounding info
  85347. */
  85348. scale(factor: number): BoundingInfo;
  85349. /**
  85350. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  85351. * @param frustumPlanes defines the frustum to test
  85352. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  85353. * @returns true if the bounding info is in the frustum planes
  85354. */
  85355. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  85356. /**
  85357. * Gets the world distance between the min and max points of the bounding box
  85358. */
  85359. get diagonalLength(): number;
  85360. /**
  85361. * Checks if a cullable object (mesh...) is in the camera frustum
  85362. * Unlike isInFrustum this cheks the full bounding box
  85363. * @param frustumPlanes Camera near/planes
  85364. * @returns true if the object is in frustum otherwise false
  85365. */
  85366. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85367. /** @hidden */
  85368. _checkCollision(collider: Collider): boolean;
  85369. /**
  85370. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  85371. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85372. * @param point the point to check intersection with
  85373. * @returns if the point intersects
  85374. */
  85375. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85376. /**
  85377. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  85378. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85379. * @param boundingInfo the bounding info to check intersection with
  85380. * @param precise if the intersection should be done using OBB
  85381. * @returns if the bounding info intersects
  85382. */
  85383. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  85384. }
  85385. }
  85386. declare module BABYLON {
  85387. /**
  85388. * Extracts minimum and maximum values from a list of indexed positions
  85389. * @param positions defines the positions to use
  85390. * @param indices defines the indices to the positions
  85391. * @param indexStart defines the start index
  85392. * @param indexCount defines the end index
  85393. * @param bias defines bias value to add to the result
  85394. * @return minimum and maximum values
  85395. */
  85396. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  85397. minimum: Vector3;
  85398. maximum: Vector3;
  85399. };
  85400. /**
  85401. * Extracts minimum and maximum values from a list of positions
  85402. * @param positions defines the positions to use
  85403. * @param start defines the start index in the positions array
  85404. * @param count defines the number of positions to handle
  85405. * @param bias defines bias value to add to the result
  85406. * @param stride defines the stride size to use (distance between two positions in the positions array)
  85407. * @return minimum and maximum values
  85408. */
  85409. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  85410. minimum: Vector3;
  85411. maximum: Vector3;
  85412. };
  85413. }
  85414. declare module BABYLON {
  85415. /** @hidden */
  85416. export class WebGLDataBuffer extends DataBuffer {
  85417. private _buffer;
  85418. constructor(resource: WebGLBuffer);
  85419. get underlyingResource(): any;
  85420. }
  85421. }
  85422. declare module BABYLON {
  85423. /** @hidden */
  85424. export class WebGLPipelineContext implements IPipelineContext {
  85425. engine: ThinEngine;
  85426. program: Nullable<WebGLProgram>;
  85427. context?: WebGLRenderingContext;
  85428. vertexShader?: WebGLShader;
  85429. fragmentShader?: WebGLShader;
  85430. isParallelCompiled: boolean;
  85431. onCompiled?: () => void;
  85432. transformFeedback?: WebGLTransformFeedback | null;
  85433. vertexCompilationError: Nullable<string>;
  85434. fragmentCompilationError: Nullable<string>;
  85435. programLinkError: Nullable<string>;
  85436. programValidationError: Nullable<string>;
  85437. get isAsync(): boolean;
  85438. get isReady(): boolean;
  85439. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  85440. _getVertexShaderCode(): string | null;
  85441. _getFragmentShaderCode(): string | null;
  85442. }
  85443. }
  85444. declare module BABYLON {
  85445. interface ThinEngine {
  85446. /**
  85447. * Create an uniform buffer
  85448. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85449. * @param elements defines the content of the uniform buffer
  85450. * @returns the webGL uniform buffer
  85451. */
  85452. createUniformBuffer(elements: FloatArray): DataBuffer;
  85453. /**
  85454. * Create a dynamic uniform buffer
  85455. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85456. * @param elements defines the content of the uniform buffer
  85457. * @returns the webGL uniform buffer
  85458. */
  85459. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  85460. /**
  85461. * Update an existing uniform buffer
  85462. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85463. * @param uniformBuffer defines the target uniform buffer
  85464. * @param elements defines the content to update
  85465. * @param offset defines the offset in the uniform buffer where update should start
  85466. * @param count defines the size of the data to update
  85467. */
  85468. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85469. /**
  85470. * Bind an uniform buffer to the current webGL context
  85471. * @param buffer defines the buffer to bind
  85472. */
  85473. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  85474. /**
  85475. * Bind a buffer to the current webGL context at a given location
  85476. * @param buffer defines the buffer to bind
  85477. * @param location defines the index where to bind the buffer
  85478. */
  85479. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  85480. /**
  85481. * Bind a specific block at a given index in a specific shader program
  85482. * @param pipelineContext defines the pipeline context to use
  85483. * @param blockName defines the block name
  85484. * @param index defines the index where to bind the block
  85485. */
  85486. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  85487. }
  85488. }
  85489. declare module BABYLON {
  85490. /**
  85491. * Uniform buffer objects.
  85492. *
  85493. * Handles blocks of uniform on the GPU.
  85494. *
  85495. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85496. *
  85497. * For more information, please refer to :
  85498. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85499. */
  85500. export class UniformBuffer {
  85501. private _engine;
  85502. private _buffer;
  85503. private _data;
  85504. private _bufferData;
  85505. private _dynamic?;
  85506. private _uniformLocations;
  85507. private _uniformSizes;
  85508. private _uniformLocationPointer;
  85509. private _needSync;
  85510. private _noUBO;
  85511. private _currentEffect;
  85512. /** @hidden */
  85513. _alreadyBound: boolean;
  85514. private static _MAX_UNIFORM_SIZE;
  85515. private static _tempBuffer;
  85516. /**
  85517. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85518. * This is dynamic to allow compat with webgl 1 and 2.
  85519. * You will need to pass the name of the uniform as well as the value.
  85520. */
  85521. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85522. /**
  85523. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85524. * This is dynamic to allow compat with webgl 1 and 2.
  85525. * You will need to pass the name of the uniform as well as the value.
  85526. */
  85527. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85528. /**
  85529. * Lambda to Update a single float in a uniform buffer.
  85530. * This is dynamic to allow compat with webgl 1 and 2.
  85531. * You will need to pass the name of the uniform as well as the value.
  85532. */
  85533. updateFloat: (name: string, x: number) => void;
  85534. /**
  85535. * Lambda to Update a vec2 of float in a uniform buffer.
  85536. * This is dynamic to allow compat with webgl 1 and 2.
  85537. * You will need to pass the name of the uniform as well as the value.
  85538. */
  85539. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85540. /**
  85541. * Lambda to Update a vec3 of float in a uniform buffer.
  85542. * This is dynamic to allow compat with webgl 1 and 2.
  85543. * You will need to pass the name of the uniform as well as the value.
  85544. */
  85545. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85546. /**
  85547. * Lambda to Update a vec4 of float in a uniform buffer.
  85548. * This is dynamic to allow compat with webgl 1 and 2.
  85549. * You will need to pass the name of the uniform as well as the value.
  85550. */
  85551. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85552. /**
  85553. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85554. * This is dynamic to allow compat with webgl 1 and 2.
  85555. * You will need to pass the name of the uniform as well as the value.
  85556. */
  85557. updateMatrix: (name: string, mat: Matrix) => void;
  85558. /**
  85559. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85560. * This is dynamic to allow compat with webgl 1 and 2.
  85561. * You will need to pass the name of the uniform as well as the value.
  85562. */
  85563. updateVector3: (name: string, vector: Vector3) => void;
  85564. /**
  85565. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85566. * This is dynamic to allow compat with webgl 1 and 2.
  85567. * You will need to pass the name of the uniform as well as the value.
  85568. */
  85569. updateVector4: (name: string, vector: Vector4) => void;
  85570. /**
  85571. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85572. * This is dynamic to allow compat with webgl 1 and 2.
  85573. * You will need to pass the name of the uniform as well as the value.
  85574. */
  85575. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85576. /**
  85577. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85578. * This is dynamic to allow compat with webgl 1 and 2.
  85579. * You will need to pass the name of the uniform as well as the value.
  85580. */
  85581. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85582. /**
  85583. * Instantiates a new Uniform buffer objects.
  85584. *
  85585. * Handles blocks of uniform on the GPU.
  85586. *
  85587. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85588. *
  85589. * For more information, please refer to :
  85590. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85591. * @param engine Define the engine the buffer is associated with
  85592. * @param data Define the data contained in the buffer
  85593. * @param dynamic Define if the buffer is updatable
  85594. */
  85595. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85596. /**
  85597. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85598. * or just falling back on setUniformXXX calls.
  85599. */
  85600. get useUbo(): boolean;
  85601. /**
  85602. * Indicates if the WebGL underlying uniform buffer is in sync
  85603. * with the javascript cache data.
  85604. */
  85605. get isSync(): boolean;
  85606. /**
  85607. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85608. * Also, a dynamic UniformBuffer will disable cache verification and always
  85609. * update the underlying WebGL uniform buffer to the GPU.
  85610. * @returns if Dynamic, otherwise false
  85611. */
  85612. isDynamic(): boolean;
  85613. /**
  85614. * The data cache on JS side.
  85615. * @returns the underlying data as a float array
  85616. */
  85617. getData(): Float32Array;
  85618. /**
  85619. * The underlying WebGL Uniform buffer.
  85620. * @returns the webgl buffer
  85621. */
  85622. getBuffer(): Nullable<DataBuffer>;
  85623. /**
  85624. * std140 layout specifies how to align data within an UBO structure.
  85625. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85626. * for specs.
  85627. */
  85628. private _fillAlignment;
  85629. /**
  85630. * Adds an uniform in the buffer.
  85631. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85632. * for the layout to be correct !
  85633. * @param name Name of the uniform, as used in the uniform block in the shader.
  85634. * @param size Data size, or data directly.
  85635. */
  85636. addUniform(name: string, size: number | number[]): void;
  85637. /**
  85638. * Adds a Matrix 4x4 to the uniform buffer.
  85639. * @param name Name of the uniform, as used in the uniform block in the shader.
  85640. * @param mat A 4x4 matrix.
  85641. */
  85642. addMatrix(name: string, mat: Matrix): void;
  85643. /**
  85644. * Adds a vec2 to the uniform buffer.
  85645. * @param name Name of the uniform, as used in the uniform block in the shader.
  85646. * @param x Define the x component value of the vec2
  85647. * @param y Define the y component value of the vec2
  85648. */
  85649. addFloat2(name: string, x: number, y: number): void;
  85650. /**
  85651. * Adds a vec3 to the uniform buffer.
  85652. * @param name Name of the uniform, as used in the uniform block in the shader.
  85653. * @param x Define the x component value of the vec3
  85654. * @param y Define the y component value of the vec3
  85655. * @param z Define the z component value of the vec3
  85656. */
  85657. addFloat3(name: string, x: number, y: number, z: number): void;
  85658. /**
  85659. * Adds a vec3 to the uniform buffer.
  85660. * @param name Name of the uniform, as used in the uniform block in the shader.
  85661. * @param color Define the vec3 from a Color
  85662. */
  85663. addColor3(name: string, color: Color3): void;
  85664. /**
  85665. * Adds a vec4 to the uniform buffer.
  85666. * @param name Name of the uniform, as used in the uniform block in the shader.
  85667. * @param color Define the rgb components from a Color
  85668. * @param alpha Define the a component of the vec4
  85669. */
  85670. addColor4(name: string, color: Color3, alpha: number): void;
  85671. /**
  85672. * Adds a vec3 to the uniform buffer.
  85673. * @param name Name of the uniform, as used in the uniform block in the shader.
  85674. * @param vector Define the vec3 components from a Vector
  85675. */
  85676. addVector3(name: string, vector: Vector3): void;
  85677. /**
  85678. * Adds a Matrix 3x3 to the uniform buffer.
  85679. * @param name Name of the uniform, as used in the uniform block in the shader.
  85680. */
  85681. addMatrix3x3(name: string): void;
  85682. /**
  85683. * Adds a Matrix 2x2 to the uniform buffer.
  85684. * @param name Name of the uniform, as used in the uniform block in the shader.
  85685. */
  85686. addMatrix2x2(name: string): void;
  85687. /**
  85688. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85689. */
  85690. create(): void;
  85691. /** @hidden */
  85692. _rebuild(): void;
  85693. /**
  85694. * Updates the WebGL Uniform Buffer on the GPU.
  85695. * If the `dynamic` flag is set to true, no cache comparison is done.
  85696. * Otherwise, the buffer will be updated only if the cache differs.
  85697. */
  85698. update(): void;
  85699. /**
  85700. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85701. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85702. * @param data Define the flattened data
  85703. * @param size Define the size of the data.
  85704. */
  85705. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85706. private _valueCache;
  85707. private _cacheMatrix;
  85708. private _updateMatrix3x3ForUniform;
  85709. private _updateMatrix3x3ForEffect;
  85710. private _updateMatrix2x2ForEffect;
  85711. private _updateMatrix2x2ForUniform;
  85712. private _updateFloatForEffect;
  85713. private _updateFloatForUniform;
  85714. private _updateFloat2ForEffect;
  85715. private _updateFloat2ForUniform;
  85716. private _updateFloat3ForEffect;
  85717. private _updateFloat3ForUniform;
  85718. private _updateFloat4ForEffect;
  85719. private _updateFloat4ForUniform;
  85720. private _updateMatrixForEffect;
  85721. private _updateMatrixForUniform;
  85722. private _updateVector3ForEffect;
  85723. private _updateVector3ForUniform;
  85724. private _updateVector4ForEffect;
  85725. private _updateVector4ForUniform;
  85726. private _updateColor3ForEffect;
  85727. private _updateColor3ForUniform;
  85728. private _updateColor4ForEffect;
  85729. private _updateColor4ForUniform;
  85730. /**
  85731. * Sets a sampler uniform on the effect.
  85732. * @param name Define the name of the sampler.
  85733. * @param texture Define the texture to set in the sampler
  85734. */
  85735. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85736. /**
  85737. * Directly updates the value of the uniform in the cache AND on the GPU.
  85738. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85739. * @param data Define the flattened data
  85740. */
  85741. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85742. /**
  85743. * Binds this uniform buffer to an effect.
  85744. * @param effect Define the effect to bind the buffer to
  85745. * @param name Name of the uniform block in the shader.
  85746. */
  85747. bindToEffect(effect: Effect, name: string): void;
  85748. /**
  85749. * Disposes the uniform buffer.
  85750. */
  85751. dispose(): void;
  85752. }
  85753. }
  85754. declare module BABYLON {
  85755. /**
  85756. * Enum that determines the text-wrapping mode to use.
  85757. */
  85758. export enum InspectableType {
  85759. /**
  85760. * Checkbox for booleans
  85761. */
  85762. Checkbox = 0,
  85763. /**
  85764. * Sliders for numbers
  85765. */
  85766. Slider = 1,
  85767. /**
  85768. * Vector3
  85769. */
  85770. Vector3 = 2,
  85771. /**
  85772. * Quaternions
  85773. */
  85774. Quaternion = 3,
  85775. /**
  85776. * Color3
  85777. */
  85778. Color3 = 4,
  85779. /**
  85780. * String
  85781. */
  85782. String = 5
  85783. }
  85784. /**
  85785. * Interface used to define custom inspectable properties.
  85786. * This interface is used by the inspector to display custom property grids
  85787. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85788. */
  85789. export interface IInspectable {
  85790. /**
  85791. * Gets the label to display
  85792. */
  85793. label: string;
  85794. /**
  85795. * Gets the name of the property to edit
  85796. */
  85797. propertyName: string;
  85798. /**
  85799. * Gets the type of the editor to use
  85800. */
  85801. type: InspectableType;
  85802. /**
  85803. * Gets the minimum value of the property when using in "slider" mode
  85804. */
  85805. min?: number;
  85806. /**
  85807. * Gets the maximum value of the property when using in "slider" mode
  85808. */
  85809. max?: number;
  85810. /**
  85811. * Gets the setp to use when using in "slider" mode
  85812. */
  85813. step?: number;
  85814. }
  85815. }
  85816. declare module BABYLON {
  85817. /**
  85818. * Class used to provide helper for timing
  85819. */
  85820. export class TimingTools {
  85821. /**
  85822. * Polyfill for setImmediate
  85823. * @param action defines the action to execute after the current execution block
  85824. */
  85825. static SetImmediate(action: () => void): void;
  85826. }
  85827. }
  85828. declare module BABYLON {
  85829. /**
  85830. * Class used to enable instatition of objects by class name
  85831. */
  85832. export class InstantiationTools {
  85833. /**
  85834. * Use this object to register external classes like custom textures or material
  85835. * to allow the laoders to instantiate them
  85836. */
  85837. static RegisteredExternalClasses: {
  85838. [key: string]: Object;
  85839. };
  85840. /**
  85841. * Tries to instantiate a new object from a given class name
  85842. * @param className defines the class name to instantiate
  85843. * @returns the new object or null if the system was not able to do the instantiation
  85844. */
  85845. static Instantiate(className: string): any;
  85846. }
  85847. }
  85848. declare module BABYLON {
  85849. /**
  85850. * Define options used to create a depth texture
  85851. */
  85852. export class DepthTextureCreationOptions {
  85853. /** Specifies whether or not a stencil should be allocated in the texture */
  85854. generateStencil?: boolean;
  85855. /** Specifies whether or not bilinear filtering is enable on the texture */
  85856. bilinearFiltering?: boolean;
  85857. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85858. comparisonFunction?: number;
  85859. /** Specifies if the created texture is a cube texture */
  85860. isCube?: boolean;
  85861. }
  85862. }
  85863. declare module BABYLON {
  85864. interface ThinEngine {
  85865. /**
  85866. * Creates a depth stencil cube texture.
  85867. * This is only available in WebGL 2.
  85868. * @param size The size of face edge in the cube texture.
  85869. * @param options The options defining the cube texture.
  85870. * @returns The cube texture
  85871. */
  85872. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  85873. /**
  85874. * Creates a cube texture
  85875. * @param rootUrl defines the url where the files to load is located
  85876. * @param scene defines the current scene
  85877. * @param files defines the list of files to load (1 per face)
  85878. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85879. * @param onLoad defines an optional callback raised when the texture is loaded
  85880. * @param onError defines an optional callback raised if there is an issue to load the texture
  85881. * @param format defines the format of the data
  85882. * @param forcedExtension defines the extension to use to pick the right loader
  85883. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85884. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85885. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85886. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85887. * @returns the cube texture as an InternalTexture
  85888. */
  85889. 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;
  85890. /**
  85891. * Creates a cube texture
  85892. * @param rootUrl defines the url where the files to load is located
  85893. * @param scene defines the current scene
  85894. * @param files defines the list of files to load (1 per face)
  85895. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85896. * @param onLoad defines an optional callback raised when the texture is loaded
  85897. * @param onError defines an optional callback raised if there is an issue to load the texture
  85898. * @param format defines the format of the data
  85899. * @param forcedExtension defines the extension to use to pick the right loader
  85900. * @returns the cube texture as an InternalTexture
  85901. */
  85902. 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;
  85903. /**
  85904. * Creates a cube texture
  85905. * @param rootUrl defines the url where the files to load is located
  85906. * @param scene defines the current scene
  85907. * @param files defines the list of files to load (1 per face)
  85908. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85909. * @param onLoad defines an optional callback raised when the texture is loaded
  85910. * @param onError defines an optional callback raised if there is an issue to load the texture
  85911. * @param format defines the format of the data
  85912. * @param forcedExtension defines the extension to use to pick the right loader
  85913. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85914. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85915. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85916. * @returns the cube texture as an InternalTexture
  85917. */
  85918. 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;
  85919. /** @hidden */
  85920. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  85921. /** @hidden */
  85922. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  85923. /** @hidden */
  85924. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85925. /** @hidden */
  85926. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85927. /**
  85928. * @hidden
  85929. */
  85930. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85931. }
  85932. }
  85933. declare module BABYLON {
  85934. /**
  85935. * Class for creating a cube texture
  85936. */
  85937. export class CubeTexture extends BaseTexture {
  85938. private _delayedOnLoad;
  85939. /**
  85940. * Observable triggered once the texture has been loaded.
  85941. */
  85942. onLoadObservable: Observable<CubeTexture>;
  85943. /**
  85944. * The url of the texture
  85945. */
  85946. url: string;
  85947. /**
  85948. * Gets or sets the center of the bounding box associated with the cube texture.
  85949. * It must define where the camera used to render the texture was set
  85950. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85951. */
  85952. boundingBoxPosition: Vector3;
  85953. private _boundingBoxSize;
  85954. /**
  85955. * Gets or sets the size of the bounding box associated with the cube texture
  85956. * When defined, the cubemap will switch to local mode
  85957. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85958. * @example https://www.babylonjs-playground.com/#RNASML
  85959. */
  85960. set boundingBoxSize(value: Vector3);
  85961. /**
  85962. * Returns the bounding box size
  85963. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85964. */
  85965. get boundingBoxSize(): Vector3;
  85966. protected _rotationY: number;
  85967. /**
  85968. * Sets texture matrix rotation angle around Y axis in radians.
  85969. */
  85970. set rotationY(value: number);
  85971. /**
  85972. * Gets texture matrix rotation angle around Y axis radians.
  85973. */
  85974. get rotationY(): number;
  85975. /**
  85976. * Are mip maps generated for this texture or not.
  85977. */
  85978. get noMipmap(): boolean;
  85979. private _noMipmap;
  85980. private _files;
  85981. protected _forcedExtension: Nullable<string>;
  85982. private _extensions;
  85983. private _textureMatrix;
  85984. private _format;
  85985. private _createPolynomials;
  85986. /**
  85987. * Creates a cube texture from an array of image urls
  85988. * @param files defines an array of image urls
  85989. * @param scene defines the hosting scene
  85990. * @param noMipmap specifies if mip maps are not used
  85991. * @returns a cube texture
  85992. */
  85993. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  85994. /**
  85995. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  85996. * @param url defines the url of the prefiltered texture
  85997. * @param scene defines the scene the texture is attached to
  85998. * @param forcedExtension defines the extension of the file if different from the url
  85999. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86000. * @return the prefiltered texture
  86001. */
  86002. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  86003. /**
  86004. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  86005. * as prefiltered data.
  86006. * @param rootUrl defines the url of the texture or the root name of the six images
  86007. * @param null defines the scene or engine the texture is attached to
  86008. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86009. * @param noMipmap defines if mipmaps should be created or not
  86010. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86011. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86012. * @param onError defines a callback triggered in case of error during load
  86013. * @param format defines the internal format to use for the texture once loaded
  86014. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86015. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86016. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86017. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86018. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86019. * @return the cube texture
  86020. */
  86021. 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);
  86022. /**
  86023. * Get the current class name of the texture useful for serialization or dynamic coding.
  86024. * @returns "CubeTexture"
  86025. */
  86026. getClassName(): string;
  86027. /**
  86028. * Update the url (and optional buffer) of this texture if url was null during construction.
  86029. * @param url the url of the texture
  86030. * @param forcedExtension defines the extension to use
  86031. * @param onLoad callback called when the texture is loaded (defaults to null)
  86032. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86033. */
  86034. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86035. /**
  86036. * Delays loading of the cube texture
  86037. * @param forcedExtension defines the extension to use
  86038. */
  86039. delayLoad(forcedExtension?: string): void;
  86040. /**
  86041. * Returns the reflection texture matrix
  86042. * @returns the reflection texture matrix
  86043. */
  86044. getReflectionTextureMatrix(): Matrix;
  86045. /**
  86046. * Sets the reflection texture matrix
  86047. * @param value Reflection texture matrix
  86048. */
  86049. setReflectionTextureMatrix(value: Matrix): void;
  86050. /**
  86051. * Parses text to create a cube texture
  86052. * @param parsedTexture define the serialized text to read from
  86053. * @param scene defines the hosting scene
  86054. * @param rootUrl defines the root url of the cube texture
  86055. * @returns a cube texture
  86056. */
  86057. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86058. /**
  86059. * Makes a clone, or deep copy, of the cube texture
  86060. * @returns a new cube texture
  86061. */
  86062. clone(): CubeTexture;
  86063. }
  86064. }
  86065. declare module BABYLON {
  86066. /**
  86067. * Manages the defines for the Material
  86068. */
  86069. export class MaterialDefines {
  86070. /** @hidden */
  86071. protected _keys: string[];
  86072. private _isDirty;
  86073. /** @hidden */
  86074. _renderId: number;
  86075. /** @hidden */
  86076. _areLightsDirty: boolean;
  86077. /** @hidden */
  86078. _areLightsDisposed: boolean;
  86079. /** @hidden */
  86080. _areAttributesDirty: boolean;
  86081. /** @hidden */
  86082. _areTexturesDirty: boolean;
  86083. /** @hidden */
  86084. _areFresnelDirty: boolean;
  86085. /** @hidden */
  86086. _areMiscDirty: boolean;
  86087. /** @hidden */
  86088. _areImageProcessingDirty: boolean;
  86089. /** @hidden */
  86090. _normals: boolean;
  86091. /** @hidden */
  86092. _uvs: boolean;
  86093. /** @hidden */
  86094. _needNormals: boolean;
  86095. /** @hidden */
  86096. _needUVs: boolean;
  86097. [id: string]: any;
  86098. /**
  86099. * Specifies if the material needs to be re-calculated
  86100. */
  86101. get isDirty(): boolean;
  86102. /**
  86103. * Marks the material to indicate that it has been re-calculated
  86104. */
  86105. markAsProcessed(): void;
  86106. /**
  86107. * Marks the material to indicate that it needs to be re-calculated
  86108. */
  86109. markAsUnprocessed(): void;
  86110. /**
  86111. * Marks the material to indicate all of its defines need to be re-calculated
  86112. */
  86113. markAllAsDirty(): void;
  86114. /**
  86115. * Marks the material to indicate that image processing needs to be re-calculated
  86116. */
  86117. markAsImageProcessingDirty(): void;
  86118. /**
  86119. * Marks the material to indicate the lights need to be re-calculated
  86120. * @param disposed Defines whether the light is dirty due to dispose or not
  86121. */
  86122. markAsLightDirty(disposed?: boolean): void;
  86123. /**
  86124. * Marks the attribute state as changed
  86125. */
  86126. markAsAttributesDirty(): void;
  86127. /**
  86128. * Marks the texture state as changed
  86129. */
  86130. markAsTexturesDirty(): void;
  86131. /**
  86132. * Marks the fresnel state as changed
  86133. */
  86134. markAsFresnelDirty(): void;
  86135. /**
  86136. * Marks the misc state as changed
  86137. */
  86138. markAsMiscDirty(): void;
  86139. /**
  86140. * Rebuilds the material defines
  86141. */
  86142. rebuild(): void;
  86143. /**
  86144. * Specifies if two material defines are equal
  86145. * @param other - A material define instance to compare to
  86146. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  86147. */
  86148. isEqual(other: MaterialDefines): boolean;
  86149. /**
  86150. * Clones this instance's defines to another instance
  86151. * @param other - material defines to clone values to
  86152. */
  86153. cloneTo(other: MaterialDefines): void;
  86154. /**
  86155. * Resets the material define values
  86156. */
  86157. reset(): void;
  86158. /**
  86159. * Converts the material define values to a string
  86160. * @returns - String of material define information
  86161. */
  86162. toString(): string;
  86163. }
  86164. }
  86165. declare module BABYLON {
  86166. /**
  86167. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86168. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86169. * 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;
  86170. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86171. */
  86172. export class ColorCurves {
  86173. private _dirty;
  86174. private _tempColor;
  86175. private _globalCurve;
  86176. private _highlightsCurve;
  86177. private _midtonesCurve;
  86178. private _shadowsCurve;
  86179. private _positiveCurve;
  86180. private _negativeCurve;
  86181. private _globalHue;
  86182. private _globalDensity;
  86183. private _globalSaturation;
  86184. private _globalExposure;
  86185. /**
  86186. * Gets the global Hue value.
  86187. * 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).
  86188. */
  86189. get globalHue(): number;
  86190. /**
  86191. * Sets the global Hue value.
  86192. * 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).
  86193. */
  86194. set globalHue(value: number);
  86195. /**
  86196. * Gets the global Density value.
  86197. * 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.
  86198. * Values less than zero provide a filter of opposite hue.
  86199. */
  86200. get globalDensity(): number;
  86201. /**
  86202. * Sets the global Density value.
  86203. * 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.
  86204. * Values less than zero provide a filter of opposite hue.
  86205. */
  86206. set globalDensity(value: number);
  86207. /**
  86208. * Gets the global Saturation value.
  86209. * 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.
  86210. */
  86211. get globalSaturation(): number;
  86212. /**
  86213. * Sets the global Saturation value.
  86214. * 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.
  86215. */
  86216. set globalSaturation(value: number);
  86217. /**
  86218. * Gets the global Exposure value.
  86219. * 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.
  86220. */
  86221. get globalExposure(): number;
  86222. /**
  86223. * Sets the global Exposure value.
  86224. * 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.
  86225. */
  86226. set globalExposure(value: number);
  86227. private _highlightsHue;
  86228. private _highlightsDensity;
  86229. private _highlightsSaturation;
  86230. private _highlightsExposure;
  86231. /**
  86232. * Gets the highlights Hue value.
  86233. * 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).
  86234. */
  86235. get highlightsHue(): number;
  86236. /**
  86237. * Sets the highlights Hue value.
  86238. * 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).
  86239. */
  86240. set highlightsHue(value: number);
  86241. /**
  86242. * Gets the highlights Density value.
  86243. * 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.
  86244. * Values less than zero provide a filter of opposite hue.
  86245. */
  86246. get highlightsDensity(): number;
  86247. /**
  86248. * Sets the highlights Density value.
  86249. * 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.
  86250. * Values less than zero provide a filter of opposite hue.
  86251. */
  86252. set highlightsDensity(value: number);
  86253. /**
  86254. * Gets the highlights Saturation value.
  86255. * 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.
  86256. */
  86257. get highlightsSaturation(): number;
  86258. /**
  86259. * Sets the highlights Saturation value.
  86260. * 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.
  86261. */
  86262. set highlightsSaturation(value: number);
  86263. /**
  86264. * Gets the highlights Exposure value.
  86265. * 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.
  86266. */
  86267. get highlightsExposure(): number;
  86268. /**
  86269. * Sets the highlights Exposure value.
  86270. * 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.
  86271. */
  86272. set highlightsExposure(value: number);
  86273. private _midtonesHue;
  86274. private _midtonesDensity;
  86275. private _midtonesSaturation;
  86276. private _midtonesExposure;
  86277. /**
  86278. * Gets the midtones Hue value.
  86279. * 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).
  86280. */
  86281. get midtonesHue(): number;
  86282. /**
  86283. * Sets the midtones Hue value.
  86284. * 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).
  86285. */
  86286. set midtonesHue(value: number);
  86287. /**
  86288. * Gets the midtones Density value.
  86289. * 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.
  86290. * Values less than zero provide a filter of opposite hue.
  86291. */
  86292. get midtonesDensity(): number;
  86293. /**
  86294. * Sets the midtones Density value.
  86295. * 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.
  86296. * Values less than zero provide a filter of opposite hue.
  86297. */
  86298. set midtonesDensity(value: number);
  86299. /**
  86300. * Gets the midtones Saturation value.
  86301. * 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.
  86302. */
  86303. get midtonesSaturation(): number;
  86304. /**
  86305. * Sets the midtones Saturation value.
  86306. * 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.
  86307. */
  86308. set midtonesSaturation(value: number);
  86309. /**
  86310. * Gets the midtones Exposure value.
  86311. * 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.
  86312. */
  86313. get midtonesExposure(): number;
  86314. /**
  86315. * Sets the midtones Exposure value.
  86316. * 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.
  86317. */
  86318. set midtonesExposure(value: number);
  86319. private _shadowsHue;
  86320. private _shadowsDensity;
  86321. private _shadowsSaturation;
  86322. private _shadowsExposure;
  86323. /**
  86324. * Gets the shadows Hue value.
  86325. * 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).
  86326. */
  86327. get shadowsHue(): number;
  86328. /**
  86329. * Sets the shadows Hue value.
  86330. * 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).
  86331. */
  86332. set shadowsHue(value: number);
  86333. /**
  86334. * Gets the shadows Density value.
  86335. * 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.
  86336. * Values less than zero provide a filter of opposite hue.
  86337. */
  86338. get shadowsDensity(): number;
  86339. /**
  86340. * Sets the shadows Density value.
  86341. * 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.
  86342. * Values less than zero provide a filter of opposite hue.
  86343. */
  86344. set shadowsDensity(value: number);
  86345. /**
  86346. * Gets the shadows Saturation value.
  86347. * 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.
  86348. */
  86349. get shadowsSaturation(): number;
  86350. /**
  86351. * Sets the shadows Saturation value.
  86352. * 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.
  86353. */
  86354. set shadowsSaturation(value: number);
  86355. /**
  86356. * Gets the shadows Exposure value.
  86357. * 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.
  86358. */
  86359. get shadowsExposure(): number;
  86360. /**
  86361. * Sets the shadows Exposure value.
  86362. * 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.
  86363. */
  86364. set shadowsExposure(value: number);
  86365. /**
  86366. * Returns the class name
  86367. * @returns The class name
  86368. */
  86369. getClassName(): string;
  86370. /**
  86371. * Binds the color curves to the shader.
  86372. * @param colorCurves The color curve to bind
  86373. * @param effect The effect to bind to
  86374. * @param positiveUniform The positive uniform shader parameter
  86375. * @param neutralUniform The neutral uniform shader parameter
  86376. * @param negativeUniform The negative uniform shader parameter
  86377. */
  86378. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86379. /**
  86380. * Prepare the list of uniforms associated with the ColorCurves effects.
  86381. * @param uniformsList The list of uniforms used in the effect
  86382. */
  86383. static PrepareUniforms(uniformsList: string[]): void;
  86384. /**
  86385. * Returns color grading data based on a hue, density, saturation and exposure value.
  86386. * @param filterHue The hue of the color filter.
  86387. * @param filterDensity The density of the color filter.
  86388. * @param saturation The saturation.
  86389. * @param exposure The exposure.
  86390. * @param result The result data container.
  86391. */
  86392. private getColorGradingDataToRef;
  86393. /**
  86394. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86395. * @param value The input slider value in range [-100,100].
  86396. * @returns Adjusted value.
  86397. */
  86398. private static applyColorGradingSliderNonlinear;
  86399. /**
  86400. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86401. * @param hue The hue (H) input.
  86402. * @param saturation The saturation (S) input.
  86403. * @param brightness The brightness (B) input.
  86404. * @result An RGBA color represented as Vector4.
  86405. */
  86406. private static fromHSBToRef;
  86407. /**
  86408. * Returns a value clamped between min and max
  86409. * @param value The value to clamp
  86410. * @param min The minimum of value
  86411. * @param max The maximum of value
  86412. * @returns The clamped value.
  86413. */
  86414. private static clamp;
  86415. /**
  86416. * Clones the current color curve instance.
  86417. * @return The cloned curves
  86418. */
  86419. clone(): ColorCurves;
  86420. /**
  86421. * Serializes the current color curve instance to a json representation.
  86422. * @return a JSON representation
  86423. */
  86424. serialize(): any;
  86425. /**
  86426. * Parses the color curve from a json representation.
  86427. * @param source the JSON source to parse
  86428. * @return The parsed curves
  86429. */
  86430. static Parse(source: any): ColorCurves;
  86431. }
  86432. }
  86433. declare module BABYLON {
  86434. /**
  86435. * Interface to follow in your material defines to integrate easily the
  86436. * Image proccessing functions.
  86437. * @hidden
  86438. */
  86439. export interface IImageProcessingConfigurationDefines {
  86440. IMAGEPROCESSING: boolean;
  86441. VIGNETTE: boolean;
  86442. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86443. VIGNETTEBLENDMODEOPAQUE: boolean;
  86444. TONEMAPPING: boolean;
  86445. TONEMAPPING_ACES: boolean;
  86446. CONTRAST: boolean;
  86447. EXPOSURE: boolean;
  86448. COLORCURVES: boolean;
  86449. COLORGRADING: boolean;
  86450. COLORGRADING3D: boolean;
  86451. SAMPLER3DGREENDEPTH: boolean;
  86452. SAMPLER3DBGRMAP: boolean;
  86453. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86454. }
  86455. /**
  86456. * @hidden
  86457. */
  86458. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86459. IMAGEPROCESSING: boolean;
  86460. VIGNETTE: boolean;
  86461. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86462. VIGNETTEBLENDMODEOPAQUE: boolean;
  86463. TONEMAPPING: boolean;
  86464. TONEMAPPING_ACES: boolean;
  86465. CONTRAST: boolean;
  86466. COLORCURVES: boolean;
  86467. COLORGRADING: boolean;
  86468. COLORGRADING3D: boolean;
  86469. SAMPLER3DGREENDEPTH: boolean;
  86470. SAMPLER3DBGRMAP: boolean;
  86471. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86472. EXPOSURE: boolean;
  86473. constructor();
  86474. }
  86475. /**
  86476. * This groups together the common properties used for image processing either in direct forward pass
  86477. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86478. * or not.
  86479. */
  86480. export class ImageProcessingConfiguration {
  86481. /**
  86482. * Default tone mapping applied in BabylonJS.
  86483. */
  86484. static readonly TONEMAPPING_STANDARD: number;
  86485. /**
  86486. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86487. * to other engines rendering to increase portability.
  86488. */
  86489. static readonly TONEMAPPING_ACES: number;
  86490. /**
  86491. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86492. */
  86493. colorCurves: Nullable<ColorCurves>;
  86494. private _colorCurvesEnabled;
  86495. /**
  86496. * Gets wether the color curves effect is enabled.
  86497. */
  86498. get colorCurvesEnabled(): boolean;
  86499. /**
  86500. * Sets wether the color curves effect is enabled.
  86501. */
  86502. set colorCurvesEnabled(value: boolean);
  86503. private _colorGradingTexture;
  86504. /**
  86505. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86506. */
  86507. get colorGradingTexture(): Nullable<BaseTexture>;
  86508. /**
  86509. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86510. */
  86511. set colorGradingTexture(value: Nullable<BaseTexture>);
  86512. private _colorGradingEnabled;
  86513. /**
  86514. * Gets wether the color grading effect is enabled.
  86515. */
  86516. get colorGradingEnabled(): boolean;
  86517. /**
  86518. * Sets wether the color grading effect is enabled.
  86519. */
  86520. set colorGradingEnabled(value: boolean);
  86521. private _colorGradingWithGreenDepth;
  86522. /**
  86523. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86524. */
  86525. get colorGradingWithGreenDepth(): boolean;
  86526. /**
  86527. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86528. */
  86529. set colorGradingWithGreenDepth(value: boolean);
  86530. private _colorGradingBGR;
  86531. /**
  86532. * Gets wether the color grading texture contains BGR values.
  86533. */
  86534. get colorGradingBGR(): boolean;
  86535. /**
  86536. * Sets wether the color grading texture contains BGR values.
  86537. */
  86538. set colorGradingBGR(value: boolean);
  86539. /** @hidden */
  86540. _exposure: number;
  86541. /**
  86542. * Gets the Exposure used in the effect.
  86543. */
  86544. get exposure(): number;
  86545. /**
  86546. * Sets the Exposure used in the effect.
  86547. */
  86548. set exposure(value: number);
  86549. private _toneMappingEnabled;
  86550. /**
  86551. * Gets wether the tone mapping effect is enabled.
  86552. */
  86553. get toneMappingEnabled(): boolean;
  86554. /**
  86555. * Sets wether the tone mapping effect is enabled.
  86556. */
  86557. set toneMappingEnabled(value: boolean);
  86558. private _toneMappingType;
  86559. /**
  86560. * Gets the type of tone mapping effect.
  86561. */
  86562. get toneMappingType(): number;
  86563. /**
  86564. * Sets the type of tone mapping effect used in BabylonJS.
  86565. */
  86566. set toneMappingType(value: number);
  86567. protected _contrast: number;
  86568. /**
  86569. * Gets the contrast used in the effect.
  86570. */
  86571. get contrast(): number;
  86572. /**
  86573. * Sets the contrast used in the effect.
  86574. */
  86575. set contrast(value: number);
  86576. /**
  86577. * Vignette stretch size.
  86578. */
  86579. vignetteStretch: number;
  86580. /**
  86581. * Vignette centre X Offset.
  86582. */
  86583. vignetteCentreX: number;
  86584. /**
  86585. * Vignette centre Y Offset.
  86586. */
  86587. vignetteCentreY: number;
  86588. /**
  86589. * Vignette weight or intensity of the vignette effect.
  86590. */
  86591. vignetteWeight: number;
  86592. /**
  86593. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86594. * if vignetteEnabled is set to true.
  86595. */
  86596. vignetteColor: Color4;
  86597. /**
  86598. * Camera field of view used by the Vignette effect.
  86599. */
  86600. vignetteCameraFov: number;
  86601. private _vignetteBlendMode;
  86602. /**
  86603. * Gets the vignette blend mode allowing different kind of effect.
  86604. */
  86605. get vignetteBlendMode(): number;
  86606. /**
  86607. * Sets the vignette blend mode allowing different kind of effect.
  86608. */
  86609. set vignetteBlendMode(value: number);
  86610. private _vignetteEnabled;
  86611. /**
  86612. * Gets wether the vignette effect is enabled.
  86613. */
  86614. get vignetteEnabled(): boolean;
  86615. /**
  86616. * Sets wether the vignette effect is enabled.
  86617. */
  86618. set vignetteEnabled(value: boolean);
  86619. private _applyByPostProcess;
  86620. /**
  86621. * Gets wether the image processing is applied through a post process or not.
  86622. */
  86623. get applyByPostProcess(): boolean;
  86624. /**
  86625. * Sets wether the image processing is applied through a post process or not.
  86626. */
  86627. set applyByPostProcess(value: boolean);
  86628. private _isEnabled;
  86629. /**
  86630. * Gets wether the image processing is enabled or not.
  86631. */
  86632. get isEnabled(): boolean;
  86633. /**
  86634. * Sets wether the image processing is enabled or not.
  86635. */
  86636. set isEnabled(value: boolean);
  86637. /**
  86638. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86639. */
  86640. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86641. /**
  86642. * Method called each time the image processing information changes requires to recompile the effect.
  86643. */
  86644. protected _updateParameters(): void;
  86645. /**
  86646. * Gets the current class name.
  86647. * @return "ImageProcessingConfiguration"
  86648. */
  86649. getClassName(): string;
  86650. /**
  86651. * Prepare the list of uniforms associated with the Image Processing effects.
  86652. * @param uniforms The list of uniforms used in the effect
  86653. * @param defines the list of defines currently in use
  86654. */
  86655. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86656. /**
  86657. * Prepare the list of samplers associated with the Image Processing effects.
  86658. * @param samplersList The list of uniforms used in the effect
  86659. * @param defines the list of defines currently in use
  86660. */
  86661. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86662. /**
  86663. * Prepare the list of defines associated to the shader.
  86664. * @param defines the list of defines to complete
  86665. * @param forPostProcess Define if we are currently in post process mode or not
  86666. */
  86667. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86668. /**
  86669. * Returns true if all the image processing information are ready.
  86670. * @returns True if ready, otherwise, false
  86671. */
  86672. isReady(): boolean;
  86673. /**
  86674. * Binds the image processing to the shader.
  86675. * @param effect The effect to bind to
  86676. * @param overrideAspectRatio Override the aspect ratio of the effect
  86677. */
  86678. bind(effect: Effect, overrideAspectRatio?: number): void;
  86679. /**
  86680. * Clones the current image processing instance.
  86681. * @return The cloned image processing
  86682. */
  86683. clone(): ImageProcessingConfiguration;
  86684. /**
  86685. * Serializes the current image processing instance to a json representation.
  86686. * @return a JSON representation
  86687. */
  86688. serialize(): any;
  86689. /**
  86690. * Parses the image processing from a json representation.
  86691. * @param source the JSON source to parse
  86692. * @return The parsed image processing
  86693. */
  86694. static Parse(source: any): ImageProcessingConfiguration;
  86695. private static _VIGNETTEMODE_MULTIPLY;
  86696. private static _VIGNETTEMODE_OPAQUE;
  86697. /**
  86698. * Used to apply the vignette as a mix with the pixel color.
  86699. */
  86700. static get VIGNETTEMODE_MULTIPLY(): number;
  86701. /**
  86702. * Used to apply the vignette as a replacement of the pixel color.
  86703. */
  86704. static get VIGNETTEMODE_OPAQUE(): number;
  86705. }
  86706. }
  86707. declare module BABYLON {
  86708. /** @hidden */
  86709. export var postprocessVertexShader: {
  86710. name: string;
  86711. shader: string;
  86712. };
  86713. }
  86714. declare module BABYLON {
  86715. interface ThinEngine {
  86716. /**
  86717. * Creates a new render target texture
  86718. * @param size defines the size of the texture
  86719. * @param options defines the options used to create the texture
  86720. * @returns a new render target texture stored in an InternalTexture
  86721. */
  86722. createRenderTargetTexture(size: number | {
  86723. width: number;
  86724. height: number;
  86725. layers?: number;
  86726. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86727. /**
  86728. * Creates a depth stencil texture.
  86729. * This is only available in WebGL 2 or with the depth texture extension available.
  86730. * @param size The size of face edge in the texture.
  86731. * @param options The options defining the texture.
  86732. * @returns The texture
  86733. */
  86734. createDepthStencilTexture(size: number | {
  86735. width: number;
  86736. height: number;
  86737. layers?: number;
  86738. }, options: DepthTextureCreationOptions): InternalTexture;
  86739. /** @hidden */
  86740. _createDepthStencilTexture(size: number | {
  86741. width: number;
  86742. height: number;
  86743. layers?: number;
  86744. }, options: DepthTextureCreationOptions): InternalTexture;
  86745. }
  86746. }
  86747. declare module BABYLON {
  86748. /**
  86749. * Defines the kind of connection point for node based material
  86750. */
  86751. export enum NodeMaterialBlockConnectionPointTypes {
  86752. /** Float */
  86753. Float = 1,
  86754. /** Int */
  86755. Int = 2,
  86756. /** Vector2 */
  86757. Vector2 = 4,
  86758. /** Vector3 */
  86759. Vector3 = 8,
  86760. /** Vector4 */
  86761. Vector4 = 16,
  86762. /** Color3 */
  86763. Color3 = 32,
  86764. /** Color4 */
  86765. Color4 = 64,
  86766. /** Matrix */
  86767. Matrix = 128,
  86768. /** Custom object */
  86769. Object = 256,
  86770. /** Detect type based on connection */
  86771. AutoDetect = 1024,
  86772. /** Output type that will be defined by input type */
  86773. BasedOnInput = 2048
  86774. }
  86775. }
  86776. declare module BABYLON {
  86777. /**
  86778. * Enum used to define the target of a block
  86779. */
  86780. export enum NodeMaterialBlockTargets {
  86781. /** Vertex shader */
  86782. Vertex = 1,
  86783. /** Fragment shader */
  86784. Fragment = 2,
  86785. /** Neutral */
  86786. Neutral = 4,
  86787. /** Vertex and Fragment */
  86788. VertexAndFragment = 3
  86789. }
  86790. }
  86791. declare module BABYLON {
  86792. /**
  86793. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  86794. */
  86795. export enum NodeMaterialBlockConnectionPointMode {
  86796. /** Value is an uniform */
  86797. Uniform = 0,
  86798. /** Value is a mesh attribute */
  86799. Attribute = 1,
  86800. /** Value is a varying between vertex and fragment shaders */
  86801. Varying = 2,
  86802. /** Mode is undefined */
  86803. Undefined = 3
  86804. }
  86805. }
  86806. declare module BABYLON {
  86807. /**
  86808. * Enum used to define system values e.g. values automatically provided by the system
  86809. */
  86810. export enum NodeMaterialSystemValues {
  86811. /** World */
  86812. World = 1,
  86813. /** View */
  86814. View = 2,
  86815. /** Projection */
  86816. Projection = 3,
  86817. /** ViewProjection */
  86818. ViewProjection = 4,
  86819. /** WorldView */
  86820. WorldView = 5,
  86821. /** WorldViewProjection */
  86822. WorldViewProjection = 6,
  86823. /** CameraPosition */
  86824. CameraPosition = 7,
  86825. /** Fog Color */
  86826. FogColor = 8,
  86827. /** Delta time */
  86828. DeltaTime = 9
  86829. }
  86830. }
  86831. declare module BABYLON {
  86832. /** Defines supported spaces */
  86833. export enum Space {
  86834. /** Local (object) space */
  86835. LOCAL = 0,
  86836. /** World space */
  86837. WORLD = 1,
  86838. /** Bone space */
  86839. BONE = 2
  86840. }
  86841. /** Defines the 3 main axes */
  86842. export class Axis {
  86843. /** X axis */
  86844. static X: Vector3;
  86845. /** Y axis */
  86846. static Y: Vector3;
  86847. /** Z axis */
  86848. static Z: Vector3;
  86849. }
  86850. }
  86851. declare module BABYLON {
  86852. /**
  86853. * Represents a camera frustum
  86854. */
  86855. export class Frustum {
  86856. /**
  86857. * Gets the planes representing the frustum
  86858. * @param transform matrix to be applied to the returned planes
  86859. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  86860. */
  86861. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  86862. /**
  86863. * Gets the near frustum plane transformed by the transform matrix
  86864. * @param transform transformation matrix to be applied to the resulting frustum plane
  86865. * @param frustumPlane the resuling frustum plane
  86866. */
  86867. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86868. /**
  86869. * Gets the far frustum plane transformed by the transform matrix
  86870. * @param transform transformation matrix to be applied to the resulting frustum plane
  86871. * @param frustumPlane the resuling frustum plane
  86872. */
  86873. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86874. /**
  86875. * Gets the left frustum plane transformed by the transform matrix
  86876. * @param transform transformation matrix to be applied to the resulting frustum plane
  86877. * @param frustumPlane the resuling frustum plane
  86878. */
  86879. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86880. /**
  86881. * Gets the right frustum plane transformed by the transform matrix
  86882. * @param transform transformation matrix to be applied to the resulting frustum plane
  86883. * @param frustumPlane the resuling frustum plane
  86884. */
  86885. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86886. /**
  86887. * Gets the top frustum plane transformed by the transform matrix
  86888. * @param transform transformation matrix to be applied to the resulting frustum plane
  86889. * @param frustumPlane the resuling frustum plane
  86890. */
  86891. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86892. /**
  86893. * Gets the bottom frustum plane transformed by the transform matrix
  86894. * @param transform transformation matrix to be applied to the resulting frustum plane
  86895. * @param frustumPlane the resuling frustum plane
  86896. */
  86897. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86898. /**
  86899. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  86900. * @param transform transformation matrix to be applied to the resulting frustum planes
  86901. * @param frustumPlanes the resuling frustum planes
  86902. */
  86903. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  86904. }
  86905. }
  86906. declare module BABYLON {
  86907. /**
  86908. * Interface for the size containing width and height
  86909. */
  86910. export interface ISize {
  86911. /**
  86912. * Width
  86913. */
  86914. width: number;
  86915. /**
  86916. * Heighht
  86917. */
  86918. height: number;
  86919. }
  86920. /**
  86921. * Size containing widht and height
  86922. */
  86923. export class Size implements ISize {
  86924. /**
  86925. * Width
  86926. */
  86927. width: number;
  86928. /**
  86929. * Height
  86930. */
  86931. height: number;
  86932. /**
  86933. * Creates a Size object from the given width and height (floats).
  86934. * @param width width of the new size
  86935. * @param height height of the new size
  86936. */
  86937. constructor(width: number, height: number);
  86938. /**
  86939. * Returns a string with the Size width and height
  86940. * @returns a string with the Size width and height
  86941. */
  86942. toString(): string;
  86943. /**
  86944. * "Size"
  86945. * @returns the string "Size"
  86946. */
  86947. getClassName(): string;
  86948. /**
  86949. * Returns the Size hash code.
  86950. * @returns a hash code for a unique width and height
  86951. */
  86952. getHashCode(): number;
  86953. /**
  86954. * Updates the current size from the given one.
  86955. * @param src the given size
  86956. */
  86957. copyFrom(src: Size): void;
  86958. /**
  86959. * Updates in place the current Size from the given floats.
  86960. * @param width width of the new size
  86961. * @param height height of the new size
  86962. * @returns the updated Size.
  86963. */
  86964. copyFromFloats(width: number, height: number): Size;
  86965. /**
  86966. * Updates in place the current Size from the given floats.
  86967. * @param width width to set
  86968. * @param height height to set
  86969. * @returns the updated Size.
  86970. */
  86971. set(width: number, height: number): Size;
  86972. /**
  86973. * Multiplies the width and height by numbers
  86974. * @param w factor to multiple the width by
  86975. * @param h factor to multiple the height by
  86976. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86977. */
  86978. multiplyByFloats(w: number, h: number): Size;
  86979. /**
  86980. * Clones the size
  86981. * @returns a new Size copied from the given one.
  86982. */
  86983. clone(): Size;
  86984. /**
  86985. * True if the current Size and the given one width and height are strictly equal.
  86986. * @param other the other size to compare against
  86987. * @returns True if the current Size and the given one width and height are strictly equal.
  86988. */
  86989. equals(other: Size): boolean;
  86990. /**
  86991. * The surface of the Size : width * height (float).
  86992. */
  86993. get surface(): number;
  86994. /**
  86995. * Create a new size of zero
  86996. * @returns a new Size set to (0.0, 0.0)
  86997. */
  86998. static Zero(): Size;
  86999. /**
  87000. * Sums the width and height of two sizes
  87001. * @param otherSize size to add to this size
  87002. * @returns a new Size set as the addition result of the current Size and the given one.
  87003. */
  87004. add(otherSize: Size): Size;
  87005. /**
  87006. * Subtracts the width and height of two
  87007. * @param otherSize size to subtract to this size
  87008. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87009. */
  87010. subtract(otherSize: Size): Size;
  87011. /**
  87012. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87013. * @param start starting size to lerp between
  87014. * @param end end size to lerp between
  87015. * @param amount amount to lerp between the start and end values
  87016. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87017. */
  87018. static Lerp(start: Size, end: Size, amount: number): Size;
  87019. }
  87020. }
  87021. declare module BABYLON {
  87022. /**
  87023. * Contains position and normal vectors for a vertex
  87024. */
  87025. export class PositionNormalVertex {
  87026. /** the position of the vertex (defaut: 0,0,0) */
  87027. position: Vector3;
  87028. /** the normal of the vertex (defaut: 0,1,0) */
  87029. normal: Vector3;
  87030. /**
  87031. * Creates a PositionNormalVertex
  87032. * @param position the position of the vertex (defaut: 0,0,0)
  87033. * @param normal the normal of the vertex (defaut: 0,1,0)
  87034. */
  87035. constructor(
  87036. /** the position of the vertex (defaut: 0,0,0) */
  87037. position?: Vector3,
  87038. /** the normal of the vertex (defaut: 0,1,0) */
  87039. normal?: Vector3);
  87040. /**
  87041. * Clones the PositionNormalVertex
  87042. * @returns the cloned PositionNormalVertex
  87043. */
  87044. clone(): PositionNormalVertex;
  87045. }
  87046. /**
  87047. * Contains position, normal and uv vectors for a vertex
  87048. */
  87049. export class PositionNormalTextureVertex {
  87050. /** the position of the vertex (defaut: 0,0,0) */
  87051. position: Vector3;
  87052. /** the normal of the vertex (defaut: 0,1,0) */
  87053. normal: Vector3;
  87054. /** the uv of the vertex (default: 0,0) */
  87055. uv: Vector2;
  87056. /**
  87057. * Creates a PositionNormalTextureVertex
  87058. * @param position the position of the vertex (defaut: 0,0,0)
  87059. * @param normal the normal of the vertex (defaut: 0,1,0)
  87060. * @param uv the uv of the vertex (default: 0,0)
  87061. */
  87062. constructor(
  87063. /** the position of the vertex (defaut: 0,0,0) */
  87064. position?: Vector3,
  87065. /** the normal of the vertex (defaut: 0,1,0) */
  87066. normal?: Vector3,
  87067. /** the uv of the vertex (default: 0,0) */
  87068. uv?: Vector2);
  87069. /**
  87070. * Clones the PositionNormalTextureVertex
  87071. * @returns the cloned PositionNormalTextureVertex
  87072. */
  87073. clone(): PositionNormalTextureVertex;
  87074. }
  87075. }
  87076. declare module BABYLON {
  87077. /**
  87078. * Enum defining the type of animations supported by InputBlock
  87079. */
  87080. export enum AnimatedInputBlockTypes {
  87081. /** No animation */
  87082. None = 0,
  87083. /** Time based animation. Will only work for floats */
  87084. Time = 1
  87085. }
  87086. }
  87087. declare module BABYLON {
  87088. /**
  87089. * Interface describing all the common properties and methods a shadow light needs to implement.
  87090. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87091. * as well as binding the different shadow properties to the effects.
  87092. */
  87093. export interface IShadowLight extends Light {
  87094. /**
  87095. * The light id in the scene (used in scene.findLighById for instance)
  87096. */
  87097. id: string;
  87098. /**
  87099. * The position the shdow will be casted from.
  87100. */
  87101. position: Vector3;
  87102. /**
  87103. * In 2d mode (needCube being false), the direction used to cast the shadow.
  87104. */
  87105. direction: Vector3;
  87106. /**
  87107. * The transformed position. Position of the light in world space taking parenting in account.
  87108. */
  87109. transformedPosition: Vector3;
  87110. /**
  87111. * The transformed direction. Direction of the light in world space taking parenting in account.
  87112. */
  87113. transformedDirection: Vector3;
  87114. /**
  87115. * The friendly name of the light in the scene.
  87116. */
  87117. name: string;
  87118. /**
  87119. * Defines the shadow projection clipping minimum z value.
  87120. */
  87121. shadowMinZ: number;
  87122. /**
  87123. * Defines the shadow projection clipping maximum z value.
  87124. */
  87125. shadowMaxZ: number;
  87126. /**
  87127. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87128. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87129. */
  87130. computeTransformedInformation(): boolean;
  87131. /**
  87132. * Gets the scene the light belongs to.
  87133. * @returns The scene
  87134. */
  87135. getScene(): Scene;
  87136. /**
  87137. * Callback defining a custom Projection Matrix Builder.
  87138. * This can be used to override the default projection matrix computation.
  87139. */
  87140. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87141. /**
  87142. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87143. * @param matrix The materix to updated with the projection information
  87144. * @param viewMatrix The transform matrix of the light
  87145. * @param renderList The list of mesh to render in the map
  87146. * @returns The current light
  87147. */
  87148. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87149. /**
  87150. * Gets the current depth scale used in ESM.
  87151. * @returns The scale
  87152. */
  87153. getDepthScale(): number;
  87154. /**
  87155. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87156. * @returns true if a cube texture needs to be use
  87157. */
  87158. needCube(): boolean;
  87159. /**
  87160. * Detects if the projection matrix requires to be recomputed this frame.
  87161. * @returns true if it requires to be recomputed otherwise, false.
  87162. */
  87163. needProjectionMatrixCompute(): boolean;
  87164. /**
  87165. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87166. */
  87167. forceProjectionMatrixCompute(): void;
  87168. /**
  87169. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87170. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87171. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87172. */
  87173. getShadowDirection(faceIndex?: number): Vector3;
  87174. /**
  87175. * Gets the minZ used for shadow according to both the scene and the light.
  87176. * @param activeCamera The camera we are returning the min for
  87177. * @returns the depth min z
  87178. */
  87179. getDepthMinZ(activeCamera: Camera): number;
  87180. /**
  87181. * Gets the maxZ used for shadow according to both the scene and the light.
  87182. * @param activeCamera The camera we are returning the max for
  87183. * @returns the depth max z
  87184. */
  87185. getDepthMaxZ(activeCamera: Camera): number;
  87186. }
  87187. /**
  87188. * Base implementation IShadowLight
  87189. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  87190. */
  87191. export abstract class ShadowLight extends Light implements IShadowLight {
  87192. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  87193. protected _position: Vector3;
  87194. protected _setPosition(value: Vector3): void;
  87195. /**
  87196. * Sets the position the shadow will be casted from. Also use as the light position for both
  87197. * point and spot lights.
  87198. */
  87199. get position(): Vector3;
  87200. /**
  87201. * Sets the position the shadow will be casted from. Also use as the light position for both
  87202. * point and spot lights.
  87203. */
  87204. set position(value: Vector3);
  87205. protected _direction: Vector3;
  87206. protected _setDirection(value: Vector3): void;
  87207. /**
  87208. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  87209. * Also use as the light direction on spot and directional lights.
  87210. */
  87211. get direction(): Vector3;
  87212. /**
  87213. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  87214. * Also use as the light direction on spot and directional lights.
  87215. */
  87216. set direction(value: Vector3);
  87217. protected _shadowMinZ: number;
  87218. /**
  87219. * Gets the shadow projection clipping minimum z value.
  87220. */
  87221. get shadowMinZ(): number;
  87222. /**
  87223. * Sets the shadow projection clipping minimum z value.
  87224. */
  87225. set shadowMinZ(value: number);
  87226. protected _shadowMaxZ: number;
  87227. /**
  87228. * Sets the shadow projection clipping maximum z value.
  87229. */
  87230. get shadowMaxZ(): number;
  87231. /**
  87232. * Gets the shadow projection clipping maximum z value.
  87233. */
  87234. set shadowMaxZ(value: number);
  87235. /**
  87236. * Callback defining a custom Projection Matrix Builder.
  87237. * This can be used to override the default projection matrix computation.
  87238. */
  87239. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87240. /**
  87241. * The transformed position. Position of the light in world space taking parenting in account.
  87242. */
  87243. transformedPosition: Vector3;
  87244. /**
  87245. * The transformed direction. Direction of the light in world space taking parenting in account.
  87246. */
  87247. transformedDirection: Vector3;
  87248. private _needProjectionMatrixCompute;
  87249. /**
  87250. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87251. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87252. */
  87253. computeTransformedInformation(): boolean;
  87254. /**
  87255. * Return the depth scale used for the shadow map.
  87256. * @returns the depth scale.
  87257. */
  87258. getDepthScale(): number;
  87259. /**
  87260. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87261. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87262. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87263. */
  87264. getShadowDirection(faceIndex?: number): Vector3;
  87265. /**
  87266. * Returns the ShadowLight absolute position in the World.
  87267. * @returns the position vector in world space
  87268. */
  87269. getAbsolutePosition(): Vector3;
  87270. /**
  87271. * Sets the ShadowLight direction toward the passed target.
  87272. * @param target The point to target in local space
  87273. * @returns the updated ShadowLight direction
  87274. */
  87275. setDirectionToTarget(target: Vector3): Vector3;
  87276. /**
  87277. * Returns the light rotation in euler definition.
  87278. * @returns the x y z rotation in local space.
  87279. */
  87280. getRotation(): Vector3;
  87281. /**
  87282. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87283. * @returns true if a cube texture needs to be use
  87284. */
  87285. needCube(): boolean;
  87286. /**
  87287. * Detects if the projection matrix requires to be recomputed this frame.
  87288. * @returns true if it requires to be recomputed otherwise, false.
  87289. */
  87290. needProjectionMatrixCompute(): boolean;
  87291. /**
  87292. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87293. */
  87294. forceProjectionMatrixCompute(): void;
  87295. /** @hidden */
  87296. _initCache(): void;
  87297. /** @hidden */
  87298. _isSynchronized(): boolean;
  87299. /**
  87300. * Computes the world matrix of the node
  87301. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87302. * @returns the world matrix
  87303. */
  87304. computeWorldMatrix(force?: boolean): Matrix;
  87305. /**
  87306. * Gets the minZ used for shadow according to both the scene and the light.
  87307. * @param activeCamera The camera we are returning the min for
  87308. * @returns the depth min z
  87309. */
  87310. getDepthMinZ(activeCamera: Camera): number;
  87311. /**
  87312. * Gets the maxZ used for shadow according to both the scene and the light.
  87313. * @param activeCamera The camera we are returning the max for
  87314. * @returns the depth max z
  87315. */
  87316. getDepthMaxZ(activeCamera: Camera): number;
  87317. /**
  87318. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87319. * @param matrix The materix to updated with the projection information
  87320. * @param viewMatrix The transform matrix of the light
  87321. * @param renderList The list of mesh to render in the map
  87322. * @returns The current light
  87323. */
  87324. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87325. }
  87326. }
  87327. declare module BABYLON {
  87328. /** @hidden */
  87329. export var packingFunctions: {
  87330. name: string;
  87331. shader: string;
  87332. };
  87333. }
  87334. declare module BABYLON {
  87335. /** @hidden */
  87336. export var bayerDitherFunctions: {
  87337. name: string;
  87338. shader: string;
  87339. };
  87340. }
  87341. declare module BABYLON {
  87342. /** @hidden */
  87343. export var shadowMapFragmentDeclaration: {
  87344. name: string;
  87345. shader: string;
  87346. };
  87347. }
  87348. declare module BABYLON {
  87349. /** @hidden */
  87350. export var clipPlaneFragmentDeclaration: {
  87351. name: string;
  87352. shader: string;
  87353. };
  87354. }
  87355. declare module BABYLON {
  87356. /** @hidden */
  87357. export var clipPlaneFragment: {
  87358. name: string;
  87359. shader: string;
  87360. };
  87361. }
  87362. declare module BABYLON {
  87363. /** @hidden */
  87364. export var shadowMapFragment: {
  87365. name: string;
  87366. shader: string;
  87367. };
  87368. }
  87369. declare module BABYLON {
  87370. /** @hidden */
  87371. export var shadowMapPixelShader: {
  87372. name: string;
  87373. shader: string;
  87374. };
  87375. }
  87376. declare module BABYLON {
  87377. /** @hidden */
  87378. export var bonesDeclaration: {
  87379. name: string;
  87380. shader: string;
  87381. };
  87382. }
  87383. declare module BABYLON {
  87384. /** @hidden */
  87385. export var morphTargetsVertexGlobalDeclaration: {
  87386. name: string;
  87387. shader: string;
  87388. };
  87389. }
  87390. declare module BABYLON {
  87391. /** @hidden */
  87392. export var morphTargetsVertexDeclaration: {
  87393. name: string;
  87394. shader: string;
  87395. };
  87396. }
  87397. declare module BABYLON {
  87398. /** @hidden */
  87399. export var instancesDeclaration: {
  87400. name: string;
  87401. shader: string;
  87402. };
  87403. }
  87404. declare module BABYLON {
  87405. /** @hidden */
  87406. export var helperFunctions: {
  87407. name: string;
  87408. shader: string;
  87409. };
  87410. }
  87411. declare module BABYLON {
  87412. /** @hidden */
  87413. export var shadowMapVertexDeclaration: {
  87414. name: string;
  87415. shader: string;
  87416. };
  87417. }
  87418. declare module BABYLON {
  87419. /** @hidden */
  87420. export var clipPlaneVertexDeclaration: {
  87421. name: string;
  87422. shader: string;
  87423. };
  87424. }
  87425. declare module BABYLON {
  87426. /** @hidden */
  87427. export var morphTargetsVertex: {
  87428. name: string;
  87429. shader: string;
  87430. };
  87431. }
  87432. declare module BABYLON {
  87433. /** @hidden */
  87434. export var instancesVertex: {
  87435. name: string;
  87436. shader: string;
  87437. };
  87438. }
  87439. declare module BABYLON {
  87440. /** @hidden */
  87441. export var bonesVertex: {
  87442. name: string;
  87443. shader: string;
  87444. };
  87445. }
  87446. declare module BABYLON {
  87447. /** @hidden */
  87448. export var shadowMapVertexNormalBias: {
  87449. name: string;
  87450. shader: string;
  87451. };
  87452. }
  87453. declare module BABYLON {
  87454. /** @hidden */
  87455. export var shadowMapVertexMetric: {
  87456. name: string;
  87457. shader: string;
  87458. };
  87459. }
  87460. declare module BABYLON {
  87461. /** @hidden */
  87462. export var clipPlaneVertex: {
  87463. name: string;
  87464. shader: string;
  87465. };
  87466. }
  87467. declare module BABYLON {
  87468. /** @hidden */
  87469. export var shadowMapVertexShader: {
  87470. name: string;
  87471. shader: string;
  87472. };
  87473. }
  87474. declare module BABYLON {
  87475. /** @hidden */
  87476. export var depthBoxBlurPixelShader: {
  87477. name: string;
  87478. shader: string;
  87479. };
  87480. }
  87481. declare module BABYLON {
  87482. /** @hidden */
  87483. export var shadowMapFragmentSoftTransparentShadow: {
  87484. name: string;
  87485. shader: string;
  87486. };
  87487. }
  87488. declare module BABYLON {
  87489. /**
  87490. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87491. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87492. */
  87493. export class EffectFallbacks implements IEffectFallbacks {
  87494. private _defines;
  87495. private _currentRank;
  87496. private _maxRank;
  87497. private _mesh;
  87498. /**
  87499. * Removes the fallback from the bound mesh.
  87500. */
  87501. unBindMesh(): void;
  87502. /**
  87503. * Adds a fallback on the specified property.
  87504. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87505. * @param define The name of the define in the shader
  87506. */
  87507. addFallback(rank: number, define: string): void;
  87508. /**
  87509. * Sets the mesh to use CPU skinning when needing to fallback.
  87510. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87511. * @param mesh The mesh to use the fallbacks.
  87512. */
  87513. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87514. /**
  87515. * Checks to see if more fallbacks are still availible.
  87516. */
  87517. get hasMoreFallbacks(): boolean;
  87518. /**
  87519. * Removes the defines that should be removed when falling back.
  87520. * @param currentDefines defines the current define statements for the shader.
  87521. * @param effect defines the current effect we try to compile
  87522. * @returns The resulting defines with defines of the current rank removed.
  87523. */
  87524. reduce(currentDefines: string, effect: Effect): string;
  87525. }
  87526. }
  87527. declare module BABYLON {
  87528. /**
  87529. * Interface used to define Action
  87530. */
  87531. export interface IAction {
  87532. /**
  87533. * Trigger for the action
  87534. */
  87535. trigger: number;
  87536. /** Options of the trigger */
  87537. triggerOptions: any;
  87538. /**
  87539. * Gets the trigger parameters
  87540. * @returns the trigger parameters
  87541. */
  87542. getTriggerParameter(): any;
  87543. /**
  87544. * Internal only - executes current action event
  87545. * @hidden
  87546. */
  87547. _executeCurrent(evt?: ActionEvent): void;
  87548. /**
  87549. * Serialize placeholder for child classes
  87550. * @param parent of child
  87551. * @returns the serialized object
  87552. */
  87553. serialize(parent: any): any;
  87554. /**
  87555. * Internal only
  87556. * @hidden
  87557. */
  87558. _prepare(): void;
  87559. /**
  87560. * Internal only - manager for action
  87561. * @hidden
  87562. */
  87563. _actionManager: AbstractActionManager;
  87564. /**
  87565. * Adds action to chain of actions, may be a DoNothingAction
  87566. * @param action defines the next action to execute
  87567. * @returns The action passed in
  87568. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87569. */
  87570. then(action: IAction): IAction;
  87571. }
  87572. /**
  87573. * The action to be carried out following a trigger
  87574. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  87575. */
  87576. export class Action implements IAction {
  87577. /** the trigger, with or without parameters, for the action */
  87578. triggerOptions: any;
  87579. /**
  87580. * Trigger for the action
  87581. */
  87582. trigger: number;
  87583. /**
  87584. * Internal only - manager for action
  87585. * @hidden
  87586. */
  87587. _actionManager: ActionManager;
  87588. private _nextActiveAction;
  87589. private _child;
  87590. private _condition?;
  87591. private _triggerParameter;
  87592. /**
  87593. * An event triggered prior to action being executed.
  87594. */
  87595. onBeforeExecuteObservable: Observable<Action>;
  87596. /**
  87597. * Creates a new Action
  87598. * @param triggerOptions the trigger, with or without parameters, for the action
  87599. * @param condition an optional determinant of action
  87600. */
  87601. constructor(
  87602. /** the trigger, with or without parameters, for the action */
  87603. triggerOptions: any, condition?: Condition);
  87604. /**
  87605. * Internal only
  87606. * @hidden
  87607. */
  87608. _prepare(): void;
  87609. /**
  87610. * Gets the trigger parameters
  87611. * @returns the trigger parameters
  87612. */
  87613. getTriggerParameter(): any;
  87614. /**
  87615. * Internal only - executes current action event
  87616. * @hidden
  87617. */
  87618. _executeCurrent(evt?: ActionEvent): void;
  87619. /**
  87620. * Execute placeholder for child classes
  87621. * @param evt optional action event
  87622. */
  87623. execute(evt?: ActionEvent): void;
  87624. /**
  87625. * Skips to next active action
  87626. */
  87627. skipToNextActiveAction(): void;
  87628. /**
  87629. * Adds action to chain of actions, may be a DoNothingAction
  87630. * @param action defines the next action to execute
  87631. * @returns The action passed in
  87632. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87633. */
  87634. then(action: Action): Action;
  87635. /**
  87636. * Internal only
  87637. * @hidden
  87638. */
  87639. _getProperty(propertyPath: string): string;
  87640. /**
  87641. * Internal only
  87642. * @hidden
  87643. */
  87644. _getEffectiveTarget(target: any, propertyPath: string): any;
  87645. /**
  87646. * Serialize placeholder for child classes
  87647. * @param parent of child
  87648. * @returns the serialized object
  87649. */
  87650. serialize(parent: any): any;
  87651. /**
  87652. * Internal only called by serialize
  87653. * @hidden
  87654. */
  87655. protected _serialize(serializedAction: any, parent?: any): any;
  87656. /**
  87657. * Internal only
  87658. * @hidden
  87659. */
  87660. static _SerializeValueAsString: (value: any) => string;
  87661. /**
  87662. * Internal only
  87663. * @hidden
  87664. */
  87665. static _GetTargetProperty: (target: Scene | Node) => {
  87666. name: string;
  87667. targetType: string;
  87668. value: string;
  87669. };
  87670. }
  87671. }
  87672. declare module BABYLON {
  87673. /**
  87674. * A Condition applied to an Action
  87675. */
  87676. export class Condition {
  87677. /**
  87678. * Internal only - manager for action
  87679. * @hidden
  87680. */
  87681. _actionManager: ActionManager;
  87682. /**
  87683. * Internal only
  87684. * @hidden
  87685. */
  87686. _evaluationId: number;
  87687. /**
  87688. * Internal only
  87689. * @hidden
  87690. */
  87691. _currentResult: boolean;
  87692. /**
  87693. * Creates a new Condition
  87694. * @param actionManager the manager of the action the condition is applied to
  87695. */
  87696. constructor(actionManager: ActionManager);
  87697. /**
  87698. * Check if the current condition is valid
  87699. * @returns a boolean
  87700. */
  87701. isValid(): boolean;
  87702. /**
  87703. * Internal only
  87704. * @hidden
  87705. */
  87706. _getProperty(propertyPath: string): string;
  87707. /**
  87708. * Internal only
  87709. * @hidden
  87710. */
  87711. _getEffectiveTarget(target: any, propertyPath: string): any;
  87712. /**
  87713. * Serialize placeholder for child classes
  87714. * @returns the serialized object
  87715. */
  87716. serialize(): any;
  87717. /**
  87718. * Internal only
  87719. * @hidden
  87720. */
  87721. protected _serialize(serializedCondition: any): any;
  87722. }
  87723. /**
  87724. * Defines specific conditional operators as extensions of Condition
  87725. */
  87726. export class ValueCondition extends Condition {
  87727. /** path to specify the property of the target the conditional operator uses */
  87728. propertyPath: string;
  87729. /** the value compared by the conditional operator against the current value of the property */
  87730. value: any;
  87731. /** the conditional operator, default ValueCondition.IsEqual */
  87732. operator: number;
  87733. /**
  87734. * Internal only
  87735. * @hidden
  87736. */
  87737. private static _IsEqual;
  87738. /**
  87739. * Internal only
  87740. * @hidden
  87741. */
  87742. private static _IsDifferent;
  87743. /**
  87744. * Internal only
  87745. * @hidden
  87746. */
  87747. private static _IsGreater;
  87748. /**
  87749. * Internal only
  87750. * @hidden
  87751. */
  87752. private static _IsLesser;
  87753. /**
  87754. * returns the number for IsEqual
  87755. */
  87756. static get IsEqual(): number;
  87757. /**
  87758. * Returns the number for IsDifferent
  87759. */
  87760. static get IsDifferent(): number;
  87761. /**
  87762. * Returns the number for IsGreater
  87763. */
  87764. static get IsGreater(): number;
  87765. /**
  87766. * Returns the number for IsLesser
  87767. */
  87768. static get IsLesser(): number;
  87769. /**
  87770. * Internal only The action manager for the condition
  87771. * @hidden
  87772. */
  87773. _actionManager: ActionManager;
  87774. /**
  87775. * Internal only
  87776. * @hidden
  87777. */
  87778. private _target;
  87779. /**
  87780. * Internal only
  87781. * @hidden
  87782. */
  87783. private _effectiveTarget;
  87784. /**
  87785. * Internal only
  87786. * @hidden
  87787. */
  87788. private _property;
  87789. /**
  87790. * Creates a new ValueCondition
  87791. * @param actionManager manager for the action the condition applies to
  87792. * @param target for the action
  87793. * @param propertyPath path to specify the property of the target the conditional operator uses
  87794. * @param value the value compared by the conditional operator against the current value of the property
  87795. * @param operator the conditional operator, default ValueCondition.IsEqual
  87796. */
  87797. constructor(actionManager: ActionManager, target: any,
  87798. /** path to specify the property of the target the conditional operator uses */
  87799. propertyPath: string,
  87800. /** the value compared by the conditional operator against the current value of the property */
  87801. value: any,
  87802. /** the conditional operator, default ValueCondition.IsEqual */
  87803. operator?: number);
  87804. /**
  87805. * Compares the given value with the property value for the specified conditional operator
  87806. * @returns the result of the comparison
  87807. */
  87808. isValid(): boolean;
  87809. /**
  87810. * Serialize the ValueCondition into a JSON compatible object
  87811. * @returns serialization object
  87812. */
  87813. serialize(): any;
  87814. /**
  87815. * Gets the name of the conditional operator for the ValueCondition
  87816. * @param operator the conditional operator
  87817. * @returns the name
  87818. */
  87819. static GetOperatorName(operator: number): string;
  87820. }
  87821. /**
  87822. * Defines a predicate condition as an extension of Condition
  87823. */
  87824. export class PredicateCondition extends Condition {
  87825. /** defines the predicate function used to validate the condition */
  87826. predicate: () => boolean;
  87827. /**
  87828. * Internal only - manager for action
  87829. * @hidden
  87830. */
  87831. _actionManager: ActionManager;
  87832. /**
  87833. * Creates a new PredicateCondition
  87834. * @param actionManager manager for the action the condition applies to
  87835. * @param predicate defines the predicate function used to validate the condition
  87836. */
  87837. constructor(actionManager: ActionManager,
  87838. /** defines the predicate function used to validate the condition */
  87839. predicate: () => boolean);
  87840. /**
  87841. * @returns the validity of the predicate condition
  87842. */
  87843. isValid(): boolean;
  87844. }
  87845. /**
  87846. * Defines a state condition as an extension of Condition
  87847. */
  87848. export class StateCondition extends Condition {
  87849. /** Value to compare with target state */
  87850. value: string;
  87851. /**
  87852. * Internal only - manager for action
  87853. * @hidden
  87854. */
  87855. _actionManager: ActionManager;
  87856. /**
  87857. * Internal only
  87858. * @hidden
  87859. */
  87860. private _target;
  87861. /**
  87862. * Creates a new StateCondition
  87863. * @param actionManager manager for the action the condition applies to
  87864. * @param target of the condition
  87865. * @param value to compare with target state
  87866. */
  87867. constructor(actionManager: ActionManager, target: any,
  87868. /** Value to compare with target state */
  87869. value: string);
  87870. /**
  87871. * Gets a boolean indicating if the current condition is met
  87872. * @returns the validity of the state
  87873. */
  87874. isValid(): boolean;
  87875. /**
  87876. * Serialize the StateCondition into a JSON compatible object
  87877. * @returns serialization object
  87878. */
  87879. serialize(): any;
  87880. }
  87881. }
  87882. declare module BABYLON {
  87883. /**
  87884. * This defines an action responsible to toggle a boolean once triggered.
  87885. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87886. */
  87887. export class SwitchBooleanAction extends Action {
  87888. /**
  87889. * The path to the boolean property in the target object
  87890. */
  87891. propertyPath: string;
  87892. private _target;
  87893. private _effectiveTarget;
  87894. private _property;
  87895. /**
  87896. * Instantiate the action
  87897. * @param triggerOptions defines the trigger options
  87898. * @param target defines the object containing the boolean
  87899. * @param propertyPath defines the path to the boolean property in the target object
  87900. * @param condition defines the trigger related conditions
  87901. */
  87902. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  87903. /** @hidden */
  87904. _prepare(): void;
  87905. /**
  87906. * Execute the action toggle the boolean value.
  87907. */
  87908. execute(): void;
  87909. /**
  87910. * Serializes the actions and its related information.
  87911. * @param parent defines the object to serialize in
  87912. * @returns the serialized object
  87913. */
  87914. serialize(parent: any): any;
  87915. }
  87916. /**
  87917. * This defines an action responsible to set a the state field of the target
  87918. * to a desired value once triggered.
  87919. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87920. */
  87921. export class SetStateAction extends Action {
  87922. /**
  87923. * The value to store in the state field.
  87924. */
  87925. value: string;
  87926. private _target;
  87927. /**
  87928. * Instantiate the action
  87929. * @param triggerOptions defines the trigger options
  87930. * @param target defines the object containing the state property
  87931. * @param value defines the value to store in the state field
  87932. * @param condition defines the trigger related conditions
  87933. */
  87934. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  87935. /**
  87936. * Execute the action and store the value on the target state property.
  87937. */
  87938. execute(): void;
  87939. /**
  87940. * Serializes the actions and its related information.
  87941. * @param parent defines the object to serialize in
  87942. * @returns the serialized object
  87943. */
  87944. serialize(parent: any): any;
  87945. }
  87946. /**
  87947. * This defines an action responsible to set a property of the target
  87948. * to a desired value once triggered.
  87949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87950. */
  87951. export class SetValueAction extends Action {
  87952. /**
  87953. * The path of the property to set in the target.
  87954. */
  87955. propertyPath: string;
  87956. /**
  87957. * The value to set in the property
  87958. */
  87959. value: any;
  87960. private _target;
  87961. private _effectiveTarget;
  87962. private _property;
  87963. /**
  87964. * Instantiate the action
  87965. * @param triggerOptions defines the trigger options
  87966. * @param target defines the object containing the property
  87967. * @param propertyPath defines the path of the property to set in the target
  87968. * @param value defines the value to set in the property
  87969. * @param condition defines the trigger related conditions
  87970. */
  87971. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87972. /** @hidden */
  87973. _prepare(): void;
  87974. /**
  87975. * Execute the action and set the targetted property to the desired value.
  87976. */
  87977. execute(): void;
  87978. /**
  87979. * Serializes the actions and its related information.
  87980. * @param parent defines the object to serialize in
  87981. * @returns the serialized object
  87982. */
  87983. serialize(parent: any): any;
  87984. }
  87985. /**
  87986. * This defines an action responsible to increment the target value
  87987. * to a desired value once triggered.
  87988. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87989. */
  87990. export class IncrementValueAction extends Action {
  87991. /**
  87992. * The path of the property to increment in the target.
  87993. */
  87994. propertyPath: string;
  87995. /**
  87996. * The value we should increment the property by.
  87997. */
  87998. value: any;
  87999. private _target;
  88000. private _effectiveTarget;
  88001. private _property;
  88002. /**
  88003. * Instantiate the action
  88004. * @param triggerOptions defines the trigger options
  88005. * @param target defines the object containing the property
  88006. * @param propertyPath defines the path of the property to increment in the target
  88007. * @param value defines the value value we should increment the property by
  88008. * @param condition defines the trigger related conditions
  88009. */
  88010. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88011. /** @hidden */
  88012. _prepare(): void;
  88013. /**
  88014. * Execute the action and increment the target of the value amount.
  88015. */
  88016. execute(): void;
  88017. /**
  88018. * Serializes the actions and its related information.
  88019. * @param parent defines the object to serialize in
  88020. * @returns the serialized object
  88021. */
  88022. serialize(parent: any): any;
  88023. }
  88024. /**
  88025. * This defines an action responsible to start an animation once triggered.
  88026. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88027. */
  88028. export class PlayAnimationAction extends Action {
  88029. /**
  88030. * Where the animation should start (animation frame)
  88031. */
  88032. from: number;
  88033. /**
  88034. * Where the animation should stop (animation frame)
  88035. */
  88036. to: number;
  88037. /**
  88038. * Define if the animation should loop or stop after the first play.
  88039. */
  88040. loop?: boolean;
  88041. private _target;
  88042. /**
  88043. * Instantiate the action
  88044. * @param triggerOptions defines the trigger options
  88045. * @param target defines the target animation or animation name
  88046. * @param from defines from where the animation should start (animation frame)
  88047. * @param end defines where the animation should stop (animation frame)
  88048. * @param loop defines if the animation should loop or stop after the first play
  88049. * @param condition defines the trigger related conditions
  88050. */
  88051. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88052. /** @hidden */
  88053. _prepare(): void;
  88054. /**
  88055. * Execute the action and play the animation.
  88056. */
  88057. execute(): void;
  88058. /**
  88059. * Serializes the actions and its related information.
  88060. * @param parent defines the object to serialize in
  88061. * @returns the serialized object
  88062. */
  88063. serialize(parent: any): any;
  88064. }
  88065. /**
  88066. * This defines an action responsible to stop an animation once triggered.
  88067. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88068. */
  88069. export class StopAnimationAction extends Action {
  88070. private _target;
  88071. /**
  88072. * Instantiate the action
  88073. * @param triggerOptions defines the trigger options
  88074. * @param target defines the target animation or animation name
  88075. * @param condition defines the trigger related conditions
  88076. */
  88077. constructor(triggerOptions: any, target: any, condition?: Condition);
  88078. /** @hidden */
  88079. _prepare(): void;
  88080. /**
  88081. * Execute the action and stop the animation.
  88082. */
  88083. execute(): void;
  88084. /**
  88085. * Serializes the actions and its related information.
  88086. * @param parent defines the object to serialize in
  88087. * @returns the serialized object
  88088. */
  88089. serialize(parent: any): any;
  88090. }
  88091. /**
  88092. * This defines an action responsible that does nothing once triggered.
  88093. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88094. */
  88095. export class DoNothingAction extends Action {
  88096. /**
  88097. * Instantiate the action
  88098. * @param triggerOptions defines the trigger options
  88099. * @param condition defines the trigger related conditions
  88100. */
  88101. constructor(triggerOptions?: any, condition?: Condition);
  88102. /**
  88103. * Execute the action and do nothing.
  88104. */
  88105. execute(): void;
  88106. /**
  88107. * Serializes the actions and its related information.
  88108. * @param parent defines the object to serialize in
  88109. * @returns the serialized object
  88110. */
  88111. serialize(parent: any): any;
  88112. }
  88113. /**
  88114. * This defines an action responsible to trigger several actions once triggered.
  88115. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88116. */
  88117. export class CombineAction extends Action {
  88118. /**
  88119. * The list of aggregated animations to run.
  88120. */
  88121. children: Action[];
  88122. /**
  88123. * Instantiate the action
  88124. * @param triggerOptions defines the trigger options
  88125. * @param children defines the list of aggregated animations to run
  88126. * @param condition defines the trigger related conditions
  88127. */
  88128. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  88129. /** @hidden */
  88130. _prepare(): void;
  88131. /**
  88132. * Execute the action and executes all the aggregated actions.
  88133. */
  88134. execute(evt: ActionEvent): void;
  88135. /**
  88136. * Serializes the actions and its related information.
  88137. * @param parent defines the object to serialize in
  88138. * @returns the serialized object
  88139. */
  88140. serialize(parent: any): any;
  88141. }
  88142. /**
  88143. * This defines an action responsible to run code (external event) once triggered.
  88144. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88145. */
  88146. export class ExecuteCodeAction extends Action {
  88147. /**
  88148. * The callback function to run.
  88149. */
  88150. func: (evt: ActionEvent) => void;
  88151. /**
  88152. * Instantiate the action
  88153. * @param triggerOptions defines the trigger options
  88154. * @param func defines the callback function to run
  88155. * @param condition defines the trigger related conditions
  88156. */
  88157. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  88158. /**
  88159. * Execute the action and run the attached code.
  88160. */
  88161. execute(evt: ActionEvent): void;
  88162. }
  88163. /**
  88164. * This defines an action responsible to set the parent property of the target once triggered.
  88165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88166. */
  88167. export class SetParentAction extends Action {
  88168. private _parent;
  88169. private _target;
  88170. /**
  88171. * Instantiate the action
  88172. * @param triggerOptions defines the trigger options
  88173. * @param target defines the target containing the parent property
  88174. * @param parent defines from where the animation should start (animation frame)
  88175. * @param condition defines the trigger related conditions
  88176. */
  88177. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  88178. /** @hidden */
  88179. _prepare(): void;
  88180. /**
  88181. * Execute the action and set the parent property.
  88182. */
  88183. execute(): void;
  88184. /**
  88185. * Serializes the actions and its related information.
  88186. * @param parent defines the object to serialize in
  88187. * @returns the serialized object
  88188. */
  88189. serialize(parent: any): any;
  88190. }
  88191. }
  88192. declare module BABYLON {
  88193. /**
  88194. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  88195. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  88196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88197. */
  88198. export class ActionManager extends AbstractActionManager {
  88199. /**
  88200. * Nothing
  88201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88202. */
  88203. static readonly NothingTrigger: number;
  88204. /**
  88205. * On pick
  88206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88207. */
  88208. static readonly OnPickTrigger: number;
  88209. /**
  88210. * On left pick
  88211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88212. */
  88213. static readonly OnLeftPickTrigger: number;
  88214. /**
  88215. * On right pick
  88216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88217. */
  88218. static readonly OnRightPickTrigger: number;
  88219. /**
  88220. * On center pick
  88221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88222. */
  88223. static readonly OnCenterPickTrigger: number;
  88224. /**
  88225. * On pick down
  88226. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88227. */
  88228. static readonly OnPickDownTrigger: number;
  88229. /**
  88230. * On double pick
  88231. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88232. */
  88233. static readonly OnDoublePickTrigger: number;
  88234. /**
  88235. * On pick up
  88236. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88237. */
  88238. static readonly OnPickUpTrigger: number;
  88239. /**
  88240. * On pick out.
  88241. * This trigger will only be raised if you also declared a OnPickDown
  88242. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88243. */
  88244. static readonly OnPickOutTrigger: number;
  88245. /**
  88246. * On long press
  88247. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88248. */
  88249. static readonly OnLongPressTrigger: number;
  88250. /**
  88251. * On pointer over
  88252. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88253. */
  88254. static readonly OnPointerOverTrigger: number;
  88255. /**
  88256. * On pointer out
  88257. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88258. */
  88259. static readonly OnPointerOutTrigger: number;
  88260. /**
  88261. * On every frame
  88262. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88263. */
  88264. static readonly OnEveryFrameTrigger: number;
  88265. /**
  88266. * On intersection enter
  88267. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88268. */
  88269. static readonly OnIntersectionEnterTrigger: number;
  88270. /**
  88271. * On intersection exit
  88272. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88273. */
  88274. static readonly OnIntersectionExitTrigger: number;
  88275. /**
  88276. * On key down
  88277. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88278. */
  88279. static readonly OnKeyDownTrigger: number;
  88280. /**
  88281. * On key up
  88282. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88283. */
  88284. static readonly OnKeyUpTrigger: number;
  88285. private _scene;
  88286. /**
  88287. * Creates a new action manager
  88288. * @param scene defines the hosting scene
  88289. */
  88290. constructor(scene: Scene);
  88291. /**
  88292. * Releases all associated resources
  88293. */
  88294. dispose(): void;
  88295. /**
  88296. * Gets hosting scene
  88297. * @returns the hosting scene
  88298. */
  88299. getScene(): Scene;
  88300. /**
  88301. * Does this action manager handles actions of any of the given triggers
  88302. * @param triggers defines the triggers to be tested
  88303. * @return a boolean indicating whether one (or more) of the triggers is handled
  88304. */
  88305. hasSpecificTriggers(triggers: number[]): boolean;
  88306. /**
  88307. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88308. * speed.
  88309. * @param triggerA defines the trigger to be tested
  88310. * @param triggerB defines the trigger to be tested
  88311. * @return a boolean indicating whether one (or more) of the triggers is handled
  88312. */
  88313. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88314. /**
  88315. * Does this action manager handles actions of a given trigger
  88316. * @param trigger defines the trigger to be tested
  88317. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88318. * @return whether the trigger is handled
  88319. */
  88320. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88321. /**
  88322. * Does this action manager has pointer triggers
  88323. */
  88324. get hasPointerTriggers(): boolean;
  88325. /**
  88326. * Does this action manager has pick triggers
  88327. */
  88328. get hasPickTriggers(): boolean;
  88329. /**
  88330. * Registers an action to this action manager
  88331. * @param action defines the action to be registered
  88332. * @return the action amended (prepared) after registration
  88333. */
  88334. registerAction(action: IAction): Nullable<IAction>;
  88335. /**
  88336. * Unregisters an action to this action manager
  88337. * @param action defines the action to be unregistered
  88338. * @return a boolean indicating whether the action has been unregistered
  88339. */
  88340. unregisterAction(action: IAction): Boolean;
  88341. /**
  88342. * Process a specific trigger
  88343. * @param trigger defines the trigger to process
  88344. * @param evt defines the event details to be processed
  88345. */
  88346. processTrigger(trigger: number, evt?: IActionEvent): void;
  88347. /** @hidden */
  88348. _getEffectiveTarget(target: any, propertyPath: string): any;
  88349. /** @hidden */
  88350. _getProperty(propertyPath: string): string;
  88351. /**
  88352. * Serialize this manager to a JSON object
  88353. * @param name defines the property name to store this manager
  88354. * @returns a JSON representation of this manager
  88355. */
  88356. serialize(name: string): any;
  88357. /**
  88358. * Creates a new ActionManager from a JSON data
  88359. * @param parsedActions defines the JSON data to read from
  88360. * @param object defines the hosting mesh
  88361. * @param scene defines the hosting scene
  88362. */
  88363. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  88364. /**
  88365. * Get a trigger name by index
  88366. * @param trigger defines the trigger index
  88367. * @returns a trigger name
  88368. */
  88369. static GetTriggerName(trigger: number): string;
  88370. }
  88371. }
  88372. declare module BABYLON {
  88373. /**
  88374. * Class used to represent a sprite
  88375. * @see https://doc.babylonjs.com/babylon101/sprites
  88376. */
  88377. export class Sprite implements IAnimatable {
  88378. /** defines the name */
  88379. name: string;
  88380. /** Gets or sets the current world position */
  88381. position: Vector3;
  88382. /** Gets or sets the main color */
  88383. color: Color4;
  88384. /** Gets or sets the width */
  88385. width: number;
  88386. /** Gets or sets the height */
  88387. height: number;
  88388. /** Gets or sets rotation angle */
  88389. angle: number;
  88390. /** Gets or sets the cell index in the sprite sheet */
  88391. cellIndex: number;
  88392. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  88393. cellRef: string;
  88394. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  88395. invertU: boolean;
  88396. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  88397. invertV: boolean;
  88398. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  88399. disposeWhenFinishedAnimating: boolean;
  88400. /** Gets the list of attached animations */
  88401. animations: Nullable<Array<Animation>>;
  88402. /** Gets or sets a boolean indicating if the sprite can be picked */
  88403. isPickable: boolean;
  88404. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  88405. useAlphaForPicking: boolean;
  88406. /** @hidden */
  88407. _xOffset: number;
  88408. /** @hidden */
  88409. _yOffset: number;
  88410. /** @hidden */
  88411. _xSize: number;
  88412. /** @hidden */
  88413. _ySize: number;
  88414. /**
  88415. * Gets or sets the associated action manager
  88416. */
  88417. actionManager: Nullable<ActionManager>;
  88418. /**
  88419. * An event triggered when the control has been disposed
  88420. */
  88421. onDisposeObservable: Observable<Sprite>;
  88422. private _animationStarted;
  88423. private _loopAnimation;
  88424. private _fromIndex;
  88425. private _toIndex;
  88426. private _delay;
  88427. private _direction;
  88428. private _manager;
  88429. private _time;
  88430. private _onAnimationEnd;
  88431. /**
  88432. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  88433. */
  88434. isVisible: boolean;
  88435. /**
  88436. * Gets or sets the sprite size
  88437. */
  88438. get size(): number;
  88439. set size(value: number);
  88440. /**
  88441. * Returns a boolean indicating if the animation is started
  88442. */
  88443. get animationStarted(): boolean;
  88444. /**
  88445. * Gets or sets the unique id of the sprite
  88446. */
  88447. uniqueId: number;
  88448. /**
  88449. * Gets the manager of this sprite
  88450. */
  88451. get manager(): ISpriteManager;
  88452. /**
  88453. * Creates a new Sprite
  88454. * @param name defines the name
  88455. * @param manager defines the manager
  88456. */
  88457. constructor(
  88458. /** defines the name */
  88459. name: string, manager: ISpriteManager);
  88460. /**
  88461. * Returns the string "Sprite"
  88462. * @returns "Sprite"
  88463. */
  88464. getClassName(): string;
  88465. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  88466. get fromIndex(): number;
  88467. set fromIndex(value: number);
  88468. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  88469. get toIndex(): number;
  88470. set toIndex(value: number);
  88471. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  88472. get loopAnimation(): boolean;
  88473. set loopAnimation(value: boolean);
  88474. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  88475. get delay(): number;
  88476. set delay(value: number);
  88477. /**
  88478. * Starts an animation
  88479. * @param from defines the initial key
  88480. * @param to defines the end key
  88481. * @param loop defines if the animation must loop
  88482. * @param delay defines the start delay (in ms)
  88483. * @param onAnimationEnd defines a callback to call when animation ends
  88484. */
  88485. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  88486. /** Stops current animation (if any) */
  88487. stopAnimation(): void;
  88488. /** @hidden */
  88489. _animate(deltaTime: number): void;
  88490. /** Release associated resources */
  88491. dispose(): void;
  88492. /**
  88493. * Serializes the sprite to a JSON object
  88494. * @returns the JSON object
  88495. */
  88496. serialize(): any;
  88497. /**
  88498. * Parses a JSON object to create a new sprite
  88499. * @param parsedSprite The JSON object to parse
  88500. * @param manager defines the hosting manager
  88501. * @returns the new sprite
  88502. */
  88503. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  88504. }
  88505. }
  88506. declare module BABYLON {
  88507. /**
  88508. * Information about the result of picking within a scene
  88509. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  88510. */
  88511. export class PickingInfo {
  88512. /** @hidden */
  88513. _pickingUnavailable: boolean;
  88514. /**
  88515. * If the pick collided with an object
  88516. */
  88517. hit: boolean;
  88518. /**
  88519. * Distance away where the pick collided
  88520. */
  88521. distance: number;
  88522. /**
  88523. * The location of pick collision
  88524. */
  88525. pickedPoint: Nullable<Vector3>;
  88526. /**
  88527. * The mesh corresponding the the pick collision
  88528. */
  88529. pickedMesh: Nullable<AbstractMesh>;
  88530. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  88531. bu: number;
  88532. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  88533. bv: number;
  88534. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88535. faceId: number;
  88536. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88537. subMeshFaceId: number;
  88538. /** Id of the the submesh that was picked */
  88539. subMeshId: number;
  88540. /** If a sprite was picked, this will be the sprite the pick collided with */
  88541. pickedSprite: Nullable<Sprite>;
  88542. /**
  88543. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  88544. */
  88545. originMesh: Nullable<AbstractMesh>;
  88546. /**
  88547. * The ray that was used to perform the picking.
  88548. */
  88549. ray: Nullable<Ray>;
  88550. /**
  88551. * Gets the normal correspodning to the face the pick collided with
  88552. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  88553. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  88554. * @returns The normal correspodning to the face the pick collided with
  88555. */
  88556. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  88557. /**
  88558. * Gets the texture coordinates of where the pick occured
  88559. * @returns the vector containing the coordnates of the texture
  88560. */
  88561. getTextureCoordinates(): Nullable<Vector2>;
  88562. }
  88563. }
  88564. declare module BABYLON {
  88565. /**
  88566. * Class representing a ray with position and direction
  88567. */
  88568. export class Ray {
  88569. /** origin point */
  88570. origin: Vector3;
  88571. /** direction */
  88572. direction: Vector3;
  88573. /** length of the ray */
  88574. length: number;
  88575. private static readonly TmpVector3;
  88576. private _tmpRay;
  88577. /**
  88578. * Creates a new ray
  88579. * @param origin origin point
  88580. * @param direction direction
  88581. * @param length length of the ray
  88582. */
  88583. constructor(
  88584. /** origin point */
  88585. origin: Vector3,
  88586. /** direction */
  88587. direction: Vector3,
  88588. /** length of the ray */
  88589. length?: number);
  88590. /**
  88591. * Checks if the ray intersects a box
  88592. * This does not account for the ray lenght by design to improve perfs.
  88593. * @param minimum bound of the box
  88594. * @param maximum bound of the box
  88595. * @param intersectionTreshold extra extend to be added to the box in all direction
  88596. * @returns if the box was hit
  88597. */
  88598. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  88599. /**
  88600. * Checks if the ray intersects a box
  88601. * This does not account for the ray lenght by design to improve perfs.
  88602. * @param box the bounding box to check
  88603. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  88604. * @returns if the box was hit
  88605. */
  88606. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  88607. /**
  88608. * If the ray hits a sphere
  88609. * @param sphere the bounding sphere to check
  88610. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  88611. * @returns true if it hits the sphere
  88612. */
  88613. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  88614. /**
  88615. * If the ray hits a triange
  88616. * @param vertex0 triangle vertex
  88617. * @param vertex1 triangle vertex
  88618. * @param vertex2 triangle vertex
  88619. * @returns intersection information if hit
  88620. */
  88621. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  88622. /**
  88623. * Checks if ray intersects a plane
  88624. * @param plane the plane to check
  88625. * @returns the distance away it was hit
  88626. */
  88627. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  88628. /**
  88629. * Calculate the intercept of a ray on a given axis
  88630. * @param axis to check 'x' | 'y' | 'z'
  88631. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  88632. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  88633. */
  88634. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  88635. /**
  88636. * Checks if ray intersects a mesh
  88637. * @param mesh the mesh to check
  88638. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88639. * @returns picking info of the intersecton
  88640. */
  88641. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  88642. /**
  88643. * Checks if ray intersects a mesh
  88644. * @param meshes the meshes to check
  88645. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88646. * @param results array to store result in
  88647. * @returns Array of picking infos
  88648. */
  88649. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  88650. private _comparePickingInfo;
  88651. private static smallnum;
  88652. private static rayl;
  88653. /**
  88654. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  88655. * @param sega the first point of the segment to test the intersection against
  88656. * @param segb the second point of the segment to test the intersection against
  88657. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  88658. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  88659. */
  88660. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  88661. /**
  88662. * Update the ray from viewport position
  88663. * @param x position
  88664. * @param y y position
  88665. * @param viewportWidth viewport width
  88666. * @param viewportHeight viewport height
  88667. * @param world world matrix
  88668. * @param view view matrix
  88669. * @param projection projection matrix
  88670. * @returns this ray updated
  88671. */
  88672. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88673. /**
  88674. * Creates a ray with origin and direction of 0,0,0
  88675. * @returns the new ray
  88676. */
  88677. static Zero(): Ray;
  88678. /**
  88679. * Creates a new ray from screen space and viewport
  88680. * @param x position
  88681. * @param y y position
  88682. * @param viewportWidth viewport width
  88683. * @param viewportHeight viewport height
  88684. * @param world world matrix
  88685. * @param view view matrix
  88686. * @param projection projection matrix
  88687. * @returns new ray
  88688. */
  88689. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88690. /**
  88691. * 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
  88692. * transformed to the given world matrix.
  88693. * @param origin The origin point
  88694. * @param end The end point
  88695. * @param world a matrix to transform the ray to. Default is the identity matrix.
  88696. * @returns the new ray
  88697. */
  88698. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  88699. /**
  88700. * Transforms a ray by a matrix
  88701. * @param ray ray to transform
  88702. * @param matrix matrix to apply
  88703. * @returns the resulting new ray
  88704. */
  88705. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  88706. /**
  88707. * Transforms a ray by a matrix
  88708. * @param ray ray to transform
  88709. * @param matrix matrix to apply
  88710. * @param result ray to store result in
  88711. */
  88712. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  88713. /**
  88714. * Unproject a ray from screen space to object space
  88715. * @param sourceX defines the screen space x coordinate to use
  88716. * @param sourceY defines the screen space y coordinate to use
  88717. * @param viewportWidth defines the current width of the viewport
  88718. * @param viewportHeight defines the current height of the viewport
  88719. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88720. * @param view defines the view matrix to use
  88721. * @param projection defines the projection matrix to use
  88722. */
  88723. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  88724. }
  88725. /**
  88726. * Type used to define predicate used to select faces when a mesh intersection is detected
  88727. */
  88728. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  88729. interface Scene {
  88730. /** @hidden */
  88731. _tempPickingRay: Nullable<Ray>;
  88732. /** @hidden */
  88733. _cachedRayForTransform: Ray;
  88734. /** @hidden */
  88735. _pickWithRayInverseMatrix: Matrix;
  88736. /** @hidden */
  88737. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  88738. /** @hidden */
  88739. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  88740. }
  88741. }
  88742. declare module BABYLON {
  88743. /**
  88744. * Groups all the scene component constants in one place to ease maintenance.
  88745. * @hidden
  88746. */
  88747. export class SceneComponentConstants {
  88748. static readonly NAME_EFFECTLAYER: string;
  88749. static readonly NAME_LAYER: string;
  88750. static readonly NAME_LENSFLARESYSTEM: string;
  88751. static readonly NAME_BOUNDINGBOXRENDERER: string;
  88752. static readonly NAME_PARTICLESYSTEM: string;
  88753. static readonly NAME_GAMEPAD: string;
  88754. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  88755. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  88756. static readonly NAME_PREPASSRENDERER: string;
  88757. static readonly NAME_DEPTHRENDERER: string;
  88758. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  88759. static readonly NAME_SPRITE: string;
  88760. static readonly NAME_OUTLINERENDERER: string;
  88761. static readonly NAME_PROCEDURALTEXTURE: string;
  88762. static readonly NAME_SHADOWGENERATOR: string;
  88763. static readonly NAME_OCTREE: string;
  88764. static readonly NAME_PHYSICSENGINE: string;
  88765. static readonly NAME_AUDIO: string;
  88766. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  88767. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88768. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  88769. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88770. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  88771. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  88772. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  88773. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  88774. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  88775. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  88776. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  88777. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  88778. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  88779. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  88780. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  88781. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  88782. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  88783. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  88784. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  88785. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  88786. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  88787. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  88788. static readonly STEP_AFTERRENDER_AUDIO: number;
  88789. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  88790. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  88791. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  88792. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  88793. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  88794. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  88795. static readonly STEP_POINTERMOVE_SPRITE: number;
  88796. static readonly STEP_POINTERDOWN_SPRITE: number;
  88797. static readonly STEP_POINTERUP_SPRITE: number;
  88798. }
  88799. /**
  88800. * This represents a scene component.
  88801. *
  88802. * This is used to decouple the dependency the scene is having on the different workloads like
  88803. * layers, post processes...
  88804. */
  88805. export interface ISceneComponent {
  88806. /**
  88807. * The name of the component. Each component must have a unique name.
  88808. */
  88809. name: string;
  88810. /**
  88811. * The scene the component belongs to.
  88812. */
  88813. scene: Scene;
  88814. /**
  88815. * Register the component to one instance of a scene.
  88816. */
  88817. register(): void;
  88818. /**
  88819. * Rebuilds the elements related to this component in case of
  88820. * context lost for instance.
  88821. */
  88822. rebuild(): void;
  88823. /**
  88824. * Disposes the component and the associated ressources.
  88825. */
  88826. dispose(): void;
  88827. }
  88828. /**
  88829. * This represents a SERIALIZABLE scene component.
  88830. *
  88831. * This extends Scene Component to add Serialization methods on top.
  88832. */
  88833. export interface ISceneSerializableComponent extends ISceneComponent {
  88834. /**
  88835. * Adds all the elements from the container to the scene
  88836. * @param container the container holding the elements
  88837. */
  88838. addFromContainer(container: AbstractScene): void;
  88839. /**
  88840. * Removes all the elements in the container from the scene
  88841. * @param container contains the elements to remove
  88842. * @param dispose if the removed element should be disposed (default: false)
  88843. */
  88844. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  88845. /**
  88846. * Serializes the component data to the specified json object
  88847. * @param serializationObject The object to serialize to
  88848. */
  88849. serialize(serializationObject: any): void;
  88850. }
  88851. /**
  88852. * Strong typing of a Mesh related stage step action
  88853. */
  88854. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  88855. /**
  88856. * Strong typing of a Evaluate Sub Mesh related stage step action
  88857. */
  88858. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  88859. /**
  88860. * Strong typing of a Active Mesh related stage step action
  88861. */
  88862. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  88863. /**
  88864. * Strong typing of a Camera related stage step action
  88865. */
  88866. export type CameraStageAction = (camera: Camera) => void;
  88867. /**
  88868. * Strong typing of a Camera Frame buffer related stage step action
  88869. */
  88870. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  88871. /**
  88872. * Strong typing of a Render Target related stage step action
  88873. */
  88874. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  88875. /**
  88876. * Strong typing of a RenderingGroup related stage step action
  88877. */
  88878. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  88879. /**
  88880. * Strong typing of a Mesh Render related stage step action
  88881. */
  88882. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  88883. /**
  88884. * Strong typing of a simple stage step action
  88885. */
  88886. export type SimpleStageAction = () => void;
  88887. /**
  88888. * Strong typing of a render target action.
  88889. */
  88890. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  88891. /**
  88892. * Strong typing of a pointer move action.
  88893. */
  88894. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  88895. /**
  88896. * Strong typing of a pointer up/down action.
  88897. */
  88898. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  88899. /**
  88900. * Representation of a stage in the scene (Basically a list of ordered steps)
  88901. * @hidden
  88902. */
  88903. export class Stage<T extends Function> extends Array<{
  88904. index: number;
  88905. component: ISceneComponent;
  88906. action: T;
  88907. }> {
  88908. /**
  88909. * Hide ctor from the rest of the world.
  88910. * @param items The items to add.
  88911. */
  88912. private constructor();
  88913. /**
  88914. * Creates a new Stage.
  88915. * @returns A new instance of a Stage
  88916. */
  88917. static Create<T extends Function>(): Stage<T>;
  88918. /**
  88919. * Registers a step in an ordered way in the targeted stage.
  88920. * @param index Defines the position to register the step in
  88921. * @param component Defines the component attached to the step
  88922. * @param action Defines the action to launch during the step
  88923. */
  88924. registerStep(index: number, component: ISceneComponent, action: T): void;
  88925. /**
  88926. * Clears all the steps from the stage.
  88927. */
  88928. clear(): void;
  88929. }
  88930. }
  88931. declare module BABYLON {
  88932. interface Scene {
  88933. /** @hidden */
  88934. _pointerOverSprite: Nullable<Sprite>;
  88935. /** @hidden */
  88936. _pickedDownSprite: Nullable<Sprite>;
  88937. /** @hidden */
  88938. _tempSpritePickingRay: Nullable<Ray>;
  88939. /**
  88940. * All of the sprite managers added to this scene
  88941. * @see https://doc.babylonjs.com/babylon101/sprites
  88942. */
  88943. spriteManagers: Array<ISpriteManager>;
  88944. /**
  88945. * An event triggered when sprites rendering is about to start
  88946. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88947. */
  88948. onBeforeSpritesRenderingObservable: Observable<Scene>;
  88949. /**
  88950. * An event triggered when sprites rendering is done
  88951. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88952. */
  88953. onAfterSpritesRenderingObservable: Observable<Scene>;
  88954. /** @hidden */
  88955. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88956. /** Launch a ray to try to pick a sprite in the scene
  88957. * @param x position on screen
  88958. * @param y position on screen
  88959. * @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
  88960. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88961. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88962. * @returns a PickingInfo
  88963. */
  88964. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88965. /** Use the given ray to pick a sprite in the scene
  88966. * @param ray The ray (in world space) to use to pick meshes
  88967. * @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
  88968. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88969. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88970. * @returns a PickingInfo
  88971. */
  88972. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88973. /** @hidden */
  88974. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88975. /** Launch a ray to try to pick sprites in the scene
  88976. * @param x position on screen
  88977. * @param y position on screen
  88978. * @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
  88979. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88980. * @returns a PickingInfo array
  88981. */
  88982. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88983. /** Use the given ray to pick sprites in the scene
  88984. * @param ray The ray (in world space) to use to pick meshes
  88985. * @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
  88986. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88987. * @returns a PickingInfo array
  88988. */
  88989. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88990. /**
  88991. * Force the sprite under the pointer
  88992. * @param sprite defines the sprite to use
  88993. */
  88994. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  88995. /**
  88996. * Gets the sprite under the pointer
  88997. * @returns a Sprite or null if no sprite is under the pointer
  88998. */
  88999. getPointerOverSprite(): Nullable<Sprite>;
  89000. }
  89001. /**
  89002. * Defines the sprite scene component responsible to manage sprites
  89003. * in a given scene.
  89004. */
  89005. export class SpriteSceneComponent implements ISceneComponent {
  89006. /**
  89007. * The component name helpfull to identify the component in the list of scene components.
  89008. */
  89009. readonly name: string;
  89010. /**
  89011. * The scene the component belongs to.
  89012. */
  89013. scene: Scene;
  89014. /** @hidden */
  89015. private _spritePredicate;
  89016. /**
  89017. * Creates a new instance of the component for the given scene
  89018. * @param scene Defines the scene to register the component in
  89019. */
  89020. constructor(scene: Scene);
  89021. /**
  89022. * Registers the component in a given scene
  89023. */
  89024. register(): void;
  89025. /**
  89026. * Rebuilds the elements related to this component in case of
  89027. * context lost for instance.
  89028. */
  89029. rebuild(): void;
  89030. /**
  89031. * Disposes the component and the associated ressources.
  89032. */
  89033. dispose(): void;
  89034. private _pickSpriteButKeepRay;
  89035. private _pointerMove;
  89036. private _pointerDown;
  89037. private _pointerUp;
  89038. }
  89039. }
  89040. declare module BABYLON {
  89041. /** @hidden */
  89042. export var fogFragmentDeclaration: {
  89043. name: string;
  89044. shader: string;
  89045. };
  89046. }
  89047. declare module BABYLON {
  89048. /** @hidden */
  89049. export var fogFragment: {
  89050. name: string;
  89051. shader: string;
  89052. };
  89053. }
  89054. declare module BABYLON {
  89055. /** @hidden */
  89056. export var spritesPixelShader: {
  89057. name: string;
  89058. shader: string;
  89059. };
  89060. }
  89061. declare module BABYLON {
  89062. /** @hidden */
  89063. export var fogVertexDeclaration: {
  89064. name: string;
  89065. shader: string;
  89066. };
  89067. }
  89068. declare module BABYLON {
  89069. /** @hidden */
  89070. export var spritesVertexShader: {
  89071. name: string;
  89072. shader: string;
  89073. };
  89074. }
  89075. declare module BABYLON {
  89076. /**
  89077. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89078. */
  89079. export interface ISpriteManager extends IDisposable {
  89080. /**
  89081. * Gets manager's name
  89082. */
  89083. name: string;
  89084. /**
  89085. * Restricts the camera to viewing objects with the same layerMask.
  89086. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89087. */
  89088. layerMask: number;
  89089. /**
  89090. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89091. */
  89092. isPickable: boolean;
  89093. /**
  89094. * Gets the hosting scene
  89095. */
  89096. scene: Scene;
  89097. /**
  89098. * Specifies the rendering group id for this mesh (0 by default)
  89099. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89100. */
  89101. renderingGroupId: number;
  89102. /**
  89103. * Defines the list of sprites managed by the manager.
  89104. */
  89105. sprites: Array<Sprite>;
  89106. /**
  89107. * Gets or sets the spritesheet texture
  89108. */
  89109. texture: Texture;
  89110. /** Defines the default width of a cell in the spritesheet */
  89111. cellWidth: number;
  89112. /** Defines the default height of a cell in the spritesheet */
  89113. cellHeight: number;
  89114. /**
  89115. * Tests the intersection of a sprite with a specific ray.
  89116. * @param ray The ray we are sending to test the collision
  89117. * @param camera The camera space we are sending rays in
  89118. * @param predicate A predicate allowing excluding sprites from the list of object to test
  89119. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89120. * @returns picking info or null.
  89121. */
  89122. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89123. /**
  89124. * Intersects the sprites with a ray
  89125. * @param ray defines the ray to intersect with
  89126. * @param camera defines the current active camera
  89127. * @param predicate defines a predicate used to select candidate sprites
  89128. * @returns null if no hit or a PickingInfo array
  89129. */
  89130. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89131. /**
  89132. * Renders the list of sprites on screen.
  89133. */
  89134. render(): void;
  89135. }
  89136. /**
  89137. * Class used to manage multiple sprites on the same spritesheet
  89138. * @see https://doc.babylonjs.com/babylon101/sprites
  89139. */
  89140. export class SpriteManager implements ISpriteManager {
  89141. /** defines the manager's name */
  89142. name: string;
  89143. /** Define the Url to load snippets */
  89144. static SnippetUrl: string;
  89145. /** Snippet ID if the manager was created from the snippet server */
  89146. snippetId: string;
  89147. /** Gets the list of sprites */
  89148. sprites: Sprite[];
  89149. /** Gets or sets the rendering group id (0 by default) */
  89150. renderingGroupId: number;
  89151. /** Gets or sets camera layer mask */
  89152. layerMask: number;
  89153. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  89154. fogEnabled: boolean;
  89155. /** Gets or sets a boolean indicating if the sprites are pickable */
  89156. isPickable: boolean;
  89157. /** Defines the default width of a cell in the spritesheet */
  89158. cellWidth: number;
  89159. /** Defines the default height of a cell in the spritesheet */
  89160. cellHeight: number;
  89161. /** Associative array from JSON sprite data file */
  89162. private _cellData;
  89163. /** Array of sprite names from JSON sprite data file */
  89164. private _spriteMap;
  89165. /** True when packed cell data from JSON file is ready*/
  89166. private _packedAndReady;
  89167. private _textureContent;
  89168. /**
  89169. * An event triggered when the manager is disposed.
  89170. */
  89171. onDisposeObservable: Observable<SpriteManager>;
  89172. private _onDisposeObserver;
  89173. /**
  89174. * Callback called when the manager is disposed
  89175. */
  89176. set onDispose(callback: () => void);
  89177. private _capacity;
  89178. private _fromPacked;
  89179. private _spriteTexture;
  89180. private _epsilon;
  89181. private _scene;
  89182. private _vertexData;
  89183. private _buffer;
  89184. private _vertexBuffers;
  89185. private _indexBuffer;
  89186. private _effectBase;
  89187. private _effectFog;
  89188. /**
  89189. * Gets or sets the unique id of the sprite
  89190. */
  89191. uniqueId: number;
  89192. /**
  89193. * Gets the array of sprites
  89194. */
  89195. get children(): Sprite[];
  89196. /**
  89197. * Gets the hosting scene
  89198. */
  89199. get scene(): Scene;
  89200. /**
  89201. * Gets the capacity of the manager
  89202. */
  89203. get capacity(): number;
  89204. /**
  89205. * Gets or sets the spritesheet texture
  89206. */
  89207. get texture(): Texture;
  89208. set texture(value: Texture);
  89209. private _blendMode;
  89210. /**
  89211. * Blend mode use to render the particle, it can be any of
  89212. * the static Constants.ALPHA_x properties provided in this class.
  89213. * Default value is Constants.ALPHA_COMBINE
  89214. */
  89215. get blendMode(): number;
  89216. set blendMode(blendMode: number);
  89217. /** Disables writing to the depth buffer when rendering the sprites.
  89218. * It can be handy to disable depth writing when using textures without alpha channel
  89219. * and setting some specific blend modes.
  89220. */
  89221. disableDepthWrite: boolean;
  89222. /**
  89223. * Creates a new sprite manager
  89224. * @param name defines the manager's name
  89225. * @param imgUrl defines the sprite sheet url
  89226. * @param capacity defines the maximum allowed number of sprites
  89227. * @param cellSize defines the size of a sprite cell
  89228. * @param scene defines the hosting scene
  89229. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  89230. * @param samplingMode defines the smapling mode to use with spritesheet
  89231. * @param fromPacked set to false; do not alter
  89232. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  89233. */
  89234. constructor(
  89235. /** defines the manager's name */
  89236. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  89237. /**
  89238. * Returns the string "SpriteManager"
  89239. * @returns "SpriteManager"
  89240. */
  89241. getClassName(): string;
  89242. private _makePacked;
  89243. private _appendSpriteVertex;
  89244. private _checkTextureAlpha;
  89245. /**
  89246. * Intersects the sprites with a ray
  89247. * @param ray defines the ray to intersect with
  89248. * @param camera defines the current active camera
  89249. * @param predicate defines a predicate used to select candidate sprites
  89250. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  89251. * @returns null if no hit or a PickingInfo
  89252. */
  89253. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89254. /**
  89255. * Intersects the sprites with a ray
  89256. * @param ray defines the ray to intersect with
  89257. * @param camera defines the current active camera
  89258. * @param predicate defines a predicate used to select candidate sprites
  89259. * @returns null if no hit or a PickingInfo array
  89260. */
  89261. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89262. /**
  89263. * Render all child sprites
  89264. */
  89265. render(): void;
  89266. /**
  89267. * Release associated resources
  89268. */
  89269. dispose(): void;
  89270. /**
  89271. * Serializes the sprite manager to a JSON object
  89272. * @param serializeTexture defines if the texture must be serialized as well
  89273. * @returns the JSON object
  89274. */
  89275. serialize(serializeTexture?: boolean): any;
  89276. /**
  89277. * Parses a JSON object to create a new sprite manager.
  89278. * @param parsedManager The JSON object to parse
  89279. * @param scene The scene to create the sprite managerin
  89280. * @param rootUrl The root url to use to load external dependencies like texture
  89281. * @returns the new sprite manager
  89282. */
  89283. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  89284. /**
  89285. * Creates a sprite manager from a snippet saved in a remote file
  89286. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  89287. * @param url defines the url to load from
  89288. * @param scene defines the hosting scene
  89289. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89290. * @returns a promise that will resolve to the new sprite manager
  89291. */
  89292. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89293. /**
  89294. * Creates a sprite manager from a snippet saved by the sprite editor
  89295. * @param snippetId defines the snippet to load
  89296. * @param scene defines the hosting scene
  89297. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89298. * @returns a promise that will resolve to the new sprite manager
  89299. */
  89300. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89301. }
  89302. }
  89303. declare module BABYLON {
  89304. /** Interface used by value gradients (color, factor, ...) */
  89305. export interface IValueGradient {
  89306. /**
  89307. * Gets or sets the gradient value (between 0 and 1)
  89308. */
  89309. gradient: number;
  89310. }
  89311. /** Class used to store color4 gradient */
  89312. export class ColorGradient implements IValueGradient {
  89313. /**
  89314. * Gets or sets the gradient value (between 0 and 1)
  89315. */
  89316. gradient: number;
  89317. /**
  89318. * Gets or sets first associated color
  89319. */
  89320. color1: Color4;
  89321. /**
  89322. * Gets or sets second associated color
  89323. */
  89324. color2?: Color4 | undefined;
  89325. /**
  89326. * Creates a new color4 gradient
  89327. * @param gradient gets or sets the gradient value (between 0 and 1)
  89328. * @param color1 gets or sets first associated color
  89329. * @param color2 gets or sets first second color
  89330. */
  89331. constructor(
  89332. /**
  89333. * Gets or sets the gradient value (between 0 and 1)
  89334. */
  89335. gradient: number,
  89336. /**
  89337. * Gets or sets first associated color
  89338. */
  89339. color1: Color4,
  89340. /**
  89341. * Gets or sets second associated color
  89342. */
  89343. color2?: Color4 | undefined);
  89344. /**
  89345. * Will get a color picked randomly between color1 and color2.
  89346. * If color2 is undefined then color1 will be used
  89347. * @param result defines the target Color4 to store the result in
  89348. */
  89349. getColorToRef(result: Color4): void;
  89350. }
  89351. /** Class used to store color 3 gradient */
  89352. export class Color3Gradient implements IValueGradient {
  89353. /**
  89354. * Gets or sets the gradient value (between 0 and 1)
  89355. */
  89356. gradient: number;
  89357. /**
  89358. * Gets or sets the associated color
  89359. */
  89360. color: Color3;
  89361. /**
  89362. * Creates a new color3 gradient
  89363. * @param gradient gets or sets the gradient value (between 0 and 1)
  89364. * @param color gets or sets associated color
  89365. */
  89366. constructor(
  89367. /**
  89368. * Gets or sets the gradient value (between 0 and 1)
  89369. */
  89370. gradient: number,
  89371. /**
  89372. * Gets or sets the associated color
  89373. */
  89374. color: Color3);
  89375. }
  89376. /** Class used to store factor gradient */
  89377. export class FactorGradient implements IValueGradient {
  89378. /**
  89379. * Gets or sets the gradient value (between 0 and 1)
  89380. */
  89381. gradient: number;
  89382. /**
  89383. * Gets or sets first associated factor
  89384. */
  89385. factor1: number;
  89386. /**
  89387. * Gets or sets second associated factor
  89388. */
  89389. factor2?: number | undefined;
  89390. /**
  89391. * Creates a new factor gradient
  89392. * @param gradient gets or sets the gradient value (between 0 and 1)
  89393. * @param factor1 gets or sets first associated factor
  89394. * @param factor2 gets or sets second associated factor
  89395. */
  89396. constructor(
  89397. /**
  89398. * Gets or sets the gradient value (between 0 and 1)
  89399. */
  89400. gradient: number,
  89401. /**
  89402. * Gets or sets first associated factor
  89403. */
  89404. factor1: number,
  89405. /**
  89406. * Gets or sets second associated factor
  89407. */
  89408. factor2?: number | undefined);
  89409. /**
  89410. * Will get a number picked randomly between factor1 and factor2.
  89411. * If factor2 is undefined then factor1 will be used
  89412. * @returns the picked number
  89413. */
  89414. getFactor(): number;
  89415. }
  89416. /**
  89417. * Helper used to simplify some generic gradient tasks
  89418. */
  89419. export class GradientHelper {
  89420. /**
  89421. * Gets the current gradient from an array of IValueGradient
  89422. * @param ratio defines the current ratio to get
  89423. * @param gradients defines the array of IValueGradient
  89424. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89425. */
  89426. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89427. }
  89428. }
  89429. declare module BABYLON {
  89430. interface ThinEngine {
  89431. /**
  89432. * Creates a raw texture
  89433. * @param data defines the data to store in the texture
  89434. * @param width defines the width of the texture
  89435. * @param height defines the height of the texture
  89436. * @param format defines the format of the data
  89437. * @param generateMipMaps defines if the engine should generate the mip levels
  89438. * @param invertY defines if data must be stored with Y axis inverted
  89439. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89440. * @param compression defines the compression used (null by default)
  89441. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89442. * @returns the raw texture inside an InternalTexture
  89443. */
  89444. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  89445. /**
  89446. * Update a raw texture
  89447. * @param texture defines the texture to update
  89448. * @param data defines the data to store in the texture
  89449. * @param format defines the format of the data
  89450. * @param invertY defines if data must be stored with Y axis inverted
  89451. */
  89452. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89453. /**
  89454. * Update a raw texture
  89455. * @param texture defines the texture to update
  89456. * @param data defines the data to store in the texture
  89457. * @param format defines the format of the data
  89458. * @param invertY defines if data must be stored with Y axis inverted
  89459. * @param compression defines the compression used (null by default)
  89460. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89461. */
  89462. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  89463. /**
  89464. * Creates a new raw cube texture
  89465. * @param data defines the array of data to use to create each face
  89466. * @param size defines the size of the textures
  89467. * @param format defines the format of the data
  89468. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89469. * @param generateMipMaps defines if the engine should generate the mip levels
  89470. * @param invertY defines if data must be stored with Y axis inverted
  89471. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89472. * @param compression defines the compression used (null by default)
  89473. * @returns the cube texture as an InternalTexture
  89474. */
  89475. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  89476. /**
  89477. * Update a raw cube texture
  89478. * @param texture defines the texture to udpdate
  89479. * @param data defines the data to store
  89480. * @param format defines the data format
  89481. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89482. * @param invertY defines if data must be stored with Y axis inverted
  89483. */
  89484. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  89485. /**
  89486. * Update a raw cube texture
  89487. * @param texture defines the texture to udpdate
  89488. * @param data defines the data to store
  89489. * @param format defines the data format
  89490. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89491. * @param invertY defines if data must be stored with Y axis inverted
  89492. * @param compression defines the compression used (null by default)
  89493. */
  89494. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  89495. /**
  89496. * Update a raw cube texture
  89497. * @param texture defines the texture to udpdate
  89498. * @param data defines the data to store
  89499. * @param format defines the data format
  89500. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89501. * @param invertY defines if data must be stored with Y axis inverted
  89502. * @param compression defines the compression used (null by default)
  89503. * @param level defines which level of the texture to update
  89504. */
  89505. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  89506. /**
  89507. * Creates a new raw cube texture from a specified url
  89508. * @param url defines the url where the data is located
  89509. * @param scene defines the current scene
  89510. * @param size defines the size of the textures
  89511. * @param format defines the format of the data
  89512. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89513. * @param noMipmap defines if the engine should avoid generating the mip levels
  89514. * @param callback defines a callback used to extract texture data from loaded data
  89515. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89516. * @param onLoad defines a callback called when texture is loaded
  89517. * @param onError defines a callback called if there is an error
  89518. * @returns the cube texture as an InternalTexture
  89519. */
  89520. 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;
  89521. /**
  89522. * Creates a new raw cube texture from a specified url
  89523. * @param url defines the url where the data is located
  89524. * @param scene defines the current scene
  89525. * @param size defines the size of the textures
  89526. * @param format defines the format of the data
  89527. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89528. * @param noMipmap defines if the engine should avoid generating the mip levels
  89529. * @param callback defines a callback used to extract texture data from loaded data
  89530. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89531. * @param onLoad defines a callback called when texture is loaded
  89532. * @param onError defines a callback called if there is an error
  89533. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89534. * @param invertY defines if data must be stored with Y axis inverted
  89535. * @returns the cube texture as an InternalTexture
  89536. */
  89537. 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;
  89538. /**
  89539. * Creates a new raw 3D texture
  89540. * @param data defines the data used to create the texture
  89541. * @param width defines the width of the texture
  89542. * @param height defines the height of the texture
  89543. * @param depth defines the depth of the texture
  89544. * @param format defines the format of the texture
  89545. * @param generateMipMaps defines if the engine must generate mip levels
  89546. * @param invertY defines if data must be stored with Y axis inverted
  89547. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89548. * @param compression defines the compressed used (can be null)
  89549. * @param textureType defines the compressed used (can be null)
  89550. * @returns a new raw 3D texture (stored in an InternalTexture)
  89551. */
  89552. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89553. /**
  89554. * Update a raw 3D texture
  89555. * @param texture defines the texture to update
  89556. * @param data defines the data to store
  89557. * @param format defines the data format
  89558. * @param invertY defines if data must be stored with Y axis inverted
  89559. */
  89560. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89561. /**
  89562. * Update a raw 3D texture
  89563. * @param texture defines the texture to update
  89564. * @param data defines the data to store
  89565. * @param format defines the data format
  89566. * @param invertY defines if data must be stored with Y axis inverted
  89567. * @param compression defines the used compression (can be null)
  89568. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89569. */
  89570. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89571. /**
  89572. * Creates a new raw 2D array texture
  89573. * @param data defines the data used to create the texture
  89574. * @param width defines the width of the texture
  89575. * @param height defines the height of the texture
  89576. * @param depth defines the number of layers of the texture
  89577. * @param format defines the format of the texture
  89578. * @param generateMipMaps defines if the engine must generate mip levels
  89579. * @param invertY defines if data must be stored with Y axis inverted
  89580. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89581. * @param compression defines the compressed used (can be null)
  89582. * @param textureType defines the compressed used (can be null)
  89583. * @returns a new raw 2D array texture (stored in an InternalTexture)
  89584. */
  89585. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89586. /**
  89587. * Update a raw 2D array texture
  89588. * @param texture defines the texture to update
  89589. * @param data defines the data to store
  89590. * @param format defines the data format
  89591. * @param invertY defines if data must be stored with Y axis inverted
  89592. */
  89593. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89594. /**
  89595. * Update a raw 2D array texture
  89596. * @param texture defines the texture to update
  89597. * @param data defines the data to store
  89598. * @param format defines the data format
  89599. * @param invertY defines if data must be stored with Y axis inverted
  89600. * @param compression defines the used compression (can be null)
  89601. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89602. */
  89603. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89604. }
  89605. }
  89606. declare module BABYLON {
  89607. /**
  89608. * Raw texture can help creating a texture directly from an array of data.
  89609. * This can be super useful if you either get the data from an uncompressed source or
  89610. * if you wish to create your texture pixel by pixel.
  89611. */
  89612. export class RawTexture extends Texture {
  89613. /**
  89614. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89615. */
  89616. format: number;
  89617. /**
  89618. * Instantiates a new RawTexture.
  89619. * Raw texture can help creating a texture directly from an array of data.
  89620. * This can be super useful if you either get the data from an uncompressed source or
  89621. * if you wish to create your texture pixel by pixel.
  89622. * @param data define the array of data to use to create the texture
  89623. * @param width define the width of the texture
  89624. * @param height define the height of the texture
  89625. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89626. * @param scene define the scene the texture belongs to
  89627. * @param generateMipMaps define whether mip maps should be generated or not
  89628. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89629. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89630. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89631. */
  89632. constructor(data: ArrayBufferView, width: number, height: number,
  89633. /**
  89634. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89635. */
  89636. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  89637. /**
  89638. * Updates the texture underlying data.
  89639. * @param data Define the new data of the texture
  89640. */
  89641. update(data: ArrayBufferView): void;
  89642. /**
  89643. * Creates a luminance texture from some data.
  89644. * @param data Define the texture data
  89645. * @param width Define the width of the texture
  89646. * @param height Define the height of the texture
  89647. * @param scene Define the scene the texture belongs to
  89648. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89649. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89650. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89651. * @returns the luminance texture
  89652. */
  89653. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89654. /**
  89655. * Creates a luminance alpha texture from some data.
  89656. * @param data Define the texture data
  89657. * @param width Define the width of the texture
  89658. * @param height Define the height of the texture
  89659. * @param scene Define the scene the texture belongs to
  89660. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89661. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89662. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89663. * @returns the luminance alpha texture
  89664. */
  89665. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89666. /**
  89667. * Creates an alpha texture from some data.
  89668. * @param data Define the texture data
  89669. * @param width Define the width of the texture
  89670. * @param height Define the height of the texture
  89671. * @param scene Define the scene the texture belongs to
  89672. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89673. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89674. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89675. * @returns the alpha texture
  89676. */
  89677. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89678. /**
  89679. * Creates a RGB texture from some data.
  89680. * @param data Define the texture data
  89681. * @param width Define the width of the texture
  89682. * @param height Define the height of the texture
  89683. * @param scene Define the scene the texture belongs to
  89684. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89685. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89686. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89687. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89688. * @returns the RGB alpha texture
  89689. */
  89690. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89691. /**
  89692. * Creates a RGBA texture from some data.
  89693. * @param data Define the texture data
  89694. * @param width Define the width of the texture
  89695. * @param height Define the height of the texture
  89696. * @param scene Define the scene the texture belongs to
  89697. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89698. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89699. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89700. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89701. * @returns the RGBA texture
  89702. */
  89703. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89704. /**
  89705. * Creates a R texture from some data.
  89706. * @param data Define the texture data
  89707. * @param width Define the width of the texture
  89708. * @param height Define the height of the texture
  89709. * @param scene Define the scene the texture belongs to
  89710. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89711. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89712. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89713. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89714. * @returns the R texture
  89715. */
  89716. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89717. }
  89718. }
  89719. declare module BABYLON {
  89720. interface AbstractScene {
  89721. /**
  89722. * The list of procedural textures added to the scene
  89723. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89724. */
  89725. proceduralTextures: Array<ProceduralTexture>;
  89726. }
  89727. /**
  89728. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89729. * in a given scene.
  89730. */
  89731. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89732. /**
  89733. * The component name helpfull to identify the component in the list of scene components.
  89734. */
  89735. readonly name: string;
  89736. /**
  89737. * The scene the component belongs to.
  89738. */
  89739. scene: Scene;
  89740. /**
  89741. * Creates a new instance of the component for the given scene
  89742. * @param scene Defines the scene to register the component in
  89743. */
  89744. constructor(scene: Scene);
  89745. /**
  89746. * Registers the component in a given scene
  89747. */
  89748. register(): void;
  89749. /**
  89750. * Rebuilds the elements related to this component in case of
  89751. * context lost for instance.
  89752. */
  89753. rebuild(): void;
  89754. /**
  89755. * Disposes the component and the associated ressources.
  89756. */
  89757. dispose(): void;
  89758. private _beforeClear;
  89759. }
  89760. }
  89761. declare module BABYLON {
  89762. interface ThinEngine {
  89763. /**
  89764. * Creates a new render target cube texture
  89765. * @param size defines the size of the texture
  89766. * @param options defines the options used to create the texture
  89767. * @returns a new render target cube texture stored in an InternalTexture
  89768. */
  89769. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89770. }
  89771. }
  89772. declare module BABYLON {
  89773. /** @hidden */
  89774. export var proceduralVertexShader: {
  89775. name: string;
  89776. shader: string;
  89777. };
  89778. }
  89779. declare module BABYLON {
  89780. /**
  89781. * 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.
  89782. * This is the base class of any Procedural texture and contains most of the shareable code.
  89783. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89784. */
  89785. export class ProceduralTexture extends Texture {
  89786. isCube: boolean;
  89787. /**
  89788. * Define if the texture is enabled or not (disabled texture will not render)
  89789. */
  89790. isEnabled: boolean;
  89791. /**
  89792. * Define if the texture must be cleared before rendering (default is true)
  89793. */
  89794. autoClear: boolean;
  89795. /**
  89796. * Callback called when the texture is generated
  89797. */
  89798. onGenerated: () => void;
  89799. /**
  89800. * Event raised when the texture is generated
  89801. */
  89802. onGeneratedObservable: Observable<ProceduralTexture>;
  89803. /** @hidden */
  89804. _generateMipMaps: boolean;
  89805. /** @hidden **/
  89806. _effect: Effect;
  89807. /** @hidden */
  89808. _textures: {
  89809. [key: string]: Texture;
  89810. };
  89811. /** @hidden */
  89812. protected _fallbackTexture: Nullable<Texture>;
  89813. private _size;
  89814. private _currentRefreshId;
  89815. private _frameId;
  89816. private _refreshRate;
  89817. private _vertexBuffers;
  89818. private _indexBuffer;
  89819. private _uniforms;
  89820. private _samplers;
  89821. private _fragment;
  89822. private _floats;
  89823. private _ints;
  89824. private _floatsArrays;
  89825. private _colors3;
  89826. private _colors4;
  89827. private _vectors2;
  89828. private _vectors3;
  89829. private _matrices;
  89830. private _fallbackTextureUsed;
  89831. private _fullEngine;
  89832. private _cachedDefines;
  89833. private _contentUpdateId;
  89834. private _contentData;
  89835. /**
  89836. * Instantiates a new procedural texture.
  89837. * 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.
  89838. * This is the base class of any Procedural texture and contains most of the shareable code.
  89839. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89840. * @param name Define the name of the texture
  89841. * @param size Define the size of the texture to create
  89842. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89843. * @param scene Define the scene the texture belongs to
  89844. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89845. * @param generateMipMaps Define if the texture should creates mip maps or not
  89846. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89847. */
  89848. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89849. /**
  89850. * The effect that is created when initializing the post process.
  89851. * @returns The created effect corresponding the the postprocess.
  89852. */
  89853. getEffect(): Effect;
  89854. /**
  89855. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89856. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89857. */
  89858. getContent(): Nullable<ArrayBufferView>;
  89859. private _createIndexBuffer;
  89860. /** @hidden */
  89861. _rebuild(): void;
  89862. /**
  89863. * Resets the texture in order to recreate its associated resources.
  89864. * This can be called in case of context loss
  89865. */
  89866. reset(): void;
  89867. protected _getDefines(): string;
  89868. /**
  89869. * Is the texture ready to be used ? (rendered at least once)
  89870. * @returns true if ready, otherwise, false.
  89871. */
  89872. isReady(): boolean;
  89873. /**
  89874. * Resets the refresh counter of the texture and start bak from scratch.
  89875. * Could be useful to regenerate the texture if it is setup to render only once.
  89876. */
  89877. resetRefreshCounter(): void;
  89878. /**
  89879. * Set the fragment shader to use in order to render the texture.
  89880. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89881. */
  89882. setFragment(fragment: any): void;
  89883. /**
  89884. * Define the refresh rate of the texture or the rendering frequency.
  89885. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89886. */
  89887. get refreshRate(): number;
  89888. set refreshRate(value: number);
  89889. /** @hidden */
  89890. _shouldRender(): boolean;
  89891. /**
  89892. * Get the size the texture is rendering at.
  89893. * @returns the size (texture is always squared)
  89894. */
  89895. getRenderSize(): number;
  89896. /**
  89897. * Resize the texture to new value.
  89898. * @param size Define the new size the texture should have
  89899. * @param generateMipMaps Define whether the new texture should create mip maps
  89900. */
  89901. resize(size: number, generateMipMaps: boolean): void;
  89902. private _checkUniform;
  89903. /**
  89904. * Set a texture in the shader program used to render.
  89905. * @param name Define the name of the uniform samplers as defined in the shader
  89906. * @param texture Define the texture to bind to this sampler
  89907. * @return the texture itself allowing "fluent" like uniform updates
  89908. */
  89909. setTexture(name: string, texture: Texture): ProceduralTexture;
  89910. /**
  89911. * Set a float in the shader.
  89912. * @param name Define the name of the uniform as defined in the shader
  89913. * @param value Define the value to give to the uniform
  89914. * @return the texture itself allowing "fluent" like uniform updates
  89915. */
  89916. setFloat(name: string, value: number): ProceduralTexture;
  89917. /**
  89918. * Set a int in the shader.
  89919. * @param name Define the name of the uniform as defined in the shader
  89920. * @param value Define the value to give to the uniform
  89921. * @return the texture itself allowing "fluent" like uniform updates
  89922. */
  89923. setInt(name: string, value: number): ProceduralTexture;
  89924. /**
  89925. * Set an array of floats in the shader.
  89926. * @param name Define the name of the uniform as defined in the shader
  89927. * @param value Define the value to give to the uniform
  89928. * @return the texture itself allowing "fluent" like uniform updates
  89929. */
  89930. setFloats(name: string, value: number[]): ProceduralTexture;
  89931. /**
  89932. * Set a vec3 in the shader from a Color3.
  89933. * @param name Define the name of the uniform as defined in the shader
  89934. * @param value Define the value to give to the uniform
  89935. * @return the texture itself allowing "fluent" like uniform updates
  89936. */
  89937. setColor3(name: string, value: Color3): ProceduralTexture;
  89938. /**
  89939. * Set a vec4 in the shader from a Color4.
  89940. * @param name Define the name of the uniform as defined in the shader
  89941. * @param value Define the value to give to the uniform
  89942. * @return the texture itself allowing "fluent" like uniform updates
  89943. */
  89944. setColor4(name: string, value: Color4): ProceduralTexture;
  89945. /**
  89946. * Set a vec2 in the shader from a Vector2.
  89947. * @param name Define the name of the uniform as defined in the shader
  89948. * @param value Define the value to give to the uniform
  89949. * @return the texture itself allowing "fluent" like uniform updates
  89950. */
  89951. setVector2(name: string, value: Vector2): ProceduralTexture;
  89952. /**
  89953. * Set a vec3 in the shader from a Vector3.
  89954. * @param name Define the name of the uniform as defined in the shader
  89955. * @param value Define the value to give to the uniform
  89956. * @return the texture itself allowing "fluent" like uniform updates
  89957. */
  89958. setVector3(name: string, value: Vector3): ProceduralTexture;
  89959. /**
  89960. * Set a mat4 in the shader from a MAtrix.
  89961. * @param name Define the name of the uniform as defined in the shader
  89962. * @param value Define the value to give to the uniform
  89963. * @return the texture itself allowing "fluent" like uniform updates
  89964. */
  89965. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89966. /**
  89967. * Render the texture to its associated render target.
  89968. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89969. */
  89970. render(useCameraPostProcess?: boolean): void;
  89971. /**
  89972. * Clone the texture.
  89973. * @returns the cloned texture
  89974. */
  89975. clone(): ProceduralTexture;
  89976. /**
  89977. * Dispose the texture and release its asoociated resources.
  89978. */
  89979. dispose(): void;
  89980. }
  89981. }
  89982. declare module BABYLON {
  89983. /**
  89984. * This represents the base class for particle system in Babylon.
  89985. * 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.
  89986. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89987. * @example https://doc.babylonjs.com/babylon101/particles
  89988. */
  89989. export class BaseParticleSystem {
  89990. /**
  89991. * Source color is added to the destination color without alpha affecting the result
  89992. */
  89993. static BLENDMODE_ONEONE: number;
  89994. /**
  89995. * Blend current color and particle color using particle’s alpha
  89996. */
  89997. static BLENDMODE_STANDARD: number;
  89998. /**
  89999. * Add current color and particle color multiplied by particle’s alpha
  90000. */
  90001. static BLENDMODE_ADD: number;
  90002. /**
  90003. * Multiply current color with particle color
  90004. */
  90005. static BLENDMODE_MULTIPLY: number;
  90006. /**
  90007. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90008. */
  90009. static BLENDMODE_MULTIPLYADD: number;
  90010. /**
  90011. * List of animations used by the particle system.
  90012. */
  90013. animations: Animation[];
  90014. /**
  90015. * Gets or sets the unique id of the particle system
  90016. */
  90017. uniqueId: number;
  90018. /**
  90019. * The id of the Particle system.
  90020. */
  90021. id: string;
  90022. /**
  90023. * The friendly name of the Particle system.
  90024. */
  90025. name: string;
  90026. /**
  90027. * Snippet ID if the particle system was created from the snippet server
  90028. */
  90029. snippetId: string;
  90030. /**
  90031. * The rendering group used by the Particle system to chose when to render.
  90032. */
  90033. renderingGroupId: number;
  90034. /**
  90035. * The emitter represents the Mesh or position we are attaching the particle system to.
  90036. */
  90037. emitter: Nullable<AbstractMesh | Vector3>;
  90038. /**
  90039. * The maximum number of particles to emit per frame
  90040. */
  90041. emitRate: number;
  90042. /**
  90043. * If you want to launch only a few particles at once, that can be done, as well.
  90044. */
  90045. manualEmitCount: number;
  90046. /**
  90047. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90048. */
  90049. updateSpeed: number;
  90050. /**
  90051. * The amount of time the particle system is running (depends of the overall update speed).
  90052. */
  90053. targetStopDuration: number;
  90054. /**
  90055. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90056. */
  90057. disposeOnStop: boolean;
  90058. /**
  90059. * Minimum power of emitting particles.
  90060. */
  90061. minEmitPower: number;
  90062. /**
  90063. * Maximum power of emitting particles.
  90064. */
  90065. maxEmitPower: number;
  90066. /**
  90067. * Minimum life time of emitting particles.
  90068. */
  90069. minLifeTime: number;
  90070. /**
  90071. * Maximum life time of emitting particles.
  90072. */
  90073. maxLifeTime: number;
  90074. /**
  90075. * Minimum Size of emitting particles.
  90076. */
  90077. minSize: number;
  90078. /**
  90079. * Maximum Size of emitting particles.
  90080. */
  90081. maxSize: number;
  90082. /**
  90083. * Minimum scale of emitting particles on X axis.
  90084. */
  90085. minScaleX: number;
  90086. /**
  90087. * Maximum scale of emitting particles on X axis.
  90088. */
  90089. maxScaleX: number;
  90090. /**
  90091. * Minimum scale of emitting particles on Y axis.
  90092. */
  90093. minScaleY: number;
  90094. /**
  90095. * Maximum scale of emitting particles on Y axis.
  90096. */
  90097. maxScaleY: number;
  90098. /**
  90099. * Gets or sets the minimal initial rotation in radians.
  90100. */
  90101. minInitialRotation: number;
  90102. /**
  90103. * Gets or sets the maximal initial rotation in radians.
  90104. */
  90105. maxInitialRotation: number;
  90106. /**
  90107. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90108. */
  90109. minAngularSpeed: number;
  90110. /**
  90111. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90112. */
  90113. maxAngularSpeed: number;
  90114. /**
  90115. * The texture used to render each particle. (this can be a spritesheet)
  90116. */
  90117. particleTexture: Nullable<Texture>;
  90118. /**
  90119. * The layer mask we are rendering the particles through.
  90120. */
  90121. layerMask: number;
  90122. /**
  90123. * This can help using your own shader to render the particle system.
  90124. * The according effect will be created
  90125. */
  90126. customShader: any;
  90127. /**
  90128. * By default particle system starts as soon as they are created. This prevents the
  90129. * automatic start to happen and let you decide when to start emitting particles.
  90130. */
  90131. preventAutoStart: boolean;
  90132. private _noiseTexture;
  90133. /**
  90134. * Gets or sets a texture used to add random noise to particle positions
  90135. */
  90136. get noiseTexture(): Nullable<ProceduralTexture>;
  90137. set noiseTexture(value: Nullable<ProceduralTexture>);
  90138. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90139. noiseStrength: Vector3;
  90140. /**
  90141. * Callback triggered when the particle animation is ending.
  90142. */
  90143. onAnimationEnd: Nullable<() => void>;
  90144. /**
  90145. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90146. */
  90147. blendMode: number;
  90148. /**
  90149. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90150. * to override the particles.
  90151. */
  90152. forceDepthWrite: boolean;
  90153. /** 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 */
  90154. preWarmCycles: number;
  90155. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  90156. preWarmStepOffset: number;
  90157. /**
  90158. * 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)
  90159. */
  90160. spriteCellChangeSpeed: number;
  90161. /**
  90162. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90163. */
  90164. startSpriteCellID: number;
  90165. /**
  90166. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90167. */
  90168. endSpriteCellID: number;
  90169. /**
  90170. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90171. */
  90172. spriteCellWidth: number;
  90173. /**
  90174. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90175. */
  90176. spriteCellHeight: number;
  90177. /**
  90178. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90179. */
  90180. spriteRandomStartCell: boolean;
  90181. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90182. translationPivot: Vector2;
  90183. /** @hidden */
  90184. protected _isAnimationSheetEnabled: boolean;
  90185. /**
  90186. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90187. */
  90188. beginAnimationOnStart: boolean;
  90189. /**
  90190. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90191. */
  90192. beginAnimationFrom: number;
  90193. /**
  90194. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90195. */
  90196. beginAnimationTo: number;
  90197. /**
  90198. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90199. */
  90200. beginAnimationLoop: boolean;
  90201. /**
  90202. * Gets or sets a world offset applied to all particles
  90203. */
  90204. worldOffset: Vector3;
  90205. /**
  90206. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  90207. */
  90208. get isAnimationSheetEnabled(): boolean;
  90209. set isAnimationSheetEnabled(value: boolean);
  90210. /**
  90211. * Get hosting scene
  90212. * @returns the scene
  90213. */
  90214. getScene(): Scene;
  90215. /**
  90216. * You can use gravity if you want to give an orientation to your particles.
  90217. */
  90218. gravity: Vector3;
  90219. protected _colorGradients: Nullable<Array<ColorGradient>>;
  90220. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  90221. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  90222. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  90223. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  90224. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  90225. protected _dragGradients: Nullable<Array<FactorGradient>>;
  90226. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  90227. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  90228. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  90229. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  90230. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  90231. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  90232. /**
  90233. * Defines the delay in milliseconds before starting the system (0 by default)
  90234. */
  90235. startDelay: number;
  90236. /**
  90237. * Gets the current list of drag gradients.
  90238. * You must use addDragGradient and removeDragGradient to udpate this list
  90239. * @returns the list of drag gradients
  90240. */
  90241. getDragGradients(): Nullable<Array<FactorGradient>>;
  90242. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90243. limitVelocityDamping: number;
  90244. /**
  90245. * Gets the current list of limit velocity gradients.
  90246. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90247. * @returns the list of limit velocity gradients
  90248. */
  90249. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90250. /**
  90251. * Gets the current list of color gradients.
  90252. * You must use addColorGradient and removeColorGradient to udpate this list
  90253. * @returns the list of color gradients
  90254. */
  90255. getColorGradients(): Nullable<Array<ColorGradient>>;
  90256. /**
  90257. * Gets the current list of size gradients.
  90258. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90259. * @returns the list of size gradients
  90260. */
  90261. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90262. /**
  90263. * Gets the current list of color remap gradients.
  90264. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90265. * @returns the list of color remap gradients
  90266. */
  90267. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90268. /**
  90269. * Gets the current list of alpha remap gradients.
  90270. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90271. * @returns the list of alpha remap gradients
  90272. */
  90273. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90274. /**
  90275. * Gets the current list of life time gradients.
  90276. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90277. * @returns the list of life time gradients
  90278. */
  90279. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  90280. /**
  90281. * Gets the current list of angular speed gradients.
  90282. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  90283. * @returns the list of angular speed gradients
  90284. */
  90285. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  90286. /**
  90287. * Gets the current list of velocity gradients.
  90288. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  90289. * @returns the list of velocity gradients
  90290. */
  90291. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  90292. /**
  90293. * Gets the current list of start size gradients.
  90294. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  90295. * @returns the list of start size gradients
  90296. */
  90297. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  90298. /**
  90299. * Gets the current list of emit rate gradients.
  90300. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  90301. * @returns the list of emit rate gradients
  90302. */
  90303. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  90304. /**
  90305. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90306. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90307. */
  90308. get direction1(): Vector3;
  90309. set direction1(value: Vector3);
  90310. /**
  90311. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90312. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90313. */
  90314. get direction2(): Vector3;
  90315. set direction2(value: Vector3);
  90316. /**
  90317. * 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.
  90318. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90319. */
  90320. get minEmitBox(): Vector3;
  90321. set minEmitBox(value: Vector3);
  90322. /**
  90323. * 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.
  90324. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90325. */
  90326. get maxEmitBox(): Vector3;
  90327. set maxEmitBox(value: Vector3);
  90328. /**
  90329. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90330. */
  90331. color1: Color4;
  90332. /**
  90333. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90334. */
  90335. color2: Color4;
  90336. /**
  90337. * Color the particle will have at the end of its lifetime
  90338. */
  90339. colorDead: Color4;
  90340. /**
  90341. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  90342. */
  90343. textureMask: Color4;
  90344. /**
  90345. * The particle emitter type defines the emitter used by the particle system.
  90346. * It can be for example box, sphere, or cone...
  90347. */
  90348. particleEmitterType: IParticleEmitterType;
  90349. /** @hidden */
  90350. _isSubEmitter: boolean;
  90351. /**
  90352. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90353. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90354. */
  90355. billboardMode: number;
  90356. protected _isBillboardBased: boolean;
  90357. /**
  90358. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90359. */
  90360. get isBillboardBased(): boolean;
  90361. set isBillboardBased(value: boolean);
  90362. /**
  90363. * The scene the particle system belongs to.
  90364. */
  90365. protected _scene: Scene;
  90366. /**
  90367. * Local cache of defines for image processing.
  90368. */
  90369. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  90370. /**
  90371. * Default configuration related to image processing available in the standard Material.
  90372. */
  90373. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90374. /**
  90375. * Gets the image processing configuration used either in this material.
  90376. */
  90377. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  90378. /**
  90379. * Sets the Default image processing configuration used either in the this material.
  90380. *
  90381. * If sets to null, the scene one is in use.
  90382. */
  90383. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  90384. /**
  90385. * Attaches a new image processing configuration to the Standard Material.
  90386. * @param configuration
  90387. */
  90388. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  90389. /** @hidden */
  90390. protected _reset(): void;
  90391. /** @hidden */
  90392. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  90393. /**
  90394. * Instantiates a particle system.
  90395. * 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.
  90396. * @param name The name of the particle system
  90397. */
  90398. constructor(name: string);
  90399. /**
  90400. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90401. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90402. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90403. * @returns the emitter
  90404. */
  90405. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90406. /**
  90407. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90408. * @param radius The radius of the hemisphere to emit from
  90409. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90410. * @returns the emitter
  90411. */
  90412. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90413. /**
  90414. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90415. * @param radius The radius of the sphere to emit from
  90416. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90417. * @returns the emitter
  90418. */
  90419. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90420. /**
  90421. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90422. * @param radius The radius of the sphere to emit from
  90423. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90424. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90425. * @returns the emitter
  90426. */
  90427. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90428. /**
  90429. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90430. * @param radius The radius of the emission cylinder
  90431. * @param height The height of the emission cylinder
  90432. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90433. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90434. * @returns the emitter
  90435. */
  90436. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90437. /**
  90438. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90439. * @param radius The radius of the cylinder to emit from
  90440. * @param height The height of the emission cylinder
  90441. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90442. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90443. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90444. * @returns the emitter
  90445. */
  90446. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90447. /**
  90448. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90449. * @param radius The radius of the cone to emit from
  90450. * @param angle The base angle of the cone
  90451. * @returns the emitter
  90452. */
  90453. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90454. /**
  90455. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90456. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90457. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90458. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90459. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90460. * @returns the emitter
  90461. */
  90462. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90463. }
  90464. }
  90465. declare module BABYLON {
  90466. /**
  90467. * Type of sub emitter
  90468. */
  90469. export enum SubEmitterType {
  90470. /**
  90471. * Attached to the particle over it's lifetime
  90472. */
  90473. ATTACHED = 0,
  90474. /**
  90475. * Created when the particle dies
  90476. */
  90477. END = 1
  90478. }
  90479. /**
  90480. * Sub emitter class used to emit particles from an existing particle
  90481. */
  90482. export class SubEmitter {
  90483. /**
  90484. * the particle system to be used by the sub emitter
  90485. */
  90486. particleSystem: ParticleSystem;
  90487. /**
  90488. * Type of the submitter (Default: END)
  90489. */
  90490. type: SubEmitterType;
  90491. /**
  90492. * 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)
  90493. * Note: This only is supported when using an emitter of type Mesh
  90494. */
  90495. inheritDirection: boolean;
  90496. /**
  90497. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90498. */
  90499. inheritedVelocityAmount: number;
  90500. /**
  90501. * Creates a sub emitter
  90502. * @param particleSystem the particle system to be used by the sub emitter
  90503. */
  90504. constructor(
  90505. /**
  90506. * the particle system to be used by the sub emitter
  90507. */
  90508. particleSystem: ParticleSystem);
  90509. /**
  90510. * Clones the sub emitter
  90511. * @returns the cloned sub emitter
  90512. */
  90513. clone(): SubEmitter;
  90514. /**
  90515. * Serialize current object to a JSON object
  90516. * @returns the serialized object
  90517. */
  90518. serialize(): any;
  90519. /** @hidden */
  90520. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90521. /**
  90522. * Creates a new SubEmitter from a serialized JSON version
  90523. * @param serializationObject defines the JSON object to read from
  90524. * @param scene defines the hosting scene
  90525. * @param rootUrl defines the rootUrl for data loading
  90526. * @returns a new SubEmitter
  90527. */
  90528. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90529. /** Release associated resources */
  90530. dispose(): void;
  90531. }
  90532. }
  90533. declare module BABYLON {
  90534. /** @hidden */
  90535. export var imageProcessingDeclaration: {
  90536. name: string;
  90537. shader: string;
  90538. };
  90539. }
  90540. declare module BABYLON {
  90541. /** @hidden */
  90542. export var imageProcessingFunctions: {
  90543. name: string;
  90544. shader: string;
  90545. };
  90546. }
  90547. declare module BABYLON {
  90548. /** @hidden */
  90549. export var particlesPixelShader: {
  90550. name: string;
  90551. shader: string;
  90552. };
  90553. }
  90554. declare module BABYLON {
  90555. /** @hidden */
  90556. export var particlesVertexShader: {
  90557. name: string;
  90558. shader: string;
  90559. };
  90560. }
  90561. declare module BABYLON {
  90562. /**
  90563. * This represents a particle system in Babylon.
  90564. * 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.
  90565. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90566. * @example https://doc.babylonjs.com/babylon101/particles
  90567. */
  90568. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90569. /**
  90570. * Billboard mode will only apply to Y axis
  90571. */
  90572. static readonly BILLBOARDMODE_Y: number;
  90573. /**
  90574. * Billboard mode will apply to all axes
  90575. */
  90576. static readonly BILLBOARDMODE_ALL: number;
  90577. /**
  90578. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90579. */
  90580. static readonly BILLBOARDMODE_STRETCHED: number;
  90581. /**
  90582. * This function can be defined to provide custom update for active particles.
  90583. * This function will be called instead of regular update (age, position, color, etc.).
  90584. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90585. */
  90586. updateFunction: (particles: Particle[]) => void;
  90587. private _emitterWorldMatrix;
  90588. /**
  90589. * This function can be defined to specify initial direction for every new particle.
  90590. * It by default use the emitterType defined function
  90591. */
  90592. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90593. /**
  90594. * This function can be defined to specify initial position for every new particle.
  90595. * It by default use the emitterType defined function
  90596. */
  90597. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90598. /**
  90599. * @hidden
  90600. */
  90601. _inheritedVelocityOffset: Vector3;
  90602. /**
  90603. * An event triggered when the system is disposed
  90604. */
  90605. onDisposeObservable: Observable<IParticleSystem>;
  90606. private _onDisposeObserver;
  90607. /**
  90608. * Sets a callback that will be triggered when the system is disposed
  90609. */
  90610. set onDispose(callback: () => void);
  90611. private _particles;
  90612. private _epsilon;
  90613. private _capacity;
  90614. private _stockParticles;
  90615. private _newPartsExcess;
  90616. private _vertexData;
  90617. private _vertexBuffer;
  90618. private _vertexBuffers;
  90619. private _spriteBuffer;
  90620. private _indexBuffer;
  90621. private _effect;
  90622. private _customEffect;
  90623. private _cachedDefines;
  90624. private _scaledColorStep;
  90625. private _colorDiff;
  90626. private _scaledDirection;
  90627. private _scaledGravity;
  90628. private _currentRenderId;
  90629. private _alive;
  90630. private _useInstancing;
  90631. private _started;
  90632. private _stopped;
  90633. private _actualFrame;
  90634. private _scaledUpdateSpeed;
  90635. private _vertexBufferSize;
  90636. /** @hidden */
  90637. _currentEmitRateGradient: Nullable<FactorGradient>;
  90638. /** @hidden */
  90639. _currentEmitRate1: number;
  90640. /** @hidden */
  90641. _currentEmitRate2: number;
  90642. /** @hidden */
  90643. _currentStartSizeGradient: Nullable<FactorGradient>;
  90644. /** @hidden */
  90645. _currentStartSize1: number;
  90646. /** @hidden */
  90647. _currentStartSize2: number;
  90648. private readonly _rawTextureWidth;
  90649. private _rampGradientsTexture;
  90650. private _useRampGradients;
  90651. /** Gets or sets a boolean indicating that ramp gradients must be used
  90652. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90653. */
  90654. get useRampGradients(): boolean;
  90655. set useRampGradients(value: boolean);
  90656. /**
  90657. * 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.
  90658. * 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: [])
  90659. */
  90660. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90661. private _subEmitters;
  90662. /**
  90663. * @hidden
  90664. * If the particle systems emitter should be disposed when the particle system is disposed
  90665. */
  90666. _disposeEmitterOnDispose: boolean;
  90667. /**
  90668. * The current active Sub-systems, this property is used by the root particle system only.
  90669. */
  90670. activeSubSystems: Array<ParticleSystem>;
  90671. /**
  90672. * Specifies if the particles are updated in emitter local space or world space
  90673. */
  90674. isLocal: boolean;
  90675. private _rootParticleSystem;
  90676. /**
  90677. * Gets the current list of active particles
  90678. */
  90679. get particles(): Particle[];
  90680. /**
  90681. * Gets the number of particles active at the same time.
  90682. * @returns The number of active particles.
  90683. */
  90684. getActiveCount(): number;
  90685. /**
  90686. * Returns the string "ParticleSystem"
  90687. * @returns a string containing the class name
  90688. */
  90689. getClassName(): string;
  90690. /**
  90691. * Gets a boolean indicating that the system is stopping
  90692. * @returns true if the system is currently stopping
  90693. */
  90694. isStopping(): boolean;
  90695. /**
  90696. * Gets the custom effect used to render the particles
  90697. * @param blendMode Blend mode for which the effect should be retrieved
  90698. * @returns The effect
  90699. */
  90700. getCustomEffect(blendMode?: number): Nullable<Effect>;
  90701. /**
  90702. * Sets the custom effect used to render the particles
  90703. * @param effect The effect to set
  90704. * @param blendMode Blend mode for which the effect should be set
  90705. */
  90706. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  90707. /** @hidden */
  90708. private _onBeforeDrawParticlesObservable;
  90709. /**
  90710. * Observable that will be called just before the particles are drawn
  90711. */
  90712. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  90713. /**
  90714. * Gets the name of the particle vertex shader
  90715. */
  90716. get vertexShaderName(): string;
  90717. /**
  90718. * Instantiates a particle system.
  90719. * 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.
  90720. * @param name The name of the particle system
  90721. * @param capacity The max number of particles alive at the same time
  90722. * @param scene The scene the particle system belongs to
  90723. * @param customEffect a custom effect used to change the way particles are rendered by default
  90724. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90725. * @param epsilon Offset used to render the particles
  90726. */
  90727. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90728. private _addFactorGradient;
  90729. private _removeFactorGradient;
  90730. /**
  90731. * Adds a new life time gradient
  90732. * @param gradient defines the gradient to use (between 0 and 1)
  90733. * @param factor defines the life time factor to affect to the specified gradient
  90734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90735. * @returns the current particle system
  90736. */
  90737. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90738. /**
  90739. * Remove a specific life time gradient
  90740. * @param gradient defines the gradient to remove
  90741. * @returns the current particle system
  90742. */
  90743. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90744. /**
  90745. * Adds a new size gradient
  90746. * @param gradient defines the gradient to use (between 0 and 1)
  90747. * @param factor defines the size factor to affect to the specified gradient
  90748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90749. * @returns the current particle system
  90750. */
  90751. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90752. /**
  90753. * Remove a specific size gradient
  90754. * @param gradient defines the gradient to remove
  90755. * @returns the current particle system
  90756. */
  90757. removeSizeGradient(gradient: number): IParticleSystem;
  90758. /**
  90759. * Adds a new color remap gradient
  90760. * @param gradient defines the gradient to use (between 0 and 1)
  90761. * @param min defines the color remap minimal range
  90762. * @param max defines the color remap maximal range
  90763. * @returns the current particle system
  90764. */
  90765. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90766. /**
  90767. * Remove a specific color remap gradient
  90768. * @param gradient defines the gradient to remove
  90769. * @returns the current particle system
  90770. */
  90771. removeColorRemapGradient(gradient: number): IParticleSystem;
  90772. /**
  90773. * Adds a new alpha remap gradient
  90774. * @param gradient defines the gradient to use (between 0 and 1)
  90775. * @param min defines the alpha remap minimal range
  90776. * @param max defines the alpha remap maximal range
  90777. * @returns the current particle system
  90778. */
  90779. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90780. /**
  90781. * Remove a specific alpha remap gradient
  90782. * @param gradient defines the gradient to remove
  90783. * @returns the current particle system
  90784. */
  90785. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90786. /**
  90787. * Adds a new angular speed gradient
  90788. * @param gradient defines the gradient to use (between 0 and 1)
  90789. * @param factor defines the angular speed to affect to the specified gradient
  90790. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90791. * @returns the current particle system
  90792. */
  90793. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90794. /**
  90795. * Remove a specific angular speed gradient
  90796. * @param gradient defines the gradient to remove
  90797. * @returns the current particle system
  90798. */
  90799. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90800. /**
  90801. * Adds a new velocity gradient
  90802. * @param gradient defines the gradient to use (between 0 and 1)
  90803. * @param factor defines the velocity to affect to the specified gradient
  90804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90805. * @returns the current particle system
  90806. */
  90807. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90808. /**
  90809. * Remove a specific velocity gradient
  90810. * @param gradient defines the gradient to remove
  90811. * @returns the current particle system
  90812. */
  90813. removeVelocityGradient(gradient: number): IParticleSystem;
  90814. /**
  90815. * Adds a new limit velocity gradient
  90816. * @param gradient defines the gradient to use (between 0 and 1)
  90817. * @param factor defines the limit velocity value to affect to the specified gradient
  90818. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90819. * @returns the current particle system
  90820. */
  90821. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90822. /**
  90823. * Remove a specific limit velocity gradient
  90824. * @param gradient defines the gradient to remove
  90825. * @returns the current particle system
  90826. */
  90827. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90828. /**
  90829. * Adds a new drag gradient
  90830. * @param gradient defines the gradient to use (between 0 and 1)
  90831. * @param factor defines the drag value to affect to the specified gradient
  90832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90833. * @returns the current particle system
  90834. */
  90835. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90836. /**
  90837. * Remove a specific drag gradient
  90838. * @param gradient defines the gradient to remove
  90839. * @returns the current particle system
  90840. */
  90841. removeDragGradient(gradient: number): IParticleSystem;
  90842. /**
  90843. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90844. * @param gradient defines the gradient to use (between 0 and 1)
  90845. * @param factor defines the emit rate value to affect to the specified gradient
  90846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90847. * @returns the current particle system
  90848. */
  90849. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90850. /**
  90851. * Remove a specific emit rate gradient
  90852. * @param gradient defines the gradient to remove
  90853. * @returns the current particle system
  90854. */
  90855. removeEmitRateGradient(gradient: number): IParticleSystem;
  90856. /**
  90857. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90858. * @param gradient defines the gradient to use (between 0 and 1)
  90859. * @param factor defines the start size value to affect to the specified gradient
  90860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90861. * @returns the current particle system
  90862. */
  90863. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90864. /**
  90865. * Remove a specific start size gradient
  90866. * @param gradient defines the gradient to remove
  90867. * @returns the current particle system
  90868. */
  90869. removeStartSizeGradient(gradient: number): IParticleSystem;
  90870. private _createRampGradientTexture;
  90871. /**
  90872. * Gets the current list of ramp gradients.
  90873. * You must use addRampGradient and removeRampGradient to udpate this list
  90874. * @returns the list of ramp gradients
  90875. */
  90876. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90877. /** Force the system to rebuild all gradients that need to be resync */
  90878. forceRefreshGradients(): void;
  90879. private _syncRampGradientTexture;
  90880. /**
  90881. * Adds a new ramp gradient used to remap particle colors
  90882. * @param gradient defines the gradient to use (between 0 and 1)
  90883. * @param color defines the color to affect to the specified gradient
  90884. * @returns the current particle system
  90885. */
  90886. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90887. /**
  90888. * Remove a specific ramp gradient
  90889. * @param gradient defines the gradient to remove
  90890. * @returns the current particle system
  90891. */
  90892. removeRampGradient(gradient: number): ParticleSystem;
  90893. /**
  90894. * Adds a new color gradient
  90895. * @param gradient defines the gradient to use (between 0 and 1)
  90896. * @param color1 defines the color to affect to the specified gradient
  90897. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90898. * @returns this particle system
  90899. */
  90900. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90901. /**
  90902. * Remove a specific color gradient
  90903. * @param gradient defines the gradient to remove
  90904. * @returns this particle system
  90905. */
  90906. removeColorGradient(gradient: number): IParticleSystem;
  90907. private _fetchR;
  90908. protected _reset(): void;
  90909. private _resetEffect;
  90910. private _createVertexBuffers;
  90911. private _createIndexBuffer;
  90912. /**
  90913. * Gets the maximum number of particles active at the same time.
  90914. * @returns The max number of active particles.
  90915. */
  90916. getCapacity(): number;
  90917. /**
  90918. * Gets whether there are still active particles in the system.
  90919. * @returns True if it is alive, otherwise false.
  90920. */
  90921. isAlive(): boolean;
  90922. /**
  90923. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90924. * @returns True if it has been started, otherwise false.
  90925. */
  90926. isStarted(): boolean;
  90927. private _prepareSubEmitterInternalArray;
  90928. /**
  90929. * Starts the particle system and begins to emit
  90930. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90931. */
  90932. start(delay?: number): void;
  90933. /**
  90934. * Stops the particle system.
  90935. * @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.
  90936. */
  90937. stop(stopSubEmitters?: boolean): void;
  90938. /**
  90939. * Remove all active particles
  90940. */
  90941. reset(): void;
  90942. /**
  90943. * @hidden (for internal use only)
  90944. */
  90945. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90946. /**
  90947. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90948. * Its lifetime will start back at 0.
  90949. */
  90950. recycleParticle: (particle: Particle) => void;
  90951. private _stopSubEmitters;
  90952. private _createParticle;
  90953. private _removeFromRoot;
  90954. private _emitFromParticle;
  90955. private _update;
  90956. /** @hidden */
  90957. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90958. /** @hidden */
  90959. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90960. /**
  90961. * Fill the defines array according to the current settings of the particle system
  90962. * @param defines Array to be updated
  90963. * @param blendMode blend mode to take into account when updating the array
  90964. */
  90965. fillDefines(defines: Array<string>, blendMode: number): void;
  90966. /**
  90967. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90968. * @param uniforms Uniforms array to fill
  90969. * @param attributes Attributes array to fill
  90970. * @param samplers Samplers array to fill
  90971. */
  90972. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90973. /** @hidden */
  90974. private _getEffect;
  90975. /**
  90976. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90977. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90978. */
  90979. animate(preWarmOnly?: boolean): void;
  90980. private _appendParticleVertices;
  90981. /**
  90982. * Rebuilds the particle system.
  90983. */
  90984. rebuild(): void;
  90985. /**
  90986. * Is this system ready to be used/rendered
  90987. * @return true if the system is ready
  90988. */
  90989. isReady(): boolean;
  90990. private _render;
  90991. /**
  90992. * Renders the particle system in its current state.
  90993. * @returns the current number of particles
  90994. */
  90995. render(): number;
  90996. /**
  90997. * Disposes the particle system and free the associated resources
  90998. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90999. */
  91000. dispose(disposeTexture?: boolean): void;
  91001. /**
  91002. * Clones the particle system.
  91003. * @param name The name of the cloned object
  91004. * @param newEmitter The new emitter to use
  91005. * @returns the cloned particle system
  91006. */
  91007. clone(name: string, newEmitter: any): ParticleSystem;
  91008. /**
  91009. * Serializes the particle system to a JSON object
  91010. * @param serializeTexture defines if the texture must be serialized as well
  91011. * @returns the JSON object
  91012. */
  91013. serialize(serializeTexture?: boolean): any;
  91014. /** @hidden */
  91015. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91016. /** @hidden */
  91017. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  91018. /**
  91019. * Parses a JSON object to create a particle system.
  91020. * @param parsedParticleSystem The JSON object to parse
  91021. * @param scene The scene to create the particle system in
  91022. * @param rootUrl The root url to use to load external dependencies like texture
  91023. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91024. * @returns the Parsed particle system
  91025. */
  91026. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91027. }
  91028. }
  91029. declare module BABYLON {
  91030. /**
  91031. * A particle represents one of the element emitted by a particle system.
  91032. * This is mainly define by its coordinates, direction, velocity and age.
  91033. */
  91034. export class Particle {
  91035. /**
  91036. * The particle system the particle belongs to.
  91037. */
  91038. particleSystem: ParticleSystem;
  91039. private static _Count;
  91040. /**
  91041. * Unique ID of the particle
  91042. */
  91043. id: number;
  91044. /**
  91045. * The world position of the particle in the scene.
  91046. */
  91047. position: Vector3;
  91048. /**
  91049. * The world direction of the particle in the scene.
  91050. */
  91051. direction: Vector3;
  91052. /**
  91053. * The color of the particle.
  91054. */
  91055. color: Color4;
  91056. /**
  91057. * The color change of the particle per step.
  91058. */
  91059. colorStep: Color4;
  91060. /**
  91061. * Defines how long will the life of the particle be.
  91062. */
  91063. lifeTime: number;
  91064. /**
  91065. * The current age of the particle.
  91066. */
  91067. age: number;
  91068. /**
  91069. * The current size of the particle.
  91070. */
  91071. size: number;
  91072. /**
  91073. * The current scale of the particle.
  91074. */
  91075. scale: Vector2;
  91076. /**
  91077. * The current angle of the particle.
  91078. */
  91079. angle: number;
  91080. /**
  91081. * Defines how fast is the angle changing.
  91082. */
  91083. angularSpeed: number;
  91084. /**
  91085. * Defines the cell index used by the particle to be rendered from a sprite.
  91086. */
  91087. cellIndex: number;
  91088. /**
  91089. * The information required to support color remapping
  91090. */
  91091. remapData: Vector4;
  91092. /** @hidden */
  91093. _randomCellOffset?: number;
  91094. /** @hidden */
  91095. _initialDirection: Nullable<Vector3>;
  91096. /** @hidden */
  91097. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  91098. /** @hidden */
  91099. _initialStartSpriteCellID: number;
  91100. /** @hidden */
  91101. _initialEndSpriteCellID: number;
  91102. /** @hidden */
  91103. _currentColorGradient: Nullable<ColorGradient>;
  91104. /** @hidden */
  91105. _currentColor1: Color4;
  91106. /** @hidden */
  91107. _currentColor2: Color4;
  91108. /** @hidden */
  91109. _currentSizeGradient: Nullable<FactorGradient>;
  91110. /** @hidden */
  91111. _currentSize1: number;
  91112. /** @hidden */
  91113. _currentSize2: number;
  91114. /** @hidden */
  91115. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  91116. /** @hidden */
  91117. _currentAngularSpeed1: number;
  91118. /** @hidden */
  91119. _currentAngularSpeed2: number;
  91120. /** @hidden */
  91121. _currentVelocityGradient: Nullable<FactorGradient>;
  91122. /** @hidden */
  91123. _currentVelocity1: number;
  91124. /** @hidden */
  91125. _currentVelocity2: number;
  91126. /** @hidden */
  91127. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  91128. /** @hidden */
  91129. _currentLimitVelocity1: number;
  91130. /** @hidden */
  91131. _currentLimitVelocity2: number;
  91132. /** @hidden */
  91133. _currentDragGradient: Nullable<FactorGradient>;
  91134. /** @hidden */
  91135. _currentDrag1: number;
  91136. /** @hidden */
  91137. _currentDrag2: number;
  91138. /** @hidden */
  91139. _randomNoiseCoordinates1: Vector3;
  91140. /** @hidden */
  91141. _randomNoiseCoordinates2: Vector3;
  91142. /** @hidden */
  91143. _localPosition?: Vector3;
  91144. /**
  91145. * Creates a new instance Particle
  91146. * @param particleSystem the particle system the particle belongs to
  91147. */
  91148. constructor(
  91149. /**
  91150. * The particle system the particle belongs to.
  91151. */
  91152. particleSystem: ParticleSystem);
  91153. private updateCellInfoFromSystem;
  91154. /**
  91155. * Defines how the sprite cell index is updated for the particle
  91156. */
  91157. updateCellIndex(): void;
  91158. /** @hidden */
  91159. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  91160. /** @hidden */
  91161. _inheritParticleInfoToSubEmitters(): void;
  91162. /** @hidden */
  91163. _reset(): void;
  91164. /**
  91165. * Copy the properties of particle to another one.
  91166. * @param other the particle to copy the information to.
  91167. */
  91168. copyTo(other: Particle): void;
  91169. }
  91170. }
  91171. declare module BABYLON {
  91172. /**
  91173. * Particle emitter represents a volume emitting particles.
  91174. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  91175. */
  91176. export interface IParticleEmitterType {
  91177. /**
  91178. * Called by the particle System when the direction is computed for the created particle.
  91179. * @param worldMatrix is the world matrix of the particle system
  91180. * @param directionToUpdate is the direction vector to update with the result
  91181. * @param particle is the particle we are computed the direction for
  91182. * @param isLocal defines if the direction should be set in local space
  91183. */
  91184. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91185. /**
  91186. * Called by the particle System when the position is computed for the created particle.
  91187. * @param worldMatrix is the world matrix of the particle system
  91188. * @param positionToUpdate is the position vector to update with the result
  91189. * @param particle is the particle we are computed the position for
  91190. * @param isLocal defines if the position should be set in local space
  91191. */
  91192. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91193. /**
  91194. * Clones the current emitter and returns a copy of it
  91195. * @returns the new emitter
  91196. */
  91197. clone(): IParticleEmitterType;
  91198. /**
  91199. * Called by the GPUParticleSystem to setup the update shader
  91200. * @param effect defines the update shader
  91201. */
  91202. applyToShader(effect: Effect): void;
  91203. /**
  91204. * Returns a string to use to update the GPU particles update shader
  91205. * @returns the effect defines string
  91206. */
  91207. getEffectDefines(): string;
  91208. /**
  91209. * Returns a string representing the class name
  91210. * @returns a string containing the class name
  91211. */
  91212. getClassName(): string;
  91213. /**
  91214. * Serializes the particle system to a JSON object.
  91215. * @returns the JSON object
  91216. */
  91217. serialize(): any;
  91218. /**
  91219. * Parse properties from a JSON object
  91220. * @param serializationObject defines the JSON object
  91221. * @param scene defines the hosting scene
  91222. */
  91223. parse(serializationObject: any, scene: Scene): void;
  91224. }
  91225. }
  91226. declare module BABYLON {
  91227. /**
  91228. * Particle emitter emitting particles from the inside of a box.
  91229. * It emits the particles randomly between 2 given directions.
  91230. */
  91231. export class BoxParticleEmitter implements IParticleEmitterType {
  91232. /**
  91233. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91234. */
  91235. direction1: Vector3;
  91236. /**
  91237. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91238. */
  91239. direction2: Vector3;
  91240. /**
  91241. * 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.
  91242. */
  91243. minEmitBox: Vector3;
  91244. /**
  91245. * 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.
  91246. */
  91247. maxEmitBox: Vector3;
  91248. /**
  91249. * Creates a new instance BoxParticleEmitter
  91250. */
  91251. constructor();
  91252. /**
  91253. * Called by the particle System when the direction is computed for the created particle.
  91254. * @param worldMatrix is the world matrix of the particle system
  91255. * @param directionToUpdate is the direction vector to update with the result
  91256. * @param particle is the particle we are computed the direction for
  91257. * @param isLocal defines if the direction should be set in local space
  91258. */
  91259. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91260. /**
  91261. * Called by the particle System when the position is computed for the created particle.
  91262. * @param worldMatrix is the world matrix of the particle system
  91263. * @param positionToUpdate is the position vector to update with the result
  91264. * @param particle is the particle we are computed the position for
  91265. * @param isLocal defines if the position should be set in local space
  91266. */
  91267. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91268. /**
  91269. * Clones the current emitter and returns a copy of it
  91270. * @returns the new emitter
  91271. */
  91272. clone(): BoxParticleEmitter;
  91273. /**
  91274. * Called by the GPUParticleSystem to setup the update shader
  91275. * @param effect defines the update shader
  91276. */
  91277. applyToShader(effect: Effect): void;
  91278. /**
  91279. * Returns a string to use to update the GPU particles update shader
  91280. * @returns a string containng the defines string
  91281. */
  91282. getEffectDefines(): string;
  91283. /**
  91284. * Returns the string "BoxParticleEmitter"
  91285. * @returns a string containing the class name
  91286. */
  91287. getClassName(): string;
  91288. /**
  91289. * Serializes the particle system to a JSON object.
  91290. * @returns the JSON object
  91291. */
  91292. serialize(): any;
  91293. /**
  91294. * Parse properties from a JSON object
  91295. * @param serializationObject defines the JSON object
  91296. */
  91297. parse(serializationObject: any): void;
  91298. }
  91299. }
  91300. declare module BABYLON {
  91301. /**
  91302. * Particle emitter emitting particles from the inside of a cone.
  91303. * It emits the particles alongside the cone volume from the base to the particle.
  91304. * The emission direction might be randomized.
  91305. */
  91306. export class ConeParticleEmitter implements IParticleEmitterType {
  91307. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91308. directionRandomizer: number;
  91309. private _radius;
  91310. private _angle;
  91311. private _height;
  91312. /**
  91313. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  91314. */
  91315. radiusRange: number;
  91316. /**
  91317. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  91318. */
  91319. heightRange: number;
  91320. /**
  91321. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  91322. */
  91323. emitFromSpawnPointOnly: boolean;
  91324. /**
  91325. * Gets or sets the radius of the emission cone
  91326. */
  91327. get radius(): number;
  91328. set radius(value: number);
  91329. /**
  91330. * Gets or sets the angle of the emission cone
  91331. */
  91332. get angle(): number;
  91333. set angle(value: number);
  91334. private _buildHeight;
  91335. /**
  91336. * Creates a new instance ConeParticleEmitter
  91337. * @param radius the radius of the emission cone (1 by default)
  91338. * @param angle the cone base angle (PI by default)
  91339. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  91340. */
  91341. constructor(radius?: number, angle?: number,
  91342. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91343. directionRandomizer?: number);
  91344. /**
  91345. * Called by the particle System when the direction is computed for the created particle.
  91346. * @param worldMatrix is the world matrix of the particle system
  91347. * @param directionToUpdate is the direction vector to update with the result
  91348. * @param particle is the particle we are computed the direction for
  91349. * @param isLocal defines if the direction should be set in local space
  91350. */
  91351. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91352. /**
  91353. * Called by the particle System when the position is computed for the created particle.
  91354. * @param worldMatrix is the world matrix of the particle system
  91355. * @param positionToUpdate is the position vector to update with the result
  91356. * @param particle is the particle we are computed the position for
  91357. * @param isLocal defines if the position should be set in local space
  91358. */
  91359. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91360. /**
  91361. * Clones the current emitter and returns a copy of it
  91362. * @returns the new emitter
  91363. */
  91364. clone(): ConeParticleEmitter;
  91365. /**
  91366. * Called by the GPUParticleSystem to setup the update shader
  91367. * @param effect defines the update shader
  91368. */
  91369. applyToShader(effect: Effect): void;
  91370. /**
  91371. * Returns a string to use to update the GPU particles update shader
  91372. * @returns a string containng the defines string
  91373. */
  91374. getEffectDefines(): string;
  91375. /**
  91376. * Returns the string "ConeParticleEmitter"
  91377. * @returns a string containing the class name
  91378. */
  91379. getClassName(): string;
  91380. /**
  91381. * Serializes the particle system to a JSON object.
  91382. * @returns the JSON object
  91383. */
  91384. serialize(): any;
  91385. /**
  91386. * Parse properties from a JSON object
  91387. * @param serializationObject defines the JSON object
  91388. */
  91389. parse(serializationObject: any): void;
  91390. }
  91391. }
  91392. declare module BABYLON {
  91393. /**
  91394. * Particle emitter emitting particles from the inside of a cylinder.
  91395. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  91396. */
  91397. export class CylinderParticleEmitter implements IParticleEmitterType {
  91398. /**
  91399. * The radius of the emission cylinder.
  91400. */
  91401. radius: number;
  91402. /**
  91403. * The height of the emission cylinder.
  91404. */
  91405. height: number;
  91406. /**
  91407. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91408. */
  91409. radiusRange: number;
  91410. /**
  91411. * How much to randomize the particle direction [0-1].
  91412. */
  91413. directionRandomizer: number;
  91414. /**
  91415. * Creates a new instance CylinderParticleEmitter
  91416. * @param radius the radius of the emission cylinder (1 by default)
  91417. * @param height the height of the emission cylinder (1 by default)
  91418. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91419. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91420. */
  91421. constructor(
  91422. /**
  91423. * The radius of the emission cylinder.
  91424. */
  91425. radius?: number,
  91426. /**
  91427. * The height of the emission cylinder.
  91428. */
  91429. height?: number,
  91430. /**
  91431. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91432. */
  91433. radiusRange?: number,
  91434. /**
  91435. * How much to randomize the particle direction [0-1].
  91436. */
  91437. directionRandomizer?: number);
  91438. /**
  91439. * Called by the particle System when the direction is computed for the created particle.
  91440. * @param worldMatrix is the world matrix of the particle system
  91441. * @param directionToUpdate is the direction vector to update with the result
  91442. * @param particle is the particle we are computed the direction for
  91443. * @param isLocal defines if the direction should be set in local space
  91444. */
  91445. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91446. /**
  91447. * Called by the particle System when the position is computed for the created particle.
  91448. * @param worldMatrix is the world matrix of the particle system
  91449. * @param positionToUpdate is the position vector to update with the result
  91450. * @param particle is the particle we are computed the position for
  91451. * @param isLocal defines if the position should be set in local space
  91452. */
  91453. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91454. /**
  91455. * Clones the current emitter and returns a copy of it
  91456. * @returns the new emitter
  91457. */
  91458. clone(): CylinderParticleEmitter;
  91459. /**
  91460. * Called by the GPUParticleSystem to setup the update shader
  91461. * @param effect defines the update shader
  91462. */
  91463. applyToShader(effect: Effect): void;
  91464. /**
  91465. * Returns a string to use to update the GPU particles update shader
  91466. * @returns a string containng the defines string
  91467. */
  91468. getEffectDefines(): string;
  91469. /**
  91470. * Returns the string "CylinderParticleEmitter"
  91471. * @returns a string containing the class name
  91472. */
  91473. getClassName(): string;
  91474. /**
  91475. * Serializes the particle system to a JSON object.
  91476. * @returns the JSON object
  91477. */
  91478. serialize(): any;
  91479. /**
  91480. * Parse properties from a JSON object
  91481. * @param serializationObject defines the JSON object
  91482. */
  91483. parse(serializationObject: any): void;
  91484. }
  91485. /**
  91486. * Particle emitter emitting particles from the inside of a cylinder.
  91487. * It emits the particles randomly between two vectors.
  91488. */
  91489. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91490. /**
  91491. * The min limit of the emission direction.
  91492. */
  91493. direction1: Vector3;
  91494. /**
  91495. * The max limit of the emission direction.
  91496. */
  91497. direction2: Vector3;
  91498. /**
  91499. * Creates a new instance CylinderDirectedParticleEmitter
  91500. * @param radius the radius of the emission cylinder (1 by default)
  91501. * @param height the height of the emission cylinder (1 by default)
  91502. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91503. * @param direction1 the min limit of the emission direction (up vector by default)
  91504. * @param direction2 the max limit of the emission direction (up vector by default)
  91505. */
  91506. constructor(radius?: number, height?: number, radiusRange?: number,
  91507. /**
  91508. * The min limit of the emission direction.
  91509. */
  91510. direction1?: Vector3,
  91511. /**
  91512. * The max limit of the emission direction.
  91513. */
  91514. direction2?: Vector3);
  91515. /**
  91516. * Called by the particle System when the direction is computed for the created particle.
  91517. * @param worldMatrix is the world matrix of the particle system
  91518. * @param directionToUpdate is the direction vector to update with the result
  91519. * @param particle is the particle we are computed the direction for
  91520. */
  91521. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91522. /**
  91523. * Clones the current emitter and returns a copy of it
  91524. * @returns the new emitter
  91525. */
  91526. clone(): CylinderDirectedParticleEmitter;
  91527. /**
  91528. * Called by the GPUParticleSystem to setup the update shader
  91529. * @param effect defines the update shader
  91530. */
  91531. applyToShader(effect: Effect): void;
  91532. /**
  91533. * Returns a string to use to update the GPU particles update shader
  91534. * @returns a string containng the defines string
  91535. */
  91536. getEffectDefines(): string;
  91537. /**
  91538. * Returns the string "CylinderDirectedParticleEmitter"
  91539. * @returns a string containing the class name
  91540. */
  91541. getClassName(): string;
  91542. /**
  91543. * Serializes the particle system to a JSON object.
  91544. * @returns the JSON object
  91545. */
  91546. serialize(): any;
  91547. /**
  91548. * Parse properties from a JSON object
  91549. * @param serializationObject defines the JSON object
  91550. */
  91551. parse(serializationObject: any): void;
  91552. }
  91553. }
  91554. declare module BABYLON {
  91555. /**
  91556. * Particle emitter emitting particles from the inside of a hemisphere.
  91557. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91558. */
  91559. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91560. /**
  91561. * The radius of the emission hemisphere.
  91562. */
  91563. radius: number;
  91564. /**
  91565. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91566. */
  91567. radiusRange: number;
  91568. /**
  91569. * How much to randomize the particle direction [0-1].
  91570. */
  91571. directionRandomizer: number;
  91572. /**
  91573. * Creates a new instance HemisphericParticleEmitter
  91574. * @param radius the radius of the emission hemisphere (1 by default)
  91575. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91576. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91577. */
  91578. constructor(
  91579. /**
  91580. * The radius of the emission hemisphere.
  91581. */
  91582. radius?: number,
  91583. /**
  91584. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91585. */
  91586. radiusRange?: number,
  91587. /**
  91588. * How much to randomize the particle direction [0-1].
  91589. */
  91590. directionRandomizer?: number);
  91591. /**
  91592. * Called by the particle System when the direction is computed for the created particle.
  91593. * @param worldMatrix is the world matrix of the particle system
  91594. * @param directionToUpdate is the direction vector to update with the result
  91595. * @param particle is the particle we are computed the direction for
  91596. * @param isLocal defines if the direction should be set in local space
  91597. */
  91598. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91599. /**
  91600. * Called by the particle System when the position is computed for the created particle.
  91601. * @param worldMatrix is the world matrix of the particle system
  91602. * @param positionToUpdate is the position vector to update with the result
  91603. * @param particle is the particle we are computed the position for
  91604. * @param isLocal defines if the position should be set in local space
  91605. */
  91606. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91607. /**
  91608. * Clones the current emitter and returns a copy of it
  91609. * @returns the new emitter
  91610. */
  91611. clone(): HemisphericParticleEmitter;
  91612. /**
  91613. * Called by the GPUParticleSystem to setup the update shader
  91614. * @param effect defines the update shader
  91615. */
  91616. applyToShader(effect: Effect): void;
  91617. /**
  91618. * Returns a string to use to update the GPU particles update shader
  91619. * @returns a string containng the defines string
  91620. */
  91621. getEffectDefines(): string;
  91622. /**
  91623. * Returns the string "HemisphericParticleEmitter"
  91624. * @returns a string containing the class name
  91625. */
  91626. getClassName(): string;
  91627. /**
  91628. * Serializes the particle system to a JSON object.
  91629. * @returns the JSON object
  91630. */
  91631. serialize(): any;
  91632. /**
  91633. * Parse properties from a JSON object
  91634. * @param serializationObject defines the JSON object
  91635. */
  91636. parse(serializationObject: any): void;
  91637. }
  91638. }
  91639. declare module BABYLON {
  91640. /**
  91641. * Particle emitter emitting particles from a point.
  91642. * It emits the particles randomly between 2 given directions.
  91643. */
  91644. export class PointParticleEmitter implements IParticleEmitterType {
  91645. /**
  91646. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91647. */
  91648. direction1: Vector3;
  91649. /**
  91650. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91651. */
  91652. direction2: Vector3;
  91653. /**
  91654. * Creates a new instance PointParticleEmitter
  91655. */
  91656. constructor();
  91657. /**
  91658. * Called by the particle System when the direction is computed for the created particle.
  91659. * @param worldMatrix is the world matrix of the particle system
  91660. * @param directionToUpdate is the direction vector to update with the result
  91661. * @param particle is the particle we are computed the direction for
  91662. * @param isLocal defines if the direction should be set in local space
  91663. */
  91664. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91665. /**
  91666. * Called by the particle System when the position is computed for the created particle.
  91667. * @param worldMatrix is the world matrix of the particle system
  91668. * @param positionToUpdate is the position vector to update with the result
  91669. * @param particle is the particle we are computed the position for
  91670. * @param isLocal defines if the position should be set in local space
  91671. */
  91672. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91673. /**
  91674. * Clones the current emitter and returns a copy of it
  91675. * @returns the new emitter
  91676. */
  91677. clone(): PointParticleEmitter;
  91678. /**
  91679. * Called by the GPUParticleSystem to setup the update shader
  91680. * @param effect defines the update shader
  91681. */
  91682. applyToShader(effect: Effect): void;
  91683. /**
  91684. * Returns a string to use to update the GPU particles update shader
  91685. * @returns a string containng the defines string
  91686. */
  91687. getEffectDefines(): string;
  91688. /**
  91689. * Returns the string "PointParticleEmitter"
  91690. * @returns a string containing the class name
  91691. */
  91692. getClassName(): string;
  91693. /**
  91694. * Serializes the particle system to a JSON object.
  91695. * @returns the JSON object
  91696. */
  91697. serialize(): any;
  91698. /**
  91699. * Parse properties from a JSON object
  91700. * @param serializationObject defines the JSON object
  91701. */
  91702. parse(serializationObject: any): void;
  91703. }
  91704. }
  91705. declare module BABYLON {
  91706. /**
  91707. * Particle emitter emitting particles from the inside of a sphere.
  91708. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91709. */
  91710. export class SphereParticleEmitter implements IParticleEmitterType {
  91711. /**
  91712. * The radius of the emission sphere.
  91713. */
  91714. radius: number;
  91715. /**
  91716. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91717. */
  91718. radiusRange: number;
  91719. /**
  91720. * How much to randomize the particle direction [0-1].
  91721. */
  91722. directionRandomizer: number;
  91723. /**
  91724. * Creates a new instance SphereParticleEmitter
  91725. * @param radius the radius of the emission sphere (1 by default)
  91726. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91727. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91728. */
  91729. constructor(
  91730. /**
  91731. * The radius of the emission sphere.
  91732. */
  91733. radius?: number,
  91734. /**
  91735. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91736. */
  91737. radiusRange?: number,
  91738. /**
  91739. * How much to randomize the particle direction [0-1].
  91740. */
  91741. directionRandomizer?: number);
  91742. /**
  91743. * Called by the particle System when the direction is computed for the created particle.
  91744. * @param worldMatrix is the world matrix of the particle system
  91745. * @param directionToUpdate is the direction vector to update with the result
  91746. * @param particle is the particle we are computed the direction for
  91747. * @param isLocal defines if the direction should be set in local space
  91748. */
  91749. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91750. /**
  91751. * Called by the particle System when the position is computed for the created particle.
  91752. * @param worldMatrix is the world matrix of the particle system
  91753. * @param positionToUpdate is the position vector to update with the result
  91754. * @param particle is the particle we are computed the position for
  91755. * @param isLocal defines if the position should be set in local space
  91756. */
  91757. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91758. /**
  91759. * Clones the current emitter and returns a copy of it
  91760. * @returns the new emitter
  91761. */
  91762. clone(): SphereParticleEmitter;
  91763. /**
  91764. * Called by the GPUParticleSystem to setup the update shader
  91765. * @param effect defines the update shader
  91766. */
  91767. applyToShader(effect: Effect): void;
  91768. /**
  91769. * Returns a string to use to update the GPU particles update shader
  91770. * @returns a string containng the defines string
  91771. */
  91772. getEffectDefines(): string;
  91773. /**
  91774. * Returns the string "SphereParticleEmitter"
  91775. * @returns a string containing the class name
  91776. */
  91777. getClassName(): string;
  91778. /**
  91779. * Serializes the particle system to a JSON object.
  91780. * @returns the JSON object
  91781. */
  91782. serialize(): any;
  91783. /**
  91784. * Parse properties from a JSON object
  91785. * @param serializationObject defines the JSON object
  91786. */
  91787. parse(serializationObject: any): void;
  91788. }
  91789. /**
  91790. * Particle emitter emitting particles from the inside of a sphere.
  91791. * It emits the particles randomly between two vectors.
  91792. */
  91793. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91794. /**
  91795. * The min limit of the emission direction.
  91796. */
  91797. direction1: Vector3;
  91798. /**
  91799. * The max limit of the emission direction.
  91800. */
  91801. direction2: Vector3;
  91802. /**
  91803. * Creates a new instance SphereDirectedParticleEmitter
  91804. * @param radius the radius of the emission sphere (1 by default)
  91805. * @param direction1 the min limit of the emission direction (up vector by default)
  91806. * @param direction2 the max limit of the emission direction (up vector by default)
  91807. */
  91808. constructor(radius?: number,
  91809. /**
  91810. * The min limit of the emission direction.
  91811. */
  91812. direction1?: Vector3,
  91813. /**
  91814. * The max limit of the emission direction.
  91815. */
  91816. direction2?: Vector3);
  91817. /**
  91818. * Called by the particle System when the direction is computed for the created particle.
  91819. * @param worldMatrix is the world matrix of the particle system
  91820. * @param directionToUpdate is the direction vector to update with the result
  91821. * @param particle is the particle we are computed the direction for
  91822. */
  91823. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91824. /**
  91825. * Clones the current emitter and returns a copy of it
  91826. * @returns the new emitter
  91827. */
  91828. clone(): SphereDirectedParticleEmitter;
  91829. /**
  91830. * Called by the GPUParticleSystem to setup the update shader
  91831. * @param effect defines the update shader
  91832. */
  91833. applyToShader(effect: Effect): void;
  91834. /**
  91835. * Returns a string to use to update the GPU particles update shader
  91836. * @returns a string containng the defines string
  91837. */
  91838. getEffectDefines(): string;
  91839. /**
  91840. * Returns the string "SphereDirectedParticleEmitter"
  91841. * @returns a string containing the class name
  91842. */
  91843. getClassName(): string;
  91844. /**
  91845. * Serializes the particle system to a JSON object.
  91846. * @returns the JSON object
  91847. */
  91848. serialize(): any;
  91849. /**
  91850. * Parse properties from a JSON object
  91851. * @param serializationObject defines the JSON object
  91852. */
  91853. parse(serializationObject: any): void;
  91854. }
  91855. }
  91856. declare module BABYLON {
  91857. /**
  91858. * Particle emitter emitting particles from a custom list of positions.
  91859. */
  91860. export class CustomParticleEmitter implements IParticleEmitterType {
  91861. /**
  91862. * Gets or sets the position generator that will create the inital position of each particle.
  91863. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91864. */
  91865. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91866. /**
  91867. * Gets or sets the destination generator that will create the final destination of each particle.
  91868. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91869. */
  91870. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91871. /**
  91872. * Creates a new instance CustomParticleEmitter
  91873. */
  91874. constructor();
  91875. /**
  91876. * Called by the particle System when the direction is computed for the created particle.
  91877. * @param worldMatrix is the world matrix of the particle system
  91878. * @param directionToUpdate is the direction vector to update with the result
  91879. * @param particle is the particle we are computed the direction for
  91880. * @param isLocal defines if the direction should be set in local space
  91881. */
  91882. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91883. /**
  91884. * Called by the particle System when the position is computed for the created particle.
  91885. * @param worldMatrix is the world matrix of the particle system
  91886. * @param positionToUpdate is the position vector to update with the result
  91887. * @param particle is the particle we are computed the position for
  91888. * @param isLocal defines if the position should be set in local space
  91889. */
  91890. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91891. /**
  91892. * Clones the current emitter and returns a copy of it
  91893. * @returns the new emitter
  91894. */
  91895. clone(): CustomParticleEmitter;
  91896. /**
  91897. * Called by the GPUParticleSystem to setup the update shader
  91898. * @param effect defines the update shader
  91899. */
  91900. applyToShader(effect: Effect): void;
  91901. /**
  91902. * Returns a string to use to update the GPU particles update shader
  91903. * @returns a string containng the defines string
  91904. */
  91905. getEffectDefines(): string;
  91906. /**
  91907. * Returns the string "PointParticleEmitter"
  91908. * @returns a string containing the class name
  91909. */
  91910. getClassName(): string;
  91911. /**
  91912. * Serializes the particle system to a JSON object.
  91913. * @returns the JSON object
  91914. */
  91915. serialize(): any;
  91916. /**
  91917. * Parse properties from a JSON object
  91918. * @param serializationObject defines the JSON object
  91919. */
  91920. parse(serializationObject: any): void;
  91921. }
  91922. }
  91923. declare module BABYLON {
  91924. /**
  91925. * Particle emitter emitting particles from the inside of a box.
  91926. * It emits the particles randomly between 2 given directions.
  91927. */
  91928. export class MeshParticleEmitter implements IParticleEmitterType {
  91929. private _indices;
  91930. private _positions;
  91931. private _normals;
  91932. private _storedNormal;
  91933. private _mesh;
  91934. /**
  91935. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91936. */
  91937. direction1: Vector3;
  91938. /**
  91939. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91940. */
  91941. direction2: Vector3;
  91942. /**
  91943. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  91944. */
  91945. useMeshNormalsForDirection: boolean;
  91946. /** Defines the mesh to use as source */
  91947. get mesh(): Nullable<AbstractMesh>;
  91948. set mesh(value: Nullable<AbstractMesh>);
  91949. /**
  91950. * Creates a new instance MeshParticleEmitter
  91951. * @param mesh defines the mesh to use as source
  91952. */
  91953. constructor(mesh?: Nullable<AbstractMesh>);
  91954. /**
  91955. * Called by the particle System when the direction is computed for the created particle.
  91956. * @param worldMatrix is the world matrix of the particle system
  91957. * @param directionToUpdate is the direction vector to update with the result
  91958. * @param particle is the particle we are computed the direction for
  91959. * @param isLocal defines if the direction should be set in local space
  91960. */
  91961. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91962. /**
  91963. * Called by the particle System when the position is computed for the created particle.
  91964. * @param worldMatrix is the world matrix of the particle system
  91965. * @param positionToUpdate is the position vector to update with the result
  91966. * @param particle is the particle we are computed the position for
  91967. * @param isLocal defines if the position should be set in local space
  91968. */
  91969. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91970. /**
  91971. * Clones the current emitter and returns a copy of it
  91972. * @returns the new emitter
  91973. */
  91974. clone(): MeshParticleEmitter;
  91975. /**
  91976. * Called by the GPUParticleSystem to setup the update shader
  91977. * @param effect defines the update shader
  91978. */
  91979. applyToShader(effect: Effect): void;
  91980. /**
  91981. * Returns a string to use to update the GPU particles update shader
  91982. * @returns a string containng the defines string
  91983. */
  91984. getEffectDefines(): string;
  91985. /**
  91986. * Returns the string "BoxParticleEmitter"
  91987. * @returns a string containing the class name
  91988. */
  91989. getClassName(): string;
  91990. /**
  91991. * Serializes the particle system to a JSON object.
  91992. * @returns the JSON object
  91993. */
  91994. serialize(): any;
  91995. /**
  91996. * Parse properties from a JSON object
  91997. * @param serializationObject defines the JSON object
  91998. * @param scene defines the hosting scene
  91999. */
  92000. parse(serializationObject: any, scene: Scene): void;
  92001. }
  92002. }
  92003. declare module BABYLON {
  92004. /**
  92005. * Interface representing a particle system in Babylon.js.
  92006. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92007. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92008. */
  92009. export interface IParticleSystem {
  92010. /**
  92011. * List of animations used by the particle system.
  92012. */
  92013. animations: Animation[];
  92014. /**
  92015. * The id of the Particle system.
  92016. */
  92017. id: string;
  92018. /**
  92019. * The name of the Particle system.
  92020. */
  92021. name: string;
  92022. /**
  92023. * The emitter represents the Mesh or position we are attaching the particle system to.
  92024. */
  92025. emitter: Nullable<AbstractMesh | Vector3>;
  92026. /**
  92027. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92028. */
  92029. isBillboardBased: boolean;
  92030. /**
  92031. * The rendering group used by the Particle system to chose when to render.
  92032. */
  92033. renderingGroupId: number;
  92034. /**
  92035. * The layer mask we are rendering the particles through.
  92036. */
  92037. layerMask: number;
  92038. /**
  92039. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92040. */
  92041. updateSpeed: number;
  92042. /**
  92043. * The amount of time the particle system is running (depends of the overall update speed).
  92044. */
  92045. targetStopDuration: number;
  92046. /**
  92047. * The texture used to render each particle. (this can be a spritesheet)
  92048. */
  92049. particleTexture: Nullable<Texture>;
  92050. /**
  92051. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92052. */
  92053. blendMode: number;
  92054. /**
  92055. * Minimum life time of emitting particles.
  92056. */
  92057. minLifeTime: number;
  92058. /**
  92059. * Maximum life time of emitting particles.
  92060. */
  92061. maxLifeTime: number;
  92062. /**
  92063. * Minimum Size of emitting particles.
  92064. */
  92065. minSize: number;
  92066. /**
  92067. * Maximum Size of emitting particles.
  92068. */
  92069. maxSize: number;
  92070. /**
  92071. * Minimum scale of emitting particles on X axis.
  92072. */
  92073. minScaleX: number;
  92074. /**
  92075. * Maximum scale of emitting particles on X axis.
  92076. */
  92077. maxScaleX: number;
  92078. /**
  92079. * Minimum scale of emitting particles on Y axis.
  92080. */
  92081. minScaleY: number;
  92082. /**
  92083. * Maximum scale of emitting particles on Y axis.
  92084. */
  92085. maxScaleY: number;
  92086. /**
  92087. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92088. */
  92089. color1: Color4;
  92090. /**
  92091. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92092. */
  92093. color2: Color4;
  92094. /**
  92095. * Color the particle will have at the end of its lifetime.
  92096. */
  92097. colorDead: Color4;
  92098. /**
  92099. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  92100. */
  92101. emitRate: number;
  92102. /**
  92103. * You can use gravity if you want to give an orientation to your particles.
  92104. */
  92105. gravity: Vector3;
  92106. /**
  92107. * Minimum power of emitting particles.
  92108. */
  92109. minEmitPower: number;
  92110. /**
  92111. * Maximum power of emitting particles.
  92112. */
  92113. maxEmitPower: number;
  92114. /**
  92115. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92116. */
  92117. minAngularSpeed: number;
  92118. /**
  92119. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92120. */
  92121. maxAngularSpeed: number;
  92122. /**
  92123. * Gets or sets the minimal initial rotation in radians.
  92124. */
  92125. minInitialRotation: number;
  92126. /**
  92127. * Gets or sets the maximal initial rotation in radians.
  92128. */
  92129. maxInitialRotation: number;
  92130. /**
  92131. * The particle emitter type defines the emitter used by the particle system.
  92132. * It can be for example box, sphere, or cone...
  92133. */
  92134. particleEmitterType: Nullable<IParticleEmitterType>;
  92135. /**
  92136. * Defines the delay in milliseconds before starting the system (0 by default)
  92137. */
  92138. startDelay: number;
  92139. /**
  92140. * 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
  92141. */
  92142. preWarmCycles: number;
  92143. /**
  92144. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  92145. */
  92146. preWarmStepOffset: number;
  92147. /**
  92148. * 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)
  92149. */
  92150. spriteCellChangeSpeed: number;
  92151. /**
  92152. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92153. */
  92154. startSpriteCellID: number;
  92155. /**
  92156. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92157. */
  92158. endSpriteCellID: number;
  92159. /**
  92160. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92161. */
  92162. spriteCellWidth: number;
  92163. /**
  92164. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92165. */
  92166. spriteCellHeight: number;
  92167. /**
  92168. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92169. */
  92170. spriteRandomStartCell: boolean;
  92171. /**
  92172. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  92173. */
  92174. isAnimationSheetEnabled: boolean;
  92175. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92176. translationPivot: Vector2;
  92177. /**
  92178. * Gets or sets a texture used to add random noise to particle positions
  92179. */
  92180. noiseTexture: Nullable<BaseTexture>;
  92181. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92182. noiseStrength: Vector3;
  92183. /**
  92184. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92185. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92186. */
  92187. billboardMode: number;
  92188. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92189. limitVelocityDamping: number;
  92190. /**
  92191. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92192. */
  92193. beginAnimationOnStart: boolean;
  92194. /**
  92195. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92196. */
  92197. beginAnimationFrom: number;
  92198. /**
  92199. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92200. */
  92201. beginAnimationTo: number;
  92202. /**
  92203. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92204. */
  92205. beginAnimationLoop: boolean;
  92206. /**
  92207. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92208. */
  92209. disposeOnStop: boolean;
  92210. /**
  92211. * Specifies if the particles are updated in emitter local space or world space
  92212. */
  92213. isLocal: boolean;
  92214. /** Snippet ID if the particle system was created from the snippet server */
  92215. snippetId: string;
  92216. /**
  92217. * Gets the maximum number of particles active at the same time.
  92218. * @returns The max number of active particles.
  92219. */
  92220. getCapacity(): number;
  92221. /**
  92222. * Gets the number of particles active at the same time.
  92223. * @returns The number of active particles.
  92224. */
  92225. getActiveCount(): number;
  92226. /**
  92227. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92228. * @returns True if it has been started, otherwise false.
  92229. */
  92230. isStarted(): boolean;
  92231. /**
  92232. * Animates the particle system for this frame.
  92233. */
  92234. animate(): void;
  92235. /**
  92236. * Renders the particle system in its current state.
  92237. * @returns the current number of particles
  92238. */
  92239. render(): number;
  92240. /**
  92241. * Dispose the particle system and frees its associated resources.
  92242. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92243. */
  92244. dispose(disposeTexture?: boolean): void;
  92245. /**
  92246. * An event triggered when the system is disposed
  92247. */
  92248. onDisposeObservable: Observable<IParticleSystem>;
  92249. /**
  92250. * Clones the particle system.
  92251. * @param name The name of the cloned object
  92252. * @param newEmitter The new emitter to use
  92253. * @returns the cloned particle system
  92254. */
  92255. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  92256. /**
  92257. * Serializes the particle system to a JSON object
  92258. * @param serializeTexture defines if the texture must be serialized as well
  92259. * @returns the JSON object
  92260. */
  92261. serialize(serializeTexture: boolean): any;
  92262. /**
  92263. * Rebuild the particle system
  92264. */
  92265. rebuild(): void;
  92266. /** Force the system to rebuild all gradients that need to be resync */
  92267. forceRefreshGradients(): void;
  92268. /**
  92269. * Starts the particle system and begins to emit
  92270. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  92271. */
  92272. start(delay?: number): void;
  92273. /**
  92274. * Stops the particle system.
  92275. */
  92276. stop(): void;
  92277. /**
  92278. * Remove all active particles
  92279. */
  92280. reset(): void;
  92281. /**
  92282. * Gets a boolean indicating that the system is stopping
  92283. * @returns true if the system is currently stopping
  92284. */
  92285. isStopping(): boolean;
  92286. /**
  92287. * Is this system ready to be used/rendered
  92288. * @return true if the system is ready
  92289. */
  92290. isReady(): boolean;
  92291. /**
  92292. * Returns the string "ParticleSystem"
  92293. * @returns a string containing the class name
  92294. */
  92295. getClassName(): string;
  92296. /**
  92297. * Gets the custom effect used to render the particles
  92298. * @param blendMode Blend mode for which the effect should be retrieved
  92299. * @returns The effect
  92300. */
  92301. getCustomEffect(blendMode: number): Nullable<Effect>;
  92302. /**
  92303. * Sets the custom effect used to render the particles
  92304. * @param effect The effect to set
  92305. * @param blendMode Blend mode for which the effect should be set
  92306. */
  92307. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  92308. /**
  92309. * Fill the defines array according to the current settings of the particle system
  92310. * @param defines Array to be updated
  92311. * @param blendMode blend mode to take into account when updating the array
  92312. */
  92313. fillDefines(defines: Array<string>, blendMode: number): void;
  92314. /**
  92315. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92316. * @param uniforms Uniforms array to fill
  92317. * @param attributes Attributes array to fill
  92318. * @param samplers Samplers array to fill
  92319. */
  92320. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92321. /**
  92322. * Observable that will be called just before the particles are drawn
  92323. */
  92324. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  92325. /**
  92326. * Gets the name of the particle vertex shader
  92327. */
  92328. vertexShaderName: string;
  92329. /**
  92330. * Adds a new color gradient
  92331. * @param gradient defines the gradient to use (between 0 and 1)
  92332. * @param color1 defines the color to affect to the specified gradient
  92333. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92334. * @returns the current particle system
  92335. */
  92336. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92337. /**
  92338. * Remove a specific color gradient
  92339. * @param gradient defines the gradient to remove
  92340. * @returns the current particle system
  92341. */
  92342. removeColorGradient(gradient: number): IParticleSystem;
  92343. /**
  92344. * Adds a new size gradient
  92345. * @param gradient defines the gradient to use (between 0 and 1)
  92346. * @param factor defines the size factor to affect to the specified gradient
  92347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92348. * @returns the current particle system
  92349. */
  92350. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92351. /**
  92352. * Remove a specific size gradient
  92353. * @param gradient defines the gradient to remove
  92354. * @returns the current particle system
  92355. */
  92356. removeSizeGradient(gradient: number): IParticleSystem;
  92357. /**
  92358. * Gets the current list of color gradients.
  92359. * You must use addColorGradient and removeColorGradient to udpate this list
  92360. * @returns the list of color gradients
  92361. */
  92362. getColorGradients(): Nullable<Array<ColorGradient>>;
  92363. /**
  92364. * Gets the current list of size gradients.
  92365. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92366. * @returns the list of size gradients
  92367. */
  92368. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92369. /**
  92370. * Gets the current list of angular speed gradients.
  92371. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92372. * @returns the list of angular speed gradients
  92373. */
  92374. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92375. /**
  92376. * Adds a new angular speed gradient
  92377. * @param gradient defines the gradient to use (between 0 and 1)
  92378. * @param factor defines the angular speed to affect to the specified gradient
  92379. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92380. * @returns the current particle system
  92381. */
  92382. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92383. /**
  92384. * Remove a specific angular speed gradient
  92385. * @param gradient defines the gradient to remove
  92386. * @returns the current particle system
  92387. */
  92388. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92389. /**
  92390. * Gets the current list of velocity gradients.
  92391. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92392. * @returns the list of velocity gradients
  92393. */
  92394. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92395. /**
  92396. * Adds a new velocity gradient
  92397. * @param gradient defines the gradient to use (between 0 and 1)
  92398. * @param factor defines the velocity to affect to the specified gradient
  92399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92400. * @returns the current particle system
  92401. */
  92402. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92403. /**
  92404. * Remove a specific velocity gradient
  92405. * @param gradient defines the gradient to remove
  92406. * @returns the current particle system
  92407. */
  92408. removeVelocityGradient(gradient: number): IParticleSystem;
  92409. /**
  92410. * Gets the current list of limit velocity gradients.
  92411. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92412. * @returns the list of limit velocity gradients
  92413. */
  92414. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92415. /**
  92416. * Adds a new limit velocity gradient
  92417. * @param gradient defines the gradient to use (between 0 and 1)
  92418. * @param factor defines the limit velocity to affect to the specified gradient
  92419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92420. * @returns the current particle system
  92421. */
  92422. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92423. /**
  92424. * Remove a specific limit velocity gradient
  92425. * @param gradient defines the gradient to remove
  92426. * @returns the current particle system
  92427. */
  92428. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92429. /**
  92430. * Adds a new drag gradient
  92431. * @param gradient defines the gradient to use (between 0 and 1)
  92432. * @param factor defines the drag to affect to the specified gradient
  92433. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92434. * @returns the current particle system
  92435. */
  92436. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92437. /**
  92438. * Remove a specific drag gradient
  92439. * @param gradient defines the gradient to remove
  92440. * @returns the current particle system
  92441. */
  92442. removeDragGradient(gradient: number): IParticleSystem;
  92443. /**
  92444. * Gets the current list of drag gradients.
  92445. * You must use addDragGradient and removeDragGradient to udpate this list
  92446. * @returns the list of drag gradients
  92447. */
  92448. getDragGradients(): Nullable<Array<FactorGradient>>;
  92449. /**
  92450. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92451. * @param gradient defines the gradient to use (between 0 and 1)
  92452. * @param factor defines the emit rate to affect to the specified gradient
  92453. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92454. * @returns the current particle system
  92455. */
  92456. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92457. /**
  92458. * Remove a specific emit rate gradient
  92459. * @param gradient defines the gradient to remove
  92460. * @returns the current particle system
  92461. */
  92462. removeEmitRateGradient(gradient: number): IParticleSystem;
  92463. /**
  92464. * Gets the current list of emit rate gradients.
  92465. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92466. * @returns the list of emit rate gradients
  92467. */
  92468. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92469. /**
  92470. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92471. * @param gradient defines the gradient to use (between 0 and 1)
  92472. * @param factor defines the start size to affect to the specified gradient
  92473. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92474. * @returns the current particle system
  92475. */
  92476. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92477. /**
  92478. * Remove a specific start size gradient
  92479. * @param gradient defines the gradient to remove
  92480. * @returns the current particle system
  92481. */
  92482. removeStartSizeGradient(gradient: number): IParticleSystem;
  92483. /**
  92484. * Gets the current list of start size gradients.
  92485. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92486. * @returns the list of start size gradients
  92487. */
  92488. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92489. /**
  92490. * Adds a new life time gradient
  92491. * @param gradient defines the gradient to use (between 0 and 1)
  92492. * @param factor defines the life time factor to affect to the specified gradient
  92493. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92494. * @returns the current particle system
  92495. */
  92496. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92497. /**
  92498. * Remove a specific life time gradient
  92499. * @param gradient defines the gradient to remove
  92500. * @returns the current particle system
  92501. */
  92502. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92503. /**
  92504. * Gets the current list of life time gradients.
  92505. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92506. * @returns the list of life time gradients
  92507. */
  92508. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92509. /**
  92510. * Gets the current list of color gradients.
  92511. * You must use addColorGradient and removeColorGradient to udpate this list
  92512. * @returns the list of color gradients
  92513. */
  92514. getColorGradients(): Nullable<Array<ColorGradient>>;
  92515. /**
  92516. * Adds a new ramp gradient used to remap particle colors
  92517. * @param gradient defines the gradient to use (between 0 and 1)
  92518. * @param color defines the color to affect to the specified gradient
  92519. * @returns the current particle system
  92520. */
  92521. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  92522. /**
  92523. * Gets the current list of ramp gradients.
  92524. * You must use addRampGradient and removeRampGradient to udpate this list
  92525. * @returns the list of ramp gradients
  92526. */
  92527. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92528. /** Gets or sets a boolean indicating that ramp gradients must be used
  92529. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92530. */
  92531. useRampGradients: boolean;
  92532. /**
  92533. * Adds a new color remap gradient
  92534. * @param gradient defines the gradient to use (between 0 and 1)
  92535. * @param min defines the color remap minimal range
  92536. * @param max defines the color remap maximal range
  92537. * @returns the current particle system
  92538. */
  92539. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92540. /**
  92541. * Gets the current list of color remap gradients.
  92542. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92543. * @returns the list of color remap gradients
  92544. */
  92545. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92546. /**
  92547. * Adds a new alpha remap gradient
  92548. * @param gradient defines the gradient to use (between 0 and 1)
  92549. * @param min defines the alpha remap minimal range
  92550. * @param max defines the alpha remap maximal range
  92551. * @returns the current particle system
  92552. */
  92553. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92554. /**
  92555. * Gets the current list of alpha remap gradients.
  92556. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92557. * @returns the list of alpha remap gradients
  92558. */
  92559. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92560. /**
  92561. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92562. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92563. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92564. * @returns the emitter
  92565. */
  92566. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92567. /**
  92568. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92569. * @param radius The radius of the hemisphere to emit from
  92570. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92571. * @returns the emitter
  92572. */
  92573. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92574. /**
  92575. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92576. * @param radius The radius of the sphere to emit from
  92577. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92578. * @returns the emitter
  92579. */
  92580. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92581. /**
  92582. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92583. * @param radius The radius of the sphere to emit from
  92584. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92585. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92586. * @returns the emitter
  92587. */
  92588. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92589. /**
  92590. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92591. * @param radius The radius of the emission cylinder
  92592. * @param height The height of the emission cylinder
  92593. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92594. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92595. * @returns the emitter
  92596. */
  92597. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92598. /**
  92599. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92600. * @param radius The radius of the cylinder to emit from
  92601. * @param height The height of the emission cylinder
  92602. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92603. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92604. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92605. * @returns the emitter
  92606. */
  92607. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92608. /**
  92609. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92610. * @param radius The radius of the cone to emit from
  92611. * @param angle The base angle of the cone
  92612. * @returns the emitter
  92613. */
  92614. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92615. /**
  92616. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92617. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92618. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92619. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92620. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92621. * @returns the emitter
  92622. */
  92623. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92624. /**
  92625. * Get hosting scene
  92626. * @returns the scene
  92627. */
  92628. getScene(): Scene;
  92629. }
  92630. }
  92631. declare module BABYLON {
  92632. /**
  92633. * 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.
  92634. * @see https://doc.babylonjs.com/how_to/transformnode
  92635. */
  92636. export class TransformNode extends Node {
  92637. /**
  92638. * Object will not rotate to face the camera
  92639. */
  92640. static BILLBOARDMODE_NONE: number;
  92641. /**
  92642. * Object will rotate to face the camera but only on the x axis
  92643. */
  92644. static BILLBOARDMODE_X: number;
  92645. /**
  92646. * Object will rotate to face the camera but only on the y axis
  92647. */
  92648. static BILLBOARDMODE_Y: number;
  92649. /**
  92650. * Object will rotate to face the camera but only on the z axis
  92651. */
  92652. static BILLBOARDMODE_Z: number;
  92653. /**
  92654. * Object will rotate to face the camera
  92655. */
  92656. static BILLBOARDMODE_ALL: number;
  92657. /**
  92658. * Object will rotate to face the camera's position instead of orientation
  92659. */
  92660. static BILLBOARDMODE_USE_POSITION: number;
  92661. private static _TmpRotation;
  92662. private static _TmpScaling;
  92663. private static _TmpTranslation;
  92664. private _forward;
  92665. private _forwardInverted;
  92666. private _up;
  92667. private _right;
  92668. private _rightInverted;
  92669. private _position;
  92670. private _rotation;
  92671. private _rotationQuaternion;
  92672. protected _scaling: Vector3;
  92673. protected _isDirty: boolean;
  92674. private _transformToBoneReferal;
  92675. private _isAbsoluteSynced;
  92676. private _billboardMode;
  92677. /**
  92678. * Gets or sets the billboard mode. Default is 0.
  92679. *
  92680. * | Value | Type | Description |
  92681. * | --- | --- | --- |
  92682. * | 0 | BILLBOARDMODE_NONE | |
  92683. * | 1 | BILLBOARDMODE_X | |
  92684. * | 2 | BILLBOARDMODE_Y | |
  92685. * | 4 | BILLBOARDMODE_Z | |
  92686. * | 7 | BILLBOARDMODE_ALL | |
  92687. *
  92688. */
  92689. get billboardMode(): number;
  92690. set billboardMode(value: number);
  92691. private _preserveParentRotationForBillboard;
  92692. /**
  92693. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  92694. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  92695. */
  92696. get preserveParentRotationForBillboard(): boolean;
  92697. set preserveParentRotationForBillboard(value: boolean);
  92698. /**
  92699. * 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
  92700. */
  92701. scalingDeterminant: number;
  92702. private _infiniteDistance;
  92703. /**
  92704. * Gets or sets the distance of the object to max, often used by skybox
  92705. */
  92706. get infiniteDistance(): boolean;
  92707. set infiniteDistance(value: boolean);
  92708. /**
  92709. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92710. * By default the system will update normals to compensate
  92711. */
  92712. ignoreNonUniformScaling: boolean;
  92713. /**
  92714. * 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
  92715. */
  92716. reIntegrateRotationIntoRotationQuaternion: boolean;
  92717. /** @hidden */
  92718. _poseMatrix: Nullable<Matrix>;
  92719. /** @hidden */
  92720. _localMatrix: Matrix;
  92721. private _usePivotMatrix;
  92722. private _absolutePosition;
  92723. private _absoluteScaling;
  92724. private _absoluteRotationQuaternion;
  92725. private _pivotMatrix;
  92726. private _pivotMatrixInverse;
  92727. protected _postMultiplyPivotMatrix: boolean;
  92728. protected _isWorldMatrixFrozen: boolean;
  92729. /** @hidden */
  92730. _indexInSceneTransformNodesArray: number;
  92731. /**
  92732. * An event triggered after the world matrix is updated
  92733. */
  92734. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  92735. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  92736. /**
  92737. * Gets a string identifying the name of the class
  92738. * @returns "TransformNode" string
  92739. */
  92740. getClassName(): string;
  92741. /**
  92742. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92743. */
  92744. get position(): Vector3;
  92745. set position(newPosition: Vector3);
  92746. /**
  92747. * 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)).
  92748. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92749. */
  92750. get rotation(): Vector3;
  92751. set rotation(newRotation: Vector3);
  92752. /**
  92753. * 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)).
  92754. */
  92755. get scaling(): Vector3;
  92756. set scaling(newScaling: Vector3);
  92757. /**
  92758. * 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).
  92759. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92760. */
  92761. get rotationQuaternion(): Nullable<Quaternion>;
  92762. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  92763. /**
  92764. * The forward direction of that transform in world space.
  92765. */
  92766. get forward(): Vector3;
  92767. /**
  92768. * The up direction of that transform in world space.
  92769. */
  92770. get up(): Vector3;
  92771. /**
  92772. * The right direction of that transform in world space.
  92773. */
  92774. get right(): Vector3;
  92775. /**
  92776. * Copies the parameter passed Matrix into the mesh Pose matrix.
  92777. * @param matrix the matrix to copy the pose from
  92778. * @returns this TransformNode.
  92779. */
  92780. updatePoseMatrix(matrix: Matrix): TransformNode;
  92781. /**
  92782. * Returns the mesh Pose matrix.
  92783. * @returns the pose matrix
  92784. */
  92785. getPoseMatrix(): Matrix;
  92786. /** @hidden */
  92787. _isSynchronized(): boolean;
  92788. /** @hidden */
  92789. _initCache(): void;
  92790. /**
  92791. * Flag the transform node as dirty (Forcing it to update everything)
  92792. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  92793. * @returns this transform node
  92794. */
  92795. markAsDirty(property: string): TransformNode;
  92796. /**
  92797. * Returns the current mesh absolute position.
  92798. * Returns a Vector3.
  92799. */
  92800. get absolutePosition(): Vector3;
  92801. /**
  92802. * Returns the current mesh absolute scaling.
  92803. * Returns a Vector3.
  92804. */
  92805. get absoluteScaling(): Vector3;
  92806. /**
  92807. * Returns the current mesh absolute rotation.
  92808. * Returns a Quaternion.
  92809. */
  92810. get absoluteRotationQuaternion(): Quaternion;
  92811. /**
  92812. * Sets a new matrix to apply before all other transformation
  92813. * @param matrix defines the transform matrix
  92814. * @returns the current TransformNode
  92815. */
  92816. setPreTransformMatrix(matrix: Matrix): TransformNode;
  92817. /**
  92818. * Sets a new pivot matrix to the current node
  92819. * @param matrix defines the new pivot matrix to use
  92820. * @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
  92821. * @returns the current TransformNode
  92822. */
  92823. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  92824. /**
  92825. * Returns the mesh pivot matrix.
  92826. * Default : Identity.
  92827. * @returns the matrix
  92828. */
  92829. getPivotMatrix(): Matrix;
  92830. /**
  92831. * Instantiate (when possible) or clone that node with its hierarchy
  92832. * @param newParent defines the new parent to use for the instance (or clone)
  92833. * @param options defines options to configure how copy is done
  92834. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  92835. * @returns an instance (or a clone) of the current node with its hiearchy
  92836. */
  92837. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92838. doNotInstantiate: boolean;
  92839. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92840. /**
  92841. * Prevents the World matrix to be computed any longer
  92842. * @param newWorldMatrix defines an optional matrix to use as world matrix
  92843. * @returns the TransformNode.
  92844. */
  92845. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  92846. /**
  92847. * Allows back the World matrix computation.
  92848. * @returns the TransformNode.
  92849. */
  92850. unfreezeWorldMatrix(): this;
  92851. /**
  92852. * True if the World matrix has been frozen.
  92853. */
  92854. get isWorldMatrixFrozen(): boolean;
  92855. /**
  92856. * Retuns the mesh absolute position in the World.
  92857. * @returns a Vector3.
  92858. */
  92859. getAbsolutePosition(): Vector3;
  92860. /**
  92861. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  92862. * @param absolutePosition the absolute position to set
  92863. * @returns the TransformNode.
  92864. */
  92865. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92866. /**
  92867. * Sets the mesh position in its local space.
  92868. * @param vector3 the position to set in localspace
  92869. * @returns the TransformNode.
  92870. */
  92871. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  92872. /**
  92873. * Returns the mesh position in the local space from the current World matrix values.
  92874. * @returns a new Vector3.
  92875. */
  92876. getPositionExpressedInLocalSpace(): Vector3;
  92877. /**
  92878. * Translates the mesh along the passed Vector3 in its local space.
  92879. * @param vector3 the distance to translate in localspace
  92880. * @returns the TransformNode.
  92881. */
  92882. locallyTranslate(vector3: Vector3): TransformNode;
  92883. private static _lookAtVectorCache;
  92884. /**
  92885. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  92886. * @param targetPoint the position (must be in same space as current mesh) to look at
  92887. * @param yawCor optional yaw (y-axis) correction in radians
  92888. * @param pitchCor optional pitch (x-axis) correction in radians
  92889. * @param rollCor optional roll (z-axis) correction in radians
  92890. * @param space the choosen space of the target
  92891. * @returns the TransformNode.
  92892. */
  92893. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  92894. /**
  92895. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92896. * This Vector3 is expressed in the World space.
  92897. * @param localAxis axis to rotate
  92898. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92899. */
  92900. getDirection(localAxis: Vector3): Vector3;
  92901. /**
  92902. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  92903. * localAxis is expressed in the mesh local space.
  92904. * result is computed in the Wordl space from the mesh World matrix.
  92905. * @param localAxis axis to rotate
  92906. * @param result the resulting transformnode
  92907. * @returns this TransformNode.
  92908. */
  92909. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  92910. /**
  92911. * Sets this transform node rotation to the given local axis.
  92912. * @param localAxis the axis in local space
  92913. * @param yawCor optional yaw (y-axis) correction in radians
  92914. * @param pitchCor optional pitch (x-axis) correction in radians
  92915. * @param rollCor optional roll (z-axis) correction in radians
  92916. * @returns this TransformNode
  92917. */
  92918. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  92919. /**
  92920. * Sets a new pivot point to the current node
  92921. * @param point defines the new pivot point to use
  92922. * @param space defines if the point is in world or local space (local by default)
  92923. * @returns the current TransformNode
  92924. */
  92925. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  92926. /**
  92927. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  92928. * @returns the pivot point
  92929. */
  92930. getPivotPoint(): Vector3;
  92931. /**
  92932. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  92933. * @param result the vector3 to store the result
  92934. * @returns this TransformNode.
  92935. */
  92936. getPivotPointToRef(result: Vector3): TransformNode;
  92937. /**
  92938. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92939. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92940. */
  92941. getAbsolutePivotPoint(): Vector3;
  92942. /**
  92943. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92944. * @param result vector3 to store the result
  92945. * @returns this TransformNode.
  92946. */
  92947. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  92948. /**
  92949. * Defines the passed node as the parent of the current node.
  92950. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92951. * @see https://doc.babylonjs.com/how_to/parenting
  92952. * @param node the node ot set as the parent
  92953. * @returns this TransformNode.
  92954. */
  92955. setParent(node: Nullable<Node>): TransformNode;
  92956. private _nonUniformScaling;
  92957. /**
  92958. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92959. */
  92960. get nonUniformScaling(): boolean;
  92961. /** @hidden */
  92962. _updateNonUniformScalingState(value: boolean): boolean;
  92963. /**
  92964. * Attach the current TransformNode to another TransformNode associated with a bone
  92965. * @param bone Bone affecting the TransformNode
  92966. * @param affectedTransformNode TransformNode associated with the bone
  92967. * @returns this object
  92968. */
  92969. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92970. /**
  92971. * Detach the transform node if its associated with a bone
  92972. * @returns this object
  92973. */
  92974. detachFromBone(): TransformNode;
  92975. private static _rotationAxisCache;
  92976. /**
  92977. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92978. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92979. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92980. * The passed axis is also normalized.
  92981. * @param axis the axis to rotate around
  92982. * @param amount the amount to rotate in radians
  92983. * @param space Space to rotate in (Default: local)
  92984. * @returns the TransformNode.
  92985. */
  92986. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92987. /**
  92988. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92989. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92990. * The passed axis is also normalized. .
  92991. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92992. * @param point the point to rotate around
  92993. * @param axis the axis to rotate around
  92994. * @param amount the amount to rotate in radians
  92995. * @returns the TransformNode
  92996. */
  92997. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  92998. /**
  92999. * Translates the mesh along the axis vector for the passed distance in the given space.
  93000. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93001. * @param axis the axis to translate in
  93002. * @param distance the distance to translate
  93003. * @param space Space to rotate in (Default: local)
  93004. * @returns the TransformNode.
  93005. */
  93006. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93007. /**
  93008. * Adds a rotation step to the mesh current rotation.
  93009. * x, y, z are Euler angles expressed in radians.
  93010. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93011. * This means this rotation is made in the mesh local space only.
  93012. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93013. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93014. * ```javascript
  93015. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93016. * ```
  93017. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93018. * 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.
  93019. * @param x Rotation to add
  93020. * @param y Rotation to add
  93021. * @param z Rotation to add
  93022. * @returns the TransformNode.
  93023. */
  93024. addRotation(x: number, y: number, z: number): TransformNode;
  93025. /**
  93026. * @hidden
  93027. */
  93028. protected _getEffectiveParent(): Nullable<Node>;
  93029. /**
  93030. * Computes the world matrix of the node
  93031. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93032. * @returns the world matrix
  93033. */
  93034. computeWorldMatrix(force?: boolean): Matrix;
  93035. /**
  93036. * Resets this nodeTransform's local matrix to Matrix.Identity().
  93037. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  93038. */
  93039. resetLocalMatrix(independentOfChildren?: boolean): void;
  93040. protected _afterComputeWorldMatrix(): void;
  93041. /**
  93042. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93043. * @param func callback function to add
  93044. *
  93045. * @returns the TransformNode.
  93046. */
  93047. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93048. /**
  93049. * Removes a registered callback function.
  93050. * @param func callback function to remove
  93051. * @returns the TransformNode.
  93052. */
  93053. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93054. /**
  93055. * Gets the position of the current mesh in camera space
  93056. * @param camera defines the camera to use
  93057. * @returns a position
  93058. */
  93059. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  93060. /**
  93061. * Returns the distance from the mesh to the active camera
  93062. * @param camera defines the camera to use
  93063. * @returns the distance
  93064. */
  93065. getDistanceToCamera(camera?: Nullable<Camera>): number;
  93066. /**
  93067. * Clone the current transform node
  93068. * @param name Name of the new clone
  93069. * @param newParent New parent for the clone
  93070. * @param doNotCloneChildren Do not clone children hierarchy
  93071. * @returns the new transform node
  93072. */
  93073. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  93074. /**
  93075. * Serializes the objects information.
  93076. * @param currentSerializationObject defines the object to serialize in
  93077. * @returns the serialized object
  93078. */
  93079. serialize(currentSerializationObject?: any): any;
  93080. /**
  93081. * Returns a new TransformNode object parsed from the source provided.
  93082. * @param parsedTransformNode is the source.
  93083. * @param scene the scne the object belongs to
  93084. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93085. * @returns a new TransformNode object parsed from the source provided.
  93086. */
  93087. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  93088. /**
  93089. * Get all child-transformNodes of this node
  93090. * @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
  93091. * @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
  93092. * @returns an array of TransformNode
  93093. */
  93094. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  93095. /**
  93096. * Releases resources associated with this transform node.
  93097. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93098. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93099. */
  93100. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93101. /**
  93102. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93103. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93104. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93105. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93106. * @returns the current mesh
  93107. */
  93108. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  93109. private _syncAbsoluteScalingAndRotation;
  93110. }
  93111. }
  93112. declare module BABYLON {
  93113. /**
  93114. * Class used to override all child animations of a given target
  93115. */
  93116. export class AnimationPropertiesOverride {
  93117. /**
  93118. * Gets or sets a value indicating if animation blending must be used
  93119. */
  93120. enableBlending: boolean;
  93121. /**
  93122. * Gets or sets the blending speed to use when enableBlending is true
  93123. */
  93124. blendingSpeed: number;
  93125. /**
  93126. * Gets or sets the default loop mode to use
  93127. */
  93128. loopMode: number;
  93129. }
  93130. }
  93131. declare module BABYLON {
  93132. /**
  93133. * Class used to store bone information
  93134. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93135. */
  93136. export class Bone extends Node {
  93137. /**
  93138. * defines the bone name
  93139. */
  93140. name: string;
  93141. private static _tmpVecs;
  93142. private static _tmpQuat;
  93143. private static _tmpMats;
  93144. /**
  93145. * Gets the list of child bones
  93146. */
  93147. children: Bone[];
  93148. /** Gets the animations associated with this bone */
  93149. animations: Animation[];
  93150. /**
  93151. * Gets or sets bone length
  93152. */
  93153. length: number;
  93154. /**
  93155. * @hidden Internal only
  93156. * Set this value to map this bone to a different index in the transform matrices
  93157. * Set this value to -1 to exclude the bone from the transform matrices
  93158. */
  93159. _index: Nullable<number>;
  93160. private _skeleton;
  93161. private _localMatrix;
  93162. private _restPose;
  93163. private _baseMatrix;
  93164. private _absoluteTransform;
  93165. private _invertedAbsoluteTransform;
  93166. private _parent;
  93167. private _scalingDeterminant;
  93168. private _worldTransform;
  93169. private _localScaling;
  93170. private _localRotation;
  93171. private _localPosition;
  93172. private _needToDecompose;
  93173. private _needToCompose;
  93174. /** @hidden */
  93175. _linkedTransformNode: Nullable<TransformNode>;
  93176. /** @hidden */
  93177. _waitingTransformNodeId: Nullable<string>;
  93178. /** @hidden */
  93179. get _matrix(): Matrix;
  93180. /** @hidden */
  93181. set _matrix(value: Matrix);
  93182. /**
  93183. * Create a new bone
  93184. * @param name defines the bone name
  93185. * @param skeleton defines the parent skeleton
  93186. * @param parentBone defines the parent (can be null if the bone is the root)
  93187. * @param localMatrix defines the local matrix
  93188. * @param restPose defines the rest pose matrix
  93189. * @param baseMatrix defines the base matrix
  93190. * @param index defines index of the bone in the hiearchy
  93191. */
  93192. constructor(
  93193. /**
  93194. * defines the bone name
  93195. */
  93196. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  93197. /**
  93198. * Gets the current object class name.
  93199. * @return the class name
  93200. */
  93201. getClassName(): string;
  93202. /**
  93203. * Gets the parent skeleton
  93204. * @returns a skeleton
  93205. */
  93206. getSkeleton(): Skeleton;
  93207. /**
  93208. * Gets parent bone
  93209. * @returns a bone or null if the bone is the root of the bone hierarchy
  93210. */
  93211. getParent(): Nullable<Bone>;
  93212. /**
  93213. * Returns an array containing the root bones
  93214. * @returns an array containing the root bones
  93215. */
  93216. getChildren(): Array<Bone>;
  93217. /**
  93218. * Gets the node index in matrix array generated for rendering
  93219. * @returns the node index
  93220. */
  93221. getIndex(): number;
  93222. /**
  93223. * Sets the parent bone
  93224. * @param parent defines the parent (can be null if the bone is the root)
  93225. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93226. */
  93227. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  93228. /**
  93229. * Gets the local matrix
  93230. * @returns a matrix
  93231. */
  93232. getLocalMatrix(): Matrix;
  93233. /**
  93234. * Gets the base matrix (initial matrix which remains unchanged)
  93235. * @returns a matrix
  93236. */
  93237. getBaseMatrix(): Matrix;
  93238. /**
  93239. * Gets the rest pose matrix
  93240. * @returns a matrix
  93241. */
  93242. getRestPose(): Matrix;
  93243. /**
  93244. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  93245. */
  93246. getWorldMatrix(): Matrix;
  93247. /**
  93248. * Sets the local matrix to rest pose matrix
  93249. */
  93250. returnToRest(): void;
  93251. /**
  93252. * Gets the inverse of the absolute transform matrix.
  93253. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  93254. * @returns a matrix
  93255. */
  93256. getInvertedAbsoluteTransform(): Matrix;
  93257. /**
  93258. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  93259. * @returns a matrix
  93260. */
  93261. getAbsoluteTransform(): Matrix;
  93262. /**
  93263. * Links with the given transform node.
  93264. * The local matrix of this bone is copied from the transform node every frame.
  93265. * @param transformNode defines the transform node to link to
  93266. */
  93267. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  93268. /**
  93269. * Gets the node used to drive the bone's transformation
  93270. * @returns a transform node or null
  93271. */
  93272. getTransformNode(): Nullable<TransformNode>;
  93273. /** Gets or sets current position (in local space) */
  93274. get position(): Vector3;
  93275. set position(newPosition: Vector3);
  93276. /** Gets or sets current rotation (in local space) */
  93277. get rotation(): Vector3;
  93278. set rotation(newRotation: Vector3);
  93279. /** Gets or sets current rotation quaternion (in local space) */
  93280. get rotationQuaternion(): Quaternion;
  93281. set rotationQuaternion(newRotation: Quaternion);
  93282. /** Gets or sets current scaling (in local space) */
  93283. get scaling(): Vector3;
  93284. set scaling(newScaling: Vector3);
  93285. /**
  93286. * Gets the animation properties override
  93287. */
  93288. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93289. private _decompose;
  93290. private _compose;
  93291. /**
  93292. * Update the base and local matrices
  93293. * @param matrix defines the new base or local matrix
  93294. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93295. * @param updateLocalMatrix defines if the local matrix should be updated
  93296. */
  93297. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  93298. /** @hidden */
  93299. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  93300. /**
  93301. * Flag the bone as dirty (Forcing it to update everything)
  93302. */
  93303. markAsDirty(): void;
  93304. /** @hidden */
  93305. _markAsDirtyAndCompose(): void;
  93306. private _markAsDirtyAndDecompose;
  93307. /**
  93308. * Translate the bone in local or world space
  93309. * @param vec The amount to translate the bone
  93310. * @param space The space that the translation is in
  93311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93312. */
  93313. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93314. /**
  93315. * Set the postion of the bone in local or world space
  93316. * @param position The position to set the bone
  93317. * @param space The space that the position is in
  93318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93319. */
  93320. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93321. /**
  93322. * Set the absolute position of the bone (world space)
  93323. * @param position The position to set the bone
  93324. * @param mesh The mesh that this bone is attached to
  93325. */
  93326. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  93327. /**
  93328. * Scale the bone on the x, y and z axes (in local space)
  93329. * @param x The amount to scale the bone on the x axis
  93330. * @param y The amount to scale the bone on the y axis
  93331. * @param z The amount to scale the bone on the z axis
  93332. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  93333. */
  93334. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  93335. /**
  93336. * Set the bone scaling in local space
  93337. * @param scale defines the scaling vector
  93338. */
  93339. setScale(scale: Vector3): void;
  93340. /**
  93341. * Gets the current scaling in local space
  93342. * @returns the current scaling vector
  93343. */
  93344. getScale(): Vector3;
  93345. /**
  93346. * Gets the current scaling in local space and stores it in a target vector
  93347. * @param result defines the target vector
  93348. */
  93349. getScaleToRef(result: Vector3): void;
  93350. /**
  93351. * Set the yaw, pitch, and roll of the bone in local or world space
  93352. * @param yaw The rotation of the bone on the y axis
  93353. * @param pitch The rotation of the bone on the x axis
  93354. * @param roll The rotation of the bone on the z axis
  93355. * @param space The space that the axes of rotation are in
  93356. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93357. */
  93358. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  93359. /**
  93360. * Add a rotation to the bone on an axis in local or world space
  93361. * @param axis The axis to rotate the bone on
  93362. * @param amount The amount to rotate the bone
  93363. * @param space The space that the axis is in
  93364. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93365. */
  93366. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  93367. /**
  93368. * Set the rotation of the bone to a particular axis angle in local or world space
  93369. * @param axis The axis to rotate the bone on
  93370. * @param angle The angle that the bone should be rotated to
  93371. * @param space The space that the axis is in
  93372. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93373. */
  93374. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  93375. /**
  93376. * Set the euler rotation of the bone in local of world space
  93377. * @param rotation The euler rotation that the bone should be set to
  93378. * @param space The space that the rotation is in
  93379. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93380. */
  93381. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93382. /**
  93383. * Set the quaternion rotation of the bone in local of world space
  93384. * @param quat The quaternion rotation that the bone should be set to
  93385. * @param space The space that the rotation is in
  93386. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93387. */
  93388. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  93389. /**
  93390. * Set the rotation matrix of the bone in local of world space
  93391. * @param rotMat The rotation matrix that the bone should be set to
  93392. * @param space The space that the rotation is in
  93393. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93394. */
  93395. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  93396. private _rotateWithMatrix;
  93397. private _getNegativeRotationToRef;
  93398. /**
  93399. * Get the position of the bone in local or world space
  93400. * @param space The space that the returned position is in
  93401. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93402. * @returns The position of the bone
  93403. */
  93404. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93405. /**
  93406. * Copy the position of the bone to a vector3 in local or world space
  93407. * @param space The space that the returned position is in
  93408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93409. * @param result The vector3 to copy the position to
  93410. */
  93411. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  93412. /**
  93413. * Get the absolute position of the bone (world space)
  93414. * @param mesh The mesh that this bone is attached to
  93415. * @returns The absolute position of the bone
  93416. */
  93417. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  93418. /**
  93419. * Copy the absolute position of the bone (world space) to the result param
  93420. * @param mesh The mesh that this bone is attached to
  93421. * @param result The vector3 to copy the absolute position to
  93422. */
  93423. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  93424. /**
  93425. * Compute the absolute transforms of this bone and its children
  93426. */
  93427. computeAbsoluteTransforms(): void;
  93428. /**
  93429. * Get the world direction from an axis that is in the local space of the bone
  93430. * @param localAxis The local direction that is used to compute the world direction
  93431. * @param mesh The mesh that this bone is attached to
  93432. * @returns The world direction
  93433. */
  93434. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93435. /**
  93436. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  93437. * @param localAxis The local direction that is used to compute the world direction
  93438. * @param mesh The mesh that this bone is attached to
  93439. * @param result The vector3 that the world direction will be copied to
  93440. */
  93441. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93442. /**
  93443. * Get the euler rotation of the bone in local or world space
  93444. * @param space The space that the rotation should be in
  93445. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93446. * @returns The euler rotation
  93447. */
  93448. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93449. /**
  93450. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  93451. * @param space The space that the rotation should be in
  93452. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93453. * @param result The vector3 that the rotation should be copied to
  93454. */
  93455. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93456. /**
  93457. * Get the quaternion rotation of the bone in either local or world space
  93458. * @param space The space that the rotation should be in
  93459. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93460. * @returns The quaternion rotation
  93461. */
  93462. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  93463. /**
  93464. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  93465. * @param space The space that the rotation should be in
  93466. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93467. * @param result The quaternion that the rotation should be copied to
  93468. */
  93469. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  93470. /**
  93471. * Get the rotation matrix of the bone in local or world space
  93472. * @param space The space that the rotation should be in
  93473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93474. * @returns The rotation matrix
  93475. */
  93476. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  93477. /**
  93478. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  93479. * @param space The space that the rotation should be in
  93480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93481. * @param result The quaternion that the rotation should be copied to
  93482. */
  93483. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  93484. /**
  93485. * Get the world position of a point that is in the local space of the bone
  93486. * @param position The local position
  93487. * @param mesh The mesh that this bone is attached to
  93488. * @returns The world position
  93489. */
  93490. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93491. /**
  93492. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  93493. * @param position The local position
  93494. * @param mesh The mesh that this bone is attached to
  93495. * @param result The vector3 that the world position should be copied to
  93496. */
  93497. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93498. /**
  93499. * Get the local position of a point that is in world space
  93500. * @param position The world position
  93501. * @param mesh The mesh that this bone is attached to
  93502. * @returns The local position
  93503. */
  93504. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93505. /**
  93506. * Get the local position of a point that is in world space and copy it to the result param
  93507. * @param position The world position
  93508. * @param mesh The mesh that this bone is attached to
  93509. * @param result The vector3 that the local position should be copied to
  93510. */
  93511. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93512. }
  93513. }
  93514. declare module BABYLON {
  93515. /**
  93516. * Defines a runtime animation
  93517. */
  93518. export class RuntimeAnimation {
  93519. private _events;
  93520. /**
  93521. * The current frame of the runtime animation
  93522. */
  93523. private _currentFrame;
  93524. /**
  93525. * The animation used by the runtime animation
  93526. */
  93527. private _animation;
  93528. /**
  93529. * The target of the runtime animation
  93530. */
  93531. private _target;
  93532. /**
  93533. * The initiating animatable
  93534. */
  93535. private _host;
  93536. /**
  93537. * The original value of the runtime animation
  93538. */
  93539. private _originalValue;
  93540. /**
  93541. * The original blend value of the runtime animation
  93542. */
  93543. private _originalBlendValue;
  93544. /**
  93545. * The offsets cache of the runtime animation
  93546. */
  93547. private _offsetsCache;
  93548. /**
  93549. * The high limits cache of the runtime animation
  93550. */
  93551. private _highLimitsCache;
  93552. /**
  93553. * Specifies if the runtime animation has been stopped
  93554. */
  93555. private _stopped;
  93556. /**
  93557. * The blending factor of the runtime animation
  93558. */
  93559. private _blendingFactor;
  93560. /**
  93561. * The BabylonJS scene
  93562. */
  93563. private _scene;
  93564. /**
  93565. * The current value of the runtime animation
  93566. */
  93567. private _currentValue;
  93568. /** @hidden */
  93569. _animationState: _IAnimationState;
  93570. /**
  93571. * The active target of the runtime animation
  93572. */
  93573. private _activeTargets;
  93574. private _currentActiveTarget;
  93575. private _directTarget;
  93576. /**
  93577. * The target path of the runtime animation
  93578. */
  93579. private _targetPath;
  93580. /**
  93581. * The weight of the runtime animation
  93582. */
  93583. private _weight;
  93584. /**
  93585. * The ratio offset of the runtime animation
  93586. */
  93587. private _ratioOffset;
  93588. /**
  93589. * The previous delay of the runtime animation
  93590. */
  93591. private _previousDelay;
  93592. /**
  93593. * The previous ratio of the runtime animation
  93594. */
  93595. private _previousRatio;
  93596. private _enableBlending;
  93597. private _keys;
  93598. private _minFrame;
  93599. private _maxFrame;
  93600. private _minValue;
  93601. private _maxValue;
  93602. private _targetIsArray;
  93603. /**
  93604. * Gets the current frame of the runtime animation
  93605. */
  93606. get currentFrame(): number;
  93607. /**
  93608. * Gets the weight of the runtime animation
  93609. */
  93610. get weight(): number;
  93611. /**
  93612. * Gets the current value of the runtime animation
  93613. */
  93614. get currentValue(): any;
  93615. /**
  93616. * Gets the target path of the runtime animation
  93617. */
  93618. get targetPath(): string;
  93619. /**
  93620. * Gets the actual target of the runtime animation
  93621. */
  93622. get target(): any;
  93623. /**
  93624. * Gets the additive state of the runtime animation
  93625. */
  93626. get isAdditive(): boolean;
  93627. /** @hidden */
  93628. _onLoop: () => void;
  93629. /**
  93630. * Create a new RuntimeAnimation object
  93631. * @param target defines the target of the animation
  93632. * @param animation defines the source animation object
  93633. * @param scene defines the hosting scene
  93634. * @param host defines the initiating Animatable
  93635. */
  93636. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  93637. private _preparePath;
  93638. /**
  93639. * Gets the animation from the runtime animation
  93640. */
  93641. get animation(): Animation;
  93642. /**
  93643. * Resets the runtime animation to the beginning
  93644. * @param restoreOriginal defines whether to restore the target property to the original value
  93645. */
  93646. reset(restoreOriginal?: boolean): void;
  93647. /**
  93648. * Specifies if the runtime animation is stopped
  93649. * @returns Boolean specifying if the runtime animation is stopped
  93650. */
  93651. isStopped(): boolean;
  93652. /**
  93653. * Disposes of the runtime animation
  93654. */
  93655. dispose(): void;
  93656. /**
  93657. * Apply the interpolated value to the target
  93658. * @param currentValue defines the value computed by the animation
  93659. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  93660. */
  93661. setValue(currentValue: any, weight: number): void;
  93662. private _getOriginalValues;
  93663. private _setValue;
  93664. /**
  93665. * Gets the loop pmode of the runtime animation
  93666. * @returns Loop Mode
  93667. */
  93668. private _getCorrectLoopMode;
  93669. /**
  93670. * Move the current animation to a given frame
  93671. * @param frame defines the frame to move to
  93672. */
  93673. goToFrame(frame: number): void;
  93674. /**
  93675. * @hidden Internal use only
  93676. */
  93677. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  93678. /**
  93679. * Execute the current animation
  93680. * @param delay defines the delay to add to the current frame
  93681. * @param from defines the lower bound of the animation range
  93682. * @param to defines the upper bound of the animation range
  93683. * @param loop defines if the current animation must loop
  93684. * @param speedRatio defines the current speed ratio
  93685. * @param weight defines the weight of the animation (default is -1 so no weight)
  93686. * @param onLoop optional callback called when animation loops
  93687. * @returns a boolean indicating if the animation is running
  93688. */
  93689. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  93690. }
  93691. }
  93692. declare module BABYLON {
  93693. /**
  93694. * Class used to store an actual running animation
  93695. */
  93696. export class Animatable {
  93697. /** defines the target object */
  93698. target: any;
  93699. /** defines the starting frame number (default is 0) */
  93700. fromFrame: number;
  93701. /** defines the ending frame number (default is 100) */
  93702. toFrame: number;
  93703. /** defines if the animation must loop (default is false) */
  93704. loopAnimation: boolean;
  93705. /** defines a callback to call when animation ends if it is not looping */
  93706. onAnimationEnd?: (() => void) | null | undefined;
  93707. /** defines a callback to call when animation loops */
  93708. onAnimationLoop?: (() => void) | null | undefined;
  93709. /** defines whether the animation should be evaluated additively */
  93710. isAdditive: boolean;
  93711. private _localDelayOffset;
  93712. private _pausedDelay;
  93713. private _runtimeAnimations;
  93714. private _paused;
  93715. private _scene;
  93716. private _speedRatio;
  93717. private _weight;
  93718. private _syncRoot;
  93719. /**
  93720. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  93721. * This will only apply for non looping animation (default is true)
  93722. */
  93723. disposeOnEnd: boolean;
  93724. /**
  93725. * Gets a boolean indicating if the animation has started
  93726. */
  93727. animationStarted: boolean;
  93728. /**
  93729. * Observer raised when the animation ends
  93730. */
  93731. onAnimationEndObservable: Observable<Animatable>;
  93732. /**
  93733. * Observer raised when the animation loops
  93734. */
  93735. onAnimationLoopObservable: Observable<Animatable>;
  93736. /**
  93737. * Gets the root Animatable used to synchronize and normalize animations
  93738. */
  93739. get syncRoot(): Nullable<Animatable>;
  93740. /**
  93741. * Gets the current frame of the first RuntimeAnimation
  93742. * Used to synchronize Animatables
  93743. */
  93744. get masterFrame(): number;
  93745. /**
  93746. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  93747. */
  93748. get weight(): number;
  93749. set weight(value: number);
  93750. /**
  93751. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  93752. */
  93753. get speedRatio(): number;
  93754. set speedRatio(value: number);
  93755. /**
  93756. * Creates a new Animatable
  93757. * @param scene defines the hosting scene
  93758. * @param target defines the target object
  93759. * @param fromFrame defines the starting frame number (default is 0)
  93760. * @param toFrame defines the ending frame number (default is 100)
  93761. * @param loopAnimation defines if the animation must loop (default is false)
  93762. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  93763. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  93764. * @param animations defines a group of animation to add to the new Animatable
  93765. * @param onAnimationLoop defines a callback to call when animation loops
  93766. * @param isAdditive defines whether the animation should be evaluated additively
  93767. */
  93768. constructor(scene: Scene,
  93769. /** defines the target object */
  93770. target: any,
  93771. /** defines the starting frame number (default is 0) */
  93772. fromFrame?: number,
  93773. /** defines the ending frame number (default is 100) */
  93774. toFrame?: number,
  93775. /** defines if the animation must loop (default is false) */
  93776. loopAnimation?: boolean, speedRatio?: number,
  93777. /** defines a callback to call when animation ends if it is not looping */
  93778. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  93779. /** defines a callback to call when animation loops */
  93780. onAnimationLoop?: (() => void) | null | undefined,
  93781. /** defines whether the animation should be evaluated additively */
  93782. isAdditive?: boolean);
  93783. /**
  93784. * Synchronize and normalize current Animatable with a source Animatable
  93785. * This is useful when using animation weights and when animations are not of the same length
  93786. * @param root defines the root Animatable to synchronize with
  93787. * @returns the current Animatable
  93788. */
  93789. syncWith(root: Animatable): Animatable;
  93790. /**
  93791. * Gets the list of runtime animations
  93792. * @returns an array of RuntimeAnimation
  93793. */
  93794. getAnimations(): RuntimeAnimation[];
  93795. /**
  93796. * Adds more animations to the current animatable
  93797. * @param target defines the target of the animations
  93798. * @param animations defines the new animations to add
  93799. */
  93800. appendAnimations(target: any, animations: Animation[]): void;
  93801. /**
  93802. * Gets the source animation for a specific property
  93803. * @param property defines the propertyu to look for
  93804. * @returns null or the source animation for the given property
  93805. */
  93806. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  93807. /**
  93808. * Gets the runtime animation for a specific property
  93809. * @param property defines the propertyu to look for
  93810. * @returns null or the runtime animation for the given property
  93811. */
  93812. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  93813. /**
  93814. * Resets the animatable to its original state
  93815. */
  93816. reset(): void;
  93817. /**
  93818. * Allows the animatable to blend with current running animations
  93819. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  93820. * @param blendingSpeed defines the blending speed to use
  93821. */
  93822. enableBlending(blendingSpeed: number): void;
  93823. /**
  93824. * Disable animation blending
  93825. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  93826. */
  93827. disableBlending(): void;
  93828. /**
  93829. * Jump directly to a given frame
  93830. * @param frame defines the frame to jump to
  93831. */
  93832. goToFrame(frame: number): void;
  93833. /**
  93834. * Pause the animation
  93835. */
  93836. pause(): void;
  93837. /**
  93838. * Restart the animation
  93839. */
  93840. restart(): void;
  93841. private _raiseOnAnimationEnd;
  93842. /**
  93843. * Stop and delete the current animation
  93844. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  93845. * @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)
  93846. */
  93847. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  93848. /**
  93849. * Wait asynchronously for the animation to end
  93850. * @returns a promise which will be fullfilled when the animation ends
  93851. */
  93852. waitAsync(): Promise<Animatable>;
  93853. /** @hidden */
  93854. _animate(delay: number): boolean;
  93855. }
  93856. interface Scene {
  93857. /** @hidden */
  93858. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  93859. /** @hidden */
  93860. _processLateAnimationBindingsForMatrices(holder: {
  93861. totalWeight: number;
  93862. totalAdditiveWeight: number;
  93863. animations: RuntimeAnimation[];
  93864. additiveAnimations: RuntimeAnimation[];
  93865. originalValue: Matrix;
  93866. }): any;
  93867. /** @hidden */
  93868. _processLateAnimationBindingsForQuaternions(holder: {
  93869. totalWeight: number;
  93870. totalAdditiveWeight: number;
  93871. animations: RuntimeAnimation[];
  93872. additiveAnimations: RuntimeAnimation[];
  93873. originalValue: Quaternion;
  93874. }, refQuaternion: Quaternion): Quaternion;
  93875. /** @hidden */
  93876. _processLateAnimationBindings(): void;
  93877. /**
  93878. * Will start the animation sequence of a given target
  93879. * @param target defines the target
  93880. * @param from defines from which frame should animation start
  93881. * @param to defines until which frame should animation run.
  93882. * @param weight defines the weight to apply to the animation (1.0 by default)
  93883. * @param loop defines if the animation loops
  93884. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93885. * @param onAnimationEnd defines the function to be executed when the animation ends
  93886. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93887. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93888. * @param onAnimationLoop defines the callback to call when an animation loops
  93889. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93890. * @returns the animatable object created for this animation
  93891. */
  93892. 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;
  93893. /**
  93894. * Will start the animation sequence of a given target
  93895. * @param target defines the target
  93896. * @param from defines from which frame should animation start
  93897. * @param to defines until which frame should animation run.
  93898. * @param loop defines if the animation loops
  93899. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93900. * @param onAnimationEnd defines the function to be executed when the animation ends
  93901. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93902. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93903. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  93904. * @param onAnimationLoop defines the callback to call when an animation loops
  93905. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93906. * @returns the animatable object created for this animation
  93907. */
  93908. 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;
  93909. /**
  93910. * Will start the animation sequence of a given target and its hierarchy
  93911. * @param target defines the target
  93912. * @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.
  93913. * @param from defines from which frame should animation start
  93914. * @param to defines until which frame should animation run.
  93915. * @param loop defines if the animation loops
  93916. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93917. * @param onAnimationEnd defines the function to be executed when the animation ends
  93918. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93919. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93920. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93921. * @param onAnimationLoop defines the callback to call when an animation loops
  93922. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93923. * @returns the list of created animatables
  93924. */
  93925. 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[];
  93926. /**
  93927. * Begin a new animation on a given node
  93928. * @param target defines the target where the animation will take place
  93929. * @param animations defines the list of animations to start
  93930. * @param from defines the initial value
  93931. * @param to defines the final value
  93932. * @param loop defines if you want animation to loop (off by default)
  93933. * @param speedRatio defines the speed ratio to apply to all animations
  93934. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93935. * @param onAnimationLoop defines the callback to call when an animation loops
  93936. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93937. * @returns the list of created animatables
  93938. */
  93939. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93940. /**
  93941. * Begin a new animation on a given node and its hierarchy
  93942. * @param target defines the root node where the animation will take place
  93943. * @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.
  93944. * @param animations defines the list of animations to start
  93945. * @param from defines the initial value
  93946. * @param to defines the final value
  93947. * @param loop defines if you want animation to loop (off by default)
  93948. * @param speedRatio defines the speed ratio to apply to all animations
  93949. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93950. * @param onAnimationLoop defines the callback to call when an animation loops
  93951. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93952. * @returns the list of animatables created for all nodes
  93953. */
  93954. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  93955. /**
  93956. * Gets the animatable associated with a specific target
  93957. * @param target defines the target of the animatable
  93958. * @returns the required animatable if found
  93959. */
  93960. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93961. /**
  93962. * Gets all animatables associated with a given target
  93963. * @param target defines the target to look animatables for
  93964. * @returns an array of Animatables
  93965. */
  93966. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93967. /**
  93968. * Stops and removes all animations that have been applied to the scene
  93969. */
  93970. stopAllAnimations(): void;
  93971. /**
  93972. * Gets the current delta time used by animation engine
  93973. */
  93974. deltaTime: number;
  93975. }
  93976. interface Bone {
  93977. /**
  93978. * Copy an animation range from another bone
  93979. * @param source defines the source bone
  93980. * @param rangeName defines the range name to copy
  93981. * @param frameOffset defines the frame offset
  93982. * @param rescaleAsRequired defines if rescaling must be applied if required
  93983. * @param skelDimensionsRatio defines the scaling ratio
  93984. * @returns true if operation was successful
  93985. */
  93986. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93987. }
  93988. }
  93989. declare module BABYLON {
  93990. /**
  93991. * Class used to handle skinning animations
  93992. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93993. */
  93994. export class Skeleton implements IAnimatable {
  93995. /** defines the skeleton name */
  93996. name: string;
  93997. /** defines the skeleton Id */
  93998. id: string;
  93999. /**
  94000. * Defines the list of child bones
  94001. */
  94002. bones: Bone[];
  94003. /**
  94004. * Defines an estimate of the dimension of the skeleton at rest
  94005. */
  94006. dimensionsAtRest: Vector3;
  94007. /**
  94008. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94009. */
  94010. needInitialSkinMatrix: boolean;
  94011. /**
  94012. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94013. */
  94014. overrideMesh: Nullable<AbstractMesh>;
  94015. /**
  94016. * Gets the list of animations attached to this skeleton
  94017. */
  94018. animations: Array<Animation>;
  94019. private _scene;
  94020. private _isDirty;
  94021. private _transformMatrices;
  94022. private _transformMatrixTexture;
  94023. private _meshesWithPoseMatrix;
  94024. private _animatables;
  94025. private _identity;
  94026. private _synchronizedWithMesh;
  94027. private _ranges;
  94028. private _lastAbsoluteTransformsUpdateId;
  94029. private _canUseTextureForBones;
  94030. private _uniqueId;
  94031. /** @hidden */
  94032. _numBonesWithLinkedTransformNode: number;
  94033. /** @hidden */
  94034. _hasWaitingData: Nullable<boolean>;
  94035. /**
  94036. * Specifies if the skeleton should be serialized
  94037. */
  94038. doNotSerialize: boolean;
  94039. private _useTextureToStoreBoneMatrices;
  94040. /**
  94041. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  94042. * Please note that this option is not available if the hardware does not support it
  94043. */
  94044. get useTextureToStoreBoneMatrices(): boolean;
  94045. set useTextureToStoreBoneMatrices(value: boolean);
  94046. private _animationPropertiesOverride;
  94047. /**
  94048. * Gets or sets the animation properties override
  94049. */
  94050. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94051. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94052. /**
  94053. * List of inspectable custom properties (used by the Inspector)
  94054. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94055. */
  94056. inspectableCustomProperties: IInspectable[];
  94057. /**
  94058. * An observable triggered before computing the skeleton's matrices
  94059. */
  94060. onBeforeComputeObservable: Observable<Skeleton>;
  94061. /**
  94062. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  94063. */
  94064. get isUsingTextureForMatrices(): boolean;
  94065. /**
  94066. * Gets the unique ID of this skeleton
  94067. */
  94068. get uniqueId(): number;
  94069. /**
  94070. * Creates a new skeleton
  94071. * @param name defines the skeleton name
  94072. * @param id defines the skeleton Id
  94073. * @param scene defines the hosting scene
  94074. */
  94075. constructor(
  94076. /** defines the skeleton name */
  94077. name: string,
  94078. /** defines the skeleton Id */
  94079. id: string, scene: Scene);
  94080. /**
  94081. * Gets the current object class name.
  94082. * @return the class name
  94083. */
  94084. getClassName(): string;
  94085. /**
  94086. * Returns an array containing the root bones
  94087. * @returns an array containing the root bones
  94088. */
  94089. getChildren(): Array<Bone>;
  94090. /**
  94091. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  94092. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94093. * @returns a Float32Array containing matrices data
  94094. */
  94095. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  94096. /**
  94097. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  94098. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94099. * @returns a raw texture containing the data
  94100. */
  94101. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  94102. /**
  94103. * Gets the current hosting scene
  94104. * @returns a scene object
  94105. */
  94106. getScene(): Scene;
  94107. /**
  94108. * Gets a string representing the current skeleton data
  94109. * @param fullDetails defines a boolean indicating if we want a verbose version
  94110. * @returns a string representing the current skeleton data
  94111. */
  94112. toString(fullDetails?: boolean): string;
  94113. /**
  94114. * Get bone's index searching by name
  94115. * @param name defines bone's name to search for
  94116. * @return the indice of the bone. Returns -1 if not found
  94117. */
  94118. getBoneIndexByName(name: string): number;
  94119. /**
  94120. * Creater a new animation range
  94121. * @param name defines the name of the range
  94122. * @param from defines the start key
  94123. * @param to defines the end key
  94124. */
  94125. createAnimationRange(name: string, from: number, to: number): void;
  94126. /**
  94127. * Delete a specific animation range
  94128. * @param name defines the name of the range
  94129. * @param deleteFrames defines if frames must be removed as well
  94130. */
  94131. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94132. /**
  94133. * Gets a specific animation range
  94134. * @param name defines the name of the range to look for
  94135. * @returns the requested animation range or null if not found
  94136. */
  94137. getAnimationRange(name: string): Nullable<AnimationRange>;
  94138. /**
  94139. * Gets the list of all animation ranges defined on this skeleton
  94140. * @returns an array
  94141. */
  94142. getAnimationRanges(): Nullable<AnimationRange>[];
  94143. /**
  94144. * Copy animation range from a source skeleton.
  94145. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  94146. * @param source defines the source skeleton
  94147. * @param name defines the name of the range to copy
  94148. * @param rescaleAsRequired defines if rescaling must be applied if required
  94149. * @returns true if operation was successful
  94150. */
  94151. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  94152. /**
  94153. * Forces the skeleton to go to rest pose
  94154. */
  94155. returnToRest(): void;
  94156. private _getHighestAnimationFrame;
  94157. /**
  94158. * Begin a specific animation range
  94159. * @param name defines the name of the range to start
  94160. * @param loop defines if looping must be turned on (false by default)
  94161. * @param speedRatio defines the speed ratio to apply (1 by default)
  94162. * @param onAnimationEnd defines a callback which will be called when animation will end
  94163. * @returns a new animatable
  94164. */
  94165. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94166. /**
  94167. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  94168. * @param skeleton defines the Skeleton containing the animation range to convert
  94169. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  94170. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  94171. * @returns the original skeleton
  94172. */
  94173. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  94174. /** @hidden */
  94175. _markAsDirty(): void;
  94176. /** @hidden */
  94177. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94178. /** @hidden */
  94179. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94180. private _computeTransformMatrices;
  94181. /**
  94182. * Build all resources required to render a skeleton
  94183. */
  94184. prepare(): void;
  94185. /**
  94186. * Gets the list of animatables currently running for this skeleton
  94187. * @returns an array of animatables
  94188. */
  94189. getAnimatables(): IAnimatable[];
  94190. /**
  94191. * Clone the current skeleton
  94192. * @param name defines the name of the new skeleton
  94193. * @param id defines the id of the new skeleton
  94194. * @returns the new skeleton
  94195. */
  94196. clone(name: string, id?: string): Skeleton;
  94197. /**
  94198. * Enable animation blending for this skeleton
  94199. * @param blendingSpeed defines the blending speed to apply
  94200. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94201. */
  94202. enableBlending(blendingSpeed?: number): void;
  94203. /**
  94204. * Releases all resources associated with the current skeleton
  94205. */
  94206. dispose(): void;
  94207. /**
  94208. * Serialize the skeleton in a JSON object
  94209. * @returns a JSON object
  94210. */
  94211. serialize(): any;
  94212. /**
  94213. * Creates a new skeleton from serialized data
  94214. * @param parsedSkeleton defines the serialized data
  94215. * @param scene defines the hosting scene
  94216. * @returns a new skeleton
  94217. */
  94218. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  94219. /**
  94220. * Compute all node absolute transforms
  94221. * @param forceUpdate defines if computation must be done even if cache is up to date
  94222. */
  94223. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  94224. /**
  94225. * Gets the root pose matrix
  94226. * @returns a matrix
  94227. */
  94228. getPoseMatrix(): Nullable<Matrix>;
  94229. /**
  94230. * Sorts bones per internal index
  94231. */
  94232. sortBones(): void;
  94233. private _sortBones;
  94234. }
  94235. }
  94236. declare module BABYLON {
  94237. /**
  94238. * Creates an instance based on a source mesh.
  94239. */
  94240. export class InstancedMesh extends AbstractMesh {
  94241. private _sourceMesh;
  94242. private _currentLOD;
  94243. /** @hidden */
  94244. _indexInSourceMeshInstanceArray: number;
  94245. constructor(name: string, source: Mesh);
  94246. /**
  94247. * Returns the string "InstancedMesh".
  94248. */
  94249. getClassName(): string;
  94250. /** Gets the list of lights affecting that mesh */
  94251. get lightSources(): Light[];
  94252. _resyncLightSources(): void;
  94253. _resyncLightSource(light: Light): void;
  94254. _removeLightSource(light: Light, dispose: boolean): void;
  94255. /**
  94256. * If the source mesh receives shadows
  94257. */
  94258. get receiveShadows(): boolean;
  94259. /**
  94260. * The material of the source mesh
  94261. */
  94262. get material(): Nullable<Material>;
  94263. /**
  94264. * Visibility of the source mesh
  94265. */
  94266. get visibility(): number;
  94267. /**
  94268. * Skeleton of the source mesh
  94269. */
  94270. get skeleton(): Nullable<Skeleton>;
  94271. /**
  94272. * Rendering ground id of the source mesh
  94273. */
  94274. get renderingGroupId(): number;
  94275. set renderingGroupId(value: number);
  94276. /**
  94277. * Returns the total number of vertices (integer).
  94278. */
  94279. getTotalVertices(): number;
  94280. /**
  94281. * Returns a positive integer : the total number of indices in this mesh geometry.
  94282. * @returns the numner of indices or zero if the mesh has no geometry.
  94283. */
  94284. getTotalIndices(): number;
  94285. /**
  94286. * The source mesh of the instance
  94287. */
  94288. get sourceMesh(): Mesh;
  94289. /**
  94290. * Creates a new InstancedMesh object from the mesh model.
  94291. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94292. * @param name defines the name of the new instance
  94293. * @returns a new InstancedMesh
  94294. */
  94295. createInstance(name: string): InstancedMesh;
  94296. /**
  94297. * Is this node ready to be used/rendered
  94298. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94299. * @return {boolean} is it ready
  94300. */
  94301. isReady(completeCheck?: boolean): boolean;
  94302. /**
  94303. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94304. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  94305. * @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.
  94306. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  94307. */
  94308. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  94309. /**
  94310. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94311. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94312. * The `data` are either a numeric array either a Float32Array.
  94313. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  94314. * 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).
  94315. * Note that a new underlying VertexBuffer object is created each call.
  94316. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94317. *
  94318. * Possible `kind` values :
  94319. * - VertexBuffer.PositionKind
  94320. * - VertexBuffer.UVKind
  94321. * - VertexBuffer.UV2Kind
  94322. * - VertexBuffer.UV3Kind
  94323. * - VertexBuffer.UV4Kind
  94324. * - VertexBuffer.UV5Kind
  94325. * - VertexBuffer.UV6Kind
  94326. * - VertexBuffer.ColorKind
  94327. * - VertexBuffer.MatricesIndicesKind
  94328. * - VertexBuffer.MatricesIndicesExtraKind
  94329. * - VertexBuffer.MatricesWeightsKind
  94330. * - VertexBuffer.MatricesWeightsExtraKind
  94331. *
  94332. * Returns the Mesh.
  94333. */
  94334. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94335. /**
  94336. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94337. * If the mesh has no geometry, it is simply returned as it is.
  94338. * The `data` are either a numeric array either a Float32Array.
  94339. * No new underlying VertexBuffer object is created.
  94340. * 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.
  94341. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  94342. *
  94343. * Possible `kind` values :
  94344. * - VertexBuffer.PositionKind
  94345. * - VertexBuffer.UVKind
  94346. * - VertexBuffer.UV2Kind
  94347. * - VertexBuffer.UV3Kind
  94348. * - VertexBuffer.UV4Kind
  94349. * - VertexBuffer.UV5Kind
  94350. * - VertexBuffer.UV6Kind
  94351. * - VertexBuffer.ColorKind
  94352. * - VertexBuffer.MatricesIndicesKind
  94353. * - VertexBuffer.MatricesIndicesExtraKind
  94354. * - VertexBuffer.MatricesWeightsKind
  94355. * - VertexBuffer.MatricesWeightsExtraKind
  94356. *
  94357. * Returns the Mesh.
  94358. */
  94359. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  94360. /**
  94361. * Sets the mesh indices.
  94362. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  94363. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94364. * This method creates a new index buffer each call.
  94365. * Returns the Mesh.
  94366. */
  94367. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  94368. /**
  94369. * Boolean : True if the mesh owns the requested kind of data.
  94370. */
  94371. isVerticesDataPresent(kind: string): boolean;
  94372. /**
  94373. * Returns an array of indices (IndicesArray).
  94374. */
  94375. getIndices(): Nullable<IndicesArray>;
  94376. get _positions(): Nullable<Vector3[]>;
  94377. /**
  94378. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94379. * This means the mesh underlying bounding box and sphere are recomputed.
  94380. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94381. * @returns the current mesh
  94382. */
  94383. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  94384. /** @hidden */
  94385. _preActivate(): InstancedMesh;
  94386. /** @hidden */
  94387. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94388. /** @hidden */
  94389. _postActivate(): void;
  94390. getWorldMatrix(): Matrix;
  94391. get isAnInstance(): boolean;
  94392. /**
  94393. * Returns the current associated LOD AbstractMesh.
  94394. */
  94395. getLOD(camera: Camera): AbstractMesh;
  94396. /** @hidden */
  94397. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94398. /** @hidden */
  94399. _syncSubMeshes(): InstancedMesh;
  94400. /** @hidden */
  94401. _generatePointsArray(): boolean;
  94402. /**
  94403. * Creates a new InstancedMesh from the current mesh.
  94404. * - name (string) : the cloned mesh name
  94405. * - newParent (optional Node) : the optional Node to parent the clone to.
  94406. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  94407. *
  94408. * Returns the clone.
  94409. */
  94410. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  94411. /**
  94412. * Disposes the InstancedMesh.
  94413. * Returns nothing.
  94414. */
  94415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94416. }
  94417. interface Mesh {
  94418. /**
  94419. * Register a custom buffer that will be instanced
  94420. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94421. * @param kind defines the buffer kind
  94422. * @param stride defines the stride in floats
  94423. */
  94424. registerInstancedBuffer(kind: string, stride: number): void;
  94425. /**
  94426. * true to use the edge renderer for all instances of this mesh
  94427. */
  94428. edgesShareWithInstances: boolean;
  94429. /** @hidden */
  94430. _userInstancedBuffersStorage: {
  94431. data: {
  94432. [key: string]: Float32Array;
  94433. };
  94434. sizes: {
  94435. [key: string]: number;
  94436. };
  94437. vertexBuffers: {
  94438. [key: string]: Nullable<VertexBuffer>;
  94439. };
  94440. strides: {
  94441. [key: string]: number;
  94442. };
  94443. };
  94444. }
  94445. interface AbstractMesh {
  94446. /**
  94447. * Object used to store instanced buffers defined by user
  94448. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94449. */
  94450. instancedBuffers: {
  94451. [key: string]: any;
  94452. };
  94453. }
  94454. }
  94455. declare module BABYLON {
  94456. /**
  94457. * Defines the options associated with the creation of a shader material.
  94458. */
  94459. export interface IShaderMaterialOptions {
  94460. /**
  94461. * Does the material work in alpha blend mode
  94462. */
  94463. needAlphaBlending: boolean;
  94464. /**
  94465. * Does the material work in alpha test mode
  94466. */
  94467. needAlphaTesting: boolean;
  94468. /**
  94469. * The list of attribute names used in the shader
  94470. */
  94471. attributes: string[];
  94472. /**
  94473. * The list of unifrom names used in the shader
  94474. */
  94475. uniforms: string[];
  94476. /**
  94477. * The list of UBO names used in the shader
  94478. */
  94479. uniformBuffers: string[];
  94480. /**
  94481. * The list of sampler names used in the shader
  94482. */
  94483. samplers: string[];
  94484. /**
  94485. * The list of defines used in the shader
  94486. */
  94487. defines: string[];
  94488. }
  94489. /**
  94490. * 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.
  94491. *
  94492. * This returned material effects how the mesh will look based on the code in the shaders.
  94493. *
  94494. * @see https://doc.babylonjs.com/how_to/shader_material
  94495. */
  94496. export class ShaderMaterial extends Material {
  94497. private _shaderPath;
  94498. private _options;
  94499. private _textures;
  94500. private _textureArrays;
  94501. private _floats;
  94502. private _ints;
  94503. private _floatsArrays;
  94504. private _colors3;
  94505. private _colors3Arrays;
  94506. private _colors4;
  94507. private _colors4Arrays;
  94508. private _vectors2;
  94509. private _vectors3;
  94510. private _vectors4;
  94511. private _matrices;
  94512. private _matrixArrays;
  94513. private _matrices3x3;
  94514. private _matrices2x2;
  94515. private _vectors2Arrays;
  94516. private _vectors3Arrays;
  94517. private _vectors4Arrays;
  94518. private _cachedWorldViewMatrix;
  94519. private _cachedWorldViewProjectionMatrix;
  94520. private _renderId;
  94521. private _multiview;
  94522. private _cachedDefines;
  94523. /** Define the Url to load snippets */
  94524. static SnippetUrl: string;
  94525. /** Snippet ID if the material was created from the snippet server */
  94526. snippetId: string;
  94527. /**
  94528. * Instantiate a new shader material.
  94529. * 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.
  94530. * This returned material effects how the mesh will look based on the code in the shaders.
  94531. * @see https://doc.babylonjs.com/how_to/shader_material
  94532. * @param name Define the name of the material in the scene
  94533. * @param scene Define the scene the material belongs to
  94534. * @param shaderPath Defines the route to the shader code in one of three ways:
  94535. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  94536. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  94537. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  94538. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  94539. * @param options Define the options used to create the shader
  94540. */
  94541. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  94542. /**
  94543. * Gets the shader path used to define the shader code
  94544. * It can be modified to trigger a new compilation
  94545. */
  94546. get shaderPath(): any;
  94547. /**
  94548. * Sets the shader path used to define the shader code
  94549. * It can be modified to trigger a new compilation
  94550. */
  94551. set shaderPath(shaderPath: any);
  94552. /**
  94553. * Gets the options used to compile the shader.
  94554. * They can be modified to trigger a new compilation
  94555. */
  94556. get options(): IShaderMaterialOptions;
  94557. /**
  94558. * Gets the current class name of the material e.g. "ShaderMaterial"
  94559. * Mainly use in serialization.
  94560. * @returns the class name
  94561. */
  94562. getClassName(): string;
  94563. /**
  94564. * Specifies if the material will require alpha blending
  94565. * @returns a boolean specifying if alpha blending is needed
  94566. */
  94567. needAlphaBlending(): boolean;
  94568. /**
  94569. * Specifies if this material should be rendered in alpha test mode
  94570. * @returns a boolean specifying if an alpha test is needed.
  94571. */
  94572. needAlphaTesting(): boolean;
  94573. private _checkUniform;
  94574. /**
  94575. * Set a texture in the shader.
  94576. * @param name Define the name of the uniform samplers as defined in the shader
  94577. * @param texture Define the texture to bind to this sampler
  94578. * @return the material itself allowing "fluent" like uniform updates
  94579. */
  94580. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  94581. /**
  94582. * Set a texture array in the shader.
  94583. * @param name Define the name of the uniform sampler array as defined in the shader
  94584. * @param textures Define the list of textures to bind to this sampler
  94585. * @return the material itself allowing "fluent" like uniform updates
  94586. */
  94587. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  94588. /**
  94589. * Set a float in the shader.
  94590. * @param name Define the name of the uniform as defined in the shader
  94591. * @param value Define the value to give to the uniform
  94592. * @return the material itself allowing "fluent" like uniform updates
  94593. */
  94594. setFloat(name: string, value: number): ShaderMaterial;
  94595. /**
  94596. * Set a int in the shader.
  94597. * @param name Define the name of the uniform as defined in the shader
  94598. * @param value Define the value to give to the uniform
  94599. * @return the material itself allowing "fluent" like uniform updates
  94600. */
  94601. setInt(name: string, value: number): ShaderMaterial;
  94602. /**
  94603. * Set an array of floats in the shader.
  94604. * @param name Define the name of the uniform as defined in the shader
  94605. * @param value Define the value to give to the uniform
  94606. * @return the material itself allowing "fluent" like uniform updates
  94607. */
  94608. setFloats(name: string, value: number[]): ShaderMaterial;
  94609. /**
  94610. * Set a vec3 in the shader from a Color3.
  94611. * @param name Define the name of the uniform as defined in the shader
  94612. * @param value Define the value to give to the uniform
  94613. * @return the material itself allowing "fluent" like uniform updates
  94614. */
  94615. setColor3(name: string, value: Color3): ShaderMaterial;
  94616. /**
  94617. * Set a vec3 array in the shader from a Color3 array.
  94618. * @param name Define the name of the uniform as defined in the shader
  94619. * @param value Define the value to give to the uniform
  94620. * @return the material itself allowing "fluent" like uniform updates
  94621. */
  94622. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  94623. /**
  94624. * Set a vec4 in the shader from a Color4.
  94625. * @param name Define the name of the uniform as defined in the shader
  94626. * @param value Define the value to give to the uniform
  94627. * @return the material itself allowing "fluent" like uniform updates
  94628. */
  94629. setColor4(name: string, value: Color4): ShaderMaterial;
  94630. /**
  94631. * Set a vec4 array in the shader from a Color4 array.
  94632. * @param name Define the name of the uniform as defined in the shader
  94633. * @param value Define the value to give to the uniform
  94634. * @return the material itself allowing "fluent" like uniform updates
  94635. */
  94636. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  94637. /**
  94638. * Set a vec2 in the shader from a Vector2.
  94639. * @param name Define the name of the uniform as defined in the shader
  94640. * @param value Define the value to give to the uniform
  94641. * @return the material itself allowing "fluent" like uniform updates
  94642. */
  94643. setVector2(name: string, value: Vector2): ShaderMaterial;
  94644. /**
  94645. * Set a vec3 in the shader from a Vector3.
  94646. * @param name Define the name of the uniform as defined in the shader
  94647. * @param value Define the value to give to the uniform
  94648. * @return the material itself allowing "fluent" like uniform updates
  94649. */
  94650. setVector3(name: string, value: Vector3): ShaderMaterial;
  94651. /**
  94652. * Set a vec4 in the shader from a Vector4.
  94653. * @param name Define the name of the uniform as defined in the shader
  94654. * @param value Define the value to give to the uniform
  94655. * @return the material itself allowing "fluent" like uniform updates
  94656. */
  94657. setVector4(name: string, value: Vector4): ShaderMaterial;
  94658. /**
  94659. * Set a mat4 in the shader from a Matrix.
  94660. * @param name Define the name of the uniform as defined in the shader
  94661. * @param value Define the value to give to the uniform
  94662. * @return the material itself allowing "fluent" like uniform updates
  94663. */
  94664. setMatrix(name: string, value: Matrix): ShaderMaterial;
  94665. /**
  94666. * Set a float32Array in the shader from a matrix array.
  94667. * @param name Define the name of the uniform as defined in the shader
  94668. * @param value Define the value to give to the uniform
  94669. * @return the material itself allowing "fluent" like uniform updates
  94670. */
  94671. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  94672. /**
  94673. * Set a mat3 in the shader from a Float32Array.
  94674. * @param name Define the name of the uniform as defined in the shader
  94675. * @param value Define the value to give to the uniform
  94676. * @return the material itself allowing "fluent" like uniform updates
  94677. */
  94678. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  94679. /**
  94680. * Set a mat2 in the shader from a Float32Array.
  94681. * @param name Define the name of the uniform as defined in the shader
  94682. * @param value Define the value to give to the uniform
  94683. * @return the material itself allowing "fluent" like uniform updates
  94684. */
  94685. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  94686. /**
  94687. * Set a vec2 array in the shader from a number array.
  94688. * @param name Define the name of the uniform as defined in the shader
  94689. * @param value Define the value to give to the uniform
  94690. * @return the material itself allowing "fluent" like uniform updates
  94691. */
  94692. setArray2(name: string, value: number[]): ShaderMaterial;
  94693. /**
  94694. * Set a vec3 array in the shader from a number array.
  94695. * @param name Define the name of the uniform as defined in the shader
  94696. * @param value Define the value to give to the uniform
  94697. * @return the material itself allowing "fluent" like uniform updates
  94698. */
  94699. setArray3(name: string, value: number[]): ShaderMaterial;
  94700. /**
  94701. * Set a vec4 array in the shader from a number array.
  94702. * @param name Define the name of the uniform as defined in the shader
  94703. * @param value Define the value to give to the uniform
  94704. * @return the material itself allowing "fluent" like uniform updates
  94705. */
  94706. setArray4(name: string, value: number[]): ShaderMaterial;
  94707. private _checkCache;
  94708. /**
  94709. * Specifies that the submesh is ready to be used
  94710. * @param mesh defines the mesh to check
  94711. * @param subMesh defines which submesh to check
  94712. * @param useInstances specifies that instances should be used
  94713. * @returns a boolean indicating that the submesh is ready or not
  94714. */
  94715. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94716. /**
  94717. * Checks if the material is ready to render the requested mesh
  94718. * @param mesh Define the mesh to render
  94719. * @param useInstances Define whether or not the material is used with instances
  94720. * @returns true if ready, otherwise false
  94721. */
  94722. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94723. /**
  94724. * Binds the world matrix to the material
  94725. * @param world defines the world transformation matrix
  94726. * @param effectOverride - If provided, use this effect instead of internal effect
  94727. */
  94728. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  94729. /**
  94730. * Binds the submesh to this material by preparing the effect and shader to draw
  94731. * @param world defines the world transformation matrix
  94732. * @param mesh defines the mesh containing the submesh
  94733. * @param subMesh defines the submesh to bind the material to
  94734. */
  94735. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94736. /**
  94737. * Binds the material to the mesh
  94738. * @param world defines the world transformation matrix
  94739. * @param mesh defines the mesh to bind the material to
  94740. * @param effectOverride - If provided, use this effect instead of internal effect
  94741. */
  94742. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  94743. protected _afterBind(mesh?: Mesh): void;
  94744. /**
  94745. * Gets the active textures from the material
  94746. * @returns an array of textures
  94747. */
  94748. getActiveTextures(): BaseTexture[];
  94749. /**
  94750. * Specifies if the material uses a texture
  94751. * @param texture defines the texture to check against the material
  94752. * @returns a boolean specifying if the material uses the texture
  94753. */
  94754. hasTexture(texture: BaseTexture): boolean;
  94755. /**
  94756. * Makes a duplicate of the material, and gives it a new name
  94757. * @param name defines the new name for the duplicated material
  94758. * @returns the cloned material
  94759. */
  94760. clone(name: string): ShaderMaterial;
  94761. /**
  94762. * Disposes the material
  94763. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94764. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94765. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94766. */
  94767. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94768. /**
  94769. * Serializes this material in a JSON representation
  94770. * @returns the serialized material object
  94771. */
  94772. serialize(): any;
  94773. /**
  94774. * Creates a shader material from parsed shader material data
  94775. * @param source defines the JSON represnetation of the material
  94776. * @param scene defines the hosting scene
  94777. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94778. * @returns a new material
  94779. */
  94780. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  94781. /**
  94782. * Creates a new ShaderMaterial from a snippet saved in a remote file
  94783. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  94784. * @param url defines the url to load from
  94785. * @param scene defines the hosting scene
  94786. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94787. * @returns a promise that will resolve to the new ShaderMaterial
  94788. */
  94789. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94790. /**
  94791. * Creates a ShaderMaterial from a snippet saved by the Inspector
  94792. * @param snippetId defines the snippet to load
  94793. * @param scene defines the hosting scene
  94794. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94795. * @returns a promise that will resolve to the new ShaderMaterial
  94796. */
  94797. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94798. }
  94799. }
  94800. declare module BABYLON {
  94801. /** @hidden */
  94802. export var colorPixelShader: {
  94803. name: string;
  94804. shader: string;
  94805. };
  94806. }
  94807. declare module BABYLON {
  94808. /** @hidden */
  94809. export var colorVertexShader: {
  94810. name: string;
  94811. shader: string;
  94812. };
  94813. }
  94814. declare module BABYLON {
  94815. /**
  94816. * Line mesh
  94817. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  94818. */
  94819. export class LinesMesh extends Mesh {
  94820. /**
  94821. * If vertex color should be applied to the mesh
  94822. */
  94823. readonly useVertexColor?: boolean | undefined;
  94824. /**
  94825. * If vertex alpha should be applied to the mesh
  94826. */
  94827. readonly useVertexAlpha?: boolean | undefined;
  94828. /**
  94829. * Color of the line (Default: White)
  94830. */
  94831. color: Color3;
  94832. /**
  94833. * Alpha of the line (Default: 1)
  94834. */
  94835. alpha: number;
  94836. /**
  94837. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94838. * This margin is expressed in world space coordinates, so its value may vary.
  94839. * Default value is 0.1
  94840. */
  94841. intersectionThreshold: number;
  94842. private _colorShader;
  94843. private color4;
  94844. /**
  94845. * Creates a new LinesMesh
  94846. * @param name defines the name
  94847. * @param scene defines the hosting scene
  94848. * @param parent defines the parent mesh if any
  94849. * @param source defines the optional source LinesMesh used to clone data from
  94850. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94851. * When false, achieved by calling a clone(), also passing False.
  94852. * This will make creation of children, recursive.
  94853. * @param useVertexColor defines if this LinesMesh supports vertex color
  94854. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  94855. */
  94856. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  94857. /**
  94858. * If vertex color should be applied to the mesh
  94859. */
  94860. useVertexColor?: boolean | undefined,
  94861. /**
  94862. * If vertex alpha should be applied to the mesh
  94863. */
  94864. useVertexAlpha?: boolean | undefined);
  94865. private _addClipPlaneDefine;
  94866. private _removeClipPlaneDefine;
  94867. isReady(): boolean;
  94868. /**
  94869. * Returns the string "LineMesh"
  94870. */
  94871. getClassName(): string;
  94872. /**
  94873. * @hidden
  94874. */
  94875. get material(): Material;
  94876. /**
  94877. * @hidden
  94878. */
  94879. set material(value: Material);
  94880. /**
  94881. * @hidden
  94882. */
  94883. get checkCollisions(): boolean;
  94884. /** @hidden */
  94885. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  94886. /** @hidden */
  94887. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  94888. /**
  94889. * Disposes of the line mesh
  94890. * @param doNotRecurse If children should be disposed
  94891. */
  94892. dispose(doNotRecurse?: boolean): void;
  94893. /**
  94894. * Returns a new LineMesh object cloned from the current one.
  94895. */
  94896. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  94897. /**
  94898. * Creates a new InstancedLinesMesh object from the mesh model.
  94899. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94900. * @param name defines the name of the new instance
  94901. * @returns a new InstancedLinesMesh
  94902. */
  94903. createInstance(name: string): InstancedLinesMesh;
  94904. }
  94905. /**
  94906. * Creates an instance based on a source LinesMesh
  94907. */
  94908. export class InstancedLinesMesh extends InstancedMesh {
  94909. /**
  94910. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94911. * This margin is expressed in world space coordinates, so its value may vary.
  94912. * Initilized with the intersectionThreshold value of the source LinesMesh
  94913. */
  94914. intersectionThreshold: number;
  94915. constructor(name: string, source: LinesMesh);
  94916. /**
  94917. * Returns the string "InstancedLinesMesh".
  94918. */
  94919. getClassName(): string;
  94920. }
  94921. }
  94922. declare module BABYLON {
  94923. /** @hidden */
  94924. export var linePixelShader: {
  94925. name: string;
  94926. shader: string;
  94927. };
  94928. }
  94929. declare module BABYLON {
  94930. /** @hidden */
  94931. export var lineVertexShader: {
  94932. name: string;
  94933. shader: string;
  94934. };
  94935. }
  94936. declare module BABYLON {
  94937. interface Scene {
  94938. /** @hidden */
  94939. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  94940. }
  94941. interface AbstractMesh {
  94942. /**
  94943. * Gets the edgesRenderer associated with the mesh
  94944. */
  94945. edgesRenderer: Nullable<EdgesRenderer>;
  94946. }
  94947. interface LinesMesh {
  94948. /**
  94949. * Enables the edge rendering mode on the mesh.
  94950. * This mode makes the mesh edges visible
  94951. * @param epsilon defines the maximal distance between two angles to detect a face
  94952. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94953. * @returns the currentAbstractMesh
  94954. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94955. */
  94956. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94957. }
  94958. interface InstancedLinesMesh {
  94959. /**
  94960. * Enables the edge rendering mode on the mesh.
  94961. * This mode makes the mesh edges visible
  94962. * @param epsilon defines the maximal distance between two angles to detect a face
  94963. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94964. * @returns the current InstancedLinesMesh
  94965. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94966. */
  94967. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  94968. }
  94969. /**
  94970. * Defines the minimum contract an Edges renderer should follow.
  94971. */
  94972. export interface IEdgesRenderer extends IDisposable {
  94973. /**
  94974. * Gets or sets a boolean indicating if the edgesRenderer is active
  94975. */
  94976. isEnabled: boolean;
  94977. /**
  94978. * Renders the edges of the attached mesh,
  94979. */
  94980. render(): void;
  94981. /**
  94982. * Checks wether or not the edges renderer is ready to render.
  94983. * @return true if ready, otherwise false.
  94984. */
  94985. isReady(): boolean;
  94986. /**
  94987. * List of instances to render in case the source mesh has instances
  94988. */
  94989. customInstances: SmartArray<Matrix>;
  94990. }
  94991. /**
  94992. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94993. */
  94994. export class EdgesRenderer implements IEdgesRenderer {
  94995. /**
  94996. * Define the size of the edges with an orthographic camera
  94997. */
  94998. edgesWidthScalerForOrthographic: number;
  94999. /**
  95000. * Define the size of the edges with a perspective camera
  95001. */
  95002. edgesWidthScalerForPerspective: number;
  95003. protected _source: AbstractMesh;
  95004. protected _linesPositions: number[];
  95005. protected _linesNormals: number[];
  95006. protected _linesIndices: number[];
  95007. protected _epsilon: number;
  95008. protected _indicesCount: number;
  95009. protected _lineShader: ShaderMaterial;
  95010. protected _ib: DataBuffer;
  95011. protected _buffers: {
  95012. [key: string]: Nullable<VertexBuffer>;
  95013. };
  95014. protected _buffersForInstances: {
  95015. [key: string]: Nullable<VertexBuffer>;
  95016. };
  95017. protected _checkVerticesInsteadOfIndices: boolean;
  95018. private _meshRebuildObserver;
  95019. private _meshDisposeObserver;
  95020. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  95021. isEnabled: boolean;
  95022. /**
  95023. * List of instances to render in case the source mesh has instances
  95024. */
  95025. customInstances: SmartArray<Matrix>;
  95026. private static GetShader;
  95027. /**
  95028. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  95029. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  95030. * @param source Mesh used to create edges
  95031. * @param epsilon sum of angles in adjacency to check for edge
  95032. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  95033. * @param generateEdgesLines - should generate Lines or only prepare resources.
  95034. */
  95035. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  95036. protected _prepareRessources(): void;
  95037. /** @hidden */
  95038. _rebuild(): void;
  95039. /**
  95040. * Releases the required resources for the edges renderer
  95041. */
  95042. dispose(): void;
  95043. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  95044. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  95045. /**
  95046. * Checks if the pair of p0 and p1 is en edge
  95047. * @param faceIndex
  95048. * @param edge
  95049. * @param faceNormals
  95050. * @param p0
  95051. * @param p1
  95052. * @private
  95053. */
  95054. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  95055. /**
  95056. * push line into the position, normal and index buffer
  95057. * @protected
  95058. */
  95059. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  95060. /**
  95061. * Generates lines edges from adjacencjes
  95062. * @private
  95063. */
  95064. _generateEdgesLines(): void;
  95065. /**
  95066. * Checks wether or not the edges renderer is ready to render.
  95067. * @return true if ready, otherwise false.
  95068. */
  95069. isReady(): boolean;
  95070. /**
  95071. * Renders the edges of the attached mesh,
  95072. */
  95073. render(): void;
  95074. }
  95075. /**
  95076. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  95077. */
  95078. export class LineEdgesRenderer extends EdgesRenderer {
  95079. /**
  95080. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  95081. * @param source LineMesh used to generate edges
  95082. * @param epsilon not important (specified angle for edge detection)
  95083. * @param checkVerticesInsteadOfIndices not important for LineMesh
  95084. */
  95085. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  95086. /**
  95087. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  95088. */
  95089. _generateEdgesLines(): void;
  95090. }
  95091. }
  95092. declare module BABYLON {
  95093. /**
  95094. * This represents the object necessary to create a rendering group.
  95095. * This is exclusively used and created by the rendering manager.
  95096. * To modify the behavior, you use the available helpers in your scene or meshes.
  95097. * @hidden
  95098. */
  95099. export class RenderingGroup {
  95100. index: number;
  95101. private static _zeroVector;
  95102. private _scene;
  95103. private _opaqueSubMeshes;
  95104. private _transparentSubMeshes;
  95105. private _alphaTestSubMeshes;
  95106. private _depthOnlySubMeshes;
  95107. private _particleSystems;
  95108. private _spriteManagers;
  95109. private _opaqueSortCompareFn;
  95110. private _alphaTestSortCompareFn;
  95111. private _transparentSortCompareFn;
  95112. private _renderOpaque;
  95113. private _renderAlphaTest;
  95114. private _renderTransparent;
  95115. /** @hidden */
  95116. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  95117. onBeforeTransparentRendering: () => void;
  95118. /**
  95119. * Set the opaque sort comparison function.
  95120. * If null the sub meshes will be render in the order they were created
  95121. */
  95122. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95123. /**
  95124. * Set the alpha test sort comparison function.
  95125. * If null the sub meshes will be render in the order they were created
  95126. */
  95127. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95128. /**
  95129. * Set the transparent sort comparison function.
  95130. * If null the sub meshes will be render in the order they were created
  95131. */
  95132. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95133. /**
  95134. * Creates a new rendering group.
  95135. * @param index The rendering group index
  95136. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  95137. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  95138. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  95139. */
  95140. 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>);
  95141. /**
  95142. * Render all the sub meshes contained in the group.
  95143. * @param customRenderFunction Used to override the default render behaviour of the group.
  95144. * @returns true if rendered some submeshes.
  95145. */
  95146. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  95147. /**
  95148. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  95149. * @param subMeshes The submeshes to render
  95150. */
  95151. private renderOpaqueSorted;
  95152. /**
  95153. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  95154. * @param subMeshes The submeshes to render
  95155. */
  95156. private renderAlphaTestSorted;
  95157. /**
  95158. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  95159. * @param subMeshes The submeshes to render
  95160. */
  95161. private renderTransparentSorted;
  95162. /**
  95163. * Renders the submeshes in a specified order.
  95164. * @param subMeshes The submeshes to sort before render
  95165. * @param sortCompareFn The comparison function use to sort
  95166. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  95167. * @param transparent Specifies to activate blending if true
  95168. */
  95169. private static renderSorted;
  95170. /**
  95171. * Renders the submeshes in the order they were dispatched (no sort applied).
  95172. * @param subMeshes The submeshes to render
  95173. */
  95174. private static renderUnsorted;
  95175. /**
  95176. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95177. * are rendered back to front if in the same alpha index.
  95178. *
  95179. * @param a The first submesh
  95180. * @param b The second submesh
  95181. * @returns The result of the comparison
  95182. */
  95183. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  95184. /**
  95185. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95186. * are rendered back to front.
  95187. *
  95188. * @param a The first submesh
  95189. * @param b The second submesh
  95190. * @returns The result of the comparison
  95191. */
  95192. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  95193. /**
  95194. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95195. * are rendered front to back (prevent overdraw).
  95196. *
  95197. * @param a The first submesh
  95198. * @param b The second submesh
  95199. * @returns The result of the comparison
  95200. */
  95201. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  95202. /**
  95203. * Resets the different lists of submeshes to prepare a new frame.
  95204. */
  95205. prepare(): void;
  95206. dispose(): void;
  95207. /**
  95208. * Inserts the submesh in its correct queue depending on its material.
  95209. * @param subMesh The submesh to dispatch
  95210. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95211. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95212. */
  95213. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95214. dispatchSprites(spriteManager: ISpriteManager): void;
  95215. dispatchParticles(particleSystem: IParticleSystem): void;
  95216. private _renderParticles;
  95217. private _renderSprites;
  95218. }
  95219. }
  95220. declare module BABYLON {
  95221. /**
  95222. * Interface describing the different options available in the rendering manager
  95223. * regarding Auto Clear between groups.
  95224. */
  95225. export interface IRenderingManagerAutoClearSetup {
  95226. /**
  95227. * Defines whether or not autoclear is enable.
  95228. */
  95229. autoClear: boolean;
  95230. /**
  95231. * Defines whether or not to autoclear the depth buffer.
  95232. */
  95233. depth: boolean;
  95234. /**
  95235. * Defines whether or not to autoclear the stencil buffer.
  95236. */
  95237. stencil: boolean;
  95238. }
  95239. /**
  95240. * This class is used by the onRenderingGroupObservable
  95241. */
  95242. export class RenderingGroupInfo {
  95243. /**
  95244. * The Scene that being rendered
  95245. */
  95246. scene: Scene;
  95247. /**
  95248. * The camera currently used for the rendering pass
  95249. */
  95250. camera: Nullable<Camera>;
  95251. /**
  95252. * The ID of the renderingGroup being processed
  95253. */
  95254. renderingGroupId: number;
  95255. }
  95256. /**
  95257. * This is the manager responsible of all the rendering for meshes sprites and particles.
  95258. * It is enable to manage the different groups as well as the different necessary sort functions.
  95259. * This should not be used directly aside of the few static configurations
  95260. */
  95261. export class RenderingManager {
  95262. /**
  95263. * The max id used for rendering groups (not included)
  95264. */
  95265. static MAX_RENDERINGGROUPS: number;
  95266. /**
  95267. * The min id used for rendering groups (included)
  95268. */
  95269. static MIN_RENDERINGGROUPS: number;
  95270. /**
  95271. * Used to globally prevent autoclearing scenes.
  95272. */
  95273. static AUTOCLEAR: boolean;
  95274. /**
  95275. * @hidden
  95276. */
  95277. _useSceneAutoClearSetup: boolean;
  95278. private _scene;
  95279. private _renderingGroups;
  95280. private _depthStencilBufferAlreadyCleaned;
  95281. private _autoClearDepthStencil;
  95282. private _customOpaqueSortCompareFn;
  95283. private _customAlphaTestSortCompareFn;
  95284. private _customTransparentSortCompareFn;
  95285. private _renderingGroupInfo;
  95286. /**
  95287. * Instantiates a new rendering group for a particular scene
  95288. * @param scene Defines the scene the groups belongs to
  95289. */
  95290. constructor(scene: Scene);
  95291. private _clearDepthStencilBuffer;
  95292. /**
  95293. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  95294. * @hidden
  95295. */
  95296. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  95297. /**
  95298. * Resets the different information of the group to prepare a new frame
  95299. * @hidden
  95300. */
  95301. reset(): void;
  95302. /**
  95303. * Dispose and release the group and its associated resources.
  95304. * @hidden
  95305. */
  95306. dispose(): void;
  95307. /**
  95308. * Clear the info related to rendering groups preventing retention points during dispose.
  95309. */
  95310. freeRenderingGroups(): void;
  95311. private _prepareRenderingGroup;
  95312. /**
  95313. * Add a sprite manager to the rendering manager in order to render it this frame.
  95314. * @param spriteManager Define the sprite manager to render
  95315. */
  95316. dispatchSprites(spriteManager: ISpriteManager): void;
  95317. /**
  95318. * Add a particle system to the rendering manager in order to render it this frame.
  95319. * @param particleSystem Define the particle system to render
  95320. */
  95321. dispatchParticles(particleSystem: IParticleSystem): void;
  95322. /**
  95323. * Add a submesh to the manager in order to render it this frame
  95324. * @param subMesh The submesh to dispatch
  95325. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95326. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95327. */
  95328. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95329. /**
  95330. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95331. * This allowed control for front to back rendering or reversly depending of the special needs.
  95332. *
  95333. * @param renderingGroupId The rendering group id corresponding to its index
  95334. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95335. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95336. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95337. */
  95338. 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;
  95339. /**
  95340. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95341. *
  95342. * @param renderingGroupId The rendering group id corresponding to its index
  95343. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95344. * @param depth Automatically clears depth between groups if true and autoClear is true.
  95345. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  95346. */
  95347. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  95348. /**
  95349. * Gets the current auto clear configuration for one rendering group of the rendering
  95350. * manager.
  95351. * @param index the rendering group index to get the information for
  95352. * @returns The auto clear setup for the requested rendering group
  95353. */
  95354. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  95355. }
  95356. }
  95357. declare module BABYLON {
  95358. /**
  95359. * Defines the options associated with the creation of a custom shader for a shadow generator.
  95360. */
  95361. export interface ICustomShaderOptions {
  95362. /**
  95363. * Gets or sets the custom shader name to use
  95364. */
  95365. shaderName: string;
  95366. /**
  95367. * The list of attribute names used in the shader
  95368. */
  95369. attributes?: string[];
  95370. /**
  95371. * The list of unifrom names used in the shader
  95372. */
  95373. uniforms?: string[];
  95374. /**
  95375. * The list of sampler names used in the shader
  95376. */
  95377. samplers?: string[];
  95378. /**
  95379. * The list of defines used in the shader
  95380. */
  95381. defines?: string[];
  95382. }
  95383. /**
  95384. * Interface to implement to create a shadow generator compatible with BJS.
  95385. */
  95386. export interface IShadowGenerator {
  95387. /**
  95388. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95389. * @returns The render target texture if present otherwise, null
  95390. */
  95391. getShadowMap(): Nullable<RenderTargetTexture>;
  95392. /**
  95393. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95394. * @param subMesh The submesh we want to render in the shadow map
  95395. * @param useInstances Defines wether will draw in the map using instances
  95396. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95397. * @returns true if ready otherwise, false
  95398. */
  95399. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95400. /**
  95401. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95402. * @param defines Defines of the material we want to update
  95403. * @param lightIndex Index of the light in the enabled light list of the material
  95404. */
  95405. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  95406. /**
  95407. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95408. * defined in the generator but impacting the effect).
  95409. * It implies the unifroms available on the materials are the standard BJS ones.
  95410. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95411. * @param effect The effect we are binfing the information for
  95412. */
  95413. bindShadowLight(lightIndex: string, effect: Effect): void;
  95414. /**
  95415. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95416. * (eq to shadow prjection matrix * light transform matrix)
  95417. * @returns The transform matrix used to create the shadow map
  95418. */
  95419. getTransformMatrix(): Matrix;
  95420. /**
  95421. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95422. * Cube and 2D textures for instance.
  95423. */
  95424. recreateShadowMap(): void;
  95425. /**
  95426. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95427. * @param onCompiled Callback triggered at the and of the effects compilation
  95428. * @param options Sets of optional options forcing the compilation with different modes
  95429. */
  95430. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95431. useInstances: boolean;
  95432. }>): void;
  95433. /**
  95434. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95435. * @param options Sets of optional options forcing the compilation with different modes
  95436. * @returns A promise that resolves when the compilation completes
  95437. */
  95438. forceCompilationAsync(options?: Partial<{
  95439. useInstances: boolean;
  95440. }>): Promise<void>;
  95441. /**
  95442. * Serializes the shadow generator setup to a json object.
  95443. * @returns The serialized JSON object
  95444. */
  95445. serialize(): any;
  95446. /**
  95447. * Disposes the Shadow map and related Textures and effects.
  95448. */
  95449. dispose(): void;
  95450. }
  95451. /**
  95452. * Default implementation IShadowGenerator.
  95453. * This is the main object responsible of generating shadows in the framework.
  95454. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  95455. */
  95456. export class ShadowGenerator implements IShadowGenerator {
  95457. /**
  95458. * Name of the shadow generator class
  95459. */
  95460. static CLASSNAME: string;
  95461. /**
  95462. * Shadow generator mode None: no filtering applied.
  95463. */
  95464. static readonly FILTER_NONE: number;
  95465. /**
  95466. * Shadow generator mode ESM: Exponential Shadow Mapping.
  95467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95468. */
  95469. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  95470. /**
  95471. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  95472. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  95473. */
  95474. static readonly FILTER_POISSONSAMPLING: number;
  95475. /**
  95476. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  95477. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95478. */
  95479. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  95480. /**
  95481. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  95482. * edge artifacts on steep falloff.
  95483. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95484. */
  95485. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  95486. /**
  95487. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  95488. * edge artifacts on steep falloff.
  95489. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95490. */
  95491. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  95492. /**
  95493. * Shadow generator mode PCF: Percentage Closer Filtering
  95494. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95495. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  95496. */
  95497. static readonly FILTER_PCF: number;
  95498. /**
  95499. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  95500. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95501. * Contact Hardening
  95502. */
  95503. static readonly FILTER_PCSS: number;
  95504. /**
  95505. * Reserved for PCF and PCSS
  95506. * Highest Quality.
  95507. *
  95508. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  95509. *
  95510. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  95511. */
  95512. static readonly QUALITY_HIGH: number;
  95513. /**
  95514. * Reserved for PCF and PCSS
  95515. * Good tradeoff for quality/perf cross devices
  95516. *
  95517. * Execute PCF on a 3*3 kernel.
  95518. *
  95519. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  95520. */
  95521. static readonly QUALITY_MEDIUM: number;
  95522. /**
  95523. * Reserved for PCF and PCSS
  95524. * The lowest quality but the fastest.
  95525. *
  95526. * Execute PCF on a 1*1 kernel.
  95527. *
  95528. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  95529. */
  95530. static readonly QUALITY_LOW: number;
  95531. /** Gets or sets the custom shader name to use */
  95532. customShaderOptions: ICustomShaderOptions;
  95533. /**
  95534. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  95535. */
  95536. onBeforeShadowMapRenderObservable: Observable<Effect>;
  95537. /**
  95538. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  95539. */
  95540. onAfterShadowMapRenderObservable: Observable<Effect>;
  95541. /**
  95542. * Observable triggered before a mesh is rendered in the shadow map.
  95543. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  95544. */
  95545. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  95546. /**
  95547. * Observable triggered after a mesh is rendered in the shadow map.
  95548. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  95549. */
  95550. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  95551. protected _bias: number;
  95552. /**
  95553. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  95554. */
  95555. get bias(): number;
  95556. /**
  95557. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  95558. */
  95559. set bias(bias: number);
  95560. protected _normalBias: number;
  95561. /**
  95562. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95563. */
  95564. get normalBias(): number;
  95565. /**
  95566. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95567. */
  95568. set normalBias(normalBias: number);
  95569. protected _blurBoxOffset: number;
  95570. /**
  95571. * Gets the blur box offset: offset applied during the blur pass.
  95572. * Only useful if useKernelBlur = false
  95573. */
  95574. get blurBoxOffset(): number;
  95575. /**
  95576. * Sets the blur box offset: offset applied during the blur pass.
  95577. * Only useful if useKernelBlur = false
  95578. */
  95579. set blurBoxOffset(value: number);
  95580. protected _blurScale: number;
  95581. /**
  95582. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  95583. * 2 means half of the size.
  95584. */
  95585. get blurScale(): number;
  95586. /**
  95587. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  95588. * 2 means half of the size.
  95589. */
  95590. set blurScale(value: number);
  95591. protected _blurKernel: number;
  95592. /**
  95593. * Gets the blur kernel: kernel size of the blur pass.
  95594. * Only useful if useKernelBlur = true
  95595. */
  95596. get blurKernel(): number;
  95597. /**
  95598. * Sets the blur kernel: kernel size of the blur pass.
  95599. * Only useful if useKernelBlur = true
  95600. */
  95601. set blurKernel(value: number);
  95602. protected _useKernelBlur: boolean;
  95603. /**
  95604. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  95605. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95606. */
  95607. get useKernelBlur(): boolean;
  95608. /**
  95609. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  95610. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95611. */
  95612. set useKernelBlur(value: boolean);
  95613. protected _depthScale: number;
  95614. /**
  95615. * Gets the depth scale used in ESM mode.
  95616. */
  95617. get depthScale(): number;
  95618. /**
  95619. * Sets the depth scale used in ESM mode.
  95620. * This can override the scale stored on the light.
  95621. */
  95622. set depthScale(value: number);
  95623. protected _validateFilter(filter: number): number;
  95624. protected _filter: number;
  95625. /**
  95626. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  95627. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95628. */
  95629. get filter(): number;
  95630. /**
  95631. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  95632. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95633. */
  95634. set filter(value: number);
  95635. /**
  95636. * Gets if the current filter is set to Poisson Sampling.
  95637. */
  95638. get usePoissonSampling(): boolean;
  95639. /**
  95640. * Sets the current filter to Poisson Sampling.
  95641. */
  95642. set usePoissonSampling(value: boolean);
  95643. /**
  95644. * Gets if the current filter is set to ESM.
  95645. */
  95646. get useExponentialShadowMap(): boolean;
  95647. /**
  95648. * Sets the current filter is to ESM.
  95649. */
  95650. set useExponentialShadowMap(value: boolean);
  95651. /**
  95652. * Gets if the current filter is set to filtered ESM.
  95653. */
  95654. get useBlurExponentialShadowMap(): boolean;
  95655. /**
  95656. * Gets if the current filter is set to filtered ESM.
  95657. */
  95658. set useBlurExponentialShadowMap(value: boolean);
  95659. /**
  95660. * Gets if the current filter is set to "close ESM" (using the inverse of the
  95661. * exponential to prevent steep falloff artifacts).
  95662. */
  95663. get useCloseExponentialShadowMap(): boolean;
  95664. /**
  95665. * Sets the current filter to "close ESM" (using the inverse of the
  95666. * exponential to prevent steep falloff artifacts).
  95667. */
  95668. set useCloseExponentialShadowMap(value: boolean);
  95669. /**
  95670. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  95671. * exponential to prevent steep falloff artifacts).
  95672. */
  95673. get useBlurCloseExponentialShadowMap(): boolean;
  95674. /**
  95675. * Sets the current filter to filtered "close ESM" (using the inverse of the
  95676. * exponential to prevent steep falloff artifacts).
  95677. */
  95678. set useBlurCloseExponentialShadowMap(value: boolean);
  95679. /**
  95680. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  95681. */
  95682. get usePercentageCloserFiltering(): boolean;
  95683. /**
  95684. * Sets the current filter to "PCF" (percentage closer filtering).
  95685. */
  95686. set usePercentageCloserFiltering(value: boolean);
  95687. protected _filteringQuality: number;
  95688. /**
  95689. * Gets the PCF or PCSS Quality.
  95690. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95691. */
  95692. get filteringQuality(): number;
  95693. /**
  95694. * Sets the PCF or PCSS Quality.
  95695. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95696. */
  95697. set filteringQuality(filteringQuality: number);
  95698. /**
  95699. * Gets if the current filter is set to "PCSS" (contact hardening).
  95700. */
  95701. get useContactHardeningShadow(): boolean;
  95702. /**
  95703. * Sets the current filter to "PCSS" (contact hardening).
  95704. */
  95705. set useContactHardeningShadow(value: boolean);
  95706. protected _contactHardeningLightSizeUVRatio: number;
  95707. /**
  95708. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95709. * Using a ratio helps keeping shape stability independently of the map size.
  95710. *
  95711. * It does not account for the light projection as it was having too much
  95712. * instability during the light setup or during light position changes.
  95713. *
  95714. * Only valid if useContactHardeningShadow is true.
  95715. */
  95716. get contactHardeningLightSizeUVRatio(): number;
  95717. /**
  95718. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95719. * Using a ratio helps keeping shape stability independently of the map size.
  95720. *
  95721. * It does not account for the light projection as it was having too much
  95722. * instability during the light setup or during light position changes.
  95723. *
  95724. * Only valid if useContactHardeningShadow is true.
  95725. */
  95726. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  95727. protected _darkness: number;
  95728. /** Gets or sets the actual darkness of a shadow */
  95729. get darkness(): number;
  95730. set darkness(value: number);
  95731. /**
  95732. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  95733. * 0 means strongest and 1 would means no shadow.
  95734. * @returns the darkness.
  95735. */
  95736. getDarkness(): number;
  95737. /**
  95738. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  95739. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  95740. * @returns the shadow generator allowing fluent coding.
  95741. */
  95742. setDarkness(darkness: number): ShadowGenerator;
  95743. protected _transparencyShadow: boolean;
  95744. /** Gets or sets the ability to have transparent shadow */
  95745. get transparencyShadow(): boolean;
  95746. set transparencyShadow(value: boolean);
  95747. /**
  95748. * Sets the ability to have transparent shadow (boolean).
  95749. * @param transparent True if transparent else False
  95750. * @returns the shadow generator allowing fluent coding
  95751. */
  95752. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  95753. /**
  95754. * Enables or disables shadows with varying strength based on the transparency
  95755. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  95756. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  95757. * mesh.visibility * alphaTexture.a
  95758. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  95759. */
  95760. enableSoftTransparentShadow: boolean;
  95761. protected _shadowMap: Nullable<RenderTargetTexture>;
  95762. protected _shadowMap2: Nullable<RenderTargetTexture>;
  95763. /**
  95764. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95765. * @returns The render target texture if present otherwise, null
  95766. */
  95767. getShadowMap(): Nullable<RenderTargetTexture>;
  95768. /**
  95769. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  95770. * @returns The render target texture if the shadow map is present otherwise, null
  95771. */
  95772. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  95773. /**
  95774. * Gets the class name of that object
  95775. * @returns "ShadowGenerator"
  95776. */
  95777. getClassName(): string;
  95778. /**
  95779. * Helper function to add a mesh and its descendants to the list of shadow casters.
  95780. * @param mesh Mesh to add
  95781. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  95782. * @returns the Shadow Generator itself
  95783. */
  95784. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95785. /**
  95786. * Helper function to remove a mesh and its descendants from the list of shadow casters
  95787. * @param mesh Mesh to remove
  95788. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  95789. * @returns the Shadow Generator itself
  95790. */
  95791. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95792. /**
  95793. * Controls the extent to which the shadows fade out at the edge of the frustum
  95794. */
  95795. frustumEdgeFalloff: number;
  95796. protected _light: IShadowLight;
  95797. /**
  95798. * Returns the associated light object.
  95799. * @returns the light generating the shadow
  95800. */
  95801. getLight(): IShadowLight;
  95802. /**
  95803. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  95804. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  95805. * It might on the other hand introduce peter panning.
  95806. */
  95807. forceBackFacesOnly: boolean;
  95808. protected _scene: Scene;
  95809. protected _lightDirection: Vector3;
  95810. protected _effect: Effect;
  95811. protected _viewMatrix: Matrix;
  95812. protected _projectionMatrix: Matrix;
  95813. protected _transformMatrix: Matrix;
  95814. protected _cachedPosition: Vector3;
  95815. protected _cachedDirection: Vector3;
  95816. protected _cachedDefines: string;
  95817. protected _currentRenderID: number;
  95818. protected _boxBlurPostprocess: Nullable<PostProcess>;
  95819. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  95820. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  95821. protected _blurPostProcesses: PostProcess[];
  95822. protected _mapSize: number;
  95823. protected _currentFaceIndex: number;
  95824. protected _currentFaceIndexCache: number;
  95825. protected _textureType: number;
  95826. protected _defaultTextureMatrix: Matrix;
  95827. protected _storedUniqueId: Nullable<number>;
  95828. /** @hidden */
  95829. static _SceneComponentInitialization: (scene: Scene) => void;
  95830. /**
  95831. * Creates a ShadowGenerator object.
  95832. * A ShadowGenerator is the required tool to use the shadows.
  95833. * Each light casting shadows needs to use its own ShadowGenerator.
  95834. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  95835. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  95836. * @param light The light object generating the shadows.
  95837. * @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.
  95838. */
  95839. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  95840. protected _initializeGenerator(): void;
  95841. protected _createTargetRenderTexture(): void;
  95842. protected _initializeShadowMap(): void;
  95843. protected _initializeBlurRTTAndPostProcesses(): void;
  95844. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  95845. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  95846. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  95847. protected _applyFilterValues(): void;
  95848. /**
  95849. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95850. * @param onCompiled Callback triggered at the and of the effects compilation
  95851. * @param options Sets of optional options forcing the compilation with different modes
  95852. */
  95853. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95854. useInstances: boolean;
  95855. }>): void;
  95856. /**
  95857. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95858. * @param options Sets of optional options forcing the compilation with different modes
  95859. * @returns A promise that resolves when the compilation completes
  95860. */
  95861. forceCompilationAsync(options?: Partial<{
  95862. useInstances: boolean;
  95863. }>): Promise<void>;
  95864. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  95865. private _prepareShadowDefines;
  95866. /**
  95867. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95868. * @param subMesh The submesh we want to render in the shadow map
  95869. * @param useInstances Defines wether will draw in the map using instances
  95870. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95871. * @returns true if ready otherwise, false
  95872. */
  95873. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95874. /**
  95875. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95876. * @param defines Defines of the material we want to update
  95877. * @param lightIndex Index of the light in the enabled light list of the material
  95878. */
  95879. prepareDefines(defines: any, lightIndex: number): void;
  95880. /**
  95881. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95882. * defined in the generator but impacting the effect).
  95883. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95884. * @param effect The effect we are binfing the information for
  95885. */
  95886. bindShadowLight(lightIndex: string, effect: Effect): void;
  95887. /**
  95888. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95889. * (eq to shadow prjection matrix * light transform matrix)
  95890. * @returns The transform matrix used to create the shadow map
  95891. */
  95892. getTransformMatrix(): Matrix;
  95893. /**
  95894. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95895. * Cube and 2D textures for instance.
  95896. */
  95897. recreateShadowMap(): void;
  95898. protected _disposeBlurPostProcesses(): void;
  95899. protected _disposeRTTandPostProcesses(): void;
  95900. /**
  95901. * Disposes the ShadowGenerator.
  95902. * Returns nothing.
  95903. */
  95904. dispose(): void;
  95905. /**
  95906. * Serializes the shadow generator setup to a json object.
  95907. * @returns The serialized JSON object
  95908. */
  95909. serialize(): any;
  95910. /**
  95911. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  95912. * @param parsedShadowGenerator The JSON object to parse
  95913. * @param scene The scene to create the shadow map for
  95914. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  95915. * @returns The parsed shadow generator
  95916. */
  95917. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  95918. }
  95919. }
  95920. declare module BABYLON {
  95921. /**
  95922. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  95923. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  95924. * 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.
  95925. */
  95926. export abstract class Light extends Node {
  95927. /**
  95928. * Falloff Default: light is falling off following the material specification:
  95929. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  95930. */
  95931. static readonly FALLOFF_DEFAULT: number;
  95932. /**
  95933. * Falloff Physical: light is falling off following the inverse squared distance law.
  95934. */
  95935. static readonly FALLOFF_PHYSICAL: number;
  95936. /**
  95937. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  95938. * to enhance interoperability with other engines.
  95939. */
  95940. static readonly FALLOFF_GLTF: number;
  95941. /**
  95942. * Falloff Standard: light is falling off like in the standard material
  95943. * to enhance interoperability with other materials.
  95944. */
  95945. static readonly FALLOFF_STANDARD: number;
  95946. /**
  95947. * If every light affecting the material is in this lightmapMode,
  95948. * material.lightmapTexture adds or multiplies
  95949. * (depends on material.useLightmapAsShadowmap)
  95950. * after every other light calculations.
  95951. */
  95952. static readonly LIGHTMAP_DEFAULT: number;
  95953. /**
  95954. * material.lightmapTexture as only diffuse lighting from this light
  95955. * adds only specular lighting from this light
  95956. * adds dynamic shadows
  95957. */
  95958. static readonly LIGHTMAP_SPECULAR: number;
  95959. /**
  95960. * material.lightmapTexture as only lighting
  95961. * no light calculation from this light
  95962. * only adds dynamic shadows from this light
  95963. */
  95964. static readonly LIGHTMAP_SHADOWSONLY: number;
  95965. /**
  95966. * Each light type uses the default quantity according to its type:
  95967. * point/spot lights use luminous intensity
  95968. * directional lights use illuminance
  95969. */
  95970. static readonly INTENSITYMODE_AUTOMATIC: number;
  95971. /**
  95972. * lumen (lm)
  95973. */
  95974. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  95975. /**
  95976. * candela (lm/sr)
  95977. */
  95978. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  95979. /**
  95980. * lux (lm/m^2)
  95981. */
  95982. static readonly INTENSITYMODE_ILLUMINANCE: number;
  95983. /**
  95984. * nit (cd/m^2)
  95985. */
  95986. static readonly INTENSITYMODE_LUMINANCE: number;
  95987. /**
  95988. * Light type const id of the point light.
  95989. */
  95990. static readonly LIGHTTYPEID_POINTLIGHT: number;
  95991. /**
  95992. * Light type const id of the directional light.
  95993. */
  95994. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  95995. /**
  95996. * Light type const id of the spot light.
  95997. */
  95998. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  95999. /**
  96000. * Light type const id of the hemispheric light.
  96001. */
  96002. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  96003. /**
  96004. * Diffuse gives the basic color to an object.
  96005. */
  96006. diffuse: Color3;
  96007. /**
  96008. * Specular produces a highlight color on an object.
  96009. * Note: This is note affecting PBR materials.
  96010. */
  96011. specular: Color3;
  96012. /**
  96013. * Defines the falloff type for this light. This lets overrriding how punctual light are
  96014. * falling off base on range or angle.
  96015. * This can be set to any values in Light.FALLOFF_x.
  96016. *
  96017. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  96018. * other types of materials.
  96019. */
  96020. falloffType: number;
  96021. /**
  96022. * Strength of the light.
  96023. * Note: By default it is define in the framework own unit.
  96024. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  96025. */
  96026. intensity: number;
  96027. private _range;
  96028. protected _inverseSquaredRange: number;
  96029. /**
  96030. * Defines how far from the source the light is impacting in scene units.
  96031. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96032. */
  96033. get range(): number;
  96034. /**
  96035. * Defines how far from the source the light is impacting in scene units.
  96036. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96037. */
  96038. set range(value: number);
  96039. /**
  96040. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  96041. * of light.
  96042. */
  96043. private _photometricScale;
  96044. private _intensityMode;
  96045. /**
  96046. * Gets the photometric scale used to interpret the intensity.
  96047. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96048. */
  96049. get intensityMode(): number;
  96050. /**
  96051. * Sets the photometric scale used to interpret the intensity.
  96052. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96053. */
  96054. set intensityMode(value: number);
  96055. private _radius;
  96056. /**
  96057. * Gets the light radius used by PBR Materials to simulate soft area lights.
  96058. */
  96059. get radius(): number;
  96060. /**
  96061. * sets the light radius used by PBR Materials to simulate soft area lights.
  96062. */
  96063. set radius(value: number);
  96064. private _renderPriority;
  96065. /**
  96066. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  96067. * exceeding the number allowed of the materials.
  96068. */
  96069. renderPriority: number;
  96070. private _shadowEnabled;
  96071. /**
  96072. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96073. * the current shadow generator.
  96074. */
  96075. get shadowEnabled(): boolean;
  96076. /**
  96077. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96078. * the current shadow generator.
  96079. */
  96080. set shadowEnabled(value: boolean);
  96081. private _includedOnlyMeshes;
  96082. /**
  96083. * Gets the only meshes impacted by this light.
  96084. */
  96085. get includedOnlyMeshes(): AbstractMesh[];
  96086. /**
  96087. * Sets the only meshes impacted by this light.
  96088. */
  96089. set includedOnlyMeshes(value: AbstractMesh[]);
  96090. private _excludedMeshes;
  96091. /**
  96092. * Gets the meshes not impacted by this light.
  96093. */
  96094. get excludedMeshes(): AbstractMesh[];
  96095. /**
  96096. * Sets the meshes not impacted by this light.
  96097. */
  96098. set excludedMeshes(value: AbstractMesh[]);
  96099. private _excludeWithLayerMask;
  96100. /**
  96101. * Gets the layer id use to find what meshes are not impacted by the light.
  96102. * Inactive if 0
  96103. */
  96104. get excludeWithLayerMask(): number;
  96105. /**
  96106. * Sets the layer id use to find what meshes are not impacted by the light.
  96107. * Inactive if 0
  96108. */
  96109. set excludeWithLayerMask(value: number);
  96110. private _includeOnlyWithLayerMask;
  96111. /**
  96112. * Gets the layer id use to find what meshes are impacted by the light.
  96113. * Inactive if 0
  96114. */
  96115. get includeOnlyWithLayerMask(): number;
  96116. /**
  96117. * Sets the layer id use to find what meshes are impacted by the light.
  96118. * Inactive if 0
  96119. */
  96120. set includeOnlyWithLayerMask(value: number);
  96121. private _lightmapMode;
  96122. /**
  96123. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96124. */
  96125. get lightmapMode(): number;
  96126. /**
  96127. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96128. */
  96129. set lightmapMode(value: number);
  96130. /**
  96131. * Shadow generator associted to the light.
  96132. * @hidden Internal use only.
  96133. */
  96134. _shadowGenerator: Nullable<IShadowGenerator>;
  96135. /**
  96136. * @hidden Internal use only.
  96137. */
  96138. _excludedMeshesIds: string[];
  96139. /**
  96140. * @hidden Internal use only.
  96141. */
  96142. _includedOnlyMeshesIds: string[];
  96143. /**
  96144. * The current light unifom buffer.
  96145. * @hidden Internal use only.
  96146. */
  96147. _uniformBuffer: UniformBuffer;
  96148. /** @hidden */
  96149. _renderId: number;
  96150. /**
  96151. * Creates a Light object in the scene.
  96152. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96153. * @param name The firendly name of the light
  96154. * @param scene The scene the light belongs too
  96155. */
  96156. constructor(name: string, scene: Scene);
  96157. protected abstract _buildUniformLayout(): void;
  96158. /**
  96159. * Sets the passed Effect "effect" with the Light information.
  96160. * @param effect The effect to update
  96161. * @param lightIndex The index of the light in the effect to update
  96162. * @returns The light
  96163. */
  96164. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  96165. /**
  96166. * Sets the passed Effect "effect" with the Light textures.
  96167. * @param effect The effect to update
  96168. * @param lightIndex The index of the light in the effect to update
  96169. * @returns The light
  96170. */
  96171. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  96172. /**
  96173. * Binds the lights information from the scene to the effect for the given mesh.
  96174. * @param lightIndex Light index
  96175. * @param scene The scene where the light belongs to
  96176. * @param effect The effect we are binding the data to
  96177. * @param useSpecular Defines if specular is supported
  96178. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  96179. */
  96180. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  96181. /**
  96182. * Sets the passed Effect "effect" with the Light information.
  96183. * @param effect The effect to update
  96184. * @param lightDataUniformName The uniform used to store light data (position or direction)
  96185. * @returns The light
  96186. */
  96187. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  96188. /**
  96189. * Returns the string "Light".
  96190. * @returns the class name
  96191. */
  96192. getClassName(): string;
  96193. /** @hidden */
  96194. readonly _isLight: boolean;
  96195. /**
  96196. * Converts the light information to a readable string for debug purpose.
  96197. * @param fullDetails Supports for multiple levels of logging within scene loading
  96198. * @returns the human readable light info
  96199. */
  96200. toString(fullDetails?: boolean): string;
  96201. /** @hidden */
  96202. protected _syncParentEnabledState(): void;
  96203. /**
  96204. * Set the enabled state of this node.
  96205. * @param value - the new enabled state
  96206. */
  96207. setEnabled(value: boolean): void;
  96208. /**
  96209. * Returns the Light associated shadow generator if any.
  96210. * @return the associated shadow generator.
  96211. */
  96212. getShadowGenerator(): Nullable<IShadowGenerator>;
  96213. /**
  96214. * Returns a Vector3, the absolute light position in the World.
  96215. * @returns the world space position of the light
  96216. */
  96217. getAbsolutePosition(): Vector3;
  96218. /**
  96219. * Specifies if the light will affect the passed mesh.
  96220. * @param mesh The mesh to test against the light
  96221. * @return true the mesh is affected otherwise, false.
  96222. */
  96223. canAffectMesh(mesh: AbstractMesh): boolean;
  96224. /**
  96225. * Sort function to order lights for rendering.
  96226. * @param a First Light object to compare to second.
  96227. * @param b Second Light object to compare first.
  96228. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  96229. */
  96230. static CompareLightsPriority(a: Light, b: Light): number;
  96231. /**
  96232. * Releases resources associated with this node.
  96233. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96234. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96235. */
  96236. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96237. /**
  96238. * Returns the light type ID (integer).
  96239. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96240. */
  96241. getTypeID(): number;
  96242. /**
  96243. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  96244. * @returns the scaled intensity in intensity mode unit
  96245. */
  96246. getScaledIntensity(): number;
  96247. /**
  96248. * Returns a new Light object, named "name", from the current one.
  96249. * @param name The name of the cloned light
  96250. * @param newParent The parent of this light, if it has one
  96251. * @returns the new created light
  96252. */
  96253. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  96254. /**
  96255. * Serializes the current light into a Serialization object.
  96256. * @returns the serialized object.
  96257. */
  96258. serialize(): any;
  96259. /**
  96260. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  96261. * This new light is named "name" and added to the passed scene.
  96262. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  96263. * @param name The friendly name of the light
  96264. * @param scene The scene the new light will belong to
  96265. * @returns the constructor function
  96266. */
  96267. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  96268. /**
  96269. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  96270. * @param parsedLight The JSON representation of the light
  96271. * @param scene The scene to create the parsed light in
  96272. * @returns the created light after parsing
  96273. */
  96274. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  96275. private _hookArrayForExcluded;
  96276. private _hookArrayForIncludedOnly;
  96277. private _resyncMeshes;
  96278. /**
  96279. * Forces the meshes to update their light related information in their rendering used effects
  96280. * @hidden Internal Use Only
  96281. */
  96282. _markMeshesAsLightDirty(): void;
  96283. /**
  96284. * Recomputes the cached photometric scale if needed.
  96285. */
  96286. private _computePhotometricScale;
  96287. /**
  96288. * Returns the Photometric Scale according to the light type and intensity mode.
  96289. */
  96290. private _getPhotometricScale;
  96291. /**
  96292. * Reorder the light in the scene according to their defined priority.
  96293. * @hidden Internal Use Only
  96294. */
  96295. _reorderLightsInScene(): void;
  96296. /**
  96297. * Prepares the list of defines specific to the light type.
  96298. * @param defines the list of defines
  96299. * @param lightIndex defines the index of the light for the effect
  96300. */
  96301. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96302. }
  96303. }
  96304. declare module BABYLON {
  96305. /**
  96306. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  96307. * This is the base of the follow, arc rotate cameras and Free camera
  96308. * @see https://doc.babylonjs.com/features/cameras
  96309. */
  96310. export class TargetCamera extends Camera {
  96311. private static _RigCamTransformMatrix;
  96312. private static _TargetTransformMatrix;
  96313. private static _TargetFocalPoint;
  96314. private _tmpUpVector;
  96315. private _tmpTargetVector;
  96316. /**
  96317. * Define the current direction the camera is moving to
  96318. */
  96319. cameraDirection: Vector3;
  96320. /**
  96321. * Define the current rotation the camera is rotating to
  96322. */
  96323. cameraRotation: Vector2;
  96324. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  96325. ignoreParentScaling: boolean;
  96326. /**
  96327. * When set, the up vector of the camera will be updated by the rotation of the camera
  96328. */
  96329. updateUpVectorFromRotation: boolean;
  96330. private _tmpQuaternion;
  96331. /**
  96332. * Define the current rotation of the camera
  96333. */
  96334. rotation: Vector3;
  96335. /**
  96336. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  96337. */
  96338. rotationQuaternion: Quaternion;
  96339. /**
  96340. * Define the current speed of the camera
  96341. */
  96342. speed: number;
  96343. /**
  96344. * Add constraint to the camera to prevent it to move freely in all directions and
  96345. * around all axis.
  96346. */
  96347. noRotationConstraint: boolean;
  96348. /**
  96349. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  96350. * panning
  96351. */
  96352. invertRotation: boolean;
  96353. /**
  96354. * Speed multiplier for inverse camera panning
  96355. */
  96356. inverseRotationSpeed: number;
  96357. /**
  96358. * Define the current target of the camera as an object or a position.
  96359. */
  96360. lockedTarget: any;
  96361. /** @hidden */
  96362. _currentTarget: Vector3;
  96363. /** @hidden */
  96364. _initialFocalDistance: number;
  96365. /** @hidden */
  96366. _viewMatrix: Matrix;
  96367. /** @hidden */
  96368. _camMatrix: Matrix;
  96369. /** @hidden */
  96370. _cameraTransformMatrix: Matrix;
  96371. /** @hidden */
  96372. _cameraRotationMatrix: Matrix;
  96373. /** @hidden */
  96374. _referencePoint: Vector3;
  96375. /** @hidden */
  96376. _transformedReferencePoint: Vector3;
  96377. /** @hidden */
  96378. _reset: () => void;
  96379. private _defaultUp;
  96380. /**
  96381. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  96382. * This is the base of the follow, arc rotate cameras and Free camera
  96383. * @see https://doc.babylonjs.com/features/cameras
  96384. * @param name Defines the name of the camera in the scene
  96385. * @param position Defines the start position of the camera in the scene
  96386. * @param scene Defines the scene the camera belongs to
  96387. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96388. */
  96389. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96390. /**
  96391. * Gets the position in front of the camera at a given distance.
  96392. * @param distance The distance from the camera we want the position to be
  96393. * @returns the position
  96394. */
  96395. getFrontPosition(distance: number): Vector3;
  96396. /** @hidden */
  96397. _getLockedTargetPosition(): Nullable<Vector3>;
  96398. private _storedPosition;
  96399. private _storedRotation;
  96400. private _storedRotationQuaternion;
  96401. /**
  96402. * Store current camera state of the camera (fov, position, rotation, etc..)
  96403. * @returns the camera
  96404. */
  96405. storeState(): Camera;
  96406. /**
  96407. * Restored camera state. You must call storeState() first
  96408. * @returns whether it was successful or not
  96409. * @hidden
  96410. */
  96411. _restoreStateValues(): boolean;
  96412. /** @hidden */
  96413. _initCache(): void;
  96414. /** @hidden */
  96415. _updateCache(ignoreParentClass?: boolean): void;
  96416. /** @hidden */
  96417. _isSynchronizedViewMatrix(): boolean;
  96418. /** @hidden */
  96419. _computeLocalCameraSpeed(): number;
  96420. /**
  96421. * Defines the target the camera should look at.
  96422. * @param target Defines the new target as a Vector or a mesh
  96423. */
  96424. setTarget(target: Vector3): void;
  96425. /**
  96426. * Return the current target position of the camera. This value is expressed in local space.
  96427. * @returns the target position
  96428. */
  96429. getTarget(): Vector3;
  96430. /** @hidden */
  96431. _decideIfNeedsToMove(): boolean;
  96432. /** @hidden */
  96433. _updatePosition(): void;
  96434. /** @hidden */
  96435. _checkInputs(): void;
  96436. protected _updateCameraRotationMatrix(): void;
  96437. /**
  96438. * 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)
  96439. * @returns the current camera
  96440. */
  96441. private _rotateUpVectorWithCameraRotationMatrix;
  96442. private _cachedRotationZ;
  96443. private _cachedQuaternionRotationZ;
  96444. /** @hidden */
  96445. _getViewMatrix(): Matrix;
  96446. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  96447. /**
  96448. * @hidden
  96449. */
  96450. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96451. /**
  96452. * @hidden
  96453. */
  96454. _updateRigCameras(): void;
  96455. private _getRigCamPositionAndTarget;
  96456. /**
  96457. * Gets the current object class name.
  96458. * @return the class name
  96459. */
  96460. getClassName(): string;
  96461. }
  96462. }
  96463. declare module BABYLON {
  96464. /**
  96465. * Gather the list of keyboard event types as constants.
  96466. */
  96467. export class KeyboardEventTypes {
  96468. /**
  96469. * The keydown event is fired when a key becomes active (pressed).
  96470. */
  96471. static readonly KEYDOWN: number;
  96472. /**
  96473. * The keyup event is fired when a key has been released.
  96474. */
  96475. static readonly KEYUP: number;
  96476. }
  96477. /**
  96478. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96479. */
  96480. export class KeyboardInfo {
  96481. /**
  96482. * Defines the type of event (KeyboardEventTypes)
  96483. */
  96484. type: number;
  96485. /**
  96486. * Defines the related dom event
  96487. */
  96488. event: KeyboardEvent;
  96489. /**
  96490. * Instantiates a new keyboard info.
  96491. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96492. * @param type Defines the type of event (KeyboardEventTypes)
  96493. * @param event Defines the related dom event
  96494. */
  96495. constructor(
  96496. /**
  96497. * Defines the type of event (KeyboardEventTypes)
  96498. */
  96499. type: number,
  96500. /**
  96501. * Defines the related dom event
  96502. */
  96503. event: KeyboardEvent);
  96504. }
  96505. /**
  96506. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96507. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  96508. */
  96509. export class KeyboardInfoPre extends KeyboardInfo {
  96510. /**
  96511. * Defines the type of event (KeyboardEventTypes)
  96512. */
  96513. type: number;
  96514. /**
  96515. * Defines the related dom event
  96516. */
  96517. event: KeyboardEvent;
  96518. /**
  96519. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  96520. */
  96521. skipOnPointerObservable: boolean;
  96522. /**
  96523. * Instantiates a new keyboard pre info.
  96524. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96525. * @param type Defines the type of event (KeyboardEventTypes)
  96526. * @param event Defines the related dom event
  96527. */
  96528. constructor(
  96529. /**
  96530. * Defines the type of event (KeyboardEventTypes)
  96531. */
  96532. type: number,
  96533. /**
  96534. * Defines the related dom event
  96535. */
  96536. event: KeyboardEvent);
  96537. }
  96538. }
  96539. declare module BABYLON {
  96540. /**
  96541. * Manage the keyboard inputs to control the movement of a free camera.
  96542. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96543. */
  96544. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  96545. /**
  96546. * Defines the camera the input is attached to.
  96547. */
  96548. camera: FreeCamera;
  96549. /**
  96550. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96551. */
  96552. keysUp: number[];
  96553. /**
  96554. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96555. */
  96556. keysUpward: number[];
  96557. /**
  96558. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96559. */
  96560. keysDown: number[];
  96561. /**
  96562. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96563. */
  96564. keysDownward: number[];
  96565. /**
  96566. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96567. */
  96568. keysLeft: number[];
  96569. /**
  96570. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96571. */
  96572. keysRight: number[];
  96573. private _keys;
  96574. private _onCanvasBlurObserver;
  96575. private _onKeyboardObserver;
  96576. private _engine;
  96577. private _scene;
  96578. /**
  96579. * Attach the input controls to a specific dom element to get the input from.
  96580. * @param element Defines the element the controls should be listened from
  96581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96582. */
  96583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96584. /**
  96585. * Detach the current controls from the specified dom element.
  96586. * @param element Defines the element to stop listening the inputs from
  96587. */
  96588. detachControl(element: Nullable<HTMLElement>): void;
  96589. /**
  96590. * Update the current camera state depending on the inputs that have been used this frame.
  96591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96592. */
  96593. checkInputs(): void;
  96594. /**
  96595. * Gets the class name of the current intput.
  96596. * @returns the class name
  96597. */
  96598. getClassName(): string;
  96599. /** @hidden */
  96600. _onLostFocus(): void;
  96601. /**
  96602. * Get the friendly name associated with the input class.
  96603. * @returns the input friendly name
  96604. */
  96605. getSimpleName(): string;
  96606. }
  96607. }
  96608. declare module BABYLON {
  96609. /**
  96610. * Gather the list of pointer event types as constants.
  96611. */
  96612. export class PointerEventTypes {
  96613. /**
  96614. * 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.
  96615. */
  96616. static readonly POINTERDOWN: number;
  96617. /**
  96618. * The pointerup event is fired when a pointer is no longer active.
  96619. */
  96620. static readonly POINTERUP: number;
  96621. /**
  96622. * The pointermove event is fired when a pointer changes coordinates.
  96623. */
  96624. static readonly POINTERMOVE: number;
  96625. /**
  96626. * The pointerwheel event is fired when a mouse wheel has been rotated.
  96627. */
  96628. static readonly POINTERWHEEL: number;
  96629. /**
  96630. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  96631. */
  96632. static readonly POINTERPICK: number;
  96633. /**
  96634. * The pointertap event is fired when a the object has been touched and released without drag.
  96635. */
  96636. static readonly POINTERTAP: number;
  96637. /**
  96638. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  96639. */
  96640. static readonly POINTERDOUBLETAP: number;
  96641. }
  96642. /**
  96643. * Base class of pointer info types.
  96644. */
  96645. export class PointerInfoBase {
  96646. /**
  96647. * Defines the type of event (PointerEventTypes)
  96648. */
  96649. type: number;
  96650. /**
  96651. * Defines the related dom event
  96652. */
  96653. event: PointerEvent | MouseWheelEvent;
  96654. /**
  96655. * Instantiates the base class of pointers info.
  96656. * @param type Defines the type of event (PointerEventTypes)
  96657. * @param event Defines the related dom event
  96658. */
  96659. constructor(
  96660. /**
  96661. * Defines the type of event (PointerEventTypes)
  96662. */
  96663. type: number,
  96664. /**
  96665. * Defines the related dom event
  96666. */
  96667. event: PointerEvent | MouseWheelEvent);
  96668. }
  96669. /**
  96670. * This class is used to store pointer related info for the onPrePointerObservable event.
  96671. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  96672. */
  96673. export class PointerInfoPre extends PointerInfoBase {
  96674. /**
  96675. * Ray from a pointer if availible (eg. 6dof controller)
  96676. */
  96677. ray: Nullable<Ray>;
  96678. /**
  96679. * Defines the local position of the pointer on the canvas.
  96680. */
  96681. localPosition: Vector2;
  96682. /**
  96683. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  96684. */
  96685. skipOnPointerObservable: boolean;
  96686. /**
  96687. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  96688. * @param type Defines the type of event (PointerEventTypes)
  96689. * @param event Defines the related dom event
  96690. * @param localX Defines the local x coordinates of the pointer when the event occured
  96691. * @param localY Defines the local y coordinates of the pointer when the event occured
  96692. */
  96693. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  96694. }
  96695. /**
  96696. * This type contains all the data related to a pointer event in Babylon.js.
  96697. * 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.
  96698. */
  96699. export class PointerInfo extends PointerInfoBase {
  96700. /**
  96701. * Defines the picking info associated to the info (if any)\
  96702. */
  96703. pickInfo: Nullable<PickingInfo>;
  96704. /**
  96705. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  96706. * @param type Defines the type of event (PointerEventTypes)
  96707. * @param event Defines the related dom event
  96708. * @param pickInfo Defines the picking info associated to the info (if any)\
  96709. */
  96710. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  96711. /**
  96712. * Defines the picking info associated to the info (if any)\
  96713. */
  96714. pickInfo: Nullable<PickingInfo>);
  96715. }
  96716. /**
  96717. * Data relating to a touch event on the screen.
  96718. */
  96719. export interface PointerTouch {
  96720. /**
  96721. * X coordinate of touch.
  96722. */
  96723. x: number;
  96724. /**
  96725. * Y coordinate of touch.
  96726. */
  96727. y: number;
  96728. /**
  96729. * Id of touch. Unique for each finger.
  96730. */
  96731. pointerId: number;
  96732. /**
  96733. * Event type passed from DOM.
  96734. */
  96735. type: any;
  96736. }
  96737. }
  96738. declare module BABYLON {
  96739. /**
  96740. * Manage the mouse inputs to control the movement of a free camera.
  96741. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96742. */
  96743. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  96744. /**
  96745. * Define if touch is enabled in the mouse input
  96746. */
  96747. touchEnabled: boolean;
  96748. /**
  96749. * Defines the camera the input is attached to.
  96750. */
  96751. camera: FreeCamera;
  96752. /**
  96753. * Defines the buttons associated with the input to handle camera move.
  96754. */
  96755. buttons: number[];
  96756. /**
  96757. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  96758. */
  96759. angularSensibility: number;
  96760. private _pointerInput;
  96761. private _onMouseMove;
  96762. private _observer;
  96763. private previousPosition;
  96764. /**
  96765. * Observable for when a pointer move event occurs containing the move offset
  96766. */
  96767. onPointerMovedObservable: Observable<{
  96768. offsetX: number;
  96769. offsetY: number;
  96770. }>;
  96771. /**
  96772. * @hidden
  96773. * If the camera should be rotated automatically based on pointer movement
  96774. */
  96775. _allowCameraRotation: boolean;
  96776. /**
  96777. * Manage the mouse inputs to control the movement of a free camera.
  96778. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96779. * @param touchEnabled Defines if touch is enabled or not
  96780. */
  96781. constructor(
  96782. /**
  96783. * Define if touch is enabled in the mouse input
  96784. */
  96785. touchEnabled?: boolean);
  96786. /**
  96787. * Attach the input controls to a specific dom element to get the input from.
  96788. * @param element Defines the element the controls should be listened from
  96789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96790. */
  96791. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96792. /**
  96793. * Called on JS contextmenu event.
  96794. * Override this method to provide functionality.
  96795. */
  96796. protected onContextMenu(evt: PointerEvent): void;
  96797. /**
  96798. * Detach the current controls from the specified dom element.
  96799. * @param element Defines the element to stop listening the inputs from
  96800. */
  96801. detachControl(element: Nullable<HTMLElement>): void;
  96802. /**
  96803. * Gets the class name of the current intput.
  96804. * @returns the class name
  96805. */
  96806. getClassName(): string;
  96807. /**
  96808. * Get the friendly name associated with the input class.
  96809. * @returns the input friendly name
  96810. */
  96811. getSimpleName(): string;
  96812. }
  96813. }
  96814. declare module BABYLON {
  96815. /**
  96816. * Manage the touch inputs to control the movement of a free camera.
  96817. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96818. */
  96819. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  96820. /**
  96821. * Defines the camera the input is attached to.
  96822. */
  96823. camera: FreeCamera;
  96824. /**
  96825. * Defines the touch sensibility for rotation.
  96826. * The higher the faster.
  96827. */
  96828. touchAngularSensibility: number;
  96829. /**
  96830. * Defines the touch sensibility for move.
  96831. * The higher the faster.
  96832. */
  96833. touchMoveSensibility: number;
  96834. private _offsetX;
  96835. private _offsetY;
  96836. private _pointerPressed;
  96837. private _pointerInput;
  96838. private _observer;
  96839. private _onLostFocus;
  96840. /**
  96841. * Attach the input controls to a specific dom element to get the input from.
  96842. * @param element Defines the element the controls should be listened from
  96843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96844. */
  96845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96846. /**
  96847. * Detach the current controls from the specified dom element.
  96848. * @param element Defines the element to stop listening the inputs from
  96849. */
  96850. detachControl(element: Nullable<HTMLElement>): void;
  96851. /**
  96852. * Update the current camera state depending on the inputs that have been used this frame.
  96853. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96854. */
  96855. checkInputs(): void;
  96856. /**
  96857. * Gets the class name of the current intput.
  96858. * @returns the class name
  96859. */
  96860. getClassName(): string;
  96861. /**
  96862. * Get the friendly name associated with the input class.
  96863. * @returns the input friendly name
  96864. */
  96865. getSimpleName(): string;
  96866. }
  96867. }
  96868. declare module BABYLON {
  96869. /**
  96870. * Default Inputs manager for the FreeCamera.
  96871. * It groups all the default supported inputs for ease of use.
  96872. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96873. */
  96874. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  96875. /**
  96876. * @hidden
  96877. */
  96878. _mouseInput: Nullable<FreeCameraMouseInput>;
  96879. /**
  96880. * Instantiates a new FreeCameraInputsManager.
  96881. * @param camera Defines the camera the inputs belong to
  96882. */
  96883. constructor(camera: FreeCamera);
  96884. /**
  96885. * Add keyboard input support to the input manager.
  96886. * @returns the current input manager
  96887. */
  96888. addKeyboard(): FreeCameraInputsManager;
  96889. /**
  96890. * Add mouse input support to the input manager.
  96891. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  96892. * @returns the current input manager
  96893. */
  96894. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  96895. /**
  96896. * Removes the mouse input support from the manager
  96897. * @returns the current input manager
  96898. */
  96899. removeMouse(): FreeCameraInputsManager;
  96900. /**
  96901. * Add touch input support to the input manager.
  96902. * @returns the current input manager
  96903. */
  96904. addTouch(): FreeCameraInputsManager;
  96905. /**
  96906. * Remove all attached input methods from a camera
  96907. */
  96908. clear(): void;
  96909. }
  96910. }
  96911. declare module BABYLON {
  96912. /**
  96913. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96914. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  96915. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  96916. */
  96917. export class FreeCamera extends TargetCamera {
  96918. /**
  96919. * Define the collision ellipsoid of the camera.
  96920. * This is helpful to simulate a camera body like the player body around the camera
  96921. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96922. */
  96923. ellipsoid: Vector3;
  96924. /**
  96925. * Define an offset for the position of the ellipsoid around the camera.
  96926. * This can be helpful to determine the center of the body near the gravity center of the body
  96927. * instead of its head.
  96928. */
  96929. ellipsoidOffset: Vector3;
  96930. /**
  96931. * Enable or disable collisions of the camera with the rest of the scene objects.
  96932. */
  96933. checkCollisions: boolean;
  96934. /**
  96935. * Enable or disable gravity on the camera.
  96936. */
  96937. applyGravity: boolean;
  96938. /**
  96939. * Define the input manager associated to the camera.
  96940. */
  96941. inputs: FreeCameraInputsManager;
  96942. /**
  96943. * Gets the input sensibility for a mouse input. (default is 2000.0)
  96944. * Higher values reduce sensitivity.
  96945. */
  96946. get angularSensibility(): number;
  96947. /**
  96948. * Sets the input sensibility for a mouse input. (default is 2000.0)
  96949. * Higher values reduce sensitivity.
  96950. */
  96951. set angularSensibility(value: number);
  96952. /**
  96953. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96954. */
  96955. get keysUp(): number[];
  96956. set keysUp(value: number[]);
  96957. /**
  96958. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96959. */
  96960. get keysUpward(): number[];
  96961. set keysUpward(value: number[]);
  96962. /**
  96963. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96964. */
  96965. get keysDown(): number[];
  96966. set keysDown(value: number[]);
  96967. /**
  96968. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96969. */
  96970. get keysDownward(): number[];
  96971. set keysDownward(value: number[]);
  96972. /**
  96973. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96974. */
  96975. get keysLeft(): number[];
  96976. set keysLeft(value: number[]);
  96977. /**
  96978. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96979. */
  96980. get keysRight(): number[];
  96981. set keysRight(value: number[]);
  96982. /**
  96983. * Event raised when the camera collide with a mesh in the scene.
  96984. */
  96985. onCollide: (collidedMesh: AbstractMesh) => void;
  96986. private _collider;
  96987. private _needMoveForGravity;
  96988. private _oldPosition;
  96989. private _diffPosition;
  96990. private _newPosition;
  96991. /** @hidden */
  96992. _localDirection: Vector3;
  96993. /** @hidden */
  96994. _transformedDirection: Vector3;
  96995. /**
  96996. * Instantiates a Free Camera.
  96997. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96998. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  96999. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97000. * @param name Define the name of the camera in the scene
  97001. * @param position Define the start position of the camera in the scene
  97002. * @param scene Define the scene the camera belongs to
  97003. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97004. */
  97005. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97006. /**
  97007. * Attached controls to the current camera.
  97008. * @param element Defines the element the controls should be listened from
  97009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97010. */
  97011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97012. /**
  97013. * Detach the current controls from the camera.
  97014. * The camera will stop reacting to inputs.
  97015. * @param element Defines the element to stop listening the inputs from
  97016. */
  97017. detachControl(element: HTMLElement): void;
  97018. private _collisionMask;
  97019. /**
  97020. * Define a collision mask to limit the list of object the camera can collide with
  97021. */
  97022. get collisionMask(): number;
  97023. set collisionMask(mask: number);
  97024. /** @hidden */
  97025. _collideWithWorld(displacement: Vector3): void;
  97026. private _onCollisionPositionChange;
  97027. /** @hidden */
  97028. _checkInputs(): void;
  97029. /** @hidden */
  97030. _decideIfNeedsToMove(): boolean;
  97031. /** @hidden */
  97032. _updatePosition(): void;
  97033. /**
  97034. * Destroy the camera and release the current resources hold by it.
  97035. */
  97036. dispose(): void;
  97037. /**
  97038. * Gets the current object class name.
  97039. * @return the class name
  97040. */
  97041. getClassName(): string;
  97042. }
  97043. }
  97044. declare module BABYLON {
  97045. /**
  97046. * Represents a gamepad control stick position
  97047. */
  97048. export class StickValues {
  97049. /**
  97050. * The x component of the control stick
  97051. */
  97052. x: number;
  97053. /**
  97054. * The y component of the control stick
  97055. */
  97056. y: number;
  97057. /**
  97058. * Initializes the gamepad x and y control stick values
  97059. * @param x The x component of the gamepad control stick value
  97060. * @param y The y component of the gamepad control stick value
  97061. */
  97062. constructor(
  97063. /**
  97064. * The x component of the control stick
  97065. */
  97066. x: number,
  97067. /**
  97068. * The y component of the control stick
  97069. */
  97070. y: number);
  97071. }
  97072. /**
  97073. * An interface which manages callbacks for gamepad button changes
  97074. */
  97075. export interface GamepadButtonChanges {
  97076. /**
  97077. * Called when a gamepad has been changed
  97078. */
  97079. changed: boolean;
  97080. /**
  97081. * Called when a gamepad press event has been triggered
  97082. */
  97083. pressChanged: boolean;
  97084. /**
  97085. * Called when a touch event has been triggered
  97086. */
  97087. touchChanged: boolean;
  97088. /**
  97089. * Called when a value has changed
  97090. */
  97091. valueChanged: boolean;
  97092. }
  97093. /**
  97094. * Represents a gamepad
  97095. */
  97096. export class Gamepad {
  97097. /**
  97098. * The id of the gamepad
  97099. */
  97100. id: string;
  97101. /**
  97102. * The index of the gamepad
  97103. */
  97104. index: number;
  97105. /**
  97106. * The browser gamepad
  97107. */
  97108. browserGamepad: any;
  97109. /**
  97110. * Specifies what type of gamepad this represents
  97111. */
  97112. type: number;
  97113. private _leftStick;
  97114. private _rightStick;
  97115. /** @hidden */
  97116. _isConnected: boolean;
  97117. private _leftStickAxisX;
  97118. private _leftStickAxisY;
  97119. private _rightStickAxisX;
  97120. private _rightStickAxisY;
  97121. /**
  97122. * Triggered when the left control stick has been changed
  97123. */
  97124. private _onleftstickchanged;
  97125. /**
  97126. * Triggered when the right control stick has been changed
  97127. */
  97128. private _onrightstickchanged;
  97129. /**
  97130. * Represents a gamepad controller
  97131. */
  97132. static GAMEPAD: number;
  97133. /**
  97134. * Represents a generic controller
  97135. */
  97136. static GENERIC: number;
  97137. /**
  97138. * Represents an XBox controller
  97139. */
  97140. static XBOX: number;
  97141. /**
  97142. * Represents a pose-enabled controller
  97143. */
  97144. static POSE_ENABLED: number;
  97145. /**
  97146. * Represents an Dual Shock controller
  97147. */
  97148. static DUALSHOCK: number;
  97149. /**
  97150. * Specifies whether the left control stick should be Y-inverted
  97151. */
  97152. protected _invertLeftStickY: boolean;
  97153. /**
  97154. * Specifies if the gamepad has been connected
  97155. */
  97156. get isConnected(): boolean;
  97157. /**
  97158. * Initializes the gamepad
  97159. * @param id The id of the gamepad
  97160. * @param index The index of the gamepad
  97161. * @param browserGamepad The browser gamepad
  97162. * @param leftStickX The x component of the left joystick
  97163. * @param leftStickY The y component of the left joystick
  97164. * @param rightStickX The x component of the right joystick
  97165. * @param rightStickY The y component of the right joystick
  97166. */
  97167. constructor(
  97168. /**
  97169. * The id of the gamepad
  97170. */
  97171. id: string,
  97172. /**
  97173. * The index of the gamepad
  97174. */
  97175. index: number,
  97176. /**
  97177. * The browser gamepad
  97178. */
  97179. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  97180. /**
  97181. * Callback triggered when the left joystick has changed
  97182. * @param callback
  97183. */
  97184. onleftstickchanged(callback: (values: StickValues) => void): void;
  97185. /**
  97186. * Callback triggered when the right joystick has changed
  97187. * @param callback
  97188. */
  97189. onrightstickchanged(callback: (values: StickValues) => void): void;
  97190. /**
  97191. * Gets the left joystick
  97192. */
  97193. get leftStick(): StickValues;
  97194. /**
  97195. * Sets the left joystick values
  97196. */
  97197. set leftStick(newValues: StickValues);
  97198. /**
  97199. * Gets the right joystick
  97200. */
  97201. get rightStick(): StickValues;
  97202. /**
  97203. * Sets the right joystick value
  97204. */
  97205. set rightStick(newValues: StickValues);
  97206. /**
  97207. * Updates the gamepad joystick positions
  97208. */
  97209. update(): void;
  97210. /**
  97211. * Disposes the gamepad
  97212. */
  97213. dispose(): void;
  97214. }
  97215. /**
  97216. * Represents a generic gamepad
  97217. */
  97218. export class GenericPad extends Gamepad {
  97219. private _buttons;
  97220. private _onbuttondown;
  97221. private _onbuttonup;
  97222. /**
  97223. * Observable triggered when a button has been pressed
  97224. */
  97225. onButtonDownObservable: Observable<number>;
  97226. /**
  97227. * Observable triggered when a button has been released
  97228. */
  97229. onButtonUpObservable: Observable<number>;
  97230. /**
  97231. * Callback triggered when a button has been pressed
  97232. * @param callback Called when a button has been pressed
  97233. */
  97234. onbuttondown(callback: (buttonPressed: number) => void): void;
  97235. /**
  97236. * Callback triggered when a button has been released
  97237. * @param callback Called when a button has been released
  97238. */
  97239. onbuttonup(callback: (buttonReleased: number) => void): void;
  97240. /**
  97241. * Initializes the generic gamepad
  97242. * @param id The id of the generic gamepad
  97243. * @param index The index of the generic gamepad
  97244. * @param browserGamepad The browser gamepad
  97245. */
  97246. constructor(id: string, index: number, browserGamepad: any);
  97247. private _setButtonValue;
  97248. /**
  97249. * Updates the generic gamepad
  97250. */
  97251. update(): void;
  97252. /**
  97253. * Disposes the generic gamepad
  97254. */
  97255. dispose(): void;
  97256. }
  97257. }
  97258. declare module BABYLON {
  97259. /**
  97260. * Defines the types of pose enabled controllers that are supported
  97261. */
  97262. export enum PoseEnabledControllerType {
  97263. /**
  97264. * HTC Vive
  97265. */
  97266. VIVE = 0,
  97267. /**
  97268. * Oculus Rift
  97269. */
  97270. OCULUS = 1,
  97271. /**
  97272. * Windows mixed reality
  97273. */
  97274. WINDOWS = 2,
  97275. /**
  97276. * Samsung gear VR
  97277. */
  97278. GEAR_VR = 3,
  97279. /**
  97280. * Google Daydream
  97281. */
  97282. DAYDREAM = 4,
  97283. /**
  97284. * Generic
  97285. */
  97286. GENERIC = 5
  97287. }
  97288. /**
  97289. * Defines the MutableGamepadButton interface for the state of a gamepad button
  97290. */
  97291. export interface MutableGamepadButton {
  97292. /**
  97293. * Value of the button/trigger
  97294. */
  97295. value: number;
  97296. /**
  97297. * If the button/trigger is currently touched
  97298. */
  97299. touched: boolean;
  97300. /**
  97301. * If the button/trigger is currently pressed
  97302. */
  97303. pressed: boolean;
  97304. }
  97305. /**
  97306. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  97307. * @hidden
  97308. */
  97309. export interface ExtendedGamepadButton extends GamepadButton {
  97310. /**
  97311. * If the button/trigger is currently pressed
  97312. */
  97313. readonly pressed: boolean;
  97314. /**
  97315. * If the button/trigger is currently touched
  97316. */
  97317. readonly touched: boolean;
  97318. /**
  97319. * Value of the button/trigger
  97320. */
  97321. readonly value: number;
  97322. }
  97323. /** @hidden */
  97324. export interface _GamePadFactory {
  97325. /**
  97326. * Returns whether or not the current gamepad can be created for this type of controller.
  97327. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97328. * @returns true if it can be created, otherwise false
  97329. */
  97330. canCreate(gamepadInfo: any): boolean;
  97331. /**
  97332. * Creates a new instance of the Gamepad.
  97333. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97334. * @returns the new gamepad instance
  97335. */
  97336. create(gamepadInfo: any): Gamepad;
  97337. }
  97338. /**
  97339. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97340. */
  97341. export class PoseEnabledControllerHelper {
  97342. /** @hidden */
  97343. static _ControllerFactories: _GamePadFactory[];
  97344. /** @hidden */
  97345. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  97346. /**
  97347. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97348. * @param vrGamepad the gamepad to initialized
  97349. * @returns a vr controller of the type the gamepad identified as
  97350. */
  97351. static InitiateController(vrGamepad: any): Gamepad;
  97352. }
  97353. /**
  97354. * Defines the PoseEnabledController object that contains state of a vr capable controller
  97355. */
  97356. export class PoseEnabledController extends Gamepad implements PoseControlled {
  97357. /**
  97358. * If the controller is used in a webXR session
  97359. */
  97360. isXR: boolean;
  97361. private _deviceRoomPosition;
  97362. private _deviceRoomRotationQuaternion;
  97363. /**
  97364. * The device position in babylon space
  97365. */
  97366. devicePosition: Vector3;
  97367. /**
  97368. * The device rotation in babylon space
  97369. */
  97370. deviceRotationQuaternion: Quaternion;
  97371. /**
  97372. * The scale factor of the device in babylon space
  97373. */
  97374. deviceScaleFactor: number;
  97375. /**
  97376. * (Likely devicePosition should be used instead) The device position in its room space
  97377. */
  97378. position: Vector3;
  97379. /**
  97380. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  97381. */
  97382. rotationQuaternion: Quaternion;
  97383. /**
  97384. * The type of controller (Eg. Windows mixed reality)
  97385. */
  97386. controllerType: PoseEnabledControllerType;
  97387. protected _calculatedPosition: Vector3;
  97388. private _calculatedRotation;
  97389. /**
  97390. * The raw pose from the device
  97391. */
  97392. rawPose: DevicePose;
  97393. private _trackPosition;
  97394. private _maxRotationDistFromHeadset;
  97395. private _draggedRoomRotation;
  97396. /**
  97397. * @hidden
  97398. */
  97399. _disableTrackPosition(fixedPosition: Vector3): void;
  97400. /**
  97401. * Internal, the mesh attached to the controller
  97402. * @hidden
  97403. */
  97404. _mesh: Nullable<AbstractMesh>;
  97405. private _poseControlledCamera;
  97406. private _leftHandSystemQuaternion;
  97407. /**
  97408. * Internal, matrix used to convert room space to babylon space
  97409. * @hidden
  97410. */
  97411. _deviceToWorld: Matrix;
  97412. /**
  97413. * Node to be used when casting a ray from the controller
  97414. * @hidden
  97415. */
  97416. _pointingPoseNode: Nullable<TransformNode>;
  97417. /**
  97418. * Name of the child mesh that can be used to cast a ray from the controller
  97419. */
  97420. static readonly POINTING_POSE: string;
  97421. /**
  97422. * Creates a new PoseEnabledController from a gamepad
  97423. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  97424. */
  97425. constructor(browserGamepad: any);
  97426. private _workingMatrix;
  97427. /**
  97428. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  97429. */
  97430. update(): void;
  97431. /**
  97432. * Updates only the pose device and mesh without doing any button event checking
  97433. */
  97434. protected _updatePoseAndMesh(): void;
  97435. /**
  97436. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  97437. * @param poseData raw pose fromthe device
  97438. */
  97439. updateFromDevice(poseData: DevicePose): void;
  97440. /**
  97441. * @hidden
  97442. */
  97443. _meshAttachedObservable: Observable<AbstractMesh>;
  97444. /**
  97445. * Attaches a mesh to the controller
  97446. * @param mesh the mesh to be attached
  97447. */
  97448. attachToMesh(mesh: AbstractMesh): void;
  97449. /**
  97450. * Attaches the controllers mesh to a camera
  97451. * @param camera the camera the mesh should be attached to
  97452. */
  97453. attachToPoseControlledCamera(camera: TargetCamera): void;
  97454. /**
  97455. * Disposes of the controller
  97456. */
  97457. dispose(): void;
  97458. /**
  97459. * The mesh that is attached to the controller
  97460. */
  97461. get mesh(): Nullable<AbstractMesh>;
  97462. /**
  97463. * Gets the ray of the controller in the direction the controller is pointing
  97464. * @param length the length the resulting ray should be
  97465. * @returns a ray in the direction the controller is pointing
  97466. */
  97467. getForwardRay(length?: number): Ray;
  97468. }
  97469. }
  97470. declare module BABYLON {
  97471. /**
  97472. * Defines the WebVRController object that represents controllers tracked in 3D space
  97473. */
  97474. export abstract class WebVRController extends PoseEnabledController {
  97475. /**
  97476. * Internal, the default controller model for the controller
  97477. */
  97478. protected _defaultModel: Nullable<AbstractMesh>;
  97479. /**
  97480. * Fired when the trigger state has changed
  97481. */
  97482. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97483. /**
  97484. * Fired when the main button state has changed
  97485. */
  97486. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97487. /**
  97488. * Fired when the secondary button state has changed
  97489. */
  97490. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97491. /**
  97492. * Fired when the pad state has changed
  97493. */
  97494. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  97495. /**
  97496. * Fired when controllers stick values have changed
  97497. */
  97498. onPadValuesChangedObservable: Observable<StickValues>;
  97499. /**
  97500. * Array of button availible on the controller
  97501. */
  97502. protected _buttons: Array<MutableGamepadButton>;
  97503. private _onButtonStateChange;
  97504. /**
  97505. * Fired when a controller button's state has changed
  97506. * @param callback the callback containing the button that was modified
  97507. */
  97508. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  97509. /**
  97510. * X and Y axis corresponding to the controllers joystick
  97511. */
  97512. pad: StickValues;
  97513. /**
  97514. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  97515. */
  97516. hand: string;
  97517. /**
  97518. * The default controller model for the controller
  97519. */
  97520. get defaultModel(): Nullable<AbstractMesh>;
  97521. /**
  97522. * Creates a new WebVRController from a gamepad
  97523. * @param vrGamepad the gamepad that the WebVRController should be created from
  97524. */
  97525. constructor(vrGamepad: any);
  97526. /**
  97527. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  97528. */
  97529. update(): void;
  97530. /**
  97531. * Function to be called when a button is modified
  97532. */
  97533. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97534. /**
  97535. * Loads a mesh and attaches it to the controller
  97536. * @param scene the scene the mesh should be added to
  97537. * @param meshLoaded callback for when the mesh has been loaded
  97538. */
  97539. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97540. private _setButtonValue;
  97541. private _changes;
  97542. private _checkChanges;
  97543. /**
  97544. * Disposes of th webVRCOntroller
  97545. */
  97546. dispose(): void;
  97547. }
  97548. }
  97549. declare module BABYLON {
  97550. /**
  97551. * The HemisphericLight simulates the ambient environment light,
  97552. * so the passed direction is the light reflection direction, not the incoming direction.
  97553. */
  97554. export class HemisphericLight extends Light {
  97555. /**
  97556. * The groundColor is the light in the opposite direction to the one specified during creation.
  97557. * 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.
  97558. */
  97559. groundColor: Color3;
  97560. /**
  97561. * The light reflection direction, not the incoming direction.
  97562. */
  97563. direction: Vector3;
  97564. /**
  97565. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  97566. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  97567. * The HemisphericLight can't cast shadows.
  97568. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97569. * @param name The friendly name of the light
  97570. * @param direction The direction of the light reflection
  97571. * @param scene The scene the light belongs to
  97572. */
  97573. constructor(name: string, direction: Vector3, scene: Scene);
  97574. protected _buildUniformLayout(): void;
  97575. /**
  97576. * Returns the string "HemisphericLight".
  97577. * @return The class name
  97578. */
  97579. getClassName(): string;
  97580. /**
  97581. * Sets the HemisphericLight direction towards the passed target (Vector3).
  97582. * Returns the updated direction.
  97583. * @param target The target the direction should point to
  97584. * @return The computed direction
  97585. */
  97586. setDirectionToTarget(target: Vector3): Vector3;
  97587. /**
  97588. * Returns the shadow generator associated to the light.
  97589. * @returns Always null for hemispheric lights because it does not support shadows.
  97590. */
  97591. getShadowGenerator(): Nullable<IShadowGenerator>;
  97592. /**
  97593. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  97594. * @param effect The effect to update
  97595. * @param lightIndex The index of the light in the effect to update
  97596. * @returns The hemispheric light
  97597. */
  97598. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  97599. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  97600. /**
  97601. * Computes the world matrix of the node
  97602. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97603. * @param useWasUpdatedFlag defines a reserved property
  97604. * @returns the world matrix
  97605. */
  97606. computeWorldMatrix(): Matrix;
  97607. /**
  97608. * Returns the integer 3.
  97609. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97610. */
  97611. getTypeID(): number;
  97612. /**
  97613. * Prepares the list of defines specific to the light type.
  97614. * @param defines the list of defines
  97615. * @param lightIndex defines the index of the light for the effect
  97616. */
  97617. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97618. }
  97619. }
  97620. declare module BABYLON {
  97621. /** @hidden */
  97622. export var vrMultiviewToSingleviewPixelShader: {
  97623. name: string;
  97624. shader: string;
  97625. };
  97626. }
  97627. declare module BABYLON {
  97628. /**
  97629. * Renders to multiple views with a single draw call
  97630. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  97631. */
  97632. export class MultiviewRenderTarget extends RenderTargetTexture {
  97633. /**
  97634. * Creates a multiview render target
  97635. * @param scene scene used with the render target
  97636. * @param size the size of the render target (used for each view)
  97637. */
  97638. constructor(scene: Scene, size?: number | {
  97639. width: number;
  97640. height: number;
  97641. } | {
  97642. ratio: number;
  97643. });
  97644. /**
  97645. * @hidden
  97646. * @param faceIndex the face index, if its a cube texture
  97647. */
  97648. _bindFrameBuffer(faceIndex?: number): void;
  97649. /**
  97650. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97651. * @returns the view count
  97652. */
  97653. getViewCount(): number;
  97654. }
  97655. }
  97656. declare module BABYLON {
  97657. interface Engine {
  97658. /**
  97659. * Creates a new multiview render target
  97660. * @param width defines the width of the texture
  97661. * @param height defines the height of the texture
  97662. * @returns the created multiview texture
  97663. */
  97664. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  97665. /**
  97666. * Binds a multiview framebuffer to be drawn to
  97667. * @param multiviewTexture texture to bind
  97668. */
  97669. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  97670. }
  97671. interface Camera {
  97672. /**
  97673. * @hidden
  97674. * 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)
  97675. */
  97676. _useMultiviewToSingleView: boolean;
  97677. /**
  97678. * @hidden
  97679. * 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)
  97680. */
  97681. _multiviewTexture: Nullable<RenderTargetTexture>;
  97682. /**
  97683. * @hidden
  97684. * ensures the multiview texture of the camera exists and has the specified width/height
  97685. * @param width height to set on the multiview texture
  97686. * @param height width to set on the multiview texture
  97687. */
  97688. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  97689. }
  97690. interface Scene {
  97691. /** @hidden */
  97692. _transformMatrixR: Matrix;
  97693. /** @hidden */
  97694. _multiviewSceneUbo: Nullable<UniformBuffer>;
  97695. /** @hidden */
  97696. _createMultiviewUbo(): void;
  97697. /** @hidden */
  97698. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  97699. /** @hidden */
  97700. _renderMultiviewToSingleView(camera: Camera): void;
  97701. }
  97702. }
  97703. declare module BABYLON {
  97704. /**
  97705. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  97706. * This will not be used for webXR as it supports displaying texture arrays directly
  97707. */
  97708. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  97709. /**
  97710. * Initializes a VRMultiviewToSingleview
  97711. * @param name name of the post process
  97712. * @param camera camera to be applied to
  97713. * @param scaleFactor scaling factor to the size of the output texture
  97714. */
  97715. constructor(name: string, camera: Camera, scaleFactor: number);
  97716. }
  97717. }
  97718. declare module BABYLON {
  97719. /**
  97720. * Interface used to define additional presentation attributes
  97721. */
  97722. export interface IVRPresentationAttributes {
  97723. /**
  97724. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  97725. */
  97726. highRefreshRate: boolean;
  97727. /**
  97728. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  97729. */
  97730. foveationLevel: number;
  97731. }
  97732. interface Engine {
  97733. /** @hidden */
  97734. _vrDisplay: any;
  97735. /** @hidden */
  97736. _vrSupported: boolean;
  97737. /** @hidden */
  97738. _oldSize: Size;
  97739. /** @hidden */
  97740. _oldHardwareScaleFactor: number;
  97741. /** @hidden */
  97742. _vrExclusivePointerMode: boolean;
  97743. /** @hidden */
  97744. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  97745. /** @hidden */
  97746. _onVRDisplayPointerRestricted: () => void;
  97747. /** @hidden */
  97748. _onVRDisplayPointerUnrestricted: () => void;
  97749. /** @hidden */
  97750. _onVrDisplayConnect: Nullable<(display: any) => void>;
  97751. /** @hidden */
  97752. _onVrDisplayDisconnect: Nullable<() => void>;
  97753. /** @hidden */
  97754. _onVrDisplayPresentChange: Nullable<() => void>;
  97755. /**
  97756. * Observable signaled when VR display mode changes
  97757. */
  97758. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  97759. /**
  97760. * Observable signaled when VR request present is complete
  97761. */
  97762. onVRRequestPresentComplete: Observable<boolean>;
  97763. /**
  97764. * Observable signaled when VR request present starts
  97765. */
  97766. onVRRequestPresentStart: Observable<Engine>;
  97767. /**
  97768. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  97769. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  97770. */
  97771. isInVRExclusivePointerMode: boolean;
  97772. /**
  97773. * Gets a boolean indicating if a webVR device was detected
  97774. * @returns true if a webVR device was detected
  97775. */
  97776. isVRDevicePresent(): boolean;
  97777. /**
  97778. * Gets the current webVR device
  97779. * @returns the current webVR device (or null)
  97780. */
  97781. getVRDevice(): any;
  97782. /**
  97783. * Initializes a webVR display and starts listening to display change events
  97784. * The onVRDisplayChangedObservable will be notified upon these changes
  97785. * @returns A promise containing a VRDisplay and if vr is supported
  97786. */
  97787. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  97788. /** @hidden */
  97789. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  97790. /**
  97791. * Gets or sets the presentation attributes used to configure VR rendering
  97792. */
  97793. vrPresentationAttributes?: IVRPresentationAttributes;
  97794. /**
  97795. * Call this function to switch to webVR mode
  97796. * Will do nothing if webVR is not supported or if there is no webVR device
  97797. * @param options the webvr options provided to the camera. mainly used for multiview
  97798. * @see https://doc.babylonjs.com/how_to/webvr_camera
  97799. */
  97800. enableVR(options: WebVROptions): void;
  97801. /** @hidden */
  97802. _onVRFullScreenTriggered(): void;
  97803. }
  97804. }
  97805. declare module BABYLON {
  97806. /**
  97807. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  97808. * IMPORTANT!! The data is right-hand data.
  97809. * @export
  97810. * @interface DevicePose
  97811. */
  97812. export interface DevicePose {
  97813. /**
  97814. * The position of the device, values in array are [x,y,z].
  97815. */
  97816. readonly position: Nullable<Float32Array>;
  97817. /**
  97818. * The linearVelocity of the device, values in array are [x,y,z].
  97819. */
  97820. readonly linearVelocity: Nullable<Float32Array>;
  97821. /**
  97822. * The linearAcceleration of the device, values in array are [x,y,z].
  97823. */
  97824. readonly linearAcceleration: Nullable<Float32Array>;
  97825. /**
  97826. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  97827. */
  97828. readonly orientation: Nullable<Float32Array>;
  97829. /**
  97830. * The angularVelocity of the device, values in array are [x,y,z].
  97831. */
  97832. readonly angularVelocity: Nullable<Float32Array>;
  97833. /**
  97834. * The angularAcceleration of the device, values in array are [x,y,z].
  97835. */
  97836. readonly angularAcceleration: Nullable<Float32Array>;
  97837. }
  97838. /**
  97839. * Interface representing a pose controlled object in Babylon.
  97840. * A pose controlled object has both regular pose values as well as pose values
  97841. * from an external device such as a VR head mounted display
  97842. */
  97843. export interface PoseControlled {
  97844. /**
  97845. * The position of the object in babylon space.
  97846. */
  97847. position: Vector3;
  97848. /**
  97849. * The rotation quaternion of the object in babylon space.
  97850. */
  97851. rotationQuaternion: Quaternion;
  97852. /**
  97853. * The position of the device in babylon space.
  97854. */
  97855. devicePosition?: Vector3;
  97856. /**
  97857. * The rotation quaternion of the device in babylon space.
  97858. */
  97859. deviceRotationQuaternion: Quaternion;
  97860. /**
  97861. * The raw pose coming from the device.
  97862. */
  97863. rawPose: Nullable<DevicePose>;
  97864. /**
  97865. * The scale of the device to be used when translating from device space to babylon space.
  97866. */
  97867. deviceScaleFactor: number;
  97868. /**
  97869. * Updates the poseControlled values based on the input device pose.
  97870. * @param poseData the pose data to update the object with
  97871. */
  97872. updateFromDevice(poseData: DevicePose): void;
  97873. }
  97874. /**
  97875. * Set of options to customize the webVRCamera
  97876. */
  97877. export interface WebVROptions {
  97878. /**
  97879. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  97880. */
  97881. trackPosition?: boolean;
  97882. /**
  97883. * Sets the scale of the vrDevice in babylon space. (default: 1)
  97884. */
  97885. positionScale?: number;
  97886. /**
  97887. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  97888. */
  97889. displayName?: string;
  97890. /**
  97891. * Should the native controller meshes be initialized. (default: true)
  97892. */
  97893. controllerMeshes?: boolean;
  97894. /**
  97895. * Creating a default HemiLight only on controllers. (default: true)
  97896. */
  97897. defaultLightingOnControllers?: boolean;
  97898. /**
  97899. * If you don't want to use the default VR button of the helper. (default: false)
  97900. */
  97901. useCustomVRButton?: boolean;
  97902. /**
  97903. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  97904. */
  97905. customVRButton?: HTMLButtonElement;
  97906. /**
  97907. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  97908. */
  97909. rayLength?: number;
  97910. /**
  97911. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  97912. */
  97913. defaultHeight?: number;
  97914. /**
  97915. * If multiview should be used if availible (default: false)
  97916. */
  97917. useMultiview?: boolean;
  97918. }
  97919. /**
  97920. * This represents a WebVR camera.
  97921. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  97922. * @example https://doc.babylonjs.com/how_to/webvr_camera
  97923. */
  97924. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  97925. private webVROptions;
  97926. /**
  97927. * @hidden
  97928. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  97929. */
  97930. _vrDevice: any;
  97931. /**
  97932. * The rawPose of the vrDevice.
  97933. */
  97934. rawPose: Nullable<DevicePose>;
  97935. private _onVREnabled;
  97936. private _specsVersion;
  97937. private _attached;
  97938. private _frameData;
  97939. protected _descendants: Array<Node>;
  97940. private _deviceRoomPosition;
  97941. /** @hidden */
  97942. _deviceRoomRotationQuaternion: Quaternion;
  97943. private _standingMatrix;
  97944. /**
  97945. * Represents device position in babylon space.
  97946. */
  97947. devicePosition: Vector3;
  97948. /**
  97949. * Represents device rotation in babylon space.
  97950. */
  97951. deviceRotationQuaternion: Quaternion;
  97952. /**
  97953. * The scale of the device to be used when translating from device space to babylon space.
  97954. */
  97955. deviceScaleFactor: number;
  97956. private _deviceToWorld;
  97957. private _worldToDevice;
  97958. /**
  97959. * References to the webVR controllers for the vrDevice.
  97960. */
  97961. controllers: Array<WebVRController>;
  97962. /**
  97963. * Emits an event when a controller is attached.
  97964. */
  97965. onControllersAttachedObservable: Observable<WebVRController[]>;
  97966. /**
  97967. * Emits an event when a controller's mesh has been loaded;
  97968. */
  97969. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97970. /**
  97971. * Emits an event when the HMD's pose has been updated.
  97972. */
  97973. onPoseUpdatedFromDeviceObservable: Observable<any>;
  97974. private _poseSet;
  97975. /**
  97976. * If the rig cameras be used as parent instead of this camera.
  97977. */
  97978. rigParenting: boolean;
  97979. private _lightOnControllers;
  97980. private _defaultHeight?;
  97981. /**
  97982. * Instantiates a WebVRFreeCamera.
  97983. * @param name The name of the WebVRFreeCamera
  97984. * @param position The starting anchor position for the camera
  97985. * @param scene The scene the camera belongs to
  97986. * @param webVROptions a set of customizable options for the webVRCamera
  97987. */
  97988. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  97989. /**
  97990. * Gets the device distance from the ground in meters.
  97991. * @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.
  97992. */
  97993. deviceDistanceToRoomGround(): number;
  97994. /**
  97995. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97996. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  97997. */
  97998. useStandingMatrix(callback?: (bool: boolean) => void): void;
  97999. /**
  98000. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98001. * @returns A promise with a boolean set to if the standing matrix is supported.
  98002. */
  98003. useStandingMatrixAsync(): Promise<boolean>;
  98004. /**
  98005. * Disposes the camera
  98006. */
  98007. dispose(): void;
  98008. /**
  98009. * Gets a vrController by name.
  98010. * @param name The name of the controller to retreive
  98011. * @returns the controller matching the name specified or null if not found
  98012. */
  98013. getControllerByName(name: string): Nullable<WebVRController>;
  98014. private _leftController;
  98015. /**
  98016. * The controller corresponding to the users left hand.
  98017. */
  98018. get leftController(): Nullable<WebVRController>;
  98019. private _rightController;
  98020. /**
  98021. * The controller corresponding to the users right hand.
  98022. */
  98023. get rightController(): Nullable<WebVRController>;
  98024. /**
  98025. * Casts a ray forward from the vrCamera's gaze.
  98026. * @param length Length of the ray (default: 100)
  98027. * @returns the ray corresponding to the gaze
  98028. */
  98029. getForwardRay(length?: number): Ray;
  98030. /**
  98031. * @hidden
  98032. * Updates the camera based on device's frame data
  98033. */
  98034. _checkInputs(): void;
  98035. /**
  98036. * Updates the poseControlled values based on the input device pose.
  98037. * @param poseData Pose coming from the device
  98038. */
  98039. updateFromDevice(poseData: DevicePose): void;
  98040. private _htmlElementAttached;
  98041. private _detachIfAttached;
  98042. /**
  98043. * WebVR's attach control will start broadcasting frames to the device.
  98044. * Note that in certain browsers (chrome for example) this function must be called
  98045. * within a user-interaction callback. Example:
  98046. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  98047. *
  98048. * @param element html element to attach the vrDevice to
  98049. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  98050. */
  98051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98052. /**
  98053. * Detaches the camera from the html element and disables VR
  98054. *
  98055. * @param element html element to detach from
  98056. */
  98057. detachControl(element: HTMLElement): void;
  98058. /**
  98059. * @returns the name of this class
  98060. */
  98061. getClassName(): string;
  98062. /**
  98063. * Calls resetPose on the vrDisplay
  98064. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  98065. */
  98066. resetToCurrentRotation(): void;
  98067. /**
  98068. * @hidden
  98069. * Updates the rig cameras (left and right eye)
  98070. */
  98071. _updateRigCameras(): void;
  98072. private _workingVector;
  98073. private _oneVector;
  98074. private _workingMatrix;
  98075. private updateCacheCalled;
  98076. private _correctPositionIfNotTrackPosition;
  98077. /**
  98078. * @hidden
  98079. * Updates the cached values of the camera
  98080. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  98081. */
  98082. _updateCache(ignoreParentClass?: boolean): void;
  98083. /**
  98084. * @hidden
  98085. * Get current device position in babylon world
  98086. */
  98087. _computeDevicePosition(): void;
  98088. /**
  98089. * Updates the current device position and rotation in the babylon world
  98090. */
  98091. update(): void;
  98092. /**
  98093. * @hidden
  98094. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  98095. * @returns an identity matrix
  98096. */
  98097. _getViewMatrix(): Matrix;
  98098. private _tmpMatrix;
  98099. /**
  98100. * This function is called by the two RIG cameras.
  98101. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  98102. * @hidden
  98103. */
  98104. _getWebVRViewMatrix(): Matrix;
  98105. /** @hidden */
  98106. _getWebVRProjectionMatrix(): Matrix;
  98107. private _onGamepadConnectedObserver;
  98108. private _onGamepadDisconnectedObserver;
  98109. private _updateCacheWhenTrackingDisabledObserver;
  98110. /**
  98111. * Initializes the controllers and their meshes
  98112. */
  98113. initControllers(): void;
  98114. }
  98115. }
  98116. declare module BABYLON {
  98117. /**
  98118. * "Static Class" containing the most commonly used helper while dealing with material for
  98119. * rendering purpose.
  98120. *
  98121. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  98122. *
  98123. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  98124. */
  98125. export class MaterialHelper {
  98126. /**
  98127. * Bind the current view position to an effect.
  98128. * @param effect The effect to be bound
  98129. * @param scene The scene the eyes position is used from
  98130. * @param variableName name of the shader variable that will hold the eye position
  98131. */
  98132. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  98133. /**
  98134. * Helps preparing the defines values about the UVs in used in the effect.
  98135. * UVs are shared as much as we can accross channels in the shaders.
  98136. * @param texture The texture we are preparing the UVs for
  98137. * @param defines The defines to update
  98138. * @param key The channel key "diffuse", "specular"... used in the shader
  98139. */
  98140. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  98141. /**
  98142. * Binds a texture matrix value to its corrsponding uniform
  98143. * @param texture The texture to bind the matrix for
  98144. * @param uniformBuffer The uniform buffer receivin the data
  98145. * @param key The channel key "diffuse", "specular"... used in the shader
  98146. */
  98147. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  98148. /**
  98149. * Gets the current status of the fog (should it be enabled?)
  98150. * @param mesh defines the mesh to evaluate for fog support
  98151. * @param scene defines the hosting scene
  98152. * @returns true if fog must be enabled
  98153. */
  98154. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  98155. /**
  98156. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  98157. * @param mesh defines the current mesh
  98158. * @param scene defines the current scene
  98159. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  98160. * @param pointsCloud defines if point cloud rendering has to be turned on
  98161. * @param fogEnabled defines if fog has to be turned on
  98162. * @param alphaTest defines if alpha testing has to be turned on
  98163. * @param defines defines the current list of defines
  98164. */
  98165. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  98166. /**
  98167. * Helper used to prepare the list of defines associated with frame values for shader compilation
  98168. * @param scene defines the current scene
  98169. * @param engine defines the current engine
  98170. * @param defines specifies the list of active defines
  98171. * @param useInstances defines if instances have to be turned on
  98172. * @param useClipPlane defines if clip plane have to be turned on
  98173. * @param useInstances defines if instances have to be turned on
  98174. * @param useThinInstances defines if thin instances have to be turned on
  98175. */
  98176. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  98177. /**
  98178. * Prepares the defines for bones
  98179. * @param mesh The mesh containing the geometry data we will draw
  98180. * @param defines The defines to update
  98181. */
  98182. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  98183. /**
  98184. * Prepares the defines for morph targets
  98185. * @param mesh The mesh containing the geometry data we will draw
  98186. * @param defines The defines to update
  98187. */
  98188. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  98189. /**
  98190. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  98191. * @param mesh The mesh containing the geometry data we will draw
  98192. * @param defines The defines to update
  98193. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  98194. * @param useBones Precise whether bones should be used or not (override mesh info)
  98195. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  98196. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  98197. * @returns false if defines are considered not dirty and have not been checked
  98198. */
  98199. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  98200. /**
  98201. * Prepares the defines related to multiview
  98202. * @param scene The scene we are intending to draw
  98203. * @param defines The defines to update
  98204. */
  98205. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  98206. /**
  98207. * Prepares the defines related to the prepass
  98208. * @param scene The scene we are intending to draw
  98209. * @param defines The defines to update
  98210. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  98211. */
  98212. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  98213. /**
  98214. * Prepares the defines related to the light information passed in parameter
  98215. * @param scene The scene we are intending to draw
  98216. * @param mesh The mesh the effect is compiling for
  98217. * @param light The light the effect is compiling for
  98218. * @param lightIndex The index of the light
  98219. * @param defines The defines to update
  98220. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98221. * @param state Defines the current state regarding what is needed (normals, etc...)
  98222. */
  98223. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  98224. needNormals: boolean;
  98225. needRebuild: boolean;
  98226. shadowEnabled: boolean;
  98227. specularEnabled: boolean;
  98228. lightmapMode: boolean;
  98229. }): void;
  98230. /**
  98231. * Prepares the defines related to the light information passed in parameter
  98232. * @param scene The scene we are intending to draw
  98233. * @param mesh The mesh the effect is compiling for
  98234. * @param defines The defines to update
  98235. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98236. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  98237. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  98238. * @returns true if normals will be required for the rest of the effect
  98239. */
  98240. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  98241. /**
  98242. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  98243. * @param lightIndex defines the light index
  98244. * @param uniformsList The uniform list
  98245. * @param samplersList The sampler list
  98246. * @param projectedLightTexture defines if projected texture must be used
  98247. * @param uniformBuffersList defines an optional list of uniform buffers
  98248. */
  98249. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  98250. /**
  98251. * Prepares the uniforms and samplers list to be used in the effect
  98252. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  98253. * @param samplersList The sampler list
  98254. * @param defines The defines helping in the list generation
  98255. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  98256. */
  98257. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  98258. /**
  98259. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  98260. * @param defines The defines to update while falling back
  98261. * @param fallbacks The authorized effect fallbacks
  98262. * @param maxSimultaneousLights The maximum number of lights allowed
  98263. * @param rank the current rank of the Effect
  98264. * @returns The newly affected rank
  98265. */
  98266. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  98267. private static _TmpMorphInfluencers;
  98268. /**
  98269. * Prepares the list of attributes required for morph targets according to the effect defines.
  98270. * @param attribs The current list of supported attribs
  98271. * @param mesh The mesh to prepare the morph targets attributes for
  98272. * @param influencers The number of influencers
  98273. */
  98274. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  98275. /**
  98276. * Prepares the list of attributes required for morph targets according to the effect defines.
  98277. * @param attribs The current list of supported attribs
  98278. * @param mesh The mesh to prepare the morph targets attributes for
  98279. * @param defines The current Defines of the effect
  98280. */
  98281. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  98282. /**
  98283. * Prepares the list of attributes required for bones according to the effect defines.
  98284. * @param attribs The current list of supported attribs
  98285. * @param mesh The mesh to prepare the bones attributes for
  98286. * @param defines The current Defines of the effect
  98287. * @param fallbacks The current efffect fallback strategy
  98288. */
  98289. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  98290. /**
  98291. * Check and prepare the list of attributes required for instances according to the effect defines.
  98292. * @param attribs The current list of supported attribs
  98293. * @param defines The current MaterialDefines of the effect
  98294. */
  98295. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  98296. /**
  98297. * Add the list of attributes required for instances to the attribs array.
  98298. * @param attribs The current list of supported attribs
  98299. */
  98300. static PushAttributesForInstances(attribs: string[]): void;
  98301. /**
  98302. * Binds the light information to the effect.
  98303. * @param light The light containing the generator
  98304. * @param effect The effect we are binding the data to
  98305. * @param lightIndex The light index in the effect used to render
  98306. */
  98307. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  98308. /**
  98309. * Binds the lights information from the scene to the effect for the given mesh.
  98310. * @param light Light to bind
  98311. * @param lightIndex Light index
  98312. * @param scene The scene where the light belongs to
  98313. * @param effect The effect we are binding the data to
  98314. * @param useSpecular Defines if specular is supported
  98315. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98316. */
  98317. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98318. /**
  98319. * Binds the lights information from the scene to the effect for the given mesh.
  98320. * @param scene The scene the lights belongs to
  98321. * @param mesh The mesh we are binding the information to render
  98322. * @param effect The effect we are binding the data to
  98323. * @param defines The generated defines for the effect
  98324. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  98325. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98326. */
  98327. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  98328. private static _tempFogColor;
  98329. /**
  98330. * Binds the fog information from the scene to the effect for the given mesh.
  98331. * @param scene The scene the lights belongs to
  98332. * @param mesh The mesh we are binding the information to render
  98333. * @param effect The effect we are binding the data to
  98334. * @param linearSpace Defines if the fog effect is applied in linear space
  98335. */
  98336. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  98337. /**
  98338. * Binds the bones information from the mesh to the effect.
  98339. * @param mesh The mesh we are binding the information to render
  98340. * @param effect The effect we are binding the data to
  98341. */
  98342. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  98343. /**
  98344. * Binds the morph targets information from the mesh to the effect.
  98345. * @param abstractMesh The mesh we are binding the information to render
  98346. * @param effect The effect we are binding the data to
  98347. */
  98348. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  98349. /**
  98350. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  98351. * @param defines The generated defines used in the effect
  98352. * @param effect The effect we are binding the data to
  98353. * @param scene The scene we are willing to render with logarithmic scale for
  98354. */
  98355. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  98356. /**
  98357. * Binds the clip plane information from the scene to the effect.
  98358. * @param scene The scene the clip plane information are extracted from
  98359. * @param effect The effect we are binding the data to
  98360. */
  98361. static BindClipPlane(effect: Effect, scene: Scene): void;
  98362. }
  98363. }
  98364. declare module BABYLON {
  98365. /**
  98366. * Block used to expose an input value
  98367. */
  98368. export class InputBlock extends NodeMaterialBlock {
  98369. private _mode;
  98370. private _associatedVariableName;
  98371. private _storedValue;
  98372. private _valueCallback;
  98373. private _type;
  98374. private _animationType;
  98375. /** Gets or set a value used to limit the range of float values */
  98376. min: number;
  98377. /** Gets or set a value used to limit the range of float values */
  98378. max: number;
  98379. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  98380. isBoolean: boolean;
  98381. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  98382. matrixMode: number;
  98383. /** @hidden */
  98384. _systemValue: Nullable<NodeMaterialSystemValues>;
  98385. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  98386. visibleInInspector: boolean;
  98387. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  98388. isConstant: boolean;
  98389. /** Gets or sets the group to use to display this block in the Inspector */
  98390. groupInInspector: string;
  98391. /** Gets an observable raised when the value is changed */
  98392. onValueChangedObservable: Observable<InputBlock>;
  98393. /**
  98394. * Gets or sets the connection point type (default is float)
  98395. */
  98396. get type(): NodeMaterialBlockConnectionPointTypes;
  98397. /**
  98398. * Creates a new InputBlock
  98399. * @param name defines the block name
  98400. * @param target defines the target of that block (Vertex by default)
  98401. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  98402. */
  98403. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  98404. /**
  98405. * Gets the output component
  98406. */
  98407. get output(): NodeMaterialConnectionPoint;
  98408. /**
  98409. * Set the source of this connection point to a vertex attribute
  98410. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  98411. * @returns the current connection point
  98412. */
  98413. setAsAttribute(attributeName?: string): InputBlock;
  98414. /**
  98415. * Set the source of this connection point to a system value
  98416. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  98417. * @returns the current connection point
  98418. */
  98419. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  98420. /**
  98421. * Gets or sets the value of that point.
  98422. * Please note that this value will be ignored if valueCallback is defined
  98423. */
  98424. get value(): any;
  98425. set value(value: any);
  98426. /**
  98427. * Gets or sets a callback used to get the value of that point.
  98428. * Please note that setting this value will force the connection point to ignore the value property
  98429. */
  98430. get valueCallback(): () => any;
  98431. set valueCallback(value: () => any);
  98432. /**
  98433. * Gets or sets the associated variable name in the shader
  98434. */
  98435. get associatedVariableName(): string;
  98436. set associatedVariableName(value: string);
  98437. /** Gets or sets the type of animation applied to the input */
  98438. get animationType(): AnimatedInputBlockTypes;
  98439. set animationType(value: AnimatedInputBlockTypes);
  98440. /**
  98441. * Gets a boolean indicating that this connection point not defined yet
  98442. */
  98443. get isUndefined(): boolean;
  98444. /**
  98445. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  98446. * In this case the connection point name must be the name of the uniform to use.
  98447. * Can only be set on inputs
  98448. */
  98449. get isUniform(): boolean;
  98450. set isUniform(value: boolean);
  98451. /**
  98452. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  98453. * In this case the connection point name must be the name of the attribute to use
  98454. * Can only be set on inputs
  98455. */
  98456. get isAttribute(): boolean;
  98457. set isAttribute(value: boolean);
  98458. /**
  98459. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  98460. * Can only be set on exit points
  98461. */
  98462. get isVarying(): boolean;
  98463. set isVarying(value: boolean);
  98464. /**
  98465. * Gets a boolean indicating that the current connection point is a system value
  98466. */
  98467. get isSystemValue(): boolean;
  98468. /**
  98469. * Gets or sets the current well known value or null if not defined as a system value
  98470. */
  98471. get systemValue(): Nullable<NodeMaterialSystemValues>;
  98472. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  98473. /**
  98474. * Gets the current class name
  98475. * @returns the class name
  98476. */
  98477. getClassName(): string;
  98478. /**
  98479. * Animate the input if animationType !== None
  98480. * @param scene defines the rendering scene
  98481. */
  98482. animate(scene: Scene): void;
  98483. private _emitDefine;
  98484. initialize(state: NodeMaterialBuildState): void;
  98485. /**
  98486. * Set the input block to its default value (based on its type)
  98487. */
  98488. setDefaultValue(): void;
  98489. private _emitConstant;
  98490. /** @hidden */
  98491. get _noContextSwitch(): boolean;
  98492. private _emit;
  98493. /** @hidden */
  98494. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  98495. /** @hidden */
  98496. _transmit(effect: Effect, scene: Scene): void;
  98497. protected _buildBlock(state: NodeMaterialBuildState): void;
  98498. protected _dumpPropertiesCode(): string;
  98499. dispose(): void;
  98500. serialize(): any;
  98501. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98502. }
  98503. }
  98504. declare module BABYLON {
  98505. /**
  98506. * Enum used to define the compatibility state between two connection points
  98507. */
  98508. export enum NodeMaterialConnectionPointCompatibilityStates {
  98509. /** Points are compatibles */
  98510. Compatible = 0,
  98511. /** Points are incompatible because of their types */
  98512. TypeIncompatible = 1,
  98513. /** Points are incompatible because of their targets (vertex vs fragment) */
  98514. TargetIncompatible = 2
  98515. }
  98516. /**
  98517. * Defines the direction of a connection point
  98518. */
  98519. export enum NodeMaterialConnectionPointDirection {
  98520. /** Input */
  98521. Input = 0,
  98522. /** Output */
  98523. Output = 1
  98524. }
  98525. /**
  98526. * Defines a connection point for a block
  98527. */
  98528. export class NodeMaterialConnectionPoint {
  98529. /** @hidden */
  98530. _ownerBlock: NodeMaterialBlock;
  98531. /** @hidden */
  98532. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  98533. private _endpoints;
  98534. private _associatedVariableName;
  98535. private _direction;
  98536. /** @hidden */
  98537. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98538. /** @hidden */
  98539. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98540. private _type;
  98541. /** @hidden */
  98542. _enforceAssociatedVariableName: boolean;
  98543. /** Gets the direction of the point */
  98544. get direction(): NodeMaterialConnectionPointDirection;
  98545. /** Indicates that this connection point needs dual validation before being connected to another point */
  98546. needDualDirectionValidation: boolean;
  98547. /**
  98548. * Gets or sets the additional types supported by this connection point
  98549. */
  98550. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98551. /**
  98552. * Gets or sets the additional types excluded by this connection point
  98553. */
  98554. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98555. /**
  98556. * Observable triggered when this point is connected
  98557. */
  98558. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  98559. /**
  98560. * Gets or sets the associated variable name in the shader
  98561. */
  98562. get associatedVariableName(): string;
  98563. set associatedVariableName(value: string);
  98564. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  98565. get innerType(): NodeMaterialBlockConnectionPointTypes;
  98566. /**
  98567. * Gets or sets the connection point type (default is float)
  98568. */
  98569. get type(): NodeMaterialBlockConnectionPointTypes;
  98570. set type(value: NodeMaterialBlockConnectionPointTypes);
  98571. /**
  98572. * Gets or sets the connection point name
  98573. */
  98574. name: string;
  98575. /**
  98576. * Gets or sets the connection point name
  98577. */
  98578. displayName: string;
  98579. /**
  98580. * Gets or sets a boolean indicating that this connection point can be omitted
  98581. */
  98582. isOptional: boolean;
  98583. /**
  98584. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  98585. */
  98586. isExposedOnFrame: boolean;
  98587. /**
  98588. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  98589. */
  98590. define: string;
  98591. /** @hidden */
  98592. _prioritizeVertex: boolean;
  98593. private _target;
  98594. /** Gets or sets the target of that connection point */
  98595. get target(): NodeMaterialBlockTargets;
  98596. set target(value: NodeMaterialBlockTargets);
  98597. /**
  98598. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  98599. */
  98600. get isConnected(): boolean;
  98601. /**
  98602. * Gets a boolean indicating that the current point is connected to an input block
  98603. */
  98604. get isConnectedToInputBlock(): boolean;
  98605. /**
  98606. * Gets a the connected input block (if any)
  98607. */
  98608. get connectInputBlock(): Nullable<InputBlock>;
  98609. /** Get the other side of the connection (if any) */
  98610. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  98611. /** Get the block that owns this connection point */
  98612. get ownerBlock(): NodeMaterialBlock;
  98613. /** Get the block connected on the other side of this connection (if any) */
  98614. get sourceBlock(): Nullable<NodeMaterialBlock>;
  98615. /** Get the block connected on the endpoints of this connection (if any) */
  98616. get connectedBlocks(): Array<NodeMaterialBlock>;
  98617. /** Gets the list of connected endpoints */
  98618. get endpoints(): NodeMaterialConnectionPoint[];
  98619. /** Gets a boolean indicating if that output point is connected to at least one input */
  98620. get hasEndpoints(): boolean;
  98621. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  98622. get isConnectedInVertexShader(): boolean;
  98623. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  98624. get isConnectedInFragmentShader(): boolean;
  98625. /**
  98626. * Creates a block suitable to be used as an input for this input point.
  98627. * If null is returned, a block based on the point type will be created.
  98628. * @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
  98629. */
  98630. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98631. /**
  98632. * Creates a new connection point
  98633. * @param name defines the connection point name
  98634. * @param ownerBlock defines the block hosting this connection point
  98635. * @param direction defines the direction of the connection point
  98636. */
  98637. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  98638. /**
  98639. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  98640. * @returns the class name
  98641. */
  98642. getClassName(): string;
  98643. /**
  98644. * Gets a boolean indicating if the current point can be connected to another point
  98645. * @param connectionPoint defines the other connection point
  98646. * @returns a boolean
  98647. */
  98648. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  98649. /**
  98650. * Gets a number indicating if the current point can be connected to another point
  98651. * @param connectionPoint defines the other connection point
  98652. * @returns a number defining the compatibility state
  98653. */
  98654. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98655. /**
  98656. * Connect this point to another connection point
  98657. * @param connectionPoint defines the other connection point
  98658. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  98659. * @returns the current connection point
  98660. */
  98661. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  98662. /**
  98663. * Disconnect this point from one of his endpoint
  98664. * @param endpoint defines the other connection point
  98665. * @returns the current connection point
  98666. */
  98667. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  98668. /**
  98669. * Serializes this point in a JSON representation
  98670. * @param isInput defines if the connection point is an input (default is true)
  98671. * @returns the serialized point object
  98672. */
  98673. serialize(isInput?: boolean): any;
  98674. /**
  98675. * Release resources
  98676. */
  98677. dispose(): void;
  98678. }
  98679. }
  98680. declare module BABYLON {
  98681. /**
  98682. * Enum used to define the material modes
  98683. */
  98684. export enum NodeMaterialModes {
  98685. /** Regular material */
  98686. Material = 0,
  98687. /** For post process */
  98688. PostProcess = 1,
  98689. /** For particle system */
  98690. Particle = 2
  98691. }
  98692. }
  98693. declare module BABYLON {
  98694. /**
  98695. * Block used to read a texture from a sampler
  98696. */
  98697. export class TextureBlock extends NodeMaterialBlock {
  98698. private _defineName;
  98699. private _linearDefineName;
  98700. private _gammaDefineName;
  98701. private _tempTextureRead;
  98702. private _samplerName;
  98703. private _transformedUVName;
  98704. private _textureTransformName;
  98705. private _textureInfoName;
  98706. private _mainUVName;
  98707. private _mainUVDefineName;
  98708. private _fragmentOnly;
  98709. /**
  98710. * Gets or sets the texture associated with the node
  98711. */
  98712. texture: Nullable<Texture>;
  98713. /**
  98714. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98715. */
  98716. convertToGammaSpace: boolean;
  98717. /**
  98718. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98719. */
  98720. convertToLinearSpace: boolean;
  98721. /**
  98722. * Create a new TextureBlock
  98723. * @param name defines the block name
  98724. */
  98725. constructor(name: string, fragmentOnly?: boolean);
  98726. /**
  98727. * Gets the current class name
  98728. * @returns the class name
  98729. */
  98730. getClassName(): string;
  98731. /**
  98732. * Gets the uv input component
  98733. */
  98734. get uv(): NodeMaterialConnectionPoint;
  98735. /**
  98736. * Gets the rgba output component
  98737. */
  98738. get rgba(): NodeMaterialConnectionPoint;
  98739. /**
  98740. * Gets the rgb output component
  98741. */
  98742. get rgb(): NodeMaterialConnectionPoint;
  98743. /**
  98744. * Gets the r output component
  98745. */
  98746. get r(): NodeMaterialConnectionPoint;
  98747. /**
  98748. * Gets the g output component
  98749. */
  98750. get g(): NodeMaterialConnectionPoint;
  98751. /**
  98752. * Gets the b output component
  98753. */
  98754. get b(): NodeMaterialConnectionPoint;
  98755. /**
  98756. * Gets the a output component
  98757. */
  98758. get a(): NodeMaterialConnectionPoint;
  98759. get target(): NodeMaterialBlockTargets;
  98760. autoConfigure(material: NodeMaterial): void;
  98761. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98762. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98763. isReady(): boolean;
  98764. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98765. private get _isMixed();
  98766. private _injectVertexCode;
  98767. private _writeTextureRead;
  98768. private _writeOutput;
  98769. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98770. protected _dumpPropertiesCode(): string;
  98771. serialize(): any;
  98772. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98773. }
  98774. }
  98775. declare module BABYLON {
  98776. /** @hidden */
  98777. export var reflectionFunction: {
  98778. name: string;
  98779. shader: string;
  98780. };
  98781. }
  98782. declare module BABYLON {
  98783. /**
  98784. * Base block used to read a reflection texture from a sampler
  98785. */
  98786. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  98787. /** @hidden */
  98788. _define3DName: string;
  98789. /** @hidden */
  98790. _defineCubicName: string;
  98791. /** @hidden */
  98792. _defineExplicitName: string;
  98793. /** @hidden */
  98794. _defineProjectionName: string;
  98795. /** @hidden */
  98796. _defineLocalCubicName: string;
  98797. /** @hidden */
  98798. _defineSphericalName: string;
  98799. /** @hidden */
  98800. _definePlanarName: string;
  98801. /** @hidden */
  98802. _defineEquirectangularName: string;
  98803. /** @hidden */
  98804. _defineMirroredEquirectangularFixedName: string;
  98805. /** @hidden */
  98806. _defineEquirectangularFixedName: string;
  98807. /** @hidden */
  98808. _defineSkyboxName: string;
  98809. /** @hidden */
  98810. _defineOppositeZ: string;
  98811. /** @hidden */
  98812. _cubeSamplerName: string;
  98813. /** @hidden */
  98814. _2DSamplerName: string;
  98815. protected _positionUVWName: string;
  98816. protected _directionWName: string;
  98817. protected _reflectionVectorName: string;
  98818. /** @hidden */
  98819. _reflectionCoordsName: string;
  98820. /** @hidden */
  98821. _reflectionMatrixName: string;
  98822. protected _reflectionColorName: string;
  98823. /**
  98824. * Gets or sets the texture associated with the node
  98825. */
  98826. texture: Nullable<BaseTexture>;
  98827. /**
  98828. * Create a new ReflectionTextureBaseBlock
  98829. * @param name defines the block name
  98830. */
  98831. constructor(name: string);
  98832. /**
  98833. * Gets the current class name
  98834. * @returns the class name
  98835. */
  98836. getClassName(): string;
  98837. /**
  98838. * Gets the world position input component
  98839. */
  98840. abstract get position(): NodeMaterialConnectionPoint;
  98841. /**
  98842. * Gets the world position input component
  98843. */
  98844. abstract get worldPosition(): NodeMaterialConnectionPoint;
  98845. /**
  98846. * Gets the world normal input component
  98847. */
  98848. abstract get worldNormal(): NodeMaterialConnectionPoint;
  98849. /**
  98850. * Gets the world input component
  98851. */
  98852. abstract get world(): NodeMaterialConnectionPoint;
  98853. /**
  98854. * Gets the camera (or eye) position component
  98855. */
  98856. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  98857. /**
  98858. * Gets the view input component
  98859. */
  98860. abstract get view(): NodeMaterialConnectionPoint;
  98861. protected _getTexture(): Nullable<BaseTexture>;
  98862. autoConfigure(material: NodeMaterial): void;
  98863. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98864. isReady(): boolean;
  98865. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98866. /**
  98867. * Gets the code to inject in the vertex shader
  98868. * @param state current state of the node material building
  98869. * @returns the shader code
  98870. */
  98871. handleVertexSide(state: NodeMaterialBuildState): string;
  98872. /**
  98873. * Handles the inits for the fragment code path
  98874. * @param state node material build state
  98875. */
  98876. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  98877. /**
  98878. * Generates the reflection coords code for the fragment code path
  98879. * @param worldNormalVarName name of the world normal variable
  98880. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  98881. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  98882. * @returns the shader code
  98883. */
  98884. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  98885. /**
  98886. * Generates the reflection color code for the fragment code path
  98887. * @param lodVarName name of the lod variable
  98888. * @param swizzleLookupTexture swizzle to use for the final color variable
  98889. * @returns the shader code
  98890. */
  98891. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  98892. /**
  98893. * Generates the code corresponding to the connected output points
  98894. * @param state node material build state
  98895. * @param varName name of the variable to output
  98896. * @returns the shader code
  98897. */
  98898. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  98899. protected _buildBlock(state: NodeMaterialBuildState): this;
  98900. protected _dumpPropertiesCode(): string;
  98901. serialize(): any;
  98902. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98903. }
  98904. }
  98905. declare module BABYLON {
  98906. /**
  98907. * Defines a connection point to be used for points with a custom object type
  98908. */
  98909. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  98910. private _blockType;
  98911. private _blockName;
  98912. private _nameForCheking?;
  98913. /**
  98914. * Creates a new connection point
  98915. * @param name defines the connection point name
  98916. * @param ownerBlock defines the block hosting this connection point
  98917. * @param direction defines the direction of the connection point
  98918. */
  98919. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  98920. /**
  98921. * Gets a number indicating if the current point can be connected to another point
  98922. * @param connectionPoint defines the other connection point
  98923. * @returns a number defining the compatibility state
  98924. */
  98925. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98926. /**
  98927. * Creates a block suitable to be used as an input for this input point.
  98928. * If null is returned, a block based on the point type will be created.
  98929. * @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
  98930. */
  98931. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98932. }
  98933. }
  98934. declare module BABYLON {
  98935. /**
  98936. * Enum defining the type of properties that can be edited in the property pages in the NME
  98937. */
  98938. export enum PropertyTypeForEdition {
  98939. /** property is a boolean */
  98940. Boolean = 0,
  98941. /** property is a float */
  98942. Float = 1,
  98943. /** property is a Vector2 */
  98944. Vector2 = 2,
  98945. /** property is a list of values */
  98946. List = 3
  98947. }
  98948. /**
  98949. * Interface that defines an option in a variable of type list
  98950. */
  98951. export interface IEditablePropertyListOption {
  98952. /** label of the option */
  98953. "label": string;
  98954. /** value of the option */
  98955. "value": number;
  98956. }
  98957. /**
  98958. * Interface that defines the options available for an editable property
  98959. */
  98960. export interface IEditablePropertyOption {
  98961. /** min value */
  98962. "min"?: number;
  98963. /** max value */
  98964. "max"?: number;
  98965. /** notifiers: indicates which actions to take when the property is changed */
  98966. "notifiers"?: {
  98967. /** the material should be rebuilt */
  98968. "rebuild"?: boolean;
  98969. /** the preview should be updated */
  98970. "update"?: boolean;
  98971. };
  98972. /** list of the options for a variable of type list */
  98973. "options"?: IEditablePropertyListOption[];
  98974. }
  98975. /**
  98976. * Interface that describes an editable property
  98977. */
  98978. export interface IPropertyDescriptionForEdition {
  98979. /** name of the property */
  98980. "propertyName": string;
  98981. /** display name of the property */
  98982. "displayName": string;
  98983. /** type of the property */
  98984. "type": PropertyTypeForEdition;
  98985. /** group of the property - all properties with the same group value will be displayed in a specific section */
  98986. "groupName": string;
  98987. /** options for the property */
  98988. "options": IEditablePropertyOption;
  98989. }
  98990. /**
  98991. * Decorator that flags a property in a node material block as being editable
  98992. */
  98993. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98994. }
  98995. declare module BABYLON {
  98996. /**
  98997. * Block used to implement the refraction part of the sub surface module of the PBR material
  98998. */
  98999. export class RefractionBlock extends NodeMaterialBlock {
  99000. /** @hidden */
  99001. _define3DName: string;
  99002. /** @hidden */
  99003. _refractionMatrixName: string;
  99004. /** @hidden */
  99005. _defineLODRefractionAlpha: string;
  99006. /** @hidden */
  99007. _defineLinearSpecularRefraction: string;
  99008. /** @hidden */
  99009. _defineOppositeZ: string;
  99010. /** @hidden */
  99011. _cubeSamplerName: string;
  99012. /** @hidden */
  99013. _2DSamplerName: string;
  99014. /** @hidden */
  99015. _vRefractionMicrosurfaceInfosName: string;
  99016. /** @hidden */
  99017. _vRefractionInfosName: string;
  99018. private _scene;
  99019. /**
  99020. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99021. * Materials half opaque for instance using refraction could benefit from this control.
  99022. */
  99023. linkRefractionWithTransparency: boolean;
  99024. /**
  99025. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99026. */
  99027. invertRefractionY: boolean;
  99028. /**
  99029. * Gets or sets the texture associated with the node
  99030. */
  99031. texture: Nullable<BaseTexture>;
  99032. /**
  99033. * Create a new RefractionBlock
  99034. * @param name defines the block name
  99035. */
  99036. constructor(name: string);
  99037. /**
  99038. * Gets the current class name
  99039. * @returns the class name
  99040. */
  99041. getClassName(): string;
  99042. /**
  99043. * Gets the intensity input component
  99044. */
  99045. get intensity(): NodeMaterialConnectionPoint;
  99046. /**
  99047. * Gets the index of refraction input component
  99048. */
  99049. get indexOfRefraction(): NodeMaterialConnectionPoint;
  99050. /**
  99051. * Gets the tint at distance input component
  99052. */
  99053. get tintAtDistance(): NodeMaterialConnectionPoint;
  99054. /**
  99055. * Gets the view input component
  99056. */
  99057. get view(): NodeMaterialConnectionPoint;
  99058. /**
  99059. * Gets the refraction object output component
  99060. */
  99061. get refraction(): NodeMaterialConnectionPoint;
  99062. /**
  99063. * Returns true if the block has a texture
  99064. */
  99065. get hasTexture(): boolean;
  99066. protected _getTexture(): Nullable<BaseTexture>;
  99067. autoConfigure(material: NodeMaterial): void;
  99068. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99069. isReady(): boolean;
  99070. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99071. /**
  99072. * Gets the main code of the block (fragment side)
  99073. * @param state current state of the node material building
  99074. * @returns the shader code
  99075. */
  99076. getCode(state: NodeMaterialBuildState): string;
  99077. protected _buildBlock(state: NodeMaterialBuildState): this;
  99078. protected _dumpPropertiesCode(): string;
  99079. serialize(): any;
  99080. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99081. }
  99082. }
  99083. declare module BABYLON {
  99084. /**
  99085. * Base block used as input for post process
  99086. */
  99087. export class CurrentScreenBlock extends NodeMaterialBlock {
  99088. private _samplerName;
  99089. private _linearDefineName;
  99090. private _gammaDefineName;
  99091. private _mainUVName;
  99092. private _tempTextureRead;
  99093. /**
  99094. * Gets or sets the texture associated with the node
  99095. */
  99096. texture: Nullable<BaseTexture>;
  99097. /**
  99098. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99099. */
  99100. convertToGammaSpace: boolean;
  99101. /**
  99102. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99103. */
  99104. convertToLinearSpace: boolean;
  99105. /**
  99106. * Create a new CurrentScreenBlock
  99107. * @param name defines the block name
  99108. */
  99109. constructor(name: string);
  99110. /**
  99111. * Gets the current class name
  99112. * @returns the class name
  99113. */
  99114. getClassName(): string;
  99115. /**
  99116. * Gets the uv input component
  99117. */
  99118. get uv(): NodeMaterialConnectionPoint;
  99119. /**
  99120. * Gets the rgba output component
  99121. */
  99122. get rgba(): NodeMaterialConnectionPoint;
  99123. /**
  99124. * Gets the rgb output component
  99125. */
  99126. get rgb(): NodeMaterialConnectionPoint;
  99127. /**
  99128. * Gets the r output component
  99129. */
  99130. get r(): NodeMaterialConnectionPoint;
  99131. /**
  99132. * Gets the g output component
  99133. */
  99134. get g(): NodeMaterialConnectionPoint;
  99135. /**
  99136. * Gets the b output component
  99137. */
  99138. get b(): NodeMaterialConnectionPoint;
  99139. /**
  99140. * Gets the a output component
  99141. */
  99142. get a(): NodeMaterialConnectionPoint;
  99143. /**
  99144. * Initialize the block and prepare the context for build
  99145. * @param state defines the state that will be used for the build
  99146. */
  99147. initialize(state: NodeMaterialBuildState): void;
  99148. get target(): NodeMaterialBlockTargets;
  99149. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99150. isReady(): boolean;
  99151. private _injectVertexCode;
  99152. private _writeTextureRead;
  99153. private _writeOutput;
  99154. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99155. serialize(): any;
  99156. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99157. }
  99158. }
  99159. declare module BABYLON {
  99160. /**
  99161. * Base block used for the particle texture
  99162. */
  99163. export class ParticleTextureBlock extends NodeMaterialBlock {
  99164. private _samplerName;
  99165. private _linearDefineName;
  99166. private _gammaDefineName;
  99167. private _tempTextureRead;
  99168. /**
  99169. * Gets or sets the texture associated with the node
  99170. */
  99171. texture: Nullable<BaseTexture>;
  99172. /**
  99173. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99174. */
  99175. convertToGammaSpace: boolean;
  99176. /**
  99177. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99178. */
  99179. convertToLinearSpace: boolean;
  99180. /**
  99181. * Create a new ParticleTextureBlock
  99182. * @param name defines the block name
  99183. */
  99184. constructor(name: string);
  99185. /**
  99186. * Gets the current class name
  99187. * @returns the class name
  99188. */
  99189. getClassName(): string;
  99190. /**
  99191. * Gets the uv input component
  99192. */
  99193. get uv(): NodeMaterialConnectionPoint;
  99194. /**
  99195. * Gets the rgba output component
  99196. */
  99197. get rgba(): NodeMaterialConnectionPoint;
  99198. /**
  99199. * Gets the rgb output component
  99200. */
  99201. get rgb(): NodeMaterialConnectionPoint;
  99202. /**
  99203. * Gets the r output component
  99204. */
  99205. get r(): NodeMaterialConnectionPoint;
  99206. /**
  99207. * Gets the g output component
  99208. */
  99209. get g(): NodeMaterialConnectionPoint;
  99210. /**
  99211. * Gets the b output component
  99212. */
  99213. get b(): NodeMaterialConnectionPoint;
  99214. /**
  99215. * Gets the a output component
  99216. */
  99217. get a(): NodeMaterialConnectionPoint;
  99218. /**
  99219. * Initialize the block and prepare the context for build
  99220. * @param state defines the state that will be used for the build
  99221. */
  99222. initialize(state: NodeMaterialBuildState): void;
  99223. autoConfigure(material: NodeMaterial): void;
  99224. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99225. isReady(): boolean;
  99226. private _writeOutput;
  99227. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99228. serialize(): any;
  99229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99230. }
  99231. }
  99232. declare module BABYLON {
  99233. /**
  99234. * Class used to store shared data between 2 NodeMaterialBuildState
  99235. */
  99236. export class NodeMaterialBuildStateSharedData {
  99237. /**
  99238. * Gets the list of emitted varyings
  99239. */
  99240. temps: string[];
  99241. /**
  99242. * Gets the list of emitted varyings
  99243. */
  99244. varyings: string[];
  99245. /**
  99246. * Gets the varying declaration string
  99247. */
  99248. varyingDeclaration: string;
  99249. /**
  99250. * Input blocks
  99251. */
  99252. inputBlocks: InputBlock[];
  99253. /**
  99254. * Input blocks
  99255. */
  99256. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99257. /**
  99258. * Bindable blocks (Blocks that need to set data to the effect)
  99259. */
  99260. bindableBlocks: NodeMaterialBlock[];
  99261. /**
  99262. * List of blocks that can provide a compilation fallback
  99263. */
  99264. blocksWithFallbacks: NodeMaterialBlock[];
  99265. /**
  99266. * List of blocks that can provide a define update
  99267. */
  99268. blocksWithDefines: NodeMaterialBlock[];
  99269. /**
  99270. * List of blocks that can provide a repeatable content
  99271. */
  99272. repeatableContentBlocks: NodeMaterialBlock[];
  99273. /**
  99274. * List of blocks that can provide a dynamic list of uniforms
  99275. */
  99276. dynamicUniformBlocks: NodeMaterialBlock[];
  99277. /**
  99278. * List of blocks that can block the isReady function for the material
  99279. */
  99280. blockingBlocks: NodeMaterialBlock[];
  99281. /**
  99282. * Gets the list of animated inputs
  99283. */
  99284. animatedInputs: InputBlock[];
  99285. /**
  99286. * Build Id used to avoid multiple recompilations
  99287. */
  99288. buildId: number;
  99289. /** List of emitted variables */
  99290. variableNames: {
  99291. [key: string]: number;
  99292. };
  99293. /** List of emitted defines */
  99294. defineNames: {
  99295. [key: string]: number;
  99296. };
  99297. /** Should emit comments? */
  99298. emitComments: boolean;
  99299. /** Emit build activity */
  99300. verbose: boolean;
  99301. /** Gets or sets the hosting scene */
  99302. scene: Scene;
  99303. /**
  99304. * Gets the compilation hints emitted at compilation time
  99305. */
  99306. hints: {
  99307. needWorldViewMatrix: boolean;
  99308. needWorldViewProjectionMatrix: boolean;
  99309. needAlphaBlending: boolean;
  99310. needAlphaTesting: boolean;
  99311. };
  99312. /**
  99313. * List of compilation checks
  99314. */
  99315. checks: {
  99316. emitVertex: boolean;
  99317. emitFragment: boolean;
  99318. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  99319. };
  99320. /**
  99321. * Is vertex program allowed to be empty?
  99322. */
  99323. allowEmptyVertexProgram: boolean;
  99324. /** Creates a new shared data */
  99325. constructor();
  99326. /**
  99327. * Emits console errors and exceptions if there is a failing check
  99328. */
  99329. emitErrors(): void;
  99330. }
  99331. }
  99332. declare module BABYLON {
  99333. /**
  99334. * Class used to store node based material build state
  99335. */
  99336. export class NodeMaterialBuildState {
  99337. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  99338. supportUniformBuffers: boolean;
  99339. /**
  99340. * Gets the list of emitted attributes
  99341. */
  99342. attributes: string[];
  99343. /**
  99344. * Gets the list of emitted uniforms
  99345. */
  99346. uniforms: string[];
  99347. /**
  99348. * Gets the list of emitted constants
  99349. */
  99350. constants: string[];
  99351. /**
  99352. * Gets the list of emitted samplers
  99353. */
  99354. samplers: string[];
  99355. /**
  99356. * Gets the list of emitted functions
  99357. */
  99358. functions: {
  99359. [key: string]: string;
  99360. };
  99361. /**
  99362. * Gets the list of emitted extensions
  99363. */
  99364. extensions: {
  99365. [key: string]: string;
  99366. };
  99367. /**
  99368. * Gets the target of the compilation state
  99369. */
  99370. target: NodeMaterialBlockTargets;
  99371. /**
  99372. * Gets the list of emitted counters
  99373. */
  99374. counters: {
  99375. [key: string]: number;
  99376. };
  99377. /**
  99378. * Shared data between multiple NodeMaterialBuildState instances
  99379. */
  99380. sharedData: NodeMaterialBuildStateSharedData;
  99381. /** @hidden */
  99382. _vertexState: NodeMaterialBuildState;
  99383. /** @hidden */
  99384. _attributeDeclaration: string;
  99385. /** @hidden */
  99386. _uniformDeclaration: string;
  99387. /** @hidden */
  99388. _constantDeclaration: string;
  99389. /** @hidden */
  99390. _samplerDeclaration: string;
  99391. /** @hidden */
  99392. _varyingTransfer: string;
  99393. /** @hidden */
  99394. _injectAtEnd: string;
  99395. private _repeatableContentAnchorIndex;
  99396. /** @hidden */
  99397. _builtCompilationString: string;
  99398. /**
  99399. * Gets the emitted compilation strings
  99400. */
  99401. compilationString: string;
  99402. /**
  99403. * Finalize the compilation strings
  99404. * @param state defines the current compilation state
  99405. */
  99406. finalize(state: NodeMaterialBuildState): void;
  99407. /** @hidden */
  99408. get _repeatableContentAnchor(): string;
  99409. /** @hidden */
  99410. _getFreeVariableName(prefix: string): string;
  99411. /** @hidden */
  99412. _getFreeDefineName(prefix: string): string;
  99413. /** @hidden */
  99414. _excludeVariableName(name: string): void;
  99415. /** @hidden */
  99416. _emit2DSampler(name: string): void;
  99417. /** @hidden */
  99418. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  99419. /** @hidden */
  99420. _emitExtension(name: string, extension: string, define?: string): void;
  99421. /** @hidden */
  99422. _emitFunction(name: string, code: string, comments: string): void;
  99423. /** @hidden */
  99424. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  99425. replaceStrings?: {
  99426. search: RegExp;
  99427. replace: string;
  99428. }[];
  99429. repeatKey?: string;
  99430. }): string;
  99431. /** @hidden */
  99432. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  99433. repeatKey?: string;
  99434. removeAttributes?: boolean;
  99435. removeUniforms?: boolean;
  99436. removeVaryings?: boolean;
  99437. removeIfDef?: boolean;
  99438. replaceStrings?: {
  99439. search: RegExp;
  99440. replace: string;
  99441. }[];
  99442. }, storeKey?: string): void;
  99443. /** @hidden */
  99444. _registerTempVariable(name: string): boolean;
  99445. /** @hidden */
  99446. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  99447. /** @hidden */
  99448. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  99449. /** @hidden */
  99450. _emitFloat(value: number): string;
  99451. }
  99452. }
  99453. declare module BABYLON {
  99454. /**
  99455. * Helper class used to generate session unique ID
  99456. */
  99457. export class UniqueIdGenerator {
  99458. private static _UniqueIdCounter;
  99459. /**
  99460. * Gets an unique (relatively to the current scene) Id
  99461. */
  99462. static get UniqueId(): number;
  99463. }
  99464. }
  99465. declare module BABYLON {
  99466. /**
  99467. * Defines a block that can be used inside a node based material
  99468. */
  99469. export class NodeMaterialBlock {
  99470. private _buildId;
  99471. private _buildTarget;
  99472. private _target;
  99473. private _isFinalMerger;
  99474. private _isInput;
  99475. protected _isUnique: boolean;
  99476. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  99477. inputsAreExclusive: boolean;
  99478. /** @hidden */
  99479. _codeVariableName: string;
  99480. /** @hidden */
  99481. _inputs: NodeMaterialConnectionPoint[];
  99482. /** @hidden */
  99483. _outputs: NodeMaterialConnectionPoint[];
  99484. /** @hidden */
  99485. _preparationId: number;
  99486. /**
  99487. * Gets or sets the name of the block
  99488. */
  99489. name: string;
  99490. /**
  99491. * Gets or sets the unique id of the node
  99492. */
  99493. uniqueId: number;
  99494. /**
  99495. * Gets or sets the comments associated with this block
  99496. */
  99497. comments: string;
  99498. /**
  99499. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  99500. */
  99501. get isUnique(): boolean;
  99502. /**
  99503. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  99504. */
  99505. get isFinalMerger(): boolean;
  99506. /**
  99507. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  99508. */
  99509. get isInput(): boolean;
  99510. /**
  99511. * Gets or sets the build Id
  99512. */
  99513. get buildId(): number;
  99514. set buildId(value: number);
  99515. /**
  99516. * Gets or sets the target of the block
  99517. */
  99518. get target(): NodeMaterialBlockTargets;
  99519. set target(value: NodeMaterialBlockTargets);
  99520. /**
  99521. * Gets the list of input points
  99522. */
  99523. get inputs(): NodeMaterialConnectionPoint[];
  99524. /** Gets the list of output points */
  99525. get outputs(): NodeMaterialConnectionPoint[];
  99526. /**
  99527. * Find an input by its name
  99528. * @param name defines the name of the input to look for
  99529. * @returns the input or null if not found
  99530. */
  99531. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99532. /**
  99533. * Find an output by its name
  99534. * @param name defines the name of the outputto look for
  99535. * @returns the output or null if not found
  99536. */
  99537. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99538. /**
  99539. * Creates a new NodeMaterialBlock
  99540. * @param name defines the block name
  99541. * @param target defines the target of that block (Vertex by default)
  99542. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  99543. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  99544. */
  99545. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  99546. /**
  99547. * Initialize the block and prepare the context for build
  99548. * @param state defines the state that will be used for the build
  99549. */
  99550. initialize(state: NodeMaterialBuildState): void;
  99551. /**
  99552. * Bind data to effect. Will only be called for blocks with isBindable === true
  99553. * @param effect defines the effect to bind data to
  99554. * @param nodeMaterial defines the hosting NodeMaterial
  99555. * @param mesh defines the mesh that will be rendered
  99556. * @param subMesh defines the submesh that will be rendered
  99557. */
  99558. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99559. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  99560. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  99561. protected _writeFloat(value: number): string;
  99562. /**
  99563. * Gets the current class name e.g. "NodeMaterialBlock"
  99564. * @returns the class name
  99565. */
  99566. getClassName(): string;
  99567. /**
  99568. * Register a new input. Must be called inside a block constructor
  99569. * @param name defines the connection point name
  99570. * @param type defines the connection point type
  99571. * @param isOptional defines a boolean indicating that this input can be omitted
  99572. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99573. * @param point an already created connection point. If not provided, create a new one
  99574. * @returns the current block
  99575. */
  99576. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99577. /**
  99578. * Register a new output. Must be called inside a block constructor
  99579. * @param name defines the connection point name
  99580. * @param type defines the connection point type
  99581. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99582. * @param point an already created connection point. If not provided, create a new one
  99583. * @returns the current block
  99584. */
  99585. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99586. /**
  99587. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  99588. * @param forOutput defines an optional connection point to check compatibility with
  99589. * @returns the first available input or null
  99590. */
  99591. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  99592. /**
  99593. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  99594. * @param forBlock defines an optional block to check compatibility with
  99595. * @returns the first available input or null
  99596. */
  99597. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  99598. /**
  99599. * Gets the sibling of the given output
  99600. * @param current defines the current output
  99601. * @returns the next output in the list or null
  99602. */
  99603. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  99604. /**
  99605. * Connect current block with another block
  99606. * @param other defines the block to connect with
  99607. * @param options define the various options to help pick the right connections
  99608. * @returns the current block
  99609. */
  99610. connectTo(other: NodeMaterialBlock, options?: {
  99611. input?: string;
  99612. output?: string;
  99613. outputSwizzle?: string;
  99614. }): this | undefined;
  99615. protected _buildBlock(state: NodeMaterialBuildState): void;
  99616. /**
  99617. * Add uniforms, samplers and uniform buffers at compilation time
  99618. * @param state defines the state to update
  99619. * @param nodeMaterial defines the node material requesting the update
  99620. * @param defines defines the material defines to update
  99621. * @param uniformBuffers defines the list of uniform buffer names
  99622. */
  99623. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  99624. /**
  99625. * Add potential fallbacks if shader compilation fails
  99626. * @param mesh defines the mesh to be rendered
  99627. * @param fallbacks defines the current prioritized list of fallbacks
  99628. */
  99629. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  99630. /**
  99631. * Initialize defines for shader compilation
  99632. * @param mesh defines the mesh to be rendered
  99633. * @param nodeMaterial defines the node material requesting the update
  99634. * @param defines defines the material defines to update
  99635. * @param useInstances specifies that instances should be used
  99636. */
  99637. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99638. /**
  99639. * Update defines for shader compilation
  99640. * @param mesh defines the mesh to be rendered
  99641. * @param nodeMaterial defines the node material requesting the update
  99642. * @param defines defines the material defines to update
  99643. * @param useInstances specifies that instances should be used
  99644. * @param subMesh defines which submesh to render
  99645. */
  99646. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99647. /**
  99648. * Lets the block try to connect some inputs automatically
  99649. * @param material defines the hosting NodeMaterial
  99650. */
  99651. autoConfigure(material: NodeMaterial): void;
  99652. /**
  99653. * Function called when a block is declared as repeatable content generator
  99654. * @param vertexShaderState defines the current compilation state for the vertex shader
  99655. * @param fragmentShaderState defines the current compilation state for the fragment shader
  99656. * @param mesh defines the mesh to be rendered
  99657. * @param defines defines the material defines to update
  99658. */
  99659. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  99660. /**
  99661. * Checks if the block is ready
  99662. * @param mesh defines the mesh to be rendered
  99663. * @param nodeMaterial defines the node material requesting the update
  99664. * @param defines defines the material defines to update
  99665. * @param useInstances specifies that instances should be used
  99666. * @returns true if the block is ready
  99667. */
  99668. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  99669. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  99670. private _processBuild;
  99671. /**
  99672. * Compile the current node and generate the shader code
  99673. * @param state defines the current compilation state (uniforms, samplers, current string)
  99674. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  99675. * @returns true if already built
  99676. */
  99677. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  99678. protected _inputRename(name: string): string;
  99679. protected _outputRename(name: string): string;
  99680. protected _dumpPropertiesCode(): string;
  99681. /** @hidden */
  99682. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  99683. /** @hidden */
  99684. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  99685. /**
  99686. * Clone the current block to a new identical block
  99687. * @param scene defines the hosting scene
  99688. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99689. * @returns a copy of the current block
  99690. */
  99691. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  99692. /**
  99693. * Serializes this block in a JSON representation
  99694. * @returns the serialized block object
  99695. */
  99696. serialize(): any;
  99697. /** @hidden */
  99698. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99699. private _deserializePortDisplayNamesAndExposedOnFrame;
  99700. /**
  99701. * Release resources
  99702. */
  99703. dispose(): void;
  99704. }
  99705. }
  99706. declare module BABYLON {
  99707. /**
  99708. * Base class of materials working in push mode in babylon JS
  99709. * @hidden
  99710. */
  99711. export class PushMaterial extends Material {
  99712. protected _activeEffect: Effect;
  99713. protected _normalMatrix: Matrix;
  99714. constructor(name: string, scene: Scene);
  99715. getEffect(): Effect;
  99716. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99717. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  99718. /**
  99719. * Binds the given world matrix to the active effect
  99720. *
  99721. * @param world the matrix to bind
  99722. */
  99723. bindOnlyWorldMatrix(world: Matrix): void;
  99724. /**
  99725. * Binds the given normal matrix to the active effect
  99726. *
  99727. * @param normalMatrix the matrix to bind
  99728. */
  99729. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99730. bind(world: Matrix, mesh?: Mesh): void;
  99731. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99732. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99733. }
  99734. }
  99735. declare module BABYLON {
  99736. /**
  99737. * Root class for all node material optimizers
  99738. */
  99739. export class NodeMaterialOptimizer {
  99740. /**
  99741. * Function used to optimize a NodeMaterial graph
  99742. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  99743. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  99744. */
  99745. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  99746. }
  99747. }
  99748. declare module BABYLON {
  99749. /**
  99750. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  99751. */
  99752. export class TransformBlock extends NodeMaterialBlock {
  99753. /**
  99754. * Defines the value to use to complement W value to transform it to a Vector4
  99755. */
  99756. complementW: number;
  99757. /**
  99758. * Defines the value to use to complement z value to transform it to a Vector4
  99759. */
  99760. complementZ: number;
  99761. /**
  99762. * Creates a new TransformBlock
  99763. * @param name defines the block name
  99764. */
  99765. constructor(name: string);
  99766. /**
  99767. * Gets the current class name
  99768. * @returns the class name
  99769. */
  99770. getClassName(): string;
  99771. /**
  99772. * Gets the vector input
  99773. */
  99774. get vector(): NodeMaterialConnectionPoint;
  99775. /**
  99776. * Gets the output component
  99777. */
  99778. get output(): NodeMaterialConnectionPoint;
  99779. /**
  99780. * Gets the xyz output component
  99781. */
  99782. get xyz(): NodeMaterialConnectionPoint;
  99783. /**
  99784. * Gets the matrix transform input
  99785. */
  99786. get transform(): NodeMaterialConnectionPoint;
  99787. protected _buildBlock(state: NodeMaterialBuildState): this;
  99788. /**
  99789. * Update defines for shader compilation
  99790. * @param mesh defines the mesh to be rendered
  99791. * @param nodeMaterial defines the node material requesting the update
  99792. * @param defines defines the material defines to update
  99793. * @param useInstances specifies that instances should be used
  99794. * @param subMesh defines which submesh to render
  99795. */
  99796. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99797. serialize(): any;
  99798. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99799. protected _dumpPropertiesCode(): string;
  99800. }
  99801. }
  99802. declare module BABYLON {
  99803. /**
  99804. * Block used to output the vertex position
  99805. */
  99806. export class VertexOutputBlock extends NodeMaterialBlock {
  99807. /**
  99808. * Creates a new VertexOutputBlock
  99809. * @param name defines the block name
  99810. */
  99811. constructor(name: string);
  99812. /**
  99813. * Gets the current class name
  99814. * @returns the class name
  99815. */
  99816. getClassName(): string;
  99817. /**
  99818. * Gets the vector input component
  99819. */
  99820. get vector(): NodeMaterialConnectionPoint;
  99821. protected _buildBlock(state: NodeMaterialBuildState): this;
  99822. }
  99823. }
  99824. declare module BABYLON {
  99825. /**
  99826. * Block used to output the final color
  99827. */
  99828. export class FragmentOutputBlock extends NodeMaterialBlock {
  99829. /**
  99830. * Create a new FragmentOutputBlock
  99831. * @param name defines the block name
  99832. */
  99833. constructor(name: string);
  99834. /**
  99835. * Gets the current class name
  99836. * @returns the class name
  99837. */
  99838. getClassName(): string;
  99839. /**
  99840. * Gets the rgba input component
  99841. */
  99842. get rgba(): NodeMaterialConnectionPoint;
  99843. /**
  99844. * Gets the rgb input component
  99845. */
  99846. get rgb(): NodeMaterialConnectionPoint;
  99847. /**
  99848. * Gets the a input component
  99849. */
  99850. get a(): NodeMaterialConnectionPoint;
  99851. protected _buildBlock(state: NodeMaterialBuildState): this;
  99852. }
  99853. }
  99854. declare module BABYLON {
  99855. /**
  99856. * Block used for the particle ramp gradient section
  99857. */
  99858. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  99859. /**
  99860. * Create a new ParticleRampGradientBlock
  99861. * @param name defines the block name
  99862. */
  99863. constructor(name: string);
  99864. /**
  99865. * Gets the current class name
  99866. * @returns the class name
  99867. */
  99868. getClassName(): string;
  99869. /**
  99870. * Gets the color input component
  99871. */
  99872. get color(): NodeMaterialConnectionPoint;
  99873. /**
  99874. * Gets the rampColor output component
  99875. */
  99876. get rampColor(): NodeMaterialConnectionPoint;
  99877. /**
  99878. * Initialize the block and prepare the context for build
  99879. * @param state defines the state that will be used for the build
  99880. */
  99881. initialize(state: NodeMaterialBuildState): void;
  99882. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99883. }
  99884. }
  99885. declare module BABYLON {
  99886. /**
  99887. * Block used for the particle blend multiply section
  99888. */
  99889. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  99890. /**
  99891. * Create a new ParticleBlendMultiplyBlock
  99892. * @param name defines the block name
  99893. */
  99894. constructor(name: string);
  99895. /**
  99896. * Gets the current class name
  99897. * @returns the class name
  99898. */
  99899. getClassName(): string;
  99900. /**
  99901. * Gets the color input component
  99902. */
  99903. get color(): NodeMaterialConnectionPoint;
  99904. /**
  99905. * Gets the alphaTexture input component
  99906. */
  99907. get alphaTexture(): NodeMaterialConnectionPoint;
  99908. /**
  99909. * Gets the alphaColor input component
  99910. */
  99911. get alphaColor(): NodeMaterialConnectionPoint;
  99912. /**
  99913. * Gets the blendColor output component
  99914. */
  99915. get blendColor(): NodeMaterialConnectionPoint;
  99916. /**
  99917. * Initialize the block and prepare the context for build
  99918. * @param state defines the state that will be used for the build
  99919. */
  99920. initialize(state: NodeMaterialBuildState): void;
  99921. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99922. }
  99923. }
  99924. declare module BABYLON {
  99925. /**
  99926. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  99927. */
  99928. export class VectorMergerBlock extends NodeMaterialBlock {
  99929. /**
  99930. * Create a new VectorMergerBlock
  99931. * @param name defines the block name
  99932. */
  99933. constructor(name: string);
  99934. /**
  99935. * Gets the current class name
  99936. * @returns the class name
  99937. */
  99938. getClassName(): string;
  99939. /**
  99940. * Gets the xyz component (input)
  99941. */
  99942. get xyzIn(): NodeMaterialConnectionPoint;
  99943. /**
  99944. * Gets the xy component (input)
  99945. */
  99946. get xyIn(): NodeMaterialConnectionPoint;
  99947. /**
  99948. * Gets the x component (input)
  99949. */
  99950. get x(): NodeMaterialConnectionPoint;
  99951. /**
  99952. * Gets the y component (input)
  99953. */
  99954. get y(): NodeMaterialConnectionPoint;
  99955. /**
  99956. * Gets the z component (input)
  99957. */
  99958. get z(): NodeMaterialConnectionPoint;
  99959. /**
  99960. * Gets the w component (input)
  99961. */
  99962. get w(): NodeMaterialConnectionPoint;
  99963. /**
  99964. * Gets the xyzw component (output)
  99965. */
  99966. get xyzw(): NodeMaterialConnectionPoint;
  99967. /**
  99968. * Gets the xyz component (output)
  99969. */
  99970. get xyzOut(): NodeMaterialConnectionPoint;
  99971. /**
  99972. * Gets the xy component (output)
  99973. */
  99974. get xyOut(): NodeMaterialConnectionPoint;
  99975. /**
  99976. * Gets the xy component (output)
  99977. * @deprecated Please use xyOut instead.
  99978. */
  99979. get xy(): NodeMaterialConnectionPoint;
  99980. /**
  99981. * Gets the xyz component (output)
  99982. * @deprecated Please use xyzOut instead.
  99983. */
  99984. get xyz(): NodeMaterialConnectionPoint;
  99985. protected _buildBlock(state: NodeMaterialBuildState): this;
  99986. }
  99987. }
  99988. declare module BABYLON {
  99989. /**
  99990. * Block used to remap a float from a range to a new one
  99991. */
  99992. export class RemapBlock extends NodeMaterialBlock {
  99993. /**
  99994. * Gets or sets the source range
  99995. */
  99996. sourceRange: Vector2;
  99997. /**
  99998. * Gets or sets the target range
  99999. */
  100000. targetRange: Vector2;
  100001. /**
  100002. * Creates a new RemapBlock
  100003. * @param name defines the block name
  100004. */
  100005. constructor(name: string);
  100006. /**
  100007. * Gets the current class name
  100008. * @returns the class name
  100009. */
  100010. getClassName(): string;
  100011. /**
  100012. * Gets the input component
  100013. */
  100014. get input(): NodeMaterialConnectionPoint;
  100015. /**
  100016. * Gets the source min input component
  100017. */
  100018. get sourceMin(): NodeMaterialConnectionPoint;
  100019. /**
  100020. * Gets the source max input component
  100021. */
  100022. get sourceMax(): NodeMaterialConnectionPoint;
  100023. /**
  100024. * Gets the target min input component
  100025. */
  100026. get targetMin(): NodeMaterialConnectionPoint;
  100027. /**
  100028. * Gets the target max input component
  100029. */
  100030. get targetMax(): NodeMaterialConnectionPoint;
  100031. /**
  100032. * Gets the output component
  100033. */
  100034. get output(): NodeMaterialConnectionPoint;
  100035. protected _buildBlock(state: NodeMaterialBuildState): this;
  100036. protected _dumpPropertiesCode(): string;
  100037. serialize(): any;
  100038. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100039. }
  100040. }
  100041. declare module BABYLON {
  100042. /**
  100043. * Block used to multiply 2 values
  100044. */
  100045. export class MultiplyBlock extends NodeMaterialBlock {
  100046. /**
  100047. * Creates a new MultiplyBlock
  100048. * @param name defines the block name
  100049. */
  100050. constructor(name: string);
  100051. /**
  100052. * Gets the current class name
  100053. * @returns the class name
  100054. */
  100055. getClassName(): string;
  100056. /**
  100057. * Gets the left operand input component
  100058. */
  100059. get left(): NodeMaterialConnectionPoint;
  100060. /**
  100061. * Gets the right operand input component
  100062. */
  100063. get right(): NodeMaterialConnectionPoint;
  100064. /**
  100065. * Gets the output component
  100066. */
  100067. get output(): NodeMaterialConnectionPoint;
  100068. protected _buildBlock(state: NodeMaterialBuildState): this;
  100069. }
  100070. }
  100071. declare module BABYLON {
  100072. /**
  100073. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  100074. */
  100075. export class ColorSplitterBlock extends NodeMaterialBlock {
  100076. /**
  100077. * Create a new ColorSplitterBlock
  100078. * @param name defines the block name
  100079. */
  100080. constructor(name: string);
  100081. /**
  100082. * Gets the current class name
  100083. * @returns the class name
  100084. */
  100085. getClassName(): string;
  100086. /**
  100087. * Gets the rgba component (input)
  100088. */
  100089. get rgba(): NodeMaterialConnectionPoint;
  100090. /**
  100091. * Gets the rgb component (input)
  100092. */
  100093. get rgbIn(): NodeMaterialConnectionPoint;
  100094. /**
  100095. * Gets the rgb component (output)
  100096. */
  100097. get rgbOut(): NodeMaterialConnectionPoint;
  100098. /**
  100099. * Gets the r component (output)
  100100. */
  100101. get r(): NodeMaterialConnectionPoint;
  100102. /**
  100103. * Gets the g component (output)
  100104. */
  100105. get g(): NodeMaterialConnectionPoint;
  100106. /**
  100107. * Gets the b component (output)
  100108. */
  100109. get b(): NodeMaterialConnectionPoint;
  100110. /**
  100111. * Gets the a component (output)
  100112. */
  100113. get a(): NodeMaterialConnectionPoint;
  100114. protected _inputRename(name: string): string;
  100115. protected _outputRename(name: string): string;
  100116. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100117. }
  100118. }
  100119. declare module BABYLON {
  100120. /**
  100121. * Interface used to configure the node material editor
  100122. */
  100123. export interface INodeMaterialEditorOptions {
  100124. /** Define the URl to load node editor script */
  100125. editorURL?: string;
  100126. }
  100127. /** @hidden */
  100128. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100129. NORMAL: boolean;
  100130. TANGENT: boolean;
  100131. UV1: boolean;
  100132. /** BONES */
  100133. NUM_BONE_INFLUENCERS: number;
  100134. BonesPerMesh: number;
  100135. BONETEXTURE: boolean;
  100136. /** MORPH TARGETS */
  100137. MORPHTARGETS: boolean;
  100138. MORPHTARGETS_NORMAL: boolean;
  100139. MORPHTARGETS_TANGENT: boolean;
  100140. MORPHTARGETS_UV: boolean;
  100141. NUM_MORPH_INFLUENCERS: number;
  100142. /** IMAGE PROCESSING */
  100143. IMAGEPROCESSING: boolean;
  100144. VIGNETTE: boolean;
  100145. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100146. VIGNETTEBLENDMODEOPAQUE: boolean;
  100147. TONEMAPPING: boolean;
  100148. TONEMAPPING_ACES: boolean;
  100149. CONTRAST: boolean;
  100150. EXPOSURE: boolean;
  100151. COLORCURVES: boolean;
  100152. COLORGRADING: boolean;
  100153. COLORGRADING3D: boolean;
  100154. SAMPLER3DGREENDEPTH: boolean;
  100155. SAMPLER3DBGRMAP: boolean;
  100156. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100157. /** MISC. */
  100158. BUMPDIRECTUV: number;
  100159. constructor();
  100160. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  100161. }
  100162. /**
  100163. * Class used to configure NodeMaterial
  100164. */
  100165. export interface INodeMaterialOptions {
  100166. /**
  100167. * Defines if blocks should emit comments
  100168. */
  100169. emitComments: boolean;
  100170. }
  100171. /**
  100172. * Class used to create a node based material built by assembling shader blocks
  100173. */
  100174. export class NodeMaterial extends PushMaterial {
  100175. private static _BuildIdGenerator;
  100176. private _options;
  100177. private _vertexCompilationState;
  100178. private _fragmentCompilationState;
  100179. private _sharedData;
  100180. private _buildId;
  100181. private _buildWasSuccessful;
  100182. private _cachedWorldViewMatrix;
  100183. private _cachedWorldViewProjectionMatrix;
  100184. private _optimizers;
  100185. private _animationFrame;
  100186. /** Define the Url to load node editor script */
  100187. static EditorURL: string;
  100188. /** Define the Url to load snippets */
  100189. static SnippetUrl: string;
  100190. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  100191. static IgnoreTexturesAtLoadTime: boolean;
  100192. private BJSNODEMATERIALEDITOR;
  100193. /** Get the inspector from bundle or global */
  100194. private _getGlobalNodeMaterialEditor;
  100195. /**
  100196. * Snippet ID if the material was created from the snippet server
  100197. */
  100198. snippetId: string;
  100199. /**
  100200. * Gets or sets data used by visual editor
  100201. * @see https://nme.babylonjs.com
  100202. */
  100203. editorData: any;
  100204. /**
  100205. * 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)
  100206. */
  100207. ignoreAlpha: boolean;
  100208. /**
  100209. * Defines the maximum number of lights that can be used in the material
  100210. */
  100211. maxSimultaneousLights: number;
  100212. /**
  100213. * Observable raised when the material is built
  100214. */
  100215. onBuildObservable: Observable<NodeMaterial>;
  100216. /**
  100217. * Gets or sets the root nodes of the material vertex shader
  100218. */
  100219. _vertexOutputNodes: NodeMaterialBlock[];
  100220. /**
  100221. * Gets or sets the root nodes of the material fragment (pixel) shader
  100222. */
  100223. _fragmentOutputNodes: NodeMaterialBlock[];
  100224. /** Gets or sets options to control the node material overall behavior */
  100225. get options(): INodeMaterialOptions;
  100226. set options(options: INodeMaterialOptions);
  100227. /**
  100228. * Default configuration related to image processing available in the standard Material.
  100229. */
  100230. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100231. /**
  100232. * Gets the image processing configuration used either in this material.
  100233. */
  100234. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100235. /**
  100236. * Sets the Default image processing configuration used either in the this material.
  100237. *
  100238. * If sets to null, the scene one is in use.
  100239. */
  100240. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100241. /**
  100242. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  100243. */
  100244. attachedBlocks: NodeMaterialBlock[];
  100245. /**
  100246. * Specifies the mode of the node material
  100247. * @hidden
  100248. */
  100249. _mode: NodeMaterialModes;
  100250. /**
  100251. * Gets the mode property
  100252. */
  100253. get mode(): NodeMaterialModes;
  100254. /**
  100255. * Create a new node based material
  100256. * @param name defines the material name
  100257. * @param scene defines the hosting scene
  100258. * @param options defines creation option
  100259. */
  100260. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  100261. /**
  100262. * Gets the current class name of the material e.g. "NodeMaterial"
  100263. * @returns the class name
  100264. */
  100265. getClassName(): string;
  100266. /**
  100267. * Keep track of the image processing observer to allow dispose and replace.
  100268. */
  100269. private _imageProcessingObserver;
  100270. /**
  100271. * Attaches a new image processing configuration to the Standard Material.
  100272. * @param configuration
  100273. */
  100274. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100275. /**
  100276. * Get a block by its name
  100277. * @param name defines the name of the block to retrieve
  100278. * @returns the required block or null if not found
  100279. */
  100280. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  100281. /**
  100282. * Get a block by its name
  100283. * @param predicate defines the predicate used to find the good candidate
  100284. * @returns the required block or null if not found
  100285. */
  100286. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  100287. /**
  100288. * Get an input block by its name
  100289. * @param predicate defines the predicate used to find the good candidate
  100290. * @returns the required input block or null if not found
  100291. */
  100292. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  100293. /**
  100294. * Gets the list of input blocks attached to this material
  100295. * @returns an array of InputBlocks
  100296. */
  100297. getInputBlocks(): InputBlock[];
  100298. /**
  100299. * Adds a new optimizer to the list of optimizers
  100300. * @param optimizer defines the optimizers to add
  100301. * @returns the current material
  100302. */
  100303. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100304. /**
  100305. * Remove an optimizer from the list of optimizers
  100306. * @param optimizer defines the optimizers to remove
  100307. * @returns the current material
  100308. */
  100309. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100310. /**
  100311. * Add a new block to the list of output nodes
  100312. * @param node defines the node to add
  100313. * @returns the current material
  100314. */
  100315. addOutputNode(node: NodeMaterialBlock): this;
  100316. /**
  100317. * Remove a block from the list of root nodes
  100318. * @param node defines the node to remove
  100319. * @returns the current material
  100320. */
  100321. removeOutputNode(node: NodeMaterialBlock): this;
  100322. private _addVertexOutputNode;
  100323. private _removeVertexOutputNode;
  100324. private _addFragmentOutputNode;
  100325. private _removeFragmentOutputNode;
  100326. /**
  100327. * Specifies if the material will require alpha blending
  100328. * @returns a boolean specifying if alpha blending is needed
  100329. */
  100330. needAlphaBlending(): boolean;
  100331. /**
  100332. * Specifies if this material should be rendered in alpha test mode
  100333. * @returns a boolean specifying if an alpha test is needed.
  100334. */
  100335. needAlphaTesting(): boolean;
  100336. private _initializeBlock;
  100337. private _resetDualBlocks;
  100338. /**
  100339. * Remove a block from the current node material
  100340. * @param block defines the block to remove
  100341. */
  100342. removeBlock(block: NodeMaterialBlock): void;
  100343. /**
  100344. * Build the material and generates the inner effect
  100345. * @param verbose defines if the build should log activity
  100346. */
  100347. build(verbose?: boolean): void;
  100348. /**
  100349. * Runs an otpimization phase to try to improve the shader code
  100350. */
  100351. optimize(): void;
  100352. private _prepareDefinesForAttributes;
  100353. /**
  100354. * Create a post process from the material
  100355. * @param camera The camera to apply the render pass to.
  100356. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100358. * @param engine The engine which the post process will be applied. (default: current engine)
  100359. * @param reusable If the post process can be reused on the same frame. (default: false)
  100360. * @param textureType Type of textures used when performing the post process. (default: 0)
  100361. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100362. * @returns the post process created
  100363. */
  100364. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  100365. /**
  100366. * Create the post process effect from the material
  100367. * @param postProcess The post process to create the effect for
  100368. */
  100369. createEffectForPostProcess(postProcess: PostProcess): void;
  100370. private _createEffectOrPostProcess;
  100371. private _createEffectForParticles;
  100372. /**
  100373. * Create the effect to be used as the custom effect for a particle system
  100374. * @param particleSystem Particle system to create the effect for
  100375. * @param onCompiled defines a function to call when the effect creation is successful
  100376. * @param onError defines a function to call when the effect creation has failed
  100377. */
  100378. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100379. private _processDefines;
  100380. /**
  100381. * Get if the submesh is ready to be used and all its information available.
  100382. * Child classes can use it to update shaders
  100383. * @param mesh defines the mesh to check
  100384. * @param subMesh defines which submesh to check
  100385. * @param useInstances specifies that instances should be used
  100386. * @returns a boolean indicating that the submesh is ready or not
  100387. */
  100388. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100389. /**
  100390. * Get a string representing the shaders built by the current node graph
  100391. */
  100392. get compiledShaders(): string;
  100393. /**
  100394. * Binds the world matrix to the material
  100395. * @param world defines the world transformation matrix
  100396. */
  100397. bindOnlyWorldMatrix(world: Matrix): void;
  100398. /**
  100399. * Binds the submesh to this material by preparing the effect and shader to draw
  100400. * @param world defines the world transformation matrix
  100401. * @param mesh defines the mesh containing the submesh
  100402. * @param subMesh defines the submesh to bind the material to
  100403. */
  100404. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100405. /**
  100406. * Gets the active textures from the material
  100407. * @returns an array of textures
  100408. */
  100409. getActiveTextures(): BaseTexture[];
  100410. /**
  100411. * Gets the list of texture blocks
  100412. * @returns an array of texture blocks
  100413. */
  100414. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100415. /**
  100416. * Specifies if the material uses a texture
  100417. * @param texture defines the texture to check against the material
  100418. * @returns a boolean specifying if the material uses the texture
  100419. */
  100420. hasTexture(texture: BaseTexture): boolean;
  100421. /**
  100422. * Disposes the material
  100423. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100424. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100425. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  100426. */
  100427. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  100428. /** Creates the node editor window. */
  100429. private _createNodeEditor;
  100430. /**
  100431. * Launch the node material editor
  100432. * @param config Define the configuration of the editor
  100433. * @return a promise fulfilled when the node editor is visible
  100434. */
  100435. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  100436. /**
  100437. * Clear the current material
  100438. */
  100439. clear(): void;
  100440. /**
  100441. * Clear the current material and set it to a default state
  100442. */
  100443. setToDefault(): void;
  100444. /**
  100445. * Clear the current material and set it to a default state for post process
  100446. */
  100447. setToDefaultPostProcess(): void;
  100448. /**
  100449. * Clear the current material and set it to a default state for particle
  100450. */
  100451. setToDefaultParticle(): void;
  100452. /**
  100453. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  100454. * @param url defines the url to load from
  100455. * @returns a promise that will fullfil when the material is fully loaded
  100456. */
  100457. loadAsync(url: string): Promise<void>;
  100458. private _gatherBlocks;
  100459. /**
  100460. * Generate a string containing the code declaration required to create an equivalent of this material
  100461. * @returns a string
  100462. */
  100463. generateCode(): string;
  100464. /**
  100465. * Serializes this material in a JSON representation
  100466. * @returns the serialized material object
  100467. */
  100468. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  100469. private _restoreConnections;
  100470. /**
  100471. * Clear the current graph and load a new one from a serialization object
  100472. * @param source defines the JSON representation of the material
  100473. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100474. * @param merge defines whether or not the source must be merged or replace the current content
  100475. */
  100476. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  100477. /**
  100478. * Makes a duplicate of the current material.
  100479. * @param name - name to use for the new material.
  100480. */
  100481. clone(name: string): NodeMaterial;
  100482. /**
  100483. * Creates a node material from parsed material data
  100484. * @param source defines the JSON representation of the material
  100485. * @param scene defines the hosting scene
  100486. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100487. * @returns a new node material
  100488. */
  100489. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  100490. /**
  100491. * Creates a node material from a snippet saved in a remote file
  100492. * @param name defines the name of the material to create
  100493. * @param url defines the url to load from
  100494. * @param scene defines the hosting scene
  100495. * @returns a promise that will resolve to the new node material
  100496. */
  100497. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  100498. /**
  100499. * Creates a node material from a snippet saved by the node material editor
  100500. * @param snippetId defines the snippet to load
  100501. * @param scene defines the hosting scene
  100502. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100503. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  100504. * @returns a promise that will resolve to the new node material
  100505. */
  100506. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  100507. /**
  100508. * Creates a new node material set to default basic configuration
  100509. * @param name defines the name of the material
  100510. * @param scene defines the hosting scene
  100511. * @returns a new NodeMaterial
  100512. */
  100513. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  100514. }
  100515. }
  100516. declare module BABYLON {
  100517. /**
  100518. * Size options for a post process
  100519. */
  100520. export type PostProcessOptions = {
  100521. width: number;
  100522. height: number;
  100523. };
  100524. /**
  100525. * PostProcess can be used to apply a shader to a texture after it has been rendered
  100526. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100527. */
  100528. export class PostProcess {
  100529. /** Name of the PostProcess. */
  100530. name: string;
  100531. /**
  100532. * Gets or sets the unique id of the post process
  100533. */
  100534. uniqueId: number;
  100535. /**
  100536. * Width of the texture to apply the post process on
  100537. */
  100538. width: number;
  100539. /**
  100540. * Height of the texture to apply the post process on
  100541. */
  100542. height: number;
  100543. /**
  100544. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  100545. */
  100546. nodeMaterialSource: Nullable<NodeMaterial>;
  100547. /**
  100548. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  100549. * @hidden
  100550. */
  100551. _outputTexture: Nullable<InternalTexture>;
  100552. /**
  100553. * Sampling mode used by the shader
  100554. * See https://doc.babylonjs.com/classes/3.1/texture
  100555. */
  100556. renderTargetSamplingMode: number;
  100557. /**
  100558. * Clear color to use when screen clearing
  100559. */
  100560. clearColor: Color4;
  100561. /**
  100562. * If the buffer needs to be cleared before applying the post process. (default: true)
  100563. * Should be set to false if shader will overwrite all previous pixels.
  100564. */
  100565. autoClear: boolean;
  100566. /**
  100567. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  100568. */
  100569. alphaMode: number;
  100570. /**
  100571. * Sets the setAlphaBlendConstants of the babylon engine
  100572. */
  100573. alphaConstants: Color4;
  100574. /**
  100575. * Animations to be used for the post processing
  100576. */
  100577. animations: Animation[];
  100578. /**
  100579. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  100580. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  100581. */
  100582. enablePixelPerfectMode: boolean;
  100583. /**
  100584. * Force the postprocess to be applied without taking in account viewport
  100585. */
  100586. forceFullscreenViewport: boolean;
  100587. /**
  100588. * List of inspectable custom properties (used by the Inspector)
  100589. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100590. */
  100591. inspectableCustomProperties: IInspectable[];
  100592. /**
  100593. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  100594. *
  100595. * | Value | Type | Description |
  100596. * | ----- | ----------------------------------- | ----------- |
  100597. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  100598. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  100599. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  100600. *
  100601. */
  100602. scaleMode: number;
  100603. /**
  100604. * Force textures to be a power of two (default: false)
  100605. */
  100606. alwaysForcePOT: boolean;
  100607. private _samples;
  100608. /**
  100609. * Number of sample textures (default: 1)
  100610. */
  100611. get samples(): number;
  100612. set samples(n: number);
  100613. /**
  100614. * Modify the scale of the post process to be the same as the viewport (default: false)
  100615. */
  100616. adaptScaleToCurrentViewport: boolean;
  100617. private _camera;
  100618. protected _scene: Scene;
  100619. private _engine;
  100620. private _options;
  100621. private _reusable;
  100622. private _textureType;
  100623. private _textureFormat;
  100624. /**
  100625. * Smart array of input and output textures for the post process.
  100626. * @hidden
  100627. */
  100628. _textures: SmartArray<InternalTexture>;
  100629. /**
  100630. * The index in _textures that corresponds to the output texture.
  100631. * @hidden
  100632. */
  100633. _currentRenderTextureInd: number;
  100634. private _effect;
  100635. private _samplers;
  100636. private _fragmentUrl;
  100637. private _vertexUrl;
  100638. private _parameters;
  100639. private _scaleRatio;
  100640. protected _indexParameters: any;
  100641. private _shareOutputWithPostProcess;
  100642. private _texelSize;
  100643. private _forcedOutputTexture;
  100644. /**
  100645. * Returns the fragment url or shader name used in the post process.
  100646. * @returns the fragment url or name in the shader store.
  100647. */
  100648. getEffectName(): string;
  100649. /**
  100650. * An event triggered when the postprocess is activated.
  100651. */
  100652. onActivateObservable: Observable<Camera>;
  100653. private _onActivateObserver;
  100654. /**
  100655. * A function that is added to the onActivateObservable
  100656. */
  100657. set onActivate(callback: Nullable<(camera: Camera) => void>);
  100658. /**
  100659. * An event triggered when the postprocess changes its size.
  100660. */
  100661. onSizeChangedObservable: Observable<PostProcess>;
  100662. private _onSizeChangedObserver;
  100663. /**
  100664. * A function that is added to the onSizeChangedObservable
  100665. */
  100666. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  100667. /**
  100668. * An event triggered when the postprocess applies its effect.
  100669. */
  100670. onApplyObservable: Observable<Effect>;
  100671. private _onApplyObserver;
  100672. /**
  100673. * A function that is added to the onApplyObservable
  100674. */
  100675. set onApply(callback: (effect: Effect) => void);
  100676. /**
  100677. * An event triggered before rendering the postprocess
  100678. */
  100679. onBeforeRenderObservable: Observable<Effect>;
  100680. private _onBeforeRenderObserver;
  100681. /**
  100682. * A function that is added to the onBeforeRenderObservable
  100683. */
  100684. set onBeforeRender(callback: (effect: Effect) => void);
  100685. /**
  100686. * An event triggered after rendering the postprocess
  100687. */
  100688. onAfterRenderObservable: Observable<Effect>;
  100689. private _onAfterRenderObserver;
  100690. /**
  100691. * A function that is added to the onAfterRenderObservable
  100692. */
  100693. set onAfterRender(callback: (efect: Effect) => void);
  100694. /**
  100695. * 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
  100696. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  100697. */
  100698. get inputTexture(): InternalTexture;
  100699. set inputTexture(value: InternalTexture);
  100700. /**
  100701. * Gets the camera which post process is applied to.
  100702. * @returns The camera the post process is applied to.
  100703. */
  100704. getCamera(): Camera;
  100705. /**
  100706. * Gets the texel size of the postprocess.
  100707. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  100708. */
  100709. get texelSize(): Vector2;
  100710. /**
  100711. * Creates a new instance PostProcess
  100712. * @param name The name of the PostProcess.
  100713. * @param fragmentUrl The url of the fragment shader to be used.
  100714. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  100715. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  100716. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100717. * @param camera The camera to apply the render pass to.
  100718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100719. * @param engine The engine which the post process will be applied. (default: current engine)
  100720. * @param reusable If the post process can be reused on the same frame. (default: false)
  100721. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  100722. * @param textureType Type of textures used when performing the post process. (default: 0)
  100723. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  100724. * @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
  100725. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  100726. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100727. */
  100728. constructor(
  100729. /** Name of the PostProcess. */
  100730. 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);
  100731. /**
  100732. * Gets a string idenfifying the name of the class
  100733. * @returns "PostProcess" string
  100734. */
  100735. getClassName(): string;
  100736. /**
  100737. * Gets the engine which this post process belongs to.
  100738. * @returns The engine the post process was enabled with.
  100739. */
  100740. getEngine(): Engine;
  100741. /**
  100742. * The effect that is created when initializing the post process.
  100743. * @returns The created effect corresponding the the postprocess.
  100744. */
  100745. getEffect(): Effect;
  100746. /**
  100747. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  100748. * @param postProcess The post process to share the output with.
  100749. * @returns This post process.
  100750. */
  100751. shareOutputWith(postProcess: PostProcess): PostProcess;
  100752. /**
  100753. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  100754. * This should be called if the post process that shares output with this post process is disabled/disposed.
  100755. */
  100756. useOwnOutput(): void;
  100757. /**
  100758. * Updates the effect with the current post process compile time values and recompiles the shader.
  100759. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100760. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100761. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100762. * @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
  100763. * @param onCompiled Called when the shader has been compiled.
  100764. * @param onError Called if there is an error when compiling a shader.
  100765. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  100766. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  100767. */
  100768. 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;
  100769. /**
  100770. * The post process is reusable if it can be used multiple times within one frame.
  100771. * @returns If the post process is reusable
  100772. */
  100773. isReusable(): boolean;
  100774. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  100775. markTextureDirty(): void;
  100776. /**
  100777. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  100778. * 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.
  100779. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  100780. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  100781. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  100782. * @returns The target texture that was bound to be written to.
  100783. */
  100784. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  100785. /**
  100786. * If the post process is supported.
  100787. */
  100788. get isSupported(): boolean;
  100789. /**
  100790. * The aspect ratio of the output texture.
  100791. */
  100792. get aspectRatio(): number;
  100793. /**
  100794. * Get a value indicating if the post-process is ready to be used
  100795. * @returns true if the post-process is ready (shader is compiled)
  100796. */
  100797. isReady(): boolean;
  100798. /**
  100799. * Binds all textures and uniforms to the shader, this will be run on every pass.
  100800. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  100801. */
  100802. apply(): Nullable<Effect>;
  100803. private _disposeTextures;
  100804. /**
  100805. * Disposes the post process.
  100806. * @param camera The camera to dispose the post process on.
  100807. */
  100808. dispose(camera?: Camera): void;
  100809. }
  100810. }
  100811. declare module BABYLON {
  100812. /** @hidden */
  100813. export var kernelBlurVaryingDeclaration: {
  100814. name: string;
  100815. shader: string;
  100816. };
  100817. }
  100818. declare module BABYLON {
  100819. /** @hidden */
  100820. export var kernelBlurFragment: {
  100821. name: string;
  100822. shader: string;
  100823. };
  100824. }
  100825. declare module BABYLON {
  100826. /** @hidden */
  100827. export var kernelBlurFragment2: {
  100828. name: string;
  100829. shader: string;
  100830. };
  100831. }
  100832. declare module BABYLON {
  100833. /** @hidden */
  100834. export var kernelBlurPixelShader: {
  100835. name: string;
  100836. shader: string;
  100837. };
  100838. }
  100839. declare module BABYLON {
  100840. /** @hidden */
  100841. export var kernelBlurVertex: {
  100842. name: string;
  100843. shader: string;
  100844. };
  100845. }
  100846. declare module BABYLON {
  100847. /** @hidden */
  100848. export var kernelBlurVertexShader: {
  100849. name: string;
  100850. shader: string;
  100851. };
  100852. }
  100853. declare module BABYLON {
  100854. /**
  100855. * The Blur Post Process which blurs an image based on a kernel and direction.
  100856. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  100857. */
  100858. export class BlurPostProcess extends PostProcess {
  100859. /** The direction in which to blur the image. */
  100860. direction: Vector2;
  100861. private blockCompilation;
  100862. protected _kernel: number;
  100863. protected _idealKernel: number;
  100864. protected _packedFloat: boolean;
  100865. private _staticDefines;
  100866. /**
  100867. * Sets the length in pixels of the blur sample region
  100868. */
  100869. set kernel(v: number);
  100870. /**
  100871. * Gets the length in pixels of the blur sample region
  100872. */
  100873. get kernel(): number;
  100874. /**
  100875. * Sets wether or not the blur needs to unpack/repack floats
  100876. */
  100877. set packedFloat(v: boolean);
  100878. /**
  100879. * Gets wether or not the blur is unpacking/repacking floats
  100880. */
  100881. get packedFloat(): boolean;
  100882. /**
  100883. * Creates a new instance BlurPostProcess
  100884. * @param name The name of the effect.
  100885. * @param direction The direction in which to blur the image.
  100886. * @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.
  100887. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100888. * @param camera The camera to apply the render pass to.
  100889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100890. * @param engine The engine which the post process will be applied. (default: current engine)
  100891. * @param reusable If the post process can be reused on the same frame. (default: false)
  100892. * @param textureType Type of textures used when performing the post process. (default: 0)
  100893. * @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)
  100894. */
  100895. constructor(name: string,
  100896. /** The direction in which to blur the image. */
  100897. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  100898. /**
  100899. * Updates the effect with the current post process compile time values and recompiles the shader.
  100900. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100901. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100902. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100903. * @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
  100904. * @param onCompiled Called when the shader has been compiled.
  100905. * @param onError Called if there is an error when compiling a shader.
  100906. */
  100907. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100908. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100909. /**
  100910. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  100911. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  100912. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  100913. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  100914. * The gaps between physical kernels are compensated for in the weighting of the samples
  100915. * @param idealKernel Ideal blur kernel.
  100916. * @return Nearest best kernel.
  100917. */
  100918. protected _nearestBestKernel(idealKernel: number): number;
  100919. /**
  100920. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  100921. * @param x The point on the Gaussian distribution to sample.
  100922. * @return the value of the Gaussian function at x.
  100923. */
  100924. protected _gaussianWeight(x: number): number;
  100925. /**
  100926. * Generates a string that can be used as a floating point number in GLSL.
  100927. * @param x Value to print.
  100928. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  100929. * @return GLSL float string.
  100930. */
  100931. protected _glslFloat(x: number, decimalFigures?: number): string;
  100932. }
  100933. }
  100934. declare module BABYLON {
  100935. /**
  100936. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100937. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100938. * You can then easily use it as a reflectionTexture on a flat surface.
  100939. * In case the surface is not a plane, please consider relying on reflection probes.
  100940. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100941. */
  100942. export class MirrorTexture extends RenderTargetTexture {
  100943. private scene;
  100944. /**
  100945. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  100946. * 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.
  100947. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100948. */
  100949. mirrorPlane: Plane;
  100950. /**
  100951. * Define the blur ratio used to blur the reflection if needed.
  100952. */
  100953. set blurRatio(value: number);
  100954. get blurRatio(): number;
  100955. /**
  100956. * Define the adaptive blur kernel used to blur the reflection if needed.
  100957. * This will autocompute the closest best match for the `blurKernel`
  100958. */
  100959. set adaptiveBlurKernel(value: number);
  100960. /**
  100961. * Define the blur kernel used to blur the reflection if needed.
  100962. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100963. */
  100964. set blurKernel(value: number);
  100965. /**
  100966. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  100967. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100968. */
  100969. set blurKernelX(value: number);
  100970. get blurKernelX(): number;
  100971. /**
  100972. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  100973. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100974. */
  100975. set blurKernelY(value: number);
  100976. get blurKernelY(): number;
  100977. private _autoComputeBlurKernel;
  100978. protected _onRatioRescale(): void;
  100979. private _updateGammaSpace;
  100980. private _imageProcessingConfigChangeObserver;
  100981. private _transformMatrix;
  100982. private _mirrorMatrix;
  100983. private _savedViewMatrix;
  100984. private _blurX;
  100985. private _blurY;
  100986. private _adaptiveBlurKernel;
  100987. private _blurKernelX;
  100988. private _blurKernelY;
  100989. private _blurRatio;
  100990. /**
  100991. * Instantiates a Mirror Texture.
  100992. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100993. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100994. * You can then easily use it as a reflectionTexture on a flat surface.
  100995. * In case the surface is not a plane, please consider relying on reflection probes.
  100996. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100997. * @param name
  100998. * @param size
  100999. * @param scene
  101000. * @param generateMipMaps
  101001. * @param type
  101002. * @param samplingMode
  101003. * @param generateDepthBuffer
  101004. */
  101005. constructor(name: string, size: number | {
  101006. width: number;
  101007. height: number;
  101008. } | {
  101009. ratio: number;
  101010. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  101011. private _preparePostProcesses;
  101012. /**
  101013. * Clone the mirror texture.
  101014. * @returns the cloned texture
  101015. */
  101016. clone(): MirrorTexture;
  101017. /**
  101018. * Serialize the texture to a JSON representation you could use in Parse later on
  101019. * @returns the serialized JSON representation
  101020. */
  101021. serialize(): any;
  101022. /**
  101023. * Dispose the texture and release its associated resources.
  101024. */
  101025. dispose(): void;
  101026. }
  101027. }
  101028. declare module BABYLON {
  101029. /**
  101030. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101031. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101032. */
  101033. export class Texture extends BaseTexture {
  101034. /**
  101035. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  101036. */
  101037. static SerializeBuffers: boolean;
  101038. /** @hidden */
  101039. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  101040. /** @hidden */
  101041. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  101042. /** @hidden */
  101043. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  101044. /** nearest is mag = nearest and min = nearest and mip = linear */
  101045. static readonly NEAREST_SAMPLINGMODE: number;
  101046. /** nearest is mag = nearest and min = nearest and mip = linear */
  101047. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  101048. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101049. static readonly BILINEAR_SAMPLINGMODE: number;
  101050. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101051. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  101052. /** Trilinear is mag = linear and min = linear and mip = linear */
  101053. static readonly TRILINEAR_SAMPLINGMODE: number;
  101054. /** Trilinear is mag = linear and min = linear and mip = linear */
  101055. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  101056. /** mag = nearest and min = nearest and mip = nearest */
  101057. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  101058. /** mag = nearest and min = linear and mip = nearest */
  101059. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  101060. /** mag = nearest and min = linear and mip = linear */
  101061. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  101062. /** mag = nearest and min = linear and mip = none */
  101063. static readonly NEAREST_LINEAR: number;
  101064. /** mag = nearest and min = nearest and mip = none */
  101065. static readonly NEAREST_NEAREST: number;
  101066. /** mag = linear and min = nearest and mip = nearest */
  101067. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  101068. /** mag = linear and min = nearest and mip = linear */
  101069. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  101070. /** mag = linear and min = linear and mip = none */
  101071. static readonly LINEAR_LINEAR: number;
  101072. /** mag = linear and min = nearest and mip = none */
  101073. static readonly LINEAR_NEAREST: number;
  101074. /** Explicit coordinates mode */
  101075. static readonly EXPLICIT_MODE: number;
  101076. /** Spherical coordinates mode */
  101077. static readonly SPHERICAL_MODE: number;
  101078. /** Planar coordinates mode */
  101079. static readonly PLANAR_MODE: number;
  101080. /** Cubic coordinates mode */
  101081. static readonly CUBIC_MODE: number;
  101082. /** Projection coordinates mode */
  101083. static readonly PROJECTION_MODE: number;
  101084. /** Inverse Cubic coordinates mode */
  101085. static readonly SKYBOX_MODE: number;
  101086. /** Inverse Cubic coordinates mode */
  101087. static readonly INVCUBIC_MODE: number;
  101088. /** Equirectangular coordinates mode */
  101089. static readonly EQUIRECTANGULAR_MODE: number;
  101090. /** Equirectangular Fixed coordinates mode */
  101091. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  101092. /** Equirectangular Fixed Mirrored coordinates mode */
  101093. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101094. /** Texture is not repeating outside of 0..1 UVs */
  101095. static readonly CLAMP_ADDRESSMODE: number;
  101096. /** Texture is repeating outside of 0..1 UVs */
  101097. static readonly WRAP_ADDRESSMODE: number;
  101098. /** Texture is repeating and mirrored */
  101099. static readonly MIRROR_ADDRESSMODE: number;
  101100. /**
  101101. * 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
  101102. */
  101103. static UseSerializedUrlIfAny: boolean;
  101104. /**
  101105. * Define the url of the texture.
  101106. */
  101107. url: Nullable<string>;
  101108. /**
  101109. * Define an offset on the texture to offset the u coordinates of the UVs
  101110. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101111. */
  101112. uOffset: number;
  101113. /**
  101114. * Define an offset on the texture to offset the v coordinates of the UVs
  101115. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101116. */
  101117. vOffset: number;
  101118. /**
  101119. * Define an offset on the texture to scale the u coordinates of the UVs
  101120. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101121. */
  101122. uScale: number;
  101123. /**
  101124. * Define an offset on the texture to scale the v coordinates of the UVs
  101125. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101126. */
  101127. vScale: number;
  101128. /**
  101129. * Define an offset on the texture to rotate around the u coordinates of the UVs
  101130. * @see https://doc.babylonjs.com/how_to/more_materials
  101131. */
  101132. uAng: number;
  101133. /**
  101134. * Define an offset on the texture to rotate around the v coordinates of the UVs
  101135. * @see https://doc.babylonjs.com/how_to/more_materials
  101136. */
  101137. vAng: number;
  101138. /**
  101139. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  101140. * @see https://doc.babylonjs.com/how_to/more_materials
  101141. */
  101142. wAng: number;
  101143. /**
  101144. * Defines the center of rotation (U)
  101145. */
  101146. uRotationCenter: number;
  101147. /**
  101148. * Defines the center of rotation (V)
  101149. */
  101150. vRotationCenter: number;
  101151. /**
  101152. * Defines the center of rotation (W)
  101153. */
  101154. wRotationCenter: number;
  101155. /**
  101156. * Are mip maps generated for this texture or not.
  101157. */
  101158. get noMipmap(): boolean;
  101159. /**
  101160. * List of inspectable custom properties (used by the Inspector)
  101161. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101162. */
  101163. inspectableCustomProperties: Nullable<IInspectable[]>;
  101164. private _noMipmap;
  101165. /** @hidden */
  101166. _invertY: boolean;
  101167. private _rowGenerationMatrix;
  101168. private _cachedTextureMatrix;
  101169. private _projectionModeMatrix;
  101170. private _t0;
  101171. private _t1;
  101172. private _t2;
  101173. private _cachedUOffset;
  101174. private _cachedVOffset;
  101175. private _cachedUScale;
  101176. private _cachedVScale;
  101177. private _cachedUAng;
  101178. private _cachedVAng;
  101179. private _cachedWAng;
  101180. private _cachedProjectionMatrixId;
  101181. private _cachedCoordinatesMode;
  101182. /** @hidden */
  101183. protected _initialSamplingMode: number;
  101184. /** @hidden */
  101185. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101186. private _deleteBuffer;
  101187. protected _format: Nullable<number>;
  101188. private _delayedOnLoad;
  101189. private _delayedOnError;
  101190. private _mimeType?;
  101191. /**
  101192. * Observable triggered once the texture has been loaded.
  101193. */
  101194. onLoadObservable: Observable<Texture>;
  101195. protected _isBlocking: boolean;
  101196. /**
  101197. * Is the texture preventing material to render while loading.
  101198. * If false, a default texture will be used instead of the loading one during the preparation step.
  101199. */
  101200. set isBlocking(value: boolean);
  101201. get isBlocking(): boolean;
  101202. /**
  101203. * Get the current sampling mode associated with the texture.
  101204. */
  101205. get samplingMode(): number;
  101206. /**
  101207. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  101208. */
  101209. get invertY(): boolean;
  101210. /**
  101211. * Instantiates a new texture.
  101212. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101213. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101214. * @param url defines the url of the picture to load as a texture
  101215. * @param sceneOrEngine defines the scene or engine the texture will belong to
  101216. * @param noMipmap defines if the texture will require mip maps or not
  101217. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  101218. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101219. * @param onLoad defines a callback triggered when the texture has been loaded
  101220. * @param onError defines a callback triggered when an error occurred during the loading session
  101221. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  101222. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  101223. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101224. * @param mimeType defines an optional mime type information
  101225. */
  101226. 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);
  101227. /**
  101228. * Update the url (and optional buffer) of this texture if url was null during construction.
  101229. * @param url the url of the texture
  101230. * @param buffer the buffer of the texture (defaults to null)
  101231. * @param onLoad callback called when the texture is loaded (defaults to null)
  101232. */
  101233. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  101234. /**
  101235. * Finish the loading sequence of a texture flagged as delayed load.
  101236. * @hidden
  101237. */
  101238. delayLoad(): void;
  101239. private _prepareRowForTextureGeneration;
  101240. /**
  101241. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  101242. * @returns the transform matrix of the texture.
  101243. */
  101244. getTextureMatrix(uBase?: number): Matrix;
  101245. /**
  101246. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  101247. * @returns The reflection texture transform
  101248. */
  101249. getReflectionTextureMatrix(): Matrix;
  101250. /**
  101251. * Clones the texture.
  101252. * @returns the cloned texture
  101253. */
  101254. clone(): Texture;
  101255. /**
  101256. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101257. * @returns The JSON representation of the texture
  101258. */
  101259. serialize(): any;
  101260. /**
  101261. * Get the current class name of the texture useful for serialization or dynamic coding.
  101262. * @returns "Texture"
  101263. */
  101264. getClassName(): string;
  101265. /**
  101266. * Dispose the texture and release its associated resources.
  101267. */
  101268. dispose(): void;
  101269. /**
  101270. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  101271. * @param parsedTexture Define the JSON representation of the texture
  101272. * @param scene Define the scene the parsed texture should be instantiated in
  101273. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101274. * @returns The parsed texture if successful
  101275. */
  101276. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  101277. /**
  101278. * Creates a texture from its base 64 representation.
  101279. * @param data Define the base64 payload without the data: prefix
  101280. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101281. * @param scene Define the scene the texture should belong to
  101282. * @param noMipmap Forces the texture to not create mip map information if true
  101283. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101284. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101285. * @param onLoad define a callback triggered when the texture has been loaded
  101286. * @param onError define a callback triggered when an error occurred during the loading session
  101287. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101288. * @returns the created texture
  101289. */
  101290. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  101291. /**
  101292. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  101293. * @param data Define the base64 payload without the data: prefix
  101294. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101295. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  101296. * @param scene Define the scene the texture should belong to
  101297. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  101298. * @param noMipmap Forces the texture to not create mip map information if true
  101299. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101300. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101301. * @param onLoad define a callback triggered when the texture has been loaded
  101302. * @param onError define a callback triggered when an error occurred during the loading session
  101303. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101304. * @returns the created texture
  101305. */
  101306. 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;
  101307. }
  101308. }
  101309. declare module BABYLON {
  101310. /**
  101311. * PostProcessManager is used to manage one or more post processes or post process pipelines
  101312. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101313. */
  101314. export class PostProcessManager {
  101315. private _scene;
  101316. private _indexBuffer;
  101317. private _vertexBuffers;
  101318. /**
  101319. * Creates a new instance PostProcess
  101320. * @param scene The scene that the post process is associated with.
  101321. */
  101322. constructor(scene: Scene);
  101323. private _prepareBuffers;
  101324. private _buildIndexBuffer;
  101325. /**
  101326. * Rebuilds the vertex buffers of the manager.
  101327. * @hidden
  101328. */
  101329. _rebuild(): void;
  101330. /**
  101331. * Prepares a frame to be run through a post process.
  101332. * @param sourceTexture The input texture to the post procesess. (default: null)
  101333. * @param postProcesses An array of post processes to be run. (default: null)
  101334. * @returns True if the post processes were able to be run.
  101335. * @hidden
  101336. */
  101337. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  101338. /**
  101339. * Manually render a set of post processes to a texture.
  101340. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  101341. * @param postProcesses An array of post processes to be run.
  101342. * @param targetTexture The target texture to render to.
  101343. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  101344. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  101345. * @param lodLevel defines which lod of the texture to render to
  101346. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  101347. */
  101348. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  101349. /**
  101350. * Finalize the result of the output of the postprocesses.
  101351. * @param doNotPresent If true the result will not be displayed to the screen.
  101352. * @param targetTexture The target texture to render to.
  101353. * @param faceIndex The index of the face to bind the target texture to.
  101354. * @param postProcesses The array of post processes to render.
  101355. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  101356. * @hidden
  101357. */
  101358. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  101359. /**
  101360. * Disposes of the post process manager.
  101361. */
  101362. dispose(): void;
  101363. }
  101364. }
  101365. declare module BABYLON {
  101366. /**
  101367. * This Helps creating a texture that will be created from a camera in your scene.
  101368. * It is basically a dynamic texture that could be used to create special effects for instance.
  101369. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  101370. */
  101371. export class RenderTargetTexture extends Texture {
  101372. isCube: boolean;
  101373. /**
  101374. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  101375. */
  101376. static readonly REFRESHRATE_RENDER_ONCE: number;
  101377. /**
  101378. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  101379. */
  101380. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  101381. /**
  101382. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  101383. * the central point of your effect and can save a lot of performances.
  101384. */
  101385. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  101386. /**
  101387. * Use this predicate to dynamically define the list of mesh you want to render.
  101388. * If set, the renderList property will be overwritten.
  101389. */
  101390. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  101391. private _renderList;
  101392. /**
  101393. * Use this list to define the list of mesh you want to render.
  101394. */
  101395. get renderList(): Nullable<Array<AbstractMesh>>;
  101396. set renderList(value: Nullable<Array<AbstractMesh>>);
  101397. /**
  101398. * Use this function to overload the renderList array at rendering time.
  101399. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  101400. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  101401. * the cube (if the RTT is a cube, else layerOrFace=0).
  101402. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  101403. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  101404. * hold dummy elements!
  101405. */
  101406. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  101407. private _hookArray;
  101408. /**
  101409. * Define if particles should be rendered in your texture.
  101410. */
  101411. renderParticles: boolean;
  101412. /**
  101413. * Define if sprites should be rendered in your texture.
  101414. */
  101415. renderSprites: boolean;
  101416. /**
  101417. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  101418. */
  101419. coordinatesMode: number;
  101420. /**
  101421. * Define the camera used to render the texture.
  101422. */
  101423. activeCamera: Nullable<Camera>;
  101424. /**
  101425. * Override the mesh isReady function with your own one.
  101426. */
  101427. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  101428. /**
  101429. * Override the render function of the texture with your own one.
  101430. */
  101431. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  101432. /**
  101433. * Define if camera post processes should be use while rendering the texture.
  101434. */
  101435. useCameraPostProcesses: boolean;
  101436. /**
  101437. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  101438. */
  101439. ignoreCameraViewport: boolean;
  101440. private _postProcessManager;
  101441. private _postProcesses;
  101442. private _resizeObserver;
  101443. /**
  101444. * An event triggered when the texture is unbind.
  101445. */
  101446. onBeforeBindObservable: Observable<RenderTargetTexture>;
  101447. /**
  101448. * An event triggered when the texture is unbind.
  101449. */
  101450. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  101451. private _onAfterUnbindObserver;
  101452. /**
  101453. * Set a after unbind callback in the texture.
  101454. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  101455. */
  101456. set onAfterUnbind(callback: () => void);
  101457. /**
  101458. * An event triggered before rendering the texture
  101459. */
  101460. onBeforeRenderObservable: Observable<number>;
  101461. private _onBeforeRenderObserver;
  101462. /**
  101463. * Set a before render callback in the texture.
  101464. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  101465. */
  101466. set onBeforeRender(callback: (faceIndex: number) => void);
  101467. /**
  101468. * An event triggered after rendering the texture
  101469. */
  101470. onAfterRenderObservable: Observable<number>;
  101471. private _onAfterRenderObserver;
  101472. /**
  101473. * Set a after render callback in the texture.
  101474. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  101475. */
  101476. set onAfterRender(callback: (faceIndex: number) => void);
  101477. /**
  101478. * An event triggered after the texture clear
  101479. */
  101480. onClearObservable: Observable<Engine>;
  101481. private _onClearObserver;
  101482. /**
  101483. * Set a clear callback in the texture.
  101484. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  101485. */
  101486. set onClear(callback: (Engine: Engine) => void);
  101487. /**
  101488. * An event triggered when the texture is resized.
  101489. */
  101490. onResizeObservable: Observable<RenderTargetTexture>;
  101491. /**
  101492. * Define the clear color of the Render Target if it should be different from the scene.
  101493. */
  101494. clearColor: Color4;
  101495. protected _size: number | {
  101496. width: number;
  101497. height: number;
  101498. layers?: number;
  101499. };
  101500. protected _initialSizeParameter: number | {
  101501. width: number;
  101502. height: number;
  101503. } | {
  101504. ratio: number;
  101505. };
  101506. protected _sizeRatio: Nullable<number>;
  101507. /** @hidden */
  101508. _generateMipMaps: boolean;
  101509. protected _renderingManager: RenderingManager;
  101510. /** @hidden */
  101511. _waitingRenderList: string[];
  101512. protected _doNotChangeAspectRatio: boolean;
  101513. protected _currentRefreshId: number;
  101514. protected _refreshRate: number;
  101515. protected _textureMatrix: Matrix;
  101516. protected _samples: number;
  101517. protected _renderTargetOptions: RenderTargetCreationOptions;
  101518. /**
  101519. * Gets render target creation options that were used.
  101520. */
  101521. get renderTargetOptions(): RenderTargetCreationOptions;
  101522. protected _onRatioRescale(): void;
  101523. /**
  101524. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  101525. * It must define where the camera used to render the texture is set
  101526. */
  101527. boundingBoxPosition: Vector3;
  101528. private _boundingBoxSize;
  101529. /**
  101530. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  101531. * When defined, the cubemap will switch to local mode
  101532. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101533. * @example https://www.babylonjs-playground.com/#RNASML
  101534. */
  101535. set boundingBoxSize(value: Vector3);
  101536. get boundingBoxSize(): Vector3;
  101537. /**
  101538. * In case the RTT has been created with a depth texture, get the associated
  101539. * depth texture.
  101540. * Otherwise, return null.
  101541. */
  101542. get depthStencilTexture(): Nullable<InternalTexture>;
  101543. /**
  101544. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  101545. * or used a shadow, depth texture...
  101546. * @param name The friendly name of the texture
  101547. * @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)
  101548. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  101549. * @param generateMipMaps True if mip maps need to be generated after render.
  101550. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  101551. * @param type The type of the buffer in the RTT (int, half float, float...)
  101552. * @param isCube True if a cube texture needs to be created
  101553. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  101554. * @param generateDepthBuffer True to generate a depth buffer
  101555. * @param generateStencilBuffer True to generate a stencil buffer
  101556. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  101557. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  101558. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101559. */
  101560. constructor(name: string, size: number | {
  101561. width: number;
  101562. height: number;
  101563. layers?: number;
  101564. } | {
  101565. ratio: number;
  101566. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  101567. /**
  101568. * Creates a depth stencil texture.
  101569. * This is only available in WebGL 2 or with the depth texture extension available.
  101570. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  101571. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  101572. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  101573. */
  101574. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  101575. private _processSizeParameter;
  101576. /**
  101577. * Define the number of samples to use in case of MSAA.
  101578. * It defaults to one meaning no MSAA has been enabled.
  101579. */
  101580. get samples(): number;
  101581. set samples(value: number);
  101582. /**
  101583. * Resets the refresh counter of the texture and start bak from scratch.
  101584. * Could be useful to regenerate the texture if it is setup to render only once.
  101585. */
  101586. resetRefreshCounter(): void;
  101587. /**
  101588. * Define the refresh rate of the texture or the rendering frequency.
  101589. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  101590. */
  101591. get refreshRate(): number;
  101592. set refreshRate(value: number);
  101593. /**
  101594. * Adds a post process to the render target rendering passes.
  101595. * @param postProcess define the post process to add
  101596. */
  101597. addPostProcess(postProcess: PostProcess): void;
  101598. /**
  101599. * Clear all the post processes attached to the render target
  101600. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  101601. */
  101602. clearPostProcesses(dispose?: boolean): void;
  101603. /**
  101604. * Remove one of the post process from the list of attached post processes to the texture
  101605. * @param postProcess define the post process to remove from the list
  101606. */
  101607. removePostProcess(postProcess: PostProcess): void;
  101608. /** @hidden */
  101609. _shouldRender(): boolean;
  101610. /**
  101611. * Gets the actual render size of the texture.
  101612. * @returns the width of the render size
  101613. */
  101614. getRenderSize(): number;
  101615. /**
  101616. * Gets the actual render width of the texture.
  101617. * @returns the width of the render size
  101618. */
  101619. getRenderWidth(): number;
  101620. /**
  101621. * Gets the actual render height of the texture.
  101622. * @returns the height of the render size
  101623. */
  101624. getRenderHeight(): number;
  101625. /**
  101626. * Gets the actual number of layers of the texture.
  101627. * @returns the number of layers
  101628. */
  101629. getRenderLayers(): number;
  101630. /**
  101631. * Get if the texture can be rescaled or not.
  101632. */
  101633. get canRescale(): boolean;
  101634. /**
  101635. * Resize the texture using a ratio.
  101636. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  101637. */
  101638. scale(ratio: number): void;
  101639. /**
  101640. * Get the texture reflection matrix used to rotate/transform the reflection.
  101641. * @returns the reflection matrix
  101642. */
  101643. getReflectionTextureMatrix(): Matrix;
  101644. /**
  101645. * Resize the texture to a new desired size.
  101646. * Be carrefull as it will recreate all the data in the new texture.
  101647. * @param size Define the new size. It can be:
  101648. * - a number for squared texture,
  101649. * - an object containing { width: number, height: number }
  101650. * - or an object containing a ratio { ratio: number }
  101651. */
  101652. resize(size: number | {
  101653. width: number;
  101654. height: number;
  101655. } | {
  101656. ratio: number;
  101657. }): void;
  101658. private _defaultRenderListPrepared;
  101659. /**
  101660. * Renders all the objects from the render list into the texture.
  101661. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  101662. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  101663. */
  101664. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  101665. private _bestReflectionRenderTargetDimension;
  101666. private _prepareRenderingManager;
  101667. /**
  101668. * @hidden
  101669. * @param faceIndex face index to bind to if this is a cubetexture
  101670. * @param layer defines the index of the texture to bind in the array
  101671. */
  101672. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  101673. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101674. private renderToTarget;
  101675. /**
  101676. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101677. * This allowed control for front to back rendering or reversly depending of the special needs.
  101678. *
  101679. * @param renderingGroupId The rendering group id corresponding to its index
  101680. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101681. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101682. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101683. */
  101684. 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;
  101685. /**
  101686. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101687. *
  101688. * @param renderingGroupId The rendering group id corresponding to its index
  101689. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101690. */
  101691. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101692. /**
  101693. * Clones the texture.
  101694. * @returns the cloned texture
  101695. */
  101696. clone(): RenderTargetTexture;
  101697. /**
  101698. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101699. * @returns The JSON representation of the texture
  101700. */
  101701. serialize(): any;
  101702. /**
  101703. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  101704. */
  101705. disposeFramebufferObjects(): void;
  101706. /**
  101707. * Dispose the texture and release its associated resources.
  101708. */
  101709. dispose(): void;
  101710. /** @hidden */
  101711. _rebuild(): void;
  101712. /**
  101713. * Clear the info related to rendering groups preventing retention point in material dispose.
  101714. */
  101715. freeRenderingGroups(): void;
  101716. /**
  101717. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101718. * @returns the view count
  101719. */
  101720. getViewCount(): number;
  101721. }
  101722. }
  101723. declare module BABYLON {
  101724. /**
  101725. * Class used to manipulate GUIDs
  101726. */
  101727. export class GUID {
  101728. /**
  101729. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101730. * Be aware Math.random() could cause collisions, but:
  101731. * "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"
  101732. * @returns a pseudo random id
  101733. */
  101734. static RandomId(): string;
  101735. }
  101736. }
  101737. declare module BABYLON {
  101738. /**
  101739. * Options to be used when creating a shadow depth material
  101740. */
  101741. export interface IIOptionShadowDepthMaterial {
  101742. /** Variables in the vertex shader code that need to have their names remapped.
  101743. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  101744. * "var_name" should be either: worldPos or vNormalW
  101745. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  101746. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  101747. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  101748. */
  101749. remappedVariables?: string[];
  101750. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  101751. standalone?: boolean;
  101752. }
  101753. /**
  101754. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  101755. */
  101756. export class ShadowDepthWrapper {
  101757. private _scene;
  101758. private _options?;
  101759. private _baseMaterial;
  101760. private _onEffectCreatedObserver;
  101761. private _subMeshToEffect;
  101762. private _subMeshToDepthEffect;
  101763. private _meshes;
  101764. /** @hidden */
  101765. _matriceNames: any;
  101766. /** Gets the standalone status of the wrapper */
  101767. get standalone(): boolean;
  101768. /** Gets the base material the wrapper is built upon */
  101769. get baseMaterial(): Material;
  101770. /**
  101771. * Instantiate a new shadow depth wrapper.
  101772. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  101773. * generate the shadow depth map. For more information, please refer to the documentation:
  101774. * https://doc.babylonjs.com/babylon101/shadows
  101775. * @param baseMaterial Material to wrap
  101776. * @param scene Define the scene the material belongs to
  101777. * @param options Options used to create the wrapper
  101778. */
  101779. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  101780. /**
  101781. * Gets the effect to use to generate the depth map
  101782. * @param subMesh subMesh to get the effect for
  101783. * @param shadowGenerator shadow generator to get the effect for
  101784. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  101785. */
  101786. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  101787. /**
  101788. * Specifies that the submesh is ready to be used for depth rendering
  101789. * @param subMesh submesh to check
  101790. * @param defines the list of defines to take into account when checking the effect
  101791. * @param shadowGenerator combined with subMesh, it defines the effect to check
  101792. * @param useInstances specifies that instances should be used
  101793. * @returns a boolean indicating that the submesh is ready or not
  101794. */
  101795. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  101796. /**
  101797. * Disposes the resources
  101798. */
  101799. dispose(): void;
  101800. private _makeEffect;
  101801. }
  101802. }
  101803. declare module BABYLON {
  101804. /**
  101805. * Options for compiling materials.
  101806. */
  101807. export interface IMaterialCompilationOptions {
  101808. /**
  101809. * Defines whether clip planes are enabled.
  101810. */
  101811. clipPlane: boolean;
  101812. /**
  101813. * Defines whether instances are enabled.
  101814. */
  101815. useInstances: boolean;
  101816. }
  101817. /**
  101818. * Options passed when calling customShaderNameResolve
  101819. */
  101820. export interface ICustomShaderNameResolveOptions {
  101821. /**
  101822. * 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
  101823. */
  101824. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  101825. }
  101826. /**
  101827. * Base class for the main features of a material in Babylon.js
  101828. */
  101829. export class Material implements IAnimatable {
  101830. /**
  101831. * Returns the triangle fill mode
  101832. */
  101833. static readonly TriangleFillMode: number;
  101834. /**
  101835. * Returns the wireframe mode
  101836. */
  101837. static readonly WireFrameFillMode: number;
  101838. /**
  101839. * Returns the point fill mode
  101840. */
  101841. static readonly PointFillMode: number;
  101842. /**
  101843. * Returns the point list draw mode
  101844. */
  101845. static readonly PointListDrawMode: number;
  101846. /**
  101847. * Returns the line list draw mode
  101848. */
  101849. static readonly LineListDrawMode: number;
  101850. /**
  101851. * Returns the line loop draw mode
  101852. */
  101853. static readonly LineLoopDrawMode: number;
  101854. /**
  101855. * Returns the line strip draw mode
  101856. */
  101857. static readonly LineStripDrawMode: number;
  101858. /**
  101859. * Returns the triangle strip draw mode
  101860. */
  101861. static readonly TriangleStripDrawMode: number;
  101862. /**
  101863. * Returns the triangle fan draw mode
  101864. */
  101865. static readonly TriangleFanDrawMode: number;
  101866. /**
  101867. * Stores the clock-wise side orientation
  101868. */
  101869. static readonly ClockWiseSideOrientation: number;
  101870. /**
  101871. * Stores the counter clock-wise side orientation
  101872. */
  101873. static readonly CounterClockWiseSideOrientation: number;
  101874. /**
  101875. * The dirty texture flag value
  101876. */
  101877. static readonly TextureDirtyFlag: number;
  101878. /**
  101879. * The dirty light flag value
  101880. */
  101881. static readonly LightDirtyFlag: number;
  101882. /**
  101883. * The dirty fresnel flag value
  101884. */
  101885. static readonly FresnelDirtyFlag: number;
  101886. /**
  101887. * The dirty attribute flag value
  101888. */
  101889. static readonly AttributesDirtyFlag: number;
  101890. /**
  101891. * The dirty misc flag value
  101892. */
  101893. static readonly MiscDirtyFlag: number;
  101894. /**
  101895. * The all dirty flag value
  101896. */
  101897. static readonly AllDirtyFlag: number;
  101898. /**
  101899. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101900. */
  101901. static readonly MATERIAL_OPAQUE: number;
  101902. /**
  101903. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101904. */
  101905. static readonly MATERIAL_ALPHATEST: number;
  101906. /**
  101907. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101908. */
  101909. static readonly MATERIAL_ALPHABLEND: number;
  101910. /**
  101911. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101912. * They are also discarded below the alpha cutoff threshold to improve performances.
  101913. */
  101914. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  101915. /**
  101916. * The Whiteout method is used to blend normals.
  101917. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101918. */
  101919. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  101920. /**
  101921. * The Reoriented Normal Mapping method is used to blend normals.
  101922. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101923. */
  101924. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  101925. /**
  101926. * Custom callback helping to override the default shader used in the material.
  101927. */
  101928. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  101929. /**
  101930. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  101931. */
  101932. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  101933. /**
  101934. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  101935. * This means that the material can keep using a previous shader while a new one is being compiled.
  101936. * This is mostly used when shader parallel compilation is supported (true by default)
  101937. */
  101938. allowShaderHotSwapping: boolean;
  101939. /**
  101940. * The ID of the material
  101941. */
  101942. id: string;
  101943. /**
  101944. * Gets or sets the unique id of the material
  101945. */
  101946. uniqueId: number;
  101947. /**
  101948. * The name of the material
  101949. */
  101950. name: string;
  101951. /**
  101952. * Gets or sets user defined metadata
  101953. */
  101954. metadata: any;
  101955. /**
  101956. * For internal use only. Please do not use.
  101957. */
  101958. reservedDataStore: any;
  101959. /**
  101960. * Specifies if the ready state should be checked on each call
  101961. */
  101962. checkReadyOnEveryCall: boolean;
  101963. /**
  101964. * Specifies if the ready state should be checked once
  101965. */
  101966. checkReadyOnlyOnce: boolean;
  101967. /**
  101968. * The state of the material
  101969. */
  101970. state: string;
  101971. /**
  101972. * If the material should be rendered to several textures with MRT extension
  101973. */
  101974. get shouldRenderToMRT(): boolean;
  101975. /**
  101976. * The alpha value of the material
  101977. */
  101978. protected _alpha: number;
  101979. /**
  101980. * List of inspectable custom properties (used by the Inspector)
  101981. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101982. */
  101983. inspectableCustomProperties: IInspectable[];
  101984. /**
  101985. * Sets the alpha value of the material
  101986. */
  101987. set alpha(value: number);
  101988. /**
  101989. * Gets the alpha value of the material
  101990. */
  101991. get alpha(): number;
  101992. /**
  101993. * Specifies if back face culling is enabled
  101994. */
  101995. protected _backFaceCulling: boolean;
  101996. /**
  101997. * Sets the back-face culling state
  101998. */
  101999. set backFaceCulling(value: boolean);
  102000. /**
  102001. * Gets the back-face culling state
  102002. */
  102003. get backFaceCulling(): boolean;
  102004. /**
  102005. * Stores the value for side orientation
  102006. */
  102007. sideOrientation: number;
  102008. /**
  102009. * Callback triggered when the material is compiled
  102010. */
  102011. onCompiled: Nullable<(effect: Effect) => void>;
  102012. /**
  102013. * Callback triggered when an error occurs
  102014. */
  102015. onError: Nullable<(effect: Effect, errors: string) => void>;
  102016. /**
  102017. * Callback triggered to get the render target textures
  102018. */
  102019. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  102020. /**
  102021. * Gets a boolean indicating that current material needs to register RTT
  102022. */
  102023. get hasRenderTargetTextures(): boolean;
  102024. /**
  102025. * Specifies if the material should be serialized
  102026. */
  102027. doNotSerialize: boolean;
  102028. /**
  102029. * @hidden
  102030. */
  102031. _storeEffectOnSubMeshes: boolean;
  102032. /**
  102033. * Stores the animations for the material
  102034. */
  102035. animations: Nullable<Array<Animation>>;
  102036. /**
  102037. * An event triggered when the material is disposed
  102038. */
  102039. onDisposeObservable: Observable<Material>;
  102040. /**
  102041. * An observer which watches for dispose events
  102042. */
  102043. private _onDisposeObserver;
  102044. private _onUnBindObservable;
  102045. /**
  102046. * Called during a dispose event
  102047. */
  102048. set onDispose(callback: () => void);
  102049. private _onBindObservable;
  102050. /**
  102051. * An event triggered when the material is bound
  102052. */
  102053. get onBindObservable(): Observable<AbstractMesh>;
  102054. /**
  102055. * An observer which watches for bind events
  102056. */
  102057. private _onBindObserver;
  102058. /**
  102059. * Called during a bind event
  102060. */
  102061. set onBind(callback: (Mesh: AbstractMesh) => void);
  102062. /**
  102063. * An event triggered when the material is unbound
  102064. */
  102065. get onUnBindObservable(): Observable<Material>;
  102066. protected _onEffectCreatedObservable: Nullable<Observable<{
  102067. effect: Effect;
  102068. subMesh: Nullable<SubMesh>;
  102069. }>>;
  102070. /**
  102071. * An event triggered when the effect is (re)created
  102072. */
  102073. get onEffectCreatedObservable(): Observable<{
  102074. effect: Effect;
  102075. subMesh: Nullable<SubMesh>;
  102076. }>;
  102077. /**
  102078. * Stores the value of the alpha mode
  102079. */
  102080. private _alphaMode;
  102081. /**
  102082. * Sets the value of the alpha mode.
  102083. *
  102084. * | Value | Type | Description |
  102085. * | --- | --- | --- |
  102086. * | 0 | ALPHA_DISABLE | |
  102087. * | 1 | ALPHA_ADD | |
  102088. * | 2 | ALPHA_COMBINE | |
  102089. * | 3 | ALPHA_SUBTRACT | |
  102090. * | 4 | ALPHA_MULTIPLY | |
  102091. * | 5 | ALPHA_MAXIMIZED | |
  102092. * | 6 | ALPHA_ONEONE | |
  102093. * | 7 | ALPHA_PREMULTIPLIED | |
  102094. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  102095. * | 9 | ALPHA_INTERPOLATE | |
  102096. * | 10 | ALPHA_SCREENMODE | |
  102097. *
  102098. */
  102099. set alphaMode(value: number);
  102100. /**
  102101. * Gets the value of the alpha mode
  102102. */
  102103. get alphaMode(): number;
  102104. /**
  102105. * Stores the state of the need depth pre-pass value
  102106. */
  102107. private _needDepthPrePass;
  102108. /**
  102109. * Sets the need depth pre-pass value
  102110. */
  102111. set needDepthPrePass(value: boolean);
  102112. /**
  102113. * Gets the depth pre-pass value
  102114. */
  102115. get needDepthPrePass(): boolean;
  102116. /**
  102117. * Specifies if depth writing should be disabled
  102118. */
  102119. disableDepthWrite: boolean;
  102120. /**
  102121. * Specifies if color writing should be disabled
  102122. */
  102123. disableColorWrite: boolean;
  102124. /**
  102125. * Specifies if depth writing should be forced
  102126. */
  102127. forceDepthWrite: boolean;
  102128. /**
  102129. * Specifies the depth function that should be used. 0 means the default engine function
  102130. */
  102131. depthFunction: number;
  102132. /**
  102133. * Specifies if there should be a separate pass for culling
  102134. */
  102135. separateCullingPass: boolean;
  102136. /**
  102137. * Stores the state specifing if fog should be enabled
  102138. */
  102139. private _fogEnabled;
  102140. /**
  102141. * Sets the state for enabling fog
  102142. */
  102143. set fogEnabled(value: boolean);
  102144. /**
  102145. * Gets the value of the fog enabled state
  102146. */
  102147. get fogEnabled(): boolean;
  102148. /**
  102149. * Stores the size of points
  102150. */
  102151. pointSize: number;
  102152. /**
  102153. * Stores the z offset value
  102154. */
  102155. zOffset: number;
  102156. get wireframe(): boolean;
  102157. /**
  102158. * Sets the state of wireframe mode
  102159. */
  102160. set wireframe(value: boolean);
  102161. /**
  102162. * Gets the value specifying if point clouds are enabled
  102163. */
  102164. get pointsCloud(): boolean;
  102165. /**
  102166. * Sets the state of point cloud mode
  102167. */
  102168. set pointsCloud(value: boolean);
  102169. /**
  102170. * Gets the material fill mode
  102171. */
  102172. get fillMode(): number;
  102173. /**
  102174. * Sets the material fill mode
  102175. */
  102176. set fillMode(value: number);
  102177. /**
  102178. * @hidden
  102179. * Stores the effects for the material
  102180. */
  102181. _effect: Nullable<Effect>;
  102182. /**
  102183. * Specifies if uniform buffers should be used
  102184. */
  102185. private _useUBO;
  102186. /**
  102187. * Stores a reference to the scene
  102188. */
  102189. private _scene;
  102190. /**
  102191. * Stores the fill mode state
  102192. */
  102193. private _fillMode;
  102194. /**
  102195. * Specifies if the depth write state should be cached
  102196. */
  102197. private _cachedDepthWriteState;
  102198. /**
  102199. * Specifies if the color write state should be cached
  102200. */
  102201. private _cachedColorWriteState;
  102202. /**
  102203. * Specifies if the depth function state should be cached
  102204. */
  102205. private _cachedDepthFunctionState;
  102206. /**
  102207. * Stores the uniform buffer
  102208. */
  102209. protected _uniformBuffer: UniformBuffer;
  102210. /** @hidden */
  102211. _indexInSceneMaterialArray: number;
  102212. /** @hidden */
  102213. meshMap: Nullable<{
  102214. [id: string]: AbstractMesh | undefined;
  102215. }>;
  102216. /**
  102217. * Creates a material instance
  102218. * @param name defines the name of the material
  102219. * @param scene defines the scene to reference
  102220. * @param doNotAdd specifies if the material should be added to the scene
  102221. */
  102222. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  102223. /**
  102224. * Returns a string representation of the current material
  102225. * @param fullDetails defines a boolean indicating which levels of logging is desired
  102226. * @returns a string with material information
  102227. */
  102228. toString(fullDetails?: boolean): string;
  102229. /**
  102230. * Gets the class name of the material
  102231. * @returns a string with the class name of the material
  102232. */
  102233. getClassName(): string;
  102234. /**
  102235. * Specifies if updates for the material been locked
  102236. */
  102237. get isFrozen(): boolean;
  102238. /**
  102239. * Locks updates for the material
  102240. */
  102241. freeze(): void;
  102242. /**
  102243. * Unlocks updates for the material
  102244. */
  102245. unfreeze(): void;
  102246. /**
  102247. * Specifies if the material is ready to be used
  102248. * @param mesh defines the mesh to check
  102249. * @param useInstances specifies if instances should be used
  102250. * @returns a boolean indicating if the material is ready to be used
  102251. */
  102252. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102253. /**
  102254. * Specifies that the submesh is ready to be used
  102255. * @param mesh defines the mesh to check
  102256. * @param subMesh defines which submesh to check
  102257. * @param useInstances specifies that instances should be used
  102258. * @returns a boolean indicating that the submesh is ready or not
  102259. */
  102260. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102261. /**
  102262. * Returns the material effect
  102263. * @returns the effect associated with the material
  102264. */
  102265. getEffect(): Nullable<Effect>;
  102266. /**
  102267. * Returns the current scene
  102268. * @returns a Scene
  102269. */
  102270. getScene(): Scene;
  102271. /**
  102272. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102273. */
  102274. protected _forceAlphaTest: boolean;
  102275. /**
  102276. * The transparency mode of the material.
  102277. */
  102278. protected _transparencyMode: Nullable<number>;
  102279. /**
  102280. * Gets the current transparency mode.
  102281. */
  102282. get transparencyMode(): Nullable<number>;
  102283. /**
  102284. * Sets the transparency mode of the material.
  102285. *
  102286. * | Value | Type | Description |
  102287. * | ----- | ----------------------------------- | ----------- |
  102288. * | 0 | OPAQUE | |
  102289. * | 1 | ALPHATEST | |
  102290. * | 2 | ALPHABLEND | |
  102291. * | 3 | ALPHATESTANDBLEND | |
  102292. *
  102293. */
  102294. set transparencyMode(value: Nullable<number>);
  102295. /**
  102296. * Returns true if alpha blending should be disabled.
  102297. */
  102298. protected get _disableAlphaBlending(): boolean;
  102299. /**
  102300. * Specifies whether or not this material should be rendered in alpha blend mode.
  102301. * @returns a boolean specifying if alpha blending is needed
  102302. */
  102303. needAlphaBlending(): boolean;
  102304. /**
  102305. * Specifies if the mesh will require alpha blending
  102306. * @param mesh defines the mesh to check
  102307. * @returns a boolean specifying if alpha blending is needed for the mesh
  102308. */
  102309. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102310. /**
  102311. * Specifies whether or not this material should be rendered in alpha test mode.
  102312. * @returns a boolean specifying if an alpha test is needed.
  102313. */
  102314. needAlphaTesting(): boolean;
  102315. /**
  102316. * Specifies if material alpha testing should be turned on for the mesh
  102317. * @param mesh defines the mesh to check
  102318. */
  102319. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  102320. /**
  102321. * Gets the texture used for the alpha test
  102322. * @returns the texture to use for alpha testing
  102323. */
  102324. getAlphaTestTexture(): Nullable<BaseTexture>;
  102325. /**
  102326. * Marks the material to indicate that it needs to be re-calculated
  102327. */
  102328. markDirty(): void;
  102329. /** @hidden */
  102330. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  102331. /**
  102332. * Binds the material to the mesh
  102333. * @param world defines the world transformation matrix
  102334. * @param mesh defines the mesh to bind the material to
  102335. */
  102336. bind(world: Matrix, mesh?: Mesh): void;
  102337. /**
  102338. * Binds the submesh to the material
  102339. * @param world defines the world transformation matrix
  102340. * @param mesh defines the mesh containing the submesh
  102341. * @param subMesh defines the submesh to bind the material to
  102342. */
  102343. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102344. /**
  102345. * Binds the world matrix to the material
  102346. * @param world defines the world transformation matrix
  102347. */
  102348. bindOnlyWorldMatrix(world: Matrix): void;
  102349. /**
  102350. * Binds the scene's uniform buffer to the effect.
  102351. * @param effect defines the effect to bind to the scene uniform buffer
  102352. * @param sceneUbo defines the uniform buffer storing scene data
  102353. */
  102354. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  102355. /**
  102356. * Binds the view matrix to the effect
  102357. * @param effect defines the effect to bind the view matrix to
  102358. */
  102359. bindView(effect: Effect): void;
  102360. /**
  102361. * Binds the view projection matrix to the effect
  102362. * @param effect defines the effect to bind the view projection matrix to
  102363. */
  102364. bindViewProjection(effect: Effect): void;
  102365. /**
  102366. * Processes to execute after binding the material to a mesh
  102367. * @param mesh defines the rendered mesh
  102368. */
  102369. protected _afterBind(mesh?: Mesh): void;
  102370. /**
  102371. * Unbinds the material from the mesh
  102372. */
  102373. unbind(): void;
  102374. /**
  102375. * Gets the active textures from the material
  102376. * @returns an array of textures
  102377. */
  102378. getActiveTextures(): BaseTexture[];
  102379. /**
  102380. * Specifies if the material uses a texture
  102381. * @param texture defines the texture to check against the material
  102382. * @returns a boolean specifying if the material uses the texture
  102383. */
  102384. hasTexture(texture: BaseTexture): boolean;
  102385. /**
  102386. * Makes a duplicate of the material, and gives it a new name
  102387. * @param name defines the new name for the duplicated material
  102388. * @returns the cloned material
  102389. */
  102390. clone(name: string): Nullable<Material>;
  102391. /**
  102392. * Gets the meshes bound to the material
  102393. * @returns an array of meshes bound to the material
  102394. */
  102395. getBindedMeshes(): AbstractMesh[];
  102396. /**
  102397. * Force shader compilation
  102398. * @param mesh defines the mesh associated with this material
  102399. * @param onCompiled defines a function to execute once the material is compiled
  102400. * @param options defines the options to configure the compilation
  102401. * @param onError defines a function to execute if the material fails compiling
  102402. */
  102403. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  102404. /**
  102405. * Force shader compilation
  102406. * @param mesh defines the mesh that will use this material
  102407. * @param options defines additional options for compiling the shaders
  102408. * @returns a promise that resolves when the compilation completes
  102409. */
  102410. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  102411. private static readonly _AllDirtyCallBack;
  102412. private static readonly _ImageProcessingDirtyCallBack;
  102413. private static readonly _TextureDirtyCallBack;
  102414. private static readonly _FresnelDirtyCallBack;
  102415. private static readonly _MiscDirtyCallBack;
  102416. private static readonly _LightsDirtyCallBack;
  102417. private static readonly _AttributeDirtyCallBack;
  102418. private static _FresnelAndMiscDirtyCallBack;
  102419. private static _TextureAndMiscDirtyCallBack;
  102420. private static readonly _DirtyCallbackArray;
  102421. private static readonly _RunDirtyCallBacks;
  102422. /**
  102423. * Marks a define in the material to indicate that it needs to be re-computed
  102424. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  102425. */
  102426. markAsDirty(flag: number): void;
  102427. /**
  102428. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  102429. * @param func defines a function which checks material defines against the submeshes
  102430. */
  102431. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  102432. /**
  102433. * Indicates that the scene should check if the rendering now needs a prepass
  102434. */
  102435. protected _markScenePrePassDirty(): void;
  102436. /**
  102437. * Indicates that we need to re-calculated for all submeshes
  102438. */
  102439. protected _markAllSubMeshesAsAllDirty(): void;
  102440. /**
  102441. * Indicates that image processing needs to be re-calculated for all submeshes
  102442. */
  102443. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  102444. /**
  102445. * Indicates that textures need to be re-calculated for all submeshes
  102446. */
  102447. protected _markAllSubMeshesAsTexturesDirty(): void;
  102448. /**
  102449. * Indicates that fresnel needs to be re-calculated for all submeshes
  102450. */
  102451. protected _markAllSubMeshesAsFresnelDirty(): void;
  102452. /**
  102453. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  102454. */
  102455. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  102456. /**
  102457. * Indicates that lights need to be re-calculated for all submeshes
  102458. */
  102459. protected _markAllSubMeshesAsLightsDirty(): void;
  102460. /**
  102461. * Indicates that attributes need to be re-calculated for all submeshes
  102462. */
  102463. protected _markAllSubMeshesAsAttributesDirty(): void;
  102464. /**
  102465. * Indicates that misc needs to be re-calculated for all submeshes
  102466. */
  102467. protected _markAllSubMeshesAsMiscDirty(): void;
  102468. /**
  102469. * Indicates that textures and misc need to be re-calculated for all submeshes
  102470. */
  102471. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  102472. /**
  102473. * Disposes the material
  102474. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102475. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102476. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102477. */
  102478. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102479. /** @hidden */
  102480. private releaseVertexArrayObject;
  102481. /**
  102482. * Serializes this material
  102483. * @returns the serialized material object
  102484. */
  102485. serialize(): any;
  102486. /**
  102487. * Creates a material from parsed material data
  102488. * @param parsedMaterial defines parsed material data
  102489. * @param scene defines the hosting scene
  102490. * @param rootUrl defines the root URL to use to load textures
  102491. * @returns a new material
  102492. */
  102493. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  102494. }
  102495. }
  102496. declare module BABYLON {
  102497. /**
  102498. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102499. * separate meshes. This can be use to improve performances.
  102500. * @see https://doc.babylonjs.com/how_to/multi_materials
  102501. */
  102502. export class MultiMaterial extends Material {
  102503. private _subMaterials;
  102504. /**
  102505. * Gets or Sets the list of Materials used within the multi material.
  102506. * They need to be ordered according to the submeshes order in the associated mesh
  102507. */
  102508. get subMaterials(): Nullable<Material>[];
  102509. set subMaterials(value: Nullable<Material>[]);
  102510. /**
  102511. * Function used to align with Node.getChildren()
  102512. * @returns the list of Materials used within the multi material
  102513. */
  102514. getChildren(): Nullable<Material>[];
  102515. /**
  102516. * Instantiates a new Multi Material
  102517. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102518. * separate meshes. This can be use to improve performances.
  102519. * @see https://doc.babylonjs.com/how_to/multi_materials
  102520. * @param name Define the name in the scene
  102521. * @param scene Define the scene the material belongs to
  102522. */
  102523. constructor(name: string, scene: Scene);
  102524. private _hookArray;
  102525. /**
  102526. * Get one of the submaterial by its index in the submaterials array
  102527. * @param index The index to look the sub material at
  102528. * @returns The Material if the index has been defined
  102529. */
  102530. getSubMaterial(index: number): Nullable<Material>;
  102531. /**
  102532. * Get the list of active textures for the whole sub materials list.
  102533. * @returns All the textures that will be used during the rendering
  102534. */
  102535. getActiveTextures(): BaseTexture[];
  102536. /**
  102537. * Gets the current class name of the material e.g. "MultiMaterial"
  102538. * Mainly use in serialization.
  102539. * @returns the class name
  102540. */
  102541. getClassName(): string;
  102542. /**
  102543. * Checks if the material is ready to render the requested sub mesh
  102544. * @param mesh Define the mesh the submesh belongs to
  102545. * @param subMesh Define the sub mesh to look readyness for
  102546. * @param useInstances Define whether or not the material is used with instances
  102547. * @returns true if ready, otherwise false
  102548. */
  102549. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102550. /**
  102551. * Clones the current material and its related sub materials
  102552. * @param name Define the name of the newly cloned material
  102553. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  102554. * @returns the cloned material
  102555. */
  102556. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  102557. /**
  102558. * Serializes the materials into a JSON representation.
  102559. * @returns the JSON representation
  102560. */
  102561. serialize(): any;
  102562. /**
  102563. * Dispose the material and release its associated resources
  102564. * @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)
  102565. * @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)
  102566. * @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)
  102567. */
  102568. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  102569. /**
  102570. * Creates a MultiMaterial from parsed MultiMaterial data.
  102571. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  102572. * @param scene defines the hosting scene
  102573. * @returns a new MultiMaterial
  102574. */
  102575. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  102576. }
  102577. }
  102578. declare module BABYLON {
  102579. /**
  102580. * Defines a subdivision inside a mesh
  102581. */
  102582. export class SubMesh implements ICullable {
  102583. /** the material index to use */
  102584. materialIndex: number;
  102585. /** vertex index start */
  102586. verticesStart: number;
  102587. /** vertices count */
  102588. verticesCount: number;
  102589. /** index start */
  102590. indexStart: number;
  102591. /** indices count */
  102592. indexCount: number;
  102593. /** @hidden */
  102594. _materialDefines: Nullable<MaterialDefines>;
  102595. /** @hidden */
  102596. _materialEffect: Nullable<Effect>;
  102597. /** @hidden */
  102598. _effectOverride: Nullable<Effect>;
  102599. /**
  102600. * Gets material defines used by the effect associated to the sub mesh
  102601. */
  102602. get materialDefines(): Nullable<MaterialDefines>;
  102603. /**
  102604. * Sets material defines used by the effect associated to the sub mesh
  102605. */
  102606. set materialDefines(defines: Nullable<MaterialDefines>);
  102607. /**
  102608. * Gets associated effect
  102609. */
  102610. get effect(): Nullable<Effect>;
  102611. /**
  102612. * Sets associated effect (effect used to render this submesh)
  102613. * @param effect defines the effect to associate with
  102614. * @param defines defines the set of defines used to compile this effect
  102615. */
  102616. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  102617. /** @hidden */
  102618. _linesIndexCount: number;
  102619. private _mesh;
  102620. private _renderingMesh;
  102621. private _boundingInfo;
  102622. private _linesIndexBuffer;
  102623. /** @hidden */
  102624. _lastColliderWorldVertices: Nullable<Vector3[]>;
  102625. /** @hidden */
  102626. _trianglePlanes: Plane[];
  102627. /** @hidden */
  102628. _lastColliderTransformMatrix: Nullable<Matrix>;
  102629. /** @hidden */
  102630. _renderId: number;
  102631. /** @hidden */
  102632. _alphaIndex: number;
  102633. /** @hidden */
  102634. _distanceToCamera: number;
  102635. /** @hidden */
  102636. _id: number;
  102637. private _currentMaterial;
  102638. /**
  102639. * Add a new submesh to a mesh
  102640. * @param materialIndex defines the material index to use
  102641. * @param verticesStart defines vertex index start
  102642. * @param verticesCount defines vertices count
  102643. * @param indexStart defines index start
  102644. * @param indexCount defines indices count
  102645. * @param mesh defines the parent mesh
  102646. * @param renderingMesh defines an optional rendering mesh
  102647. * @param createBoundingBox defines if bounding box should be created for this submesh
  102648. * @returns the new submesh
  102649. */
  102650. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  102651. /**
  102652. * Creates a new submesh
  102653. * @param materialIndex defines the material index to use
  102654. * @param verticesStart defines vertex index start
  102655. * @param verticesCount defines vertices count
  102656. * @param indexStart defines index start
  102657. * @param indexCount defines indices count
  102658. * @param mesh defines the parent mesh
  102659. * @param renderingMesh defines an optional rendering mesh
  102660. * @param createBoundingBox defines if bounding box should be created for this submesh
  102661. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  102662. */
  102663. constructor(
  102664. /** the material index to use */
  102665. materialIndex: number,
  102666. /** vertex index start */
  102667. verticesStart: number,
  102668. /** vertices count */
  102669. verticesCount: number,
  102670. /** index start */
  102671. indexStart: number,
  102672. /** indices count */
  102673. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  102674. /**
  102675. * Returns true if this submesh covers the entire parent mesh
  102676. * @ignorenaming
  102677. */
  102678. get IsGlobal(): boolean;
  102679. /**
  102680. * Returns the submesh BoudingInfo object
  102681. * @returns current bounding info (or mesh's one if the submesh is global)
  102682. */
  102683. getBoundingInfo(): BoundingInfo;
  102684. /**
  102685. * Sets the submesh BoundingInfo
  102686. * @param boundingInfo defines the new bounding info to use
  102687. * @returns the SubMesh
  102688. */
  102689. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  102690. /**
  102691. * Returns the mesh of the current submesh
  102692. * @return the parent mesh
  102693. */
  102694. getMesh(): AbstractMesh;
  102695. /**
  102696. * Returns the rendering mesh of the submesh
  102697. * @returns the rendering mesh (could be different from parent mesh)
  102698. */
  102699. getRenderingMesh(): Mesh;
  102700. /**
  102701. * Returns the replacement mesh of the submesh
  102702. * @returns the replacement mesh (could be different from parent mesh)
  102703. */
  102704. getReplacementMesh(): Nullable<AbstractMesh>;
  102705. /**
  102706. * Returns the effective mesh of the submesh
  102707. * @returns the effective mesh (could be different from parent mesh)
  102708. */
  102709. getEffectiveMesh(): AbstractMesh;
  102710. /**
  102711. * Returns the submesh material
  102712. * @returns null or the current material
  102713. */
  102714. getMaterial(): Nullable<Material>;
  102715. private _IsMultiMaterial;
  102716. /**
  102717. * Sets a new updated BoundingInfo object to the submesh
  102718. * @param data defines an optional position array to use to determine the bounding info
  102719. * @returns the SubMesh
  102720. */
  102721. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  102722. /** @hidden */
  102723. _checkCollision(collider: Collider): boolean;
  102724. /**
  102725. * Updates the submesh BoundingInfo
  102726. * @param world defines the world matrix to use to update the bounding info
  102727. * @returns the submesh
  102728. */
  102729. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  102730. /**
  102731. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  102732. * @param frustumPlanes defines the frustum planes
  102733. * @returns true if the submesh is intersecting with the frustum
  102734. */
  102735. isInFrustum(frustumPlanes: Plane[]): boolean;
  102736. /**
  102737. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  102738. * @param frustumPlanes defines the frustum planes
  102739. * @returns true if the submesh is inside the frustum
  102740. */
  102741. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102742. /**
  102743. * Renders the submesh
  102744. * @param enableAlphaMode defines if alpha needs to be used
  102745. * @returns the submesh
  102746. */
  102747. render(enableAlphaMode: boolean): SubMesh;
  102748. /**
  102749. * @hidden
  102750. */
  102751. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  102752. /**
  102753. * Checks if the submesh intersects with a ray
  102754. * @param ray defines the ray to test
  102755. * @returns true is the passed ray intersects the submesh bounding box
  102756. */
  102757. canIntersects(ray: Ray): boolean;
  102758. /**
  102759. * Intersects current submesh with a ray
  102760. * @param ray defines the ray to test
  102761. * @param positions defines mesh's positions array
  102762. * @param indices defines mesh's indices array
  102763. * @param fastCheck defines if the first intersection will be used (and not the closest)
  102764. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102765. * @returns intersection info or null if no intersection
  102766. */
  102767. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  102768. /** @hidden */
  102769. private _intersectLines;
  102770. /** @hidden */
  102771. private _intersectUnIndexedLines;
  102772. /** @hidden */
  102773. private _intersectTriangles;
  102774. /** @hidden */
  102775. private _intersectUnIndexedTriangles;
  102776. /** @hidden */
  102777. _rebuild(): void;
  102778. /**
  102779. * Creates a new submesh from the passed mesh
  102780. * @param newMesh defines the new hosting mesh
  102781. * @param newRenderingMesh defines an optional rendering mesh
  102782. * @returns the new submesh
  102783. */
  102784. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  102785. /**
  102786. * Release associated resources
  102787. */
  102788. dispose(): void;
  102789. /**
  102790. * Gets the class name
  102791. * @returns the string "SubMesh".
  102792. */
  102793. getClassName(): string;
  102794. /**
  102795. * Creates a new submesh from indices data
  102796. * @param materialIndex the index of the main mesh material
  102797. * @param startIndex the index where to start the copy in the mesh indices array
  102798. * @param indexCount the number of indices to copy then from the startIndex
  102799. * @param mesh the main mesh to create the submesh from
  102800. * @param renderingMesh the optional rendering mesh
  102801. * @returns a new submesh
  102802. */
  102803. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  102804. }
  102805. }
  102806. declare module BABYLON {
  102807. /**
  102808. * Class used to represent data loading progression
  102809. */
  102810. export class SceneLoaderFlags {
  102811. private static _ForceFullSceneLoadingForIncremental;
  102812. private static _ShowLoadingScreen;
  102813. private static _CleanBoneMatrixWeights;
  102814. private static _loggingLevel;
  102815. /**
  102816. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  102817. */
  102818. static get ForceFullSceneLoadingForIncremental(): boolean;
  102819. static set ForceFullSceneLoadingForIncremental(value: boolean);
  102820. /**
  102821. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  102822. */
  102823. static get ShowLoadingScreen(): boolean;
  102824. static set ShowLoadingScreen(value: boolean);
  102825. /**
  102826. * Defines the current logging level (while loading the scene)
  102827. * @ignorenaming
  102828. */
  102829. static get loggingLevel(): number;
  102830. static set loggingLevel(value: number);
  102831. /**
  102832. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  102833. */
  102834. static get CleanBoneMatrixWeights(): boolean;
  102835. static set CleanBoneMatrixWeights(value: boolean);
  102836. }
  102837. }
  102838. declare module BABYLON {
  102839. /**
  102840. * Class used to store geometry data (vertex buffers + index buffer)
  102841. */
  102842. export class Geometry implements IGetSetVerticesData {
  102843. /**
  102844. * Gets or sets the ID of the geometry
  102845. */
  102846. id: string;
  102847. /**
  102848. * Gets or sets the unique ID of the geometry
  102849. */
  102850. uniqueId: number;
  102851. /**
  102852. * Gets the delay loading state of the geometry (none by default which means not delayed)
  102853. */
  102854. delayLoadState: number;
  102855. /**
  102856. * Gets the file containing the data to load when running in delay load state
  102857. */
  102858. delayLoadingFile: Nullable<string>;
  102859. /**
  102860. * Callback called when the geometry is updated
  102861. */
  102862. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  102863. private _scene;
  102864. private _engine;
  102865. private _meshes;
  102866. private _totalVertices;
  102867. /** @hidden */
  102868. _indices: IndicesArray;
  102869. /** @hidden */
  102870. _vertexBuffers: {
  102871. [key: string]: VertexBuffer;
  102872. };
  102873. private _isDisposed;
  102874. private _extend;
  102875. private _boundingBias;
  102876. /** @hidden */
  102877. _delayInfo: Array<string>;
  102878. private _indexBuffer;
  102879. private _indexBufferIsUpdatable;
  102880. /** @hidden */
  102881. _boundingInfo: Nullable<BoundingInfo>;
  102882. /** @hidden */
  102883. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  102884. /** @hidden */
  102885. _softwareSkinningFrameId: number;
  102886. private _vertexArrayObjects;
  102887. private _updatable;
  102888. /** @hidden */
  102889. _positions: Nullable<Vector3[]>;
  102890. /**
  102891. * 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
  102892. */
  102893. get boundingBias(): Vector2;
  102894. /**
  102895. * 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
  102896. */
  102897. set boundingBias(value: Vector2);
  102898. /**
  102899. * Static function used to attach a new empty geometry to a mesh
  102900. * @param mesh defines the mesh to attach the geometry to
  102901. * @returns the new Geometry
  102902. */
  102903. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  102904. /** Get the list of meshes using this geometry */
  102905. get meshes(): Mesh[];
  102906. /**
  102907. * 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
  102908. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  102909. */
  102910. useBoundingInfoFromGeometry: boolean;
  102911. /**
  102912. * Creates a new geometry
  102913. * @param id defines the unique ID
  102914. * @param scene defines the hosting scene
  102915. * @param vertexData defines the VertexData used to get geometry data
  102916. * @param updatable defines if geometry must be updatable (false by default)
  102917. * @param mesh defines the mesh that will be associated with the geometry
  102918. */
  102919. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  102920. /**
  102921. * Gets the current extend of the geometry
  102922. */
  102923. get extend(): {
  102924. minimum: Vector3;
  102925. maximum: Vector3;
  102926. };
  102927. /**
  102928. * Gets the hosting scene
  102929. * @returns the hosting Scene
  102930. */
  102931. getScene(): Scene;
  102932. /**
  102933. * Gets the hosting engine
  102934. * @returns the hosting Engine
  102935. */
  102936. getEngine(): Engine;
  102937. /**
  102938. * Defines if the geometry is ready to use
  102939. * @returns true if the geometry is ready to be used
  102940. */
  102941. isReady(): boolean;
  102942. /**
  102943. * Gets a value indicating that the geometry should not be serialized
  102944. */
  102945. get doNotSerialize(): boolean;
  102946. /** @hidden */
  102947. _rebuild(): void;
  102948. /**
  102949. * Affects all geometry data in one call
  102950. * @param vertexData defines the geometry data
  102951. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  102952. */
  102953. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  102954. /**
  102955. * Set specific vertex data
  102956. * @param kind defines the data kind (Position, normal, etc...)
  102957. * @param data defines the vertex data to use
  102958. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102959. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102960. */
  102961. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  102962. /**
  102963. * Removes a specific vertex data
  102964. * @param kind defines the data kind (Position, normal, etc...)
  102965. */
  102966. removeVerticesData(kind: string): void;
  102967. /**
  102968. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  102969. * @param buffer defines the vertex buffer to use
  102970. * @param totalVertices defines the total number of vertices for position kind (could be null)
  102971. */
  102972. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  102973. /**
  102974. * Update a specific vertex buffer
  102975. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  102976. * It will do nothing if the buffer is not updatable
  102977. * @param kind defines the data kind (Position, normal, etc...)
  102978. * @param data defines the data to use
  102979. * @param offset defines the offset in the target buffer where to store the data
  102980. * @param useBytes set to true if the offset is in bytes
  102981. */
  102982. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  102983. /**
  102984. * Update a specific vertex buffer
  102985. * This function will create a new buffer if the current one is not updatable
  102986. * @param kind defines the data kind (Position, normal, etc...)
  102987. * @param data defines the data to use
  102988. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  102989. */
  102990. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  102991. private _updateBoundingInfo;
  102992. /** @hidden */
  102993. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  102994. /**
  102995. * Gets total number of vertices
  102996. * @returns the total number of vertices
  102997. */
  102998. getTotalVertices(): number;
  102999. /**
  103000. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  103001. * @param kind defines the data kind (Position, normal, etc...)
  103002. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103003. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103004. * @returns a float array containing vertex data
  103005. */
  103006. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  103007. /**
  103008. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  103009. * @param kind defines the data kind (Position, normal, etc...)
  103010. * @returns true if the vertex buffer with the specified kind is updatable
  103011. */
  103012. isVertexBufferUpdatable(kind: string): boolean;
  103013. /**
  103014. * Gets a specific vertex buffer
  103015. * @param kind defines the data kind (Position, normal, etc...)
  103016. * @returns a VertexBuffer
  103017. */
  103018. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  103019. /**
  103020. * Returns all vertex buffers
  103021. * @return an object holding all vertex buffers indexed by kind
  103022. */
  103023. getVertexBuffers(): Nullable<{
  103024. [key: string]: VertexBuffer;
  103025. }>;
  103026. /**
  103027. * Gets a boolean indicating if specific vertex buffer is present
  103028. * @param kind defines the data kind (Position, normal, etc...)
  103029. * @returns true if data is present
  103030. */
  103031. isVerticesDataPresent(kind: string): boolean;
  103032. /**
  103033. * Gets a list of all attached data kinds (Position, normal, etc...)
  103034. * @returns a list of string containing all kinds
  103035. */
  103036. getVerticesDataKinds(): string[];
  103037. /**
  103038. * Update index buffer
  103039. * @param indices defines the indices to store in the index buffer
  103040. * @param offset defines the offset in the target buffer where to store the data
  103041. * @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)
  103042. */
  103043. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  103044. /**
  103045. * Creates a new index buffer
  103046. * @param indices defines the indices to store in the index buffer
  103047. * @param totalVertices defines the total number of vertices (could be null)
  103048. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  103049. */
  103050. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  103051. /**
  103052. * Return the total number of indices
  103053. * @returns the total number of indices
  103054. */
  103055. getTotalIndices(): number;
  103056. /**
  103057. * Gets the index buffer array
  103058. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103059. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103060. * @returns the index buffer array
  103061. */
  103062. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  103063. /**
  103064. * Gets the index buffer
  103065. * @return the index buffer
  103066. */
  103067. getIndexBuffer(): Nullable<DataBuffer>;
  103068. /** @hidden */
  103069. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  103070. /**
  103071. * Release the associated resources for a specific mesh
  103072. * @param mesh defines the source mesh
  103073. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  103074. */
  103075. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  103076. /**
  103077. * Apply current geometry to a given mesh
  103078. * @param mesh defines the mesh to apply geometry to
  103079. */
  103080. applyToMesh(mesh: Mesh): void;
  103081. private _updateExtend;
  103082. private _applyToMesh;
  103083. private notifyUpdate;
  103084. /**
  103085. * Load the geometry if it was flagged as delay loaded
  103086. * @param scene defines the hosting scene
  103087. * @param onLoaded defines a callback called when the geometry is loaded
  103088. */
  103089. load(scene: Scene, onLoaded?: () => void): void;
  103090. private _queueLoad;
  103091. /**
  103092. * Invert the geometry to move from a right handed system to a left handed one.
  103093. */
  103094. toLeftHanded(): void;
  103095. /** @hidden */
  103096. _resetPointsArrayCache(): void;
  103097. /** @hidden */
  103098. _generatePointsArray(): boolean;
  103099. /**
  103100. * Gets a value indicating if the geometry is disposed
  103101. * @returns true if the geometry was disposed
  103102. */
  103103. isDisposed(): boolean;
  103104. private _disposeVertexArrayObjects;
  103105. /**
  103106. * Free all associated resources
  103107. */
  103108. dispose(): void;
  103109. /**
  103110. * Clone the current geometry into a new geometry
  103111. * @param id defines the unique ID of the new geometry
  103112. * @returns a new geometry object
  103113. */
  103114. copy(id: string): Geometry;
  103115. /**
  103116. * Serialize the current geometry info (and not the vertices data) into a JSON object
  103117. * @return a JSON representation of the current geometry data (without the vertices data)
  103118. */
  103119. serialize(): any;
  103120. private toNumberArray;
  103121. /**
  103122. * Serialize all vertices data into a JSON oject
  103123. * @returns a JSON representation of the current geometry data
  103124. */
  103125. serializeVerticeData(): any;
  103126. /**
  103127. * Extracts a clone of a mesh geometry
  103128. * @param mesh defines the source mesh
  103129. * @param id defines the unique ID of the new geometry object
  103130. * @returns the new geometry object
  103131. */
  103132. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  103133. /**
  103134. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  103135. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103136. * Be aware Math.random() could cause collisions, but:
  103137. * "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"
  103138. * @returns a string containing a new GUID
  103139. */
  103140. static RandomId(): string;
  103141. /** @hidden */
  103142. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  103143. private static _CleanMatricesWeights;
  103144. /**
  103145. * Create a new geometry from persisted data (Using .babylon file format)
  103146. * @param parsedVertexData defines the persisted data
  103147. * @param scene defines the hosting scene
  103148. * @param rootUrl defines the root url to use to load assets (like delayed data)
  103149. * @returns the new geometry object
  103150. */
  103151. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  103152. }
  103153. }
  103154. declare module BABYLON {
  103155. /**
  103156. * Define an interface for all classes that will get and set the data on vertices
  103157. */
  103158. export interface IGetSetVerticesData {
  103159. /**
  103160. * Gets a boolean indicating if specific vertex data is present
  103161. * @param kind defines the vertex data kind to use
  103162. * @returns true is data kind is present
  103163. */
  103164. isVerticesDataPresent(kind: string): boolean;
  103165. /**
  103166. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  103167. * @param kind defines the data kind (Position, normal, etc...)
  103168. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103169. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103170. * @returns a float array containing vertex data
  103171. */
  103172. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  103173. /**
  103174. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  103175. * @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.
  103176. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103177. * @returns the indices array or an empty array if the mesh has no geometry
  103178. */
  103179. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  103180. /**
  103181. * Set specific vertex data
  103182. * @param kind defines the data kind (Position, normal, etc...)
  103183. * @param data defines the vertex data to use
  103184. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  103185. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  103186. */
  103187. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  103188. /**
  103189. * Update a specific associated vertex buffer
  103190. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  103191. * - VertexBuffer.PositionKind
  103192. * - VertexBuffer.UVKind
  103193. * - VertexBuffer.UV2Kind
  103194. * - VertexBuffer.UV3Kind
  103195. * - VertexBuffer.UV4Kind
  103196. * - VertexBuffer.UV5Kind
  103197. * - VertexBuffer.UV6Kind
  103198. * - VertexBuffer.ColorKind
  103199. * - VertexBuffer.MatricesIndicesKind
  103200. * - VertexBuffer.MatricesIndicesExtraKind
  103201. * - VertexBuffer.MatricesWeightsKind
  103202. * - VertexBuffer.MatricesWeightsExtraKind
  103203. * @param data defines the data source
  103204. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  103205. * @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)
  103206. */
  103207. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  103208. /**
  103209. * Creates a new index buffer
  103210. * @param indices defines the indices to store in the index buffer
  103211. * @param totalVertices defines the total number of vertices (could be null)
  103212. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  103213. */
  103214. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  103215. }
  103216. /**
  103217. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  103218. */
  103219. export class VertexData {
  103220. /**
  103221. * Mesh side orientation : usually the external or front surface
  103222. */
  103223. static readonly FRONTSIDE: number;
  103224. /**
  103225. * Mesh side orientation : usually the internal or back surface
  103226. */
  103227. static readonly BACKSIDE: number;
  103228. /**
  103229. * Mesh side orientation : both internal and external or front and back surfaces
  103230. */
  103231. static readonly DOUBLESIDE: number;
  103232. /**
  103233. * Mesh side orientation : by default, `FRONTSIDE`
  103234. */
  103235. static readonly DEFAULTSIDE: number;
  103236. /**
  103237. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  103238. */
  103239. positions: Nullable<FloatArray>;
  103240. /**
  103241. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  103242. */
  103243. normals: Nullable<FloatArray>;
  103244. /**
  103245. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  103246. */
  103247. tangents: Nullable<FloatArray>;
  103248. /**
  103249. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103250. */
  103251. uvs: Nullable<FloatArray>;
  103252. /**
  103253. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103254. */
  103255. uvs2: Nullable<FloatArray>;
  103256. /**
  103257. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103258. */
  103259. uvs3: Nullable<FloatArray>;
  103260. /**
  103261. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103262. */
  103263. uvs4: Nullable<FloatArray>;
  103264. /**
  103265. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103266. */
  103267. uvs5: Nullable<FloatArray>;
  103268. /**
  103269. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103270. */
  103271. uvs6: Nullable<FloatArray>;
  103272. /**
  103273. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  103274. */
  103275. colors: Nullable<FloatArray>;
  103276. /**
  103277. * 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).
  103278. */
  103279. matricesIndices: Nullable<FloatArray>;
  103280. /**
  103281. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  103282. */
  103283. matricesWeights: Nullable<FloatArray>;
  103284. /**
  103285. * An array extending the number of possible indices
  103286. */
  103287. matricesIndicesExtra: Nullable<FloatArray>;
  103288. /**
  103289. * An array extending the number of possible weights when the number of indices is extended
  103290. */
  103291. matricesWeightsExtra: Nullable<FloatArray>;
  103292. /**
  103293. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  103294. */
  103295. indices: Nullable<IndicesArray>;
  103296. /**
  103297. * Uses the passed data array to set the set the values for the specified kind of data
  103298. * @param data a linear array of floating numbers
  103299. * @param kind the type of data that is being set, eg positions, colors etc
  103300. */
  103301. set(data: FloatArray, kind: string): void;
  103302. /**
  103303. * Associates the vertexData to the passed Mesh.
  103304. * Sets it as updatable or not (default `false`)
  103305. * @param mesh the mesh the vertexData is applied to
  103306. * @param updatable when used and having the value true allows new data to update the vertexData
  103307. * @returns the VertexData
  103308. */
  103309. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  103310. /**
  103311. * Associates the vertexData to the passed Geometry.
  103312. * Sets it as updatable or not (default `false`)
  103313. * @param geometry the geometry the vertexData is applied to
  103314. * @param updatable when used and having the value true allows new data to update the vertexData
  103315. * @returns VertexData
  103316. */
  103317. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  103318. /**
  103319. * Updates the associated mesh
  103320. * @param mesh the mesh to be updated
  103321. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  103322. * @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
  103323. * @returns VertexData
  103324. */
  103325. updateMesh(mesh: Mesh): VertexData;
  103326. /**
  103327. * Updates the associated geometry
  103328. * @param geometry the geometry to be updated
  103329. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  103330. * @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
  103331. * @returns VertexData.
  103332. */
  103333. updateGeometry(geometry: Geometry): VertexData;
  103334. private _applyTo;
  103335. private _update;
  103336. /**
  103337. * Transforms each position and each normal of the vertexData according to the passed Matrix
  103338. * @param matrix the transforming matrix
  103339. * @returns the VertexData
  103340. */
  103341. transform(matrix: Matrix): VertexData;
  103342. /**
  103343. * Merges the passed VertexData into the current one
  103344. * @param other the VertexData to be merged into the current one
  103345. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  103346. * @returns the modified VertexData
  103347. */
  103348. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  103349. private _mergeElement;
  103350. private _validate;
  103351. /**
  103352. * Serializes the VertexData
  103353. * @returns a serialized object
  103354. */
  103355. serialize(): any;
  103356. /**
  103357. * Extracts the vertexData from a mesh
  103358. * @param mesh the mesh from which to extract the VertexData
  103359. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  103360. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  103361. * @returns the object VertexData associated to the passed mesh
  103362. */
  103363. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  103364. /**
  103365. * Extracts the vertexData from the geometry
  103366. * @param geometry the geometry from which to extract the VertexData
  103367. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  103368. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  103369. * @returns the object VertexData associated to the passed mesh
  103370. */
  103371. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  103372. private static _ExtractFrom;
  103373. /**
  103374. * Creates the VertexData for a Ribbon
  103375. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  103376. * * pathArray array of paths, each of which an array of successive Vector3
  103377. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  103378. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  103379. * * 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
  103380. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103381. * * 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)
  103382. * * 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)
  103383. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  103384. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  103385. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  103386. * @returns the VertexData of the ribbon
  103387. */
  103388. static CreateRibbon(options: {
  103389. pathArray: Vector3[][];
  103390. closeArray?: boolean;
  103391. closePath?: boolean;
  103392. offset?: number;
  103393. sideOrientation?: number;
  103394. frontUVs?: Vector4;
  103395. backUVs?: Vector4;
  103396. invertUV?: boolean;
  103397. uvs?: Vector2[];
  103398. colors?: Color4[];
  103399. }): VertexData;
  103400. /**
  103401. * Creates the VertexData for a box
  103402. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103403. * * size sets the width, height and depth of the box to the value of size, optional default 1
  103404. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  103405. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  103406. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  103407. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103408. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103409. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103410. * * 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)
  103411. * * 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)
  103412. * @returns the VertexData of the box
  103413. */
  103414. static CreateBox(options: {
  103415. size?: number;
  103416. width?: number;
  103417. height?: number;
  103418. depth?: number;
  103419. faceUV?: Vector4[];
  103420. faceColors?: Color4[];
  103421. sideOrientation?: number;
  103422. frontUVs?: Vector4;
  103423. backUVs?: Vector4;
  103424. }): VertexData;
  103425. /**
  103426. * Creates the VertexData for a tiled box
  103427. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103428. * * faceTiles sets the pattern, tile size and number of tiles for a face
  103429. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103430. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103431. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103432. * @returns the VertexData of the box
  103433. */
  103434. static CreateTiledBox(options: {
  103435. pattern?: number;
  103436. width?: number;
  103437. height?: number;
  103438. depth?: number;
  103439. tileSize?: number;
  103440. tileWidth?: number;
  103441. tileHeight?: number;
  103442. alignHorizontal?: number;
  103443. alignVertical?: number;
  103444. faceUV?: Vector4[];
  103445. faceColors?: Color4[];
  103446. sideOrientation?: number;
  103447. }): VertexData;
  103448. /**
  103449. * Creates the VertexData for a tiled plane
  103450. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103451. * * pattern a limited pattern arrangement depending on the number
  103452. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  103453. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  103454. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  103455. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103456. * * 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)
  103457. * * 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)
  103458. * @returns the VertexData of the tiled plane
  103459. */
  103460. static CreateTiledPlane(options: {
  103461. pattern?: number;
  103462. tileSize?: number;
  103463. tileWidth?: number;
  103464. tileHeight?: number;
  103465. size?: number;
  103466. width?: number;
  103467. height?: number;
  103468. alignHorizontal?: number;
  103469. alignVertical?: number;
  103470. sideOrientation?: number;
  103471. frontUVs?: Vector4;
  103472. backUVs?: Vector4;
  103473. }): VertexData;
  103474. /**
  103475. * Creates the VertexData for an ellipsoid, defaults to a sphere
  103476. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103477. * * segments sets the number of horizontal strips optional, default 32
  103478. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  103479. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  103480. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  103481. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  103482. * * 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
  103483. * * 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
  103484. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103485. * * 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)
  103486. * * 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)
  103487. * @returns the VertexData of the ellipsoid
  103488. */
  103489. static CreateSphere(options: {
  103490. segments?: number;
  103491. diameter?: number;
  103492. diameterX?: number;
  103493. diameterY?: number;
  103494. diameterZ?: number;
  103495. arc?: number;
  103496. slice?: number;
  103497. sideOrientation?: number;
  103498. frontUVs?: Vector4;
  103499. backUVs?: Vector4;
  103500. }): VertexData;
  103501. /**
  103502. * Creates the VertexData for a cylinder, cone or prism
  103503. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103504. * * height sets the height (y direction) of the cylinder, optional, default 2
  103505. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  103506. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  103507. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  103508. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103509. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  103510. * * 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
  103511. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103512. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103513. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  103514. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  103515. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103516. * * 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)
  103517. * * 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)
  103518. * @returns the VertexData of the cylinder, cone or prism
  103519. */
  103520. static CreateCylinder(options: {
  103521. height?: number;
  103522. diameterTop?: number;
  103523. diameterBottom?: number;
  103524. diameter?: number;
  103525. tessellation?: number;
  103526. subdivisions?: number;
  103527. arc?: number;
  103528. faceColors?: Color4[];
  103529. faceUV?: Vector4[];
  103530. hasRings?: boolean;
  103531. enclose?: boolean;
  103532. sideOrientation?: number;
  103533. frontUVs?: Vector4;
  103534. backUVs?: Vector4;
  103535. }): VertexData;
  103536. /**
  103537. * Creates the VertexData for a torus
  103538. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103539. * * diameter the diameter of the torus, optional default 1
  103540. * * thickness the diameter of the tube forming the torus, optional default 0.5
  103541. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103542. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103543. * * 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)
  103544. * * 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)
  103545. * @returns the VertexData of the torus
  103546. */
  103547. static CreateTorus(options: {
  103548. diameter?: number;
  103549. thickness?: number;
  103550. tessellation?: number;
  103551. sideOrientation?: number;
  103552. frontUVs?: Vector4;
  103553. backUVs?: Vector4;
  103554. }): VertexData;
  103555. /**
  103556. * Creates the VertexData of the LineSystem
  103557. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  103558. * - lines an array of lines, each line being an array of successive Vector3
  103559. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  103560. * @returns the VertexData of the LineSystem
  103561. */
  103562. static CreateLineSystem(options: {
  103563. lines: Vector3[][];
  103564. colors?: Nullable<Color4[][]>;
  103565. }): VertexData;
  103566. /**
  103567. * Create the VertexData for a DashedLines
  103568. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  103569. * - points an array successive Vector3
  103570. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  103571. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  103572. * - dashNb the intended total number of dashes, optional, default 200
  103573. * @returns the VertexData for the DashedLines
  103574. */
  103575. static CreateDashedLines(options: {
  103576. points: Vector3[];
  103577. dashSize?: number;
  103578. gapSize?: number;
  103579. dashNb?: number;
  103580. }): VertexData;
  103581. /**
  103582. * Creates the VertexData for a Ground
  103583. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103584. * - width the width (x direction) of the ground, optional, default 1
  103585. * - height the height (z direction) of the ground, optional, default 1
  103586. * - subdivisions the number of subdivisions per side, optional, default 1
  103587. * @returns the VertexData of the Ground
  103588. */
  103589. static CreateGround(options: {
  103590. width?: number;
  103591. height?: number;
  103592. subdivisions?: number;
  103593. subdivisionsX?: number;
  103594. subdivisionsY?: number;
  103595. }): VertexData;
  103596. /**
  103597. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  103598. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103599. * * xmin the ground minimum X coordinate, optional, default -1
  103600. * * zmin the ground minimum Z coordinate, optional, default -1
  103601. * * xmax the ground maximum X coordinate, optional, default 1
  103602. * * zmax the ground maximum Z coordinate, optional, default 1
  103603. * * 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}
  103604. * * 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}
  103605. * @returns the VertexData of the TiledGround
  103606. */
  103607. static CreateTiledGround(options: {
  103608. xmin: number;
  103609. zmin: number;
  103610. xmax: number;
  103611. zmax: number;
  103612. subdivisions?: {
  103613. w: number;
  103614. h: number;
  103615. };
  103616. precision?: {
  103617. w: number;
  103618. h: number;
  103619. };
  103620. }): VertexData;
  103621. /**
  103622. * Creates the VertexData of the Ground designed from a heightmap
  103623. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  103624. * * width the width (x direction) of the ground
  103625. * * height the height (z direction) of the ground
  103626. * * subdivisions the number of subdivisions per side
  103627. * * minHeight the minimum altitude on the ground, optional, default 0
  103628. * * maxHeight the maximum altitude on the ground, optional default 1
  103629. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  103630. * * buffer the array holding the image color data
  103631. * * bufferWidth the width of image
  103632. * * bufferHeight the height of image
  103633. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  103634. * @returns the VertexData of the Ground designed from a heightmap
  103635. */
  103636. static CreateGroundFromHeightMap(options: {
  103637. width: number;
  103638. height: number;
  103639. subdivisions: number;
  103640. minHeight: number;
  103641. maxHeight: number;
  103642. colorFilter: Color3;
  103643. buffer: Uint8Array;
  103644. bufferWidth: number;
  103645. bufferHeight: number;
  103646. alphaFilter: number;
  103647. }): VertexData;
  103648. /**
  103649. * Creates the VertexData for a Plane
  103650. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  103651. * * size sets the width and height of the plane to the value of size, optional default 1
  103652. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  103653. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  103654. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103655. * * 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)
  103656. * * 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)
  103657. * @returns the VertexData of the box
  103658. */
  103659. static CreatePlane(options: {
  103660. size?: number;
  103661. width?: number;
  103662. height?: number;
  103663. sideOrientation?: number;
  103664. frontUVs?: Vector4;
  103665. backUVs?: Vector4;
  103666. }): VertexData;
  103667. /**
  103668. * Creates the VertexData of the Disc or regular Polygon
  103669. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  103670. * * radius the radius of the disc, optional default 0.5
  103671. * * tessellation the number of polygon sides, optional, default 64
  103672. * * 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
  103673. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103674. * * 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)
  103675. * * 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)
  103676. * @returns the VertexData of the box
  103677. */
  103678. static CreateDisc(options: {
  103679. radius?: number;
  103680. tessellation?: number;
  103681. arc?: number;
  103682. sideOrientation?: number;
  103683. frontUVs?: Vector4;
  103684. backUVs?: Vector4;
  103685. }): VertexData;
  103686. /**
  103687. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  103688. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  103689. * @param polygon a mesh built from polygonTriangulation.build()
  103690. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103691. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103692. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103693. * @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)
  103694. * @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)
  103695. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  103696. * @returns the VertexData of the Polygon
  103697. */
  103698. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  103699. /**
  103700. * Creates the VertexData of the IcoSphere
  103701. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  103702. * * radius the radius of the IcoSphere, optional default 1
  103703. * * radiusX allows stretching in the x direction, optional, default radius
  103704. * * radiusY allows stretching in the y direction, optional, default radius
  103705. * * radiusZ allows stretching in the z direction, optional, default radius
  103706. * * flat when true creates a flat shaded mesh, optional, default true
  103707. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103709. * * 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)
  103710. * * 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)
  103711. * @returns the VertexData of the IcoSphere
  103712. */
  103713. static CreateIcoSphere(options: {
  103714. radius?: number;
  103715. radiusX?: number;
  103716. radiusY?: number;
  103717. radiusZ?: number;
  103718. flat?: boolean;
  103719. subdivisions?: number;
  103720. sideOrientation?: number;
  103721. frontUVs?: Vector4;
  103722. backUVs?: Vector4;
  103723. }): VertexData;
  103724. /**
  103725. * Creates the VertexData for a Polyhedron
  103726. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  103727. * * type provided types are:
  103728. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  103729. * * 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)
  103730. * * size the size of the IcoSphere, optional default 1
  103731. * * sizeX allows stretching in the x direction, optional, default size
  103732. * * sizeY allows stretching in the y direction, optional, default size
  103733. * * sizeZ allows stretching in the z direction, optional, default size
  103734. * * 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
  103735. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103736. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103737. * * flat when true creates a flat shaded mesh, optional, default true
  103738. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103739. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103740. * * 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)
  103741. * * 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)
  103742. * @returns the VertexData of the Polyhedron
  103743. */
  103744. static CreatePolyhedron(options: {
  103745. type?: number;
  103746. size?: number;
  103747. sizeX?: number;
  103748. sizeY?: number;
  103749. sizeZ?: number;
  103750. custom?: any;
  103751. faceUV?: Vector4[];
  103752. faceColors?: Color4[];
  103753. flat?: boolean;
  103754. sideOrientation?: number;
  103755. frontUVs?: Vector4;
  103756. backUVs?: Vector4;
  103757. }): VertexData;
  103758. /**
  103759. * Creates the VertexData for a TorusKnot
  103760. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  103761. * * radius the radius of the torus knot, optional, default 2
  103762. * * tube the thickness of the tube, optional, default 0.5
  103763. * * radialSegments the number of sides on each tube segments, optional, default 32
  103764. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  103765. * * p the number of windings around the z axis, optional, default 2
  103766. * * q the number of windings around the x axis, optional, default 3
  103767. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103768. * * 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)
  103769. * * 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)
  103770. * @returns the VertexData of the Torus Knot
  103771. */
  103772. static CreateTorusKnot(options: {
  103773. radius?: number;
  103774. tube?: number;
  103775. radialSegments?: number;
  103776. tubularSegments?: number;
  103777. p?: number;
  103778. q?: number;
  103779. sideOrientation?: number;
  103780. frontUVs?: Vector4;
  103781. backUVs?: Vector4;
  103782. }): VertexData;
  103783. /**
  103784. * Compute normals for given positions and indices
  103785. * @param positions an array of vertex positions, [...., x, y, z, ......]
  103786. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  103787. * @param normals an array of vertex normals, [...., x, y, z, ......]
  103788. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  103789. * * facetNormals : optional array of facet normals (vector3)
  103790. * * facetPositions : optional array of facet positions (vector3)
  103791. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  103792. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  103793. * * bInfo : optional bounding info, required for facetPartitioning computation
  103794. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  103795. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  103796. * * useRightHandedSystem: optional boolean to for right handed system computation
  103797. * * depthSort : optional boolean to enable the facet depth sort computation
  103798. * * distanceTo : optional Vector3 to compute the facet depth from this location
  103799. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  103800. */
  103801. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  103802. facetNormals?: any;
  103803. facetPositions?: any;
  103804. facetPartitioning?: any;
  103805. ratio?: number;
  103806. bInfo?: any;
  103807. bbSize?: Vector3;
  103808. subDiv?: any;
  103809. useRightHandedSystem?: boolean;
  103810. depthSort?: boolean;
  103811. distanceTo?: Vector3;
  103812. depthSortedFacets?: any;
  103813. }): void;
  103814. /** @hidden */
  103815. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  103816. /**
  103817. * Applies VertexData created from the imported parameters to the geometry
  103818. * @param parsedVertexData the parsed data from an imported file
  103819. * @param geometry the geometry to apply the VertexData to
  103820. */
  103821. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  103822. }
  103823. }
  103824. declare module BABYLON {
  103825. /**
  103826. * Defines a target to use with MorphTargetManager
  103827. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103828. */
  103829. export class MorphTarget implements IAnimatable {
  103830. /** defines the name of the target */
  103831. name: string;
  103832. /**
  103833. * Gets or sets the list of animations
  103834. */
  103835. animations: Animation[];
  103836. private _scene;
  103837. private _positions;
  103838. private _normals;
  103839. private _tangents;
  103840. private _uvs;
  103841. private _influence;
  103842. private _uniqueId;
  103843. /**
  103844. * Observable raised when the influence changes
  103845. */
  103846. onInfluenceChanged: Observable<boolean>;
  103847. /** @hidden */
  103848. _onDataLayoutChanged: Observable<void>;
  103849. /**
  103850. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  103851. */
  103852. get influence(): number;
  103853. set influence(influence: number);
  103854. /**
  103855. * Gets or sets the id of the morph Target
  103856. */
  103857. id: string;
  103858. private _animationPropertiesOverride;
  103859. /**
  103860. * Gets or sets the animation properties override
  103861. */
  103862. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103863. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103864. /**
  103865. * Creates a new MorphTarget
  103866. * @param name defines the name of the target
  103867. * @param influence defines the influence to use
  103868. * @param scene defines the scene the morphtarget belongs to
  103869. */
  103870. constructor(
  103871. /** defines the name of the target */
  103872. name: string, influence?: number, scene?: Nullable<Scene>);
  103873. /**
  103874. * Gets the unique ID of this manager
  103875. */
  103876. get uniqueId(): number;
  103877. /**
  103878. * Gets a boolean defining if the target contains position data
  103879. */
  103880. get hasPositions(): boolean;
  103881. /**
  103882. * Gets a boolean defining if the target contains normal data
  103883. */
  103884. get hasNormals(): boolean;
  103885. /**
  103886. * Gets a boolean defining if the target contains tangent data
  103887. */
  103888. get hasTangents(): boolean;
  103889. /**
  103890. * Gets a boolean defining if the target contains texture coordinates data
  103891. */
  103892. get hasUVs(): boolean;
  103893. /**
  103894. * Affects position data to this target
  103895. * @param data defines the position data to use
  103896. */
  103897. setPositions(data: Nullable<FloatArray>): void;
  103898. /**
  103899. * Gets the position data stored in this target
  103900. * @returns a FloatArray containing the position data (or null if not present)
  103901. */
  103902. getPositions(): Nullable<FloatArray>;
  103903. /**
  103904. * Affects normal data to this target
  103905. * @param data defines the normal data to use
  103906. */
  103907. setNormals(data: Nullable<FloatArray>): void;
  103908. /**
  103909. * Gets the normal data stored in this target
  103910. * @returns a FloatArray containing the normal data (or null if not present)
  103911. */
  103912. getNormals(): Nullable<FloatArray>;
  103913. /**
  103914. * Affects tangent data to this target
  103915. * @param data defines the tangent data to use
  103916. */
  103917. setTangents(data: Nullable<FloatArray>): void;
  103918. /**
  103919. * Gets the tangent data stored in this target
  103920. * @returns a FloatArray containing the tangent data (or null if not present)
  103921. */
  103922. getTangents(): Nullable<FloatArray>;
  103923. /**
  103924. * Affects texture coordinates data to this target
  103925. * @param data defines the texture coordinates data to use
  103926. */
  103927. setUVs(data: Nullable<FloatArray>): void;
  103928. /**
  103929. * Gets the texture coordinates data stored in this target
  103930. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  103931. */
  103932. getUVs(): Nullable<FloatArray>;
  103933. /**
  103934. * Clone the current target
  103935. * @returns a new MorphTarget
  103936. */
  103937. clone(): MorphTarget;
  103938. /**
  103939. * Serializes the current target into a Serialization object
  103940. * @returns the serialized object
  103941. */
  103942. serialize(): any;
  103943. /**
  103944. * Returns the string "MorphTarget"
  103945. * @returns "MorphTarget"
  103946. */
  103947. getClassName(): string;
  103948. /**
  103949. * Creates a new target from serialized data
  103950. * @param serializationObject defines the serialized data to use
  103951. * @returns a new MorphTarget
  103952. */
  103953. static Parse(serializationObject: any): MorphTarget;
  103954. /**
  103955. * Creates a MorphTarget from mesh data
  103956. * @param mesh defines the source mesh
  103957. * @param name defines the name to use for the new target
  103958. * @param influence defines the influence to attach to the target
  103959. * @returns a new MorphTarget
  103960. */
  103961. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  103962. }
  103963. }
  103964. declare module BABYLON {
  103965. /**
  103966. * This class is used to deform meshes using morphing between different targets
  103967. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103968. */
  103969. export class MorphTargetManager {
  103970. private _targets;
  103971. private _targetInfluenceChangedObservers;
  103972. private _targetDataLayoutChangedObservers;
  103973. private _activeTargets;
  103974. private _scene;
  103975. private _influences;
  103976. private _supportsNormals;
  103977. private _supportsTangents;
  103978. private _supportsUVs;
  103979. private _vertexCount;
  103980. private _uniqueId;
  103981. private _tempInfluences;
  103982. /**
  103983. * Gets or sets a boolean indicating if normals must be morphed
  103984. */
  103985. enableNormalMorphing: boolean;
  103986. /**
  103987. * Gets or sets a boolean indicating if tangents must be morphed
  103988. */
  103989. enableTangentMorphing: boolean;
  103990. /**
  103991. * Gets or sets a boolean indicating if UV must be morphed
  103992. */
  103993. enableUVMorphing: boolean;
  103994. /**
  103995. * Creates a new MorphTargetManager
  103996. * @param scene defines the current scene
  103997. */
  103998. constructor(scene?: Nullable<Scene>);
  103999. /**
  104000. * Gets the unique ID of this manager
  104001. */
  104002. get uniqueId(): number;
  104003. /**
  104004. * Gets the number of vertices handled by this manager
  104005. */
  104006. get vertexCount(): number;
  104007. /**
  104008. * Gets a boolean indicating if this manager supports morphing of normals
  104009. */
  104010. get supportsNormals(): boolean;
  104011. /**
  104012. * Gets a boolean indicating if this manager supports morphing of tangents
  104013. */
  104014. get supportsTangents(): boolean;
  104015. /**
  104016. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  104017. */
  104018. get supportsUVs(): boolean;
  104019. /**
  104020. * Gets the number of targets stored in this manager
  104021. */
  104022. get numTargets(): number;
  104023. /**
  104024. * Gets the number of influencers (ie. the number of targets with influences > 0)
  104025. */
  104026. get numInfluencers(): number;
  104027. /**
  104028. * Gets the list of influences (one per target)
  104029. */
  104030. get influences(): Float32Array;
  104031. /**
  104032. * Gets the active target at specified index. An active target is a target with an influence > 0
  104033. * @param index defines the index to check
  104034. * @returns the requested target
  104035. */
  104036. getActiveTarget(index: number): MorphTarget;
  104037. /**
  104038. * Gets the target at specified index
  104039. * @param index defines the index to check
  104040. * @returns the requested target
  104041. */
  104042. getTarget(index: number): MorphTarget;
  104043. /**
  104044. * Add a new target to this manager
  104045. * @param target defines the target to add
  104046. */
  104047. addTarget(target: MorphTarget): void;
  104048. /**
  104049. * Removes a target from the manager
  104050. * @param target defines the target to remove
  104051. */
  104052. removeTarget(target: MorphTarget): void;
  104053. /**
  104054. * Clone the current manager
  104055. * @returns a new MorphTargetManager
  104056. */
  104057. clone(): MorphTargetManager;
  104058. /**
  104059. * Serializes the current manager into a Serialization object
  104060. * @returns the serialized object
  104061. */
  104062. serialize(): any;
  104063. private _syncActiveTargets;
  104064. /**
  104065. * Syncrhonize the targets with all the meshes using this morph target manager
  104066. */
  104067. synchronize(): void;
  104068. /**
  104069. * Creates a new MorphTargetManager from serialized data
  104070. * @param serializationObject defines the serialized data
  104071. * @param scene defines the hosting scene
  104072. * @returns the new MorphTargetManager
  104073. */
  104074. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  104075. }
  104076. }
  104077. declare module BABYLON {
  104078. /**
  104079. * Class used to represent a specific level of detail of a mesh
  104080. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104081. */
  104082. export class MeshLODLevel {
  104083. /** Defines the distance where this level should start being displayed */
  104084. distance: number;
  104085. /** Defines the mesh to use to render this level */
  104086. mesh: Nullable<Mesh>;
  104087. /**
  104088. * Creates a new LOD level
  104089. * @param distance defines the distance where this level should star being displayed
  104090. * @param mesh defines the mesh to use to render this level
  104091. */
  104092. constructor(
  104093. /** Defines the distance where this level should start being displayed */
  104094. distance: number,
  104095. /** Defines the mesh to use to render this level */
  104096. mesh: Nullable<Mesh>);
  104097. }
  104098. }
  104099. declare module BABYLON {
  104100. /**
  104101. * Helper class used to generate a canvas to manipulate images
  104102. */
  104103. export class CanvasGenerator {
  104104. /**
  104105. * Create a new canvas (or offscreen canvas depending on the context)
  104106. * @param width defines the expected width
  104107. * @param height defines the expected height
  104108. * @return a new canvas or offscreen canvas
  104109. */
  104110. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  104111. }
  104112. }
  104113. declare module BABYLON {
  104114. /**
  104115. * Mesh representing the gorund
  104116. */
  104117. export class GroundMesh extends Mesh {
  104118. /** If octree should be generated */
  104119. generateOctree: boolean;
  104120. private _heightQuads;
  104121. /** @hidden */
  104122. _subdivisionsX: number;
  104123. /** @hidden */
  104124. _subdivisionsY: number;
  104125. /** @hidden */
  104126. _width: number;
  104127. /** @hidden */
  104128. _height: number;
  104129. /** @hidden */
  104130. _minX: number;
  104131. /** @hidden */
  104132. _maxX: number;
  104133. /** @hidden */
  104134. _minZ: number;
  104135. /** @hidden */
  104136. _maxZ: number;
  104137. constructor(name: string, scene: Scene);
  104138. /**
  104139. * "GroundMesh"
  104140. * @returns "GroundMesh"
  104141. */
  104142. getClassName(): string;
  104143. /**
  104144. * The minimum of x and y subdivisions
  104145. */
  104146. get subdivisions(): number;
  104147. /**
  104148. * X subdivisions
  104149. */
  104150. get subdivisionsX(): number;
  104151. /**
  104152. * Y subdivisions
  104153. */
  104154. get subdivisionsY(): number;
  104155. /**
  104156. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  104157. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  104158. * @param chunksCount the number of subdivisions for x and y
  104159. * @param octreeBlocksSize (Default: 32)
  104160. */
  104161. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  104162. /**
  104163. * Returns a height (y) value in the Worl system :
  104164. * the ground altitude at the coordinates (x, z) expressed in the World system.
  104165. * @param x x coordinate
  104166. * @param z z coordinate
  104167. * @returns the ground y position if (x, z) are outside the ground surface.
  104168. */
  104169. getHeightAtCoordinates(x: number, z: number): number;
  104170. /**
  104171. * Returns a normalized vector (Vector3) orthogonal to the ground
  104172. * at the ground coordinates (x, z) expressed in the World system.
  104173. * @param x x coordinate
  104174. * @param z z coordinate
  104175. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  104176. */
  104177. getNormalAtCoordinates(x: number, z: number): Vector3;
  104178. /**
  104179. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  104180. * at the ground coordinates (x, z) expressed in the World system.
  104181. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  104182. * @param x x coordinate
  104183. * @param z z coordinate
  104184. * @param ref vector to store the result
  104185. * @returns the GroundMesh.
  104186. */
  104187. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  104188. /**
  104189. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  104190. * if the ground has been updated.
  104191. * This can be used in the render loop.
  104192. * @returns the GroundMesh.
  104193. */
  104194. updateCoordinateHeights(): GroundMesh;
  104195. private _getFacetAt;
  104196. private _initHeightQuads;
  104197. private _computeHeightQuads;
  104198. /**
  104199. * Serializes this ground mesh
  104200. * @param serializationObject object to write serialization to
  104201. */
  104202. serialize(serializationObject: any): void;
  104203. /**
  104204. * Parses a serialized ground mesh
  104205. * @param parsedMesh the serialized mesh
  104206. * @param scene the scene to create the ground mesh in
  104207. * @returns the created ground mesh
  104208. */
  104209. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  104210. }
  104211. }
  104212. declare module BABYLON {
  104213. /**
  104214. * Interface for Physics-Joint data
  104215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104216. */
  104217. export interface PhysicsJointData {
  104218. /**
  104219. * The main pivot of the joint
  104220. */
  104221. mainPivot?: Vector3;
  104222. /**
  104223. * The connected pivot of the joint
  104224. */
  104225. connectedPivot?: Vector3;
  104226. /**
  104227. * The main axis of the joint
  104228. */
  104229. mainAxis?: Vector3;
  104230. /**
  104231. * The connected axis of the joint
  104232. */
  104233. connectedAxis?: Vector3;
  104234. /**
  104235. * The collision of the joint
  104236. */
  104237. collision?: boolean;
  104238. /**
  104239. * Native Oimo/Cannon/Energy data
  104240. */
  104241. nativeParams?: any;
  104242. }
  104243. /**
  104244. * This is a holder class for the physics joint created by the physics plugin
  104245. * It holds a set of functions to control the underlying joint
  104246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104247. */
  104248. export class PhysicsJoint {
  104249. /**
  104250. * The type of the physics joint
  104251. */
  104252. type: number;
  104253. /**
  104254. * The data for the physics joint
  104255. */
  104256. jointData: PhysicsJointData;
  104257. private _physicsJoint;
  104258. protected _physicsPlugin: IPhysicsEnginePlugin;
  104259. /**
  104260. * Initializes the physics joint
  104261. * @param type The type of the physics joint
  104262. * @param jointData The data for the physics joint
  104263. */
  104264. constructor(
  104265. /**
  104266. * The type of the physics joint
  104267. */
  104268. type: number,
  104269. /**
  104270. * The data for the physics joint
  104271. */
  104272. jointData: PhysicsJointData);
  104273. /**
  104274. * Gets the physics joint
  104275. */
  104276. get physicsJoint(): any;
  104277. /**
  104278. * Sets the physics joint
  104279. */
  104280. set physicsJoint(newJoint: any);
  104281. /**
  104282. * Sets the physics plugin
  104283. */
  104284. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  104285. /**
  104286. * Execute a function that is physics-plugin specific.
  104287. * @param {Function} func the function that will be executed.
  104288. * It accepts two parameters: the physics world and the physics joint
  104289. */
  104290. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  104291. /**
  104292. * Distance-Joint type
  104293. */
  104294. static DistanceJoint: number;
  104295. /**
  104296. * Hinge-Joint type
  104297. */
  104298. static HingeJoint: number;
  104299. /**
  104300. * Ball-and-Socket joint type
  104301. */
  104302. static BallAndSocketJoint: number;
  104303. /**
  104304. * Wheel-Joint type
  104305. */
  104306. static WheelJoint: number;
  104307. /**
  104308. * Slider-Joint type
  104309. */
  104310. static SliderJoint: number;
  104311. /**
  104312. * Prismatic-Joint type
  104313. */
  104314. static PrismaticJoint: number;
  104315. /**
  104316. * Universal-Joint type
  104317. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  104318. */
  104319. static UniversalJoint: number;
  104320. /**
  104321. * Hinge-Joint 2 type
  104322. */
  104323. static Hinge2Joint: number;
  104324. /**
  104325. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  104326. */
  104327. static PointToPointJoint: number;
  104328. /**
  104329. * Spring-Joint type
  104330. */
  104331. static SpringJoint: number;
  104332. /**
  104333. * Lock-Joint type
  104334. */
  104335. static LockJoint: number;
  104336. }
  104337. /**
  104338. * A class representing a physics distance joint
  104339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104340. */
  104341. export class DistanceJoint extends PhysicsJoint {
  104342. /**
  104343. *
  104344. * @param jointData The data for the Distance-Joint
  104345. */
  104346. constructor(jointData: DistanceJointData);
  104347. /**
  104348. * Update the predefined distance.
  104349. * @param maxDistance The maximum preferred distance
  104350. * @param minDistance The minimum preferred distance
  104351. */
  104352. updateDistance(maxDistance: number, minDistance?: number): void;
  104353. }
  104354. /**
  104355. * Represents a Motor-Enabled Joint
  104356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104357. */
  104358. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  104359. /**
  104360. * Initializes the Motor-Enabled Joint
  104361. * @param type The type of the joint
  104362. * @param jointData The physica joint data for the joint
  104363. */
  104364. constructor(type: number, jointData: PhysicsJointData);
  104365. /**
  104366. * Set the motor values.
  104367. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104368. * @param force the force to apply
  104369. * @param maxForce max force for this motor.
  104370. */
  104371. setMotor(force?: number, maxForce?: number): void;
  104372. /**
  104373. * Set the motor's limits.
  104374. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104375. * @param upperLimit The upper limit of the motor
  104376. * @param lowerLimit The lower limit of the motor
  104377. */
  104378. setLimit(upperLimit: number, lowerLimit?: number): void;
  104379. }
  104380. /**
  104381. * This class represents a single physics Hinge-Joint
  104382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104383. */
  104384. export class HingeJoint extends MotorEnabledJoint {
  104385. /**
  104386. * Initializes the Hinge-Joint
  104387. * @param jointData The joint data for the Hinge-Joint
  104388. */
  104389. constructor(jointData: PhysicsJointData);
  104390. /**
  104391. * Set the motor values.
  104392. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104393. * @param {number} force the force to apply
  104394. * @param {number} maxForce max force for this motor.
  104395. */
  104396. setMotor(force?: number, maxForce?: number): void;
  104397. /**
  104398. * Set the motor's limits.
  104399. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104400. * @param upperLimit The upper limit of the motor
  104401. * @param lowerLimit The lower limit of the motor
  104402. */
  104403. setLimit(upperLimit: number, lowerLimit?: number): void;
  104404. }
  104405. /**
  104406. * This class represents a dual hinge physics joint (same as wheel joint)
  104407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104408. */
  104409. export class Hinge2Joint extends MotorEnabledJoint {
  104410. /**
  104411. * Initializes the Hinge2-Joint
  104412. * @param jointData The joint data for the Hinge2-Joint
  104413. */
  104414. constructor(jointData: PhysicsJointData);
  104415. /**
  104416. * Set the motor values.
  104417. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104418. * @param {number} targetSpeed the speed the motor is to reach
  104419. * @param {number} maxForce max force for this motor.
  104420. * @param {motorIndex} the motor's index, 0 or 1.
  104421. */
  104422. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  104423. /**
  104424. * Set the motor limits.
  104425. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104426. * @param {number} upperLimit the upper limit
  104427. * @param {number} lowerLimit lower limit
  104428. * @param {motorIndex} the motor's index, 0 or 1.
  104429. */
  104430. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104431. }
  104432. /**
  104433. * Interface for a motor enabled joint
  104434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104435. */
  104436. export interface IMotorEnabledJoint {
  104437. /**
  104438. * Physics joint
  104439. */
  104440. physicsJoint: any;
  104441. /**
  104442. * Sets the motor of the motor-enabled joint
  104443. * @param force The force of the motor
  104444. * @param maxForce The maximum force of the motor
  104445. * @param motorIndex The index of the motor
  104446. */
  104447. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  104448. /**
  104449. * Sets the limit of the motor
  104450. * @param upperLimit The upper limit of the motor
  104451. * @param lowerLimit The lower limit of the motor
  104452. * @param motorIndex The index of the motor
  104453. */
  104454. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104455. }
  104456. /**
  104457. * Joint data for a Distance-Joint
  104458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104459. */
  104460. export interface DistanceJointData extends PhysicsJointData {
  104461. /**
  104462. * Max distance the 2 joint objects can be apart
  104463. */
  104464. maxDistance: number;
  104465. }
  104466. /**
  104467. * Joint data from a spring joint
  104468. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104469. */
  104470. export interface SpringJointData extends PhysicsJointData {
  104471. /**
  104472. * Length of the spring
  104473. */
  104474. length: number;
  104475. /**
  104476. * Stiffness of the spring
  104477. */
  104478. stiffness: number;
  104479. /**
  104480. * Damping of the spring
  104481. */
  104482. damping: number;
  104483. /** this callback will be called when applying the force to the impostors. */
  104484. forceApplicationCallback: () => void;
  104485. }
  104486. }
  104487. declare module BABYLON {
  104488. /**
  104489. * Holds the data for the raycast result
  104490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104491. */
  104492. export class PhysicsRaycastResult {
  104493. private _hasHit;
  104494. private _hitDistance;
  104495. private _hitNormalWorld;
  104496. private _hitPointWorld;
  104497. private _rayFromWorld;
  104498. private _rayToWorld;
  104499. /**
  104500. * Gets if there was a hit
  104501. */
  104502. get hasHit(): boolean;
  104503. /**
  104504. * Gets the distance from the hit
  104505. */
  104506. get hitDistance(): number;
  104507. /**
  104508. * Gets the hit normal/direction in the world
  104509. */
  104510. get hitNormalWorld(): Vector3;
  104511. /**
  104512. * Gets the hit point in the world
  104513. */
  104514. get hitPointWorld(): Vector3;
  104515. /**
  104516. * Gets the ray "start point" of the ray in the world
  104517. */
  104518. get rayFromWorld(): Vector3;
  104519. /**
  104520. * Gets the ray "end point" of the ray in the world
  104521. */
  104522. get rayToWorld(): Vector3;
  104523. /**
  104524. * Sets the hit data (normal & point in world space)
  104525. * @param hitNormalWorld defines the normal in world space
  104526. * @param hitPointWorld defines the point in world space
  104527. */
  104528. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  104529. /**
  104530. * Sets the distance from the start point to the hit point
  104531. * @param distance
  104532. */
  104533. setHitDistance(distance: number): void;
  104534. /**
  104535. * Calculates the distance manually
  104536. */
  104537. calculateHitDistance(): void;
  104538. /**
  104539. * Resets all the values to default
  104540. * @param from The from point on world space
  104541. * @param to The to point on world space
  104542. */
  104543. reset(from?: Vector3, to?: Vector3): void;
  104544. }
  104545. /**
  104546. * Interface for the size containing width and height
  104547. */
  104548. interface IXYZ {
  104549. /**
  104550. * X
  104551. */
  104552. x: number;
  104553. /**
  104554. * Y
  104555. */
  104556. y: number;
  104557. /**
  104558. * Z
  104559. */
  104560. z: number;
  104561. }
  104562. }
  104563. declare module BABYLON {
  104564. /**
  104565. * Interface used to describe a physics joint
  104566. */
  104567. export interface PhysicsImpostorJoint {
  104568. /** Defines the main impostor to which the joint is linked */
  104569. mainImpostor: PhysicsImpostor;
  104570. /** Defines the impostor that is connected to the main impostor using this joint */
  104571. connectedImpostor: PhysicsImpostor;
  104572. /** Defines the joint itself */
  104573. joint: PhysicsJoint;
  104574. }
  104575. /** @hidden */
  104576. export interface IPhysicsEnginePlugin {
  104577. world: any;
  104578. name: string;
  104579. setGravity(gravity: Vector3): void;
  104580. setTimeStep(timeStep: number): void;
  104581. getTimeStep(): number;
  104582. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104583. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104584. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104585. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104586. removePhysicsBody(impostor: PhysicsImpostor): void;
  104587. generateJoint(joint: PhysicsImpostorJoint): void;
  104588. removeJoint(joint: PhysicsImpostorJoint): void;
  104589. isSupported(): boolean;
  104590. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104591. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104592. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104593. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104594. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104595. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104596. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104597. getBodyMass(impostor: PhysicsImpostor): number;
  104598. getBodyFriction(impostor: PhysicsImpostor): number;
  104599. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104600. getBodyRestitution(impostor: PhysicsImpostor): number;
  104601. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104602. getBodyPressure?(impostor: PhysicsImpostor): number;
  104603. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  104604. getBodyStiffness?(impostor: PhysicsImpostor): number;
  104605. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  104606. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  104607. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  104608. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  104609. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  104610. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104611. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104612. sleepBody(impostor: PhysicsImpostor): void;
  104613. wakeUpBody(impostor: PhysicsImpostor): void;
  104614. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104615. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104616. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  104617. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104618. getRadius(impostor: PhysicsImpostor): number;
  104619. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104620. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104621. dispose(): void;
  104622. }
  104623. /**
  104624. * Interface used to define a physics engine
  104625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104626. */
  104627. export interface IPhysicsEngine {
  104628. /**
  104629. * Gets the gravity vector used by the simulation
  104630. */
  104631. gravity: Vector3;
  104632. /**
  104633. * Sets the gravity vector used by the simulation
  104634. * @param gravity defines the gravity vector to use
  104635. */
  104636. setGravity(gravity: Vector3): void;
  104637. /**
  104638. * Set the time step of the physics engine.
  104639. * Default is 1/60.
  104640. * To slow it down, enter 1/600 for example.
  104641. * To speed it up, 1/30
  104642. * @param newTimeStep the new timestep to apply to this world.
  104643. */
  104644. setTimeStep(newTimeStep: number): void;
  104645. /**
  104646. * Get the time step of the physics engine.
  104647. * @returns the current time step
  104648. */
  104649. getTimeStep(): number;
  104650. /**
  104651. * Set the sub time step of the physics engine.
  104652. * Default is 0 meaning there is no sub steps
  104653. * To increase physics resolution precision, set a small value (like 1 ms)
  104654. * @param subTimeStep defines the new sub timestep used for physics resolution.
  104655. */
  104656. setSubTimeStep(subTimeStep: number): void;
  104657. /**
  104658. * Get the sub time step of the physics engine.
  104659. * @returns the current sub time step
  104660. */
  104661. getSubTimeStep(): number;
  104662. /**
  104663. * Release all resources
  104664. */
  104665. dispose(): void;
  104666. /**
  104667. * Gets the name of the current physics plugin
  104668. * @returns the name of the plugin
  104669. */
  104670. getPhysicsPluginName(): string;
  104671. /**
  104672. * Adding a new impostor for the impostor tracking.
  104673. * This will be done by the impostor itself.
  104674. * @param impostor the impostor to add
  104675. */
  104676. addImpostor(impostor: PhysicsImpostor): void;
  104677. /**
  104678. * Remove an impostor from the engine.
  104679. * This impostor and its mesh will not longer be updated by the physics engine.
  104680. * @param impostor the impostor to remove
  104681. */
  104682. removeImpostor(impostor: PhysicsImpostor): void;
  104683. /**
  104684. * Add a joint to the physics engine
  104685. * @param mainImpostor defines the main impostor to which the joint is added.
  104686. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104687. * @param joint defines the joint that will connect both impostors.
  104688. */
  104689. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104690. /**
  104691. * Removes a joint from the simulation
  104692. * @param mainImpostor defines the impostor used with the joint
  104693. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104694. * @param joint defines the joint to remove
  104695. */
  104696. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104697. /**
  104698. * Gets the current plugin used to run the simulation
  104699. * @returns current plugin
  104700. */
  104701. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104702. /**
  104703. * Gets the list of physic impostors
  104704. * @returns an array of PhysicsImpostor
  104705. */
  104706. getImpostors(): Array<PhysicsImpostor>;
  104707. /**
  104708. * Gets the impostor for a physics enabled object
  104709. * @param object defines the object impersonated by the impostor
  104710. * @returns the PhysicsImpostor or null if not found
  104711. */
  104712. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104713. /**
  104714. * Gets the impostor for a physics body object
  104715. * @param body defines physics body used by the impostor
  104716. * @returns the PhysicsImpostor or null if not found
  104717. */
  104718. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104719. /**
  104720. * Does a raycast in the physics world
  104721. * @param from when should the ray start?
  104722. * @param to when should the ray end?
  104723. * @returns PhysicsRaycastResult
  104724. */
  104725. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104726. /**
  104727. * Called by the scene. No need to call it.
  104728. * @param delta defines the timespam between frames
  104729. */
  104730. _step(delta: number): void;
  104731. }
  104732. }
  104733. declare module BABYLON {
  104734. /**
  104735. * The interface for the physics imposter parameters
  104736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104737. */
  104738. export interface PhysicsImpostorParameters {
  104739. /**
  104740. * The mass of the physics imposter
  104741. */
  104742. mass: number;
  104743. /**
  104744. * The friction of the physics imposter
  104745. */
  104746. friction?: number;
  104747. /**
  104748. * The coefficient of restitution of the physics imposter
  104749. */
  104750. restitution?: number;
  104751. /**
  104752. * The native options of the physics imposter
  104753. */
  104754. nativeOptions?: any;
  104755. /**
  104756. * Specifies if the parent should be ignored
  104757. */
  104758. ignoreParent?: boolean;
  104759. /**
  104760. * Specifies if bi-directional transformations should be disabled
  104761. */
  104762. disableBidirectionalTransformation?: boolean;
  104763. /**
  104764. * The pressure inside the physics imposter, soft object only
  104765. */
  104766. pressure?: number;
  104767. /**
  104768. * The stiffness the physics imposter, soft object only
  104769. */
  104770. stiffness?: number;
  104771. /**
  104772. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  104773. */
  104774. velocityIterations?: number;
  104775. /**
  104776. * The number of iterations used in maintaining consistent vertex positions, soft object only
  104777. */
  104778. positionIterations?: number;
  104779. /**
  104780. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  104781. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  104782. * Add to fix multiple points
  104783. */
  104784. fixedPoints?: number;
  104785. /**
  104786. * The collision margin around a soft object
  104787. */
  104788. margin?: number;
  104789. /**
  104790. * The collision margin around a soft object
  104791. */
  104792. damping?: number;
  104793. /**
  104794. * The path for a rope based on an extrusion
  104795. */
  104796. path?: any;
  104797. /**
  104798. * The shape of an extrusion used for a rope based on an extrusion
  104799. */
  104800. shape?: any;
  104801. }
  104802. /**
  104803. * Interface for a physics-enabled object
  104804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104805. */
  104806. export interface IPhysicsEnabledObject {
  104807. /**
  104808. * The position of the physics-enabled object
  104809. */
  104810. position: Vector3;
  104811. /**
  104812. * The rotation of the physics-enabled object
  104813. */
  104814. rotationQuaternion: Nullable<Quaternion>;
  104815. /**
  104816. * The scale of the physics-enabled object
  104817. */
  104818. scaling: Vector3;
  104819. /**
  104820. * The rotation of the physics-enabled object
  104821. */
  104822. rotation?: Vector3;
  104823. /**
  104824. * The parent of the physics-enabled object
  104825. */
  104826. parent?: any;
  104827. /**
  104828. * The bounding info of the physics-enabled object
  104829. * @returns The bounding info of the physics-enabled object
  104830. */
  104831. getBoundingInfo(): BoundingInfo;
  104832. /**
  104833. * Computes the world matrix
  104834. * @param force Specifies if the world matrix should be computed by force
  104835. * @returns A world matrix
  104836. */
  104837. computeWorldMatrix(force: boolean): Matrix;
  104838. /**
  104839. * Gets the world matrix
  104840. * @returns A world matrix
  104841. */
  104842. getWorldMatrix?(): Matrix;
  104843. /**
  104844. * Gets the child meshes
  104845. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  104846. * @returns An array of abstract meshes
  104847. */
  104848. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  104849. /**
  104850. * Gets the vertex data
  104851. * @param kind The type of vertex data
  104852. * @returns A nullable array of numbers, or a float32 array
  104853. */
  104854. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  104855. /**
  104856. * Gets the indices from the mesh
  104857. * @returns A nullable array of index arrays
  104858. */
  104859. getIndices?(): Nullable<IndicesArray>;
  104860. /**
  104861. * Gets the scene from the mesh
  104862. * @returns the indices array or null
  104863. */
  104864. getScene?(): Scene;
  104865. /**
  104866. * Gets the absolute position from the mesh
  104867. * @returns the absolute position
  104868. */
  104869. getAbsolutePosition(): Vector3;
  104870. /**
  104871. * Gets the absolute pivot point from the mesh
  104872. * @returns the absolute pivot point
  104873. */
  104874. getAbsolutePivotPoint(): Vector3;
  104875. /**
  104876. * Rotates the mesh
  104877. * @param axis The axis of rotation
  104878. * @param amount The amount of rotation
  104879. * @param space The space of the rotation
  104880. * @returns The rotation transform node
  104881. */
  104882. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  104883. /**
  104884. * Translates the mesh
  104885. * @param axis The axis of translation
  104886. * @param distance The distance of translation
  104887. * @param space The space of the translation
  104888. * @returns The transform node
  104889. */
  104890. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  104891. /**
  104892. * Sets the absolute position of the mesh
  104893. * @param absolutePosition The absolute position of the mesh
  104894. * @returns The transform node
  104895. */
  104896. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  104897. /**
  104898. * Gets the class name of the mesh
  104899. * @returns The class name
  104900. */
  104901. getClassName(): string;
  104902. }
  104903. /**
  104904. * Represents a physics imposter
  104905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104906. */
  104907. export class PhysicsImpostor {
  104908. /**
  104909. * The physics-enabled object used as the physics imposter
  104910. */
  104911. object: IPhysicsEnabledObject;
  104912. /**
  104913. * The type of the physics imposter
  104914. */
  104915. type: number;
  104916. private _options;
  104917. private _scene?;
  104918. /**
  104919. * The default object size of the imposter
  104920. */
  104921. static DEFAULT_OBJECT_SIZE: Vector3;
  104922. /**
  104923. * The identity quaternion of the imposter
  104924. */
  104925. static IDENTITY_QUATERNION: Quaternion;
  104926. /** @hidden */
  104927. _pluginData: any;
  104928. private _physicsEngine;
  104929. private _physicsBody;
  104930. private _bodyUpdateRequired;
  104931. private _onBeforePhysicsStepCallbacks;
  104932. private _onAfterPhysicsStepCallbacks;
  104933. /** @hidden */
  104934. _onPhysicsCollideCallbacks: Array<{
  104935. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  104936. otherImpostors: Array<PhysicsImpostor>;
  104937. }>;
  104938. private _deltaPosition;
  104939. private _deltaRotation;
  104940. private _deltaRotationConjugated;
  104941. /** @hidden */
  104942. _isFromLine: boolean;
  104943. private _parent;
  104944. private _isDisposed;
  104945. private static _tmpVecs;
  104946. private static _tmpQuat;
  104947. /**
  104948. * Specifies if the physics imposter is disposed
  104949. */
  104950. get isDisposed(): boolean;
  104951. /**
  104952. * Gets the mass of the physics imposter
  104953. */
  104954. get mass(): number;
  104955. set mass(value: number);
  104956. /**
  104957. * Gets the coefficient of friction
  104958. */
  104959. get friction(): number;
  104960. /**
  104961. * Sets the coefficient of friction
  104962. */
  104963. set friction(value: number);
  104964. /**
  104965. * Gets the coefficient of restitution
  104966. */
  104967. get restitution(): number;
  104968. /**
  104969. * Sets the coefficient of restitution
  104970. */
  104971. set restitution(value: number);
  104972. /**
  104973. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  104974. */
  104975. get pressure(): number;
  104976. /**
  104977. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  104978. */
  104979. set pressure(value: number);
  104980. /**
  104981. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104982. */
  104983. get stiffness(): number;
  104984. /**
  104985. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104986. */
  104987. set stiffness(value: number);
  104988. /**
  104989. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104990. */
  104991. get velocityIterations(): number;
  104992. /**
  104993. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104994. */
  104995. set velocityIterations(value: number);
  104996. /**
  104997. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104998. */
  104999. get positionIterations(): number;
  105000. /**
  105001. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  105002. */
  105003. set positionIterations(value: number);
  105004. /**
  105005. * The unique id of the physics imposter
  105006. * set by the physics engine when adding this impostor to the array
  105007. */
  105008. uniqueId: number;
  105009. /**
  105010. * @hidden
  105011. */
  105012. soft: boolean;
  105013. /**
  105014. * @hidden
  105015. */
  105016. segments: number;
  105017. private _joints;
  105018. /**
  105019. * Initializes the physics imposter
  105020. * @param object The physics-enabled object used as the physics imposter
  105021. * @param type The type of the physics imposter
  105022. * @param _options The options for the physics imposter
  105023. * @param _scene The Babylon scene
  105024. */
  105025. constructor(
  105026. /**
  105027. * The physics-enabled object used as the physics imposter
  105028. */
  105029. object: IPhysicsEnabledObject,
  105030. /**
  105031. * The type of the physics imposter
  105032. */
  105033. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  105034. /**
  105035. * This function will completly initialize this impostor.
  105036. * It will create a new body - but only if this mesh has no parent.
  105037. * If it has, this impostor will not be used other than to define the impostor
  105038. * of the child mesh.
  105039. * @hidden
  105040. */
  105041. _init(): void;
  105042. private _getPhysicsParent;
  105043. /**
  105044. * Should a new body be generated.
  105045. * @returns boolean specifying if body initialization is required
  105046. */
  105047. isBodyInitRequired(): boolean;
  105048. /**
  105049. * Sets the updated scaling
  105050. * @param updated Specifies if the scaling is updated
  105051. */
  105052. setScalingUpdated(): void;
  105053. /**
  105054. * Force a regeneration of this or the parent's impostor's body.
  105055. * Use under cautious - This will remove all joints already implemented.
  105056. */
  105057. forceUpdate(): void;
  105058. /**
  105059. * Gets the body that holds this impostor. Either its own, or its parent.
  105060. */
  105061. get physicsBody(): any;
  105062. /**
  105063. * Get the parent of the physics imposter
  105064. * @returns Physics imposter or null
  105065. */
  105066. get parent(): Nullable<PhysicsImpostor>;
  105067. /**
  105068. * Sets the parent of the physics imposter
  105069. */
  105070. set parent(value: Nullable<PhysicsImpostor>);
  105071. /**
  105072. * Set the physics body. Used mainly by the physics engine/plugin
  105073. */
  105074. set physicsBody(physicsBody: any);
  105075. /**
  105076. * Resets the update flags
  105077. */
  105078. resetUpdateFlags(): void;
  105079. /**
  105080. * Gets the object extend size
  105081. * @returns the object extend size
  105082. */
  105083. getObjectExtendSize(): Vector3;
  105084. /**
  105085. * Gets the object center
  105086. * @returns The object center
  105087. */
  105088. getObjectCenter(): Vector3;
  105089. /**
  105090. * Get a specific parameter from the options parameters
  105091. * @param paramName The object parameter name
  105092. * @returns The object parameter
  105093. */
  105094. getParam(paramName: string): any;
  105095. /**
  105096. * Sets a specific parameter in the options given to the physics plugin
  105097. * @param paramName The parameter name
  105098. * @param value The value of the parameter
  105099. */
  105100. setParam(paramName: string, value: number): void;
  105101. /**
  105102. * Specifically change the body's mass option. Won't recreate the physics body object
  105103. * @param mass The mass of the physics imposter
  105104. */
  105105. setMass(mass: number): void;
  105106. /**
  105107. * Gets the linear velocity
  105108. * @returns linear velocity or null
  105109. */
  105110. getLinearVelocity(): Nullable<Vector3>;
  105111. /**
  105112. * Sets the linear velocity
  105113. * @param velocity linear velocity or null
  105114. */
  105115. setLinearVelocity(velocity: Nullable<Vector3>): void;
  105116. /**
  105117. * Gets the angular velocity
  105118. * @returns angular velocity or null
  105119. */
  105120. getAngularVelocity(): Nullable<Vector3>;
  105121. /**
  105122. * Sets the angular velocity
  105123. * @param velocity The velocity or null
  105124. */
  105125. setAngularVelocity(velocity: Nullable<Vector3>): void;
  105126. /**
  105127. * Execute a function with the physics plugin native code
  105128. * Provide a function the will have two variables - the world object and the physics body object
  105129. * @param func The function to execute with the physics plugin native code
  105130. */
  105131. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  105132. /**
  105133. * Register a function that will be executed before the physics world is stepping forward
  105134. * @param func The function to execute before the physics world is stepped forward
  105135. */
  105136. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105137. /**
  105138. * Unregister a function that will be executed before the physics world is stepping forward
  105139. * @param func The function to execute before the physics world is stepped forward
  105140. */
  105141. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105142. /**
  105143. * Register a function that will be executed after the physics step
  105144. * @param func The function to execute after physics step
  105145. */
  105146. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105147. /**
  105148. * Unregisters a function that will be executed after the physics step
  105149. * @param func The function to execute after physics step
  105150. */
  105151. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105152. /**
  105153. * register a function that will be executed when this impostor collides against a different body
  105154. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  105155. * @param func Callback that is executed on collision
  105156. */
  105157. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  105158. /**
  105159. * Unregisters the physics imposter on contact
  105160. * @param collideAgainst The physics object to collide against
  105161. * @param func Callback to execute on collision
  105162. */
  105163. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  105164. private _tmpQuat;
  105165. private _tmpQuat2;
  105166. /**
  105167. * Get the parent rotation
  105168. * @returns The parent rotation
  105169. */
  105170. getParentsRotation(): Quaternion;
  105171. /**
  105172. * this function is executed by the physics engine.
  105173. */
  105174. beforeStep: () => void;
  105175. /**
  105176. * this function is executed by the physics engine
  105177. */
  105178. afterStep: () => void;
  105179. /**
  105180. * Legacy collision detection event support
  105181. */
  105182. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  105183. /**
  105184. * event and body object due to cannon's event-based architecture.
  105185. */
  105186. onCollide: (e: {
  105187. body: any;
  105188. }) => void;
  105189. /**
  105190. * Apply a force
  105191. * @param force The force to apply
  105192. * @param contactPoint The contact point for the force
  105193. * @returns The physics imposter
  105194. */
  105195. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  105196. /**
  105197. * Apply an impulse
  105198. * @param force The impulse force
  105199. * @param contactPoint The contact point for the impulse force
  105200. * @returns The physics imposter
  105201. */
  105202. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  105203. /**
  105204. * A help function to create a joint
  105205. * @param otherImpostor A physics imposter used to create a joint
  105206. * @param jointType The type of joint
  105207. * @param jointData The data for the joint
  105208. * @returns The physics imposter
  105209. */
  105210. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  105211. /**
  105212. * Add a joint to this impostor with a different impostor
  105213. * @param otherImpostor A physics imposter used to add a joint
  105214. * @param joint The joint to add
  105215. * @returns The physics imposter
  105216. */
  105217. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  105218. /**
  105219. * Add an anchor to a cloth impostor
  105220. * @param otherImpostor rigid impostor to anchor to
  105221. * @param width ratio across width from 0 to 1
  105222. * @param height ratio up height from 0 to 1
  105223. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  105224. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  105225. * @returns impostor the soft imposter
  105226. */
  105227. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  105228. /**
  105229. * Add a hook to a rope impostor
  105230. * @param otherImpostor rigid impostor to anchor to
  105231. * @param length ratio across rope from 0 to 1
  105232. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  105233. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  105234. * @returns impostor the rope imposter
  105235. */
  105236. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  105237. /**
  105238. * Will keep this body still, in a sleep mode.
  105239. * @returns the physics imposter
  105240. */
  105241. sleep(): PhysicsImpostor;
  105242. /**
  105243. * Wake the body up.
  105244. * @returns The physics imposter
  105245. */
  105246. wakeUp(): PhysicsImpostor;
  105247. /**
  105248. * Clones the physics imposter
  105249. * @param newObject The physics imposter clones to this physics-enabled object
  105250. * @returns A nullable physics imposter
  105251. */
  105252. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105253. /**
  105254. * Disposes the physics imposter
  105255. */
  105256. dispose(): void;
  105257. /**
  105258. * Sets the delta position
  105259. * @param position The delta position amount
  105260. */
  105261. setDeltaPosition(position: Vector3): void;
  105262. /**
  105263. * Sets the delta rotation
  105264. * @param rotation The delta rotation amount
  105265. */
  105266. setDeltaRotation(rotation: Quaternion): void;
  105267. /**
  105268. * Gets the box size of the physics imposter and stores the result in the input parameter
  105269. * @param result Stores the box size
  105270. * @returns The physics imposter
  105271. */
  105272. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  105273. /**
  105274. * Gets the radius of the physics imposter
  105275. * @returns Radius of the physics imposter
  105276. */
  105277. getRadius(): number;
  105278. /**
  105279. * Sync a bone with this impostor
  105280. * @param bone The bone to sync to the impostor.
  105281. * @param boneMesh The mesh that the bone is influencing.
  105282. * @param jointPivot The pivot of the joint / bone in local space.
  105283. * @param distToJoint Optional distance from the impostor to the joint.
  105284. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  105285. */
  105286. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  105287. /**
  105288. * Sync impostor to a bone
  105289. * @param bone The bone that the impostor will be synced to.
  105290. * @param boneMesh The mesh that the bone is influencing.
  105291. * @param jointPivot The pivot of the joint / bone in local space.
  105292. * @param distToJoint Optional distance from the impostor to the joint.
  105293. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  105294. * @param boneAxis Optional vector3 axis the bone is aligned with
  105295. */
  105296. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  105297. /**
  105298. * No-Imposter type
  105299. */
  105300. static NoImpostor: number;
  105301. /**
  105302. * Sphere-Imposter type
  105303. */
  105304. static SphereImpostor: number;
  105305. /**
  105306. * Box-Imposter type
  105307. */
  105308. static BoxImpostor: number;
  105309. /**
  105310. * Plane-Imposter type
  105311. */
  105312. static PlaneImpostor: number;
  105313. /**
  105314. * Mesh-imposter type
  105315. */
  105316. static MeshImpostor: number;
  105317. /**
  105318. * Capsule-Impostor type (Ammo.js plugin only)
  105319. */
  105320. static CapsuleImpostor: number;
  105321. /**
  105322. * Cylinder-Imposter type
  105323. */
  105324. static CylinderImpostor: number;
  105325. /**
  105326. * Particle-Imposter type
  105327. */
  105328. static ParticleImpostor: number;
  105329. /**
  105330. * Heightmap-Imposter type
  105331. */
  105332. static HeightmapImpostor: number;
  105333. /**
  105334. * ConvexHull-Impostor type (Ammo.js plugin only)
  105335. */
  105336. static ConvexHullImpostor: number;
  105337. /**
  105338. * Custom-Imposter type (Ammo.js plugin only)
  105339. */
  105340. static CustomImpostor: number;
  105341. /**
  105342. * Rope-Imposter type
  105343. */
  105344. static RopeImpostor: number;
  105345. /**
  105346. * Cloth-Imposter type
  105347. */
  105348. static ClothImpostor: number;
  105349. /**
  105350. * Softbody-Imposter type
  105351. */
  105352. static SoftbodyImpostor: number;
  105353. }
  105354. }
  105355. declare module BABYLON {
  105356. /**
  105357. * @hidden
  105358. **/
  105359. export class _CreationDataStorage {
  105360. closePath?: boolean;
  105361. closeArray?: boolean;
  105362. idx: number[];
  105363. dashSize: number;
  105364. gapSize: number;
  105365. path3D: Path3D;
  105366. pathArray: Vector3[][];
  105367. arc: number;
  105368. radius: number;
  105369. cap: number;
  105370. tessellation: number;
  105371. }
  105372. /**
  105373. * @hidden
  105374. **/
  105375. class _InstanceDataStorage {
  105376. visibleInstances: any;
  105377. batchCache: _InstancesBatch;
  105378. instancesBufferSize: number;
  105379. instancesBuffer: Nullable<Buffer>;
  105380. instancesData: Float32Array;
  105381. overridenInstanceCount: number;
  105382. isFrozen: boolean;
  105383. previousBatch: Nullable<_InstancesBatch>;
  105384. hardwareInstancedRendering: boolean;
  105385. sideOrientation: number;
  105386. manualUpdate: boolean;
  105387. }
  105388. /**
  105389. * @hidden
  105390. **/
  105391. export class _InstancesBatch {
  105392. mustReturn: boolean;
  105393. visibleInstances: Nullable<InstancedMesh[]>[];
  105394. renderSelf: boolean[];
  105395. hardwareInstancedRendering: boolean[];
  105396. }
  105397. /**
  105398. * @hidden
  105399. **/
  105400. class _ThinInstanceDataStorage {
  105401. instancesCount: number;
  105402. matrixBuffer: Nullable<Buffer>;
  105403. matrixBufferSize: number;
  105404. matrixData: Nullable<Float32Array>;
  105405. boundingVectors: Array<Vector3>;
  105406. }
  105407. /**
  105408. * Class used to represent renderable models
  105409. */
  105410. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  105411. /**
  105412. * Mesh side orientation : usually the external or front surface
  105413. */
  105414. static readonly FRONTSIDE: number;
  105415. /**
  105416. * Mesh side orientation : usually the internal or back surface
  105417. */
  105418. static readonly BACKSIDE: number;
  105419. /**
  105420. * Mesh side orientation : both internal and external or front and back surfaces
  105421. */
  105422. static readonly DOUBLESIDE: number;
  105423. /**
  105424. * Mesh side orientation : by default, `FRONTSIDE`
  105425. */
  105426. static readonly DEFAULTSIDE: number;
  105427. /**
  105428. * Mesh cap setting : no cap
  105429. */
  105430. static readonly NO_CAP: number;
  105431. /**
  105432. * Mesh cap setting : one cap at the beginning of the mesh
  105433. */
  105434. static readonly CAP_START: number;
  105435. /**
  105436. * Mesh cap setting : one cap at the end of the mesh
  105437. */
  105438. static readonly CAP_END: number;
  105439. /**
  105440. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  105441. */
  105442. static readonly CAP_ALL: number;
  105443. /**
  105444. * Mesh pattern setting : no flip or rotate
  105445. */
  105446. static readonly NO_FLIP: number;
  105447. /**
  105448. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  105449. */
  105450. static readonly FLIP_TILE: number;
  105451. /**
  105452. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  105453. */
  105454. static readonly ROTATE_TILE: number;
  105455. /**
  105456. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  105457. */
  105458. static readonly FLIP_ROW: number;
  105459. /**
  105460. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  105461. */
  105462. static readonly ROTATE_ROW: number;
  105463. /**
  105464. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  105465. */
  105466. static readonly FLIP_N_ROTATE_TILE: number;
  105467. /**
  105468. * Mesh pattern setting : rotate pattern and rotate
  105469. */
  105470. static readonly FLIP_N_ROTATE_ROW: number;
  105471. /**
  105472. * Mesh tile positioning : part tiles same on left/right or top/bottom
  105473. */
  105474. static readonly CENTER: number;
  105475. /**
  105476. * Mesh tile positioning : part tiles on left
  105477. */
  105478. static readonly LEFT: number;
  105479. /**
  105480. * Mesh tile positioning : part tiles on right
  105481. */
  105482. static readonly RIGHT: number;
  105483. /**
  105484. * Mesh tile positioning : part tiles on top
  105485. */
  105486. static readonly TOP: number;
  105487. /**
  105488. * Mesh tile positioning : part tiles on bottom
  105489. */
  105490. static readonly BOTTOM: number;
  105491. /**
  105492. * Gets the default side orientation.
  105493. * @param orientation the orientation to value to attempt to get
  105494. * @returns the default orientation
  105495. * @hidden
  105496. */
  105497. static _GetDefaultSideOrientation(orientation?: number): number;
  105498. private _internalMeshDataInfo;
  105499. /**
  105500. * An event triggered before rendering the mesh
  105501. */
  105502. get onBeforeRenderObservable(): Observable<Mesh>;
  105503. /**
  105504. * An event triggered before binding the mesh
  105505. */
  105506. get onBeforeBindObservable(): Observable<Mesh>;
  105507. /**
  105508. * An event triggered after rendering the mesh
  105509. */
  105510. get onAfterRenderObservable(): Observable<Mesh>;
  105511. /**
  105512. * An event triggered before drawing the mesh
  105513. */
  105514. get onBeforeDrawObservable(): Observable<Mesh>;
  105515. private _onBeforeDrawObserver;
  105516. /**
  105517. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  105518. */
  105519. set onBeforeDraw(callback: () => void);
  105520. get hasInstances(): boolean;
  105521. get hasThinInstances(): boolean;
  105522. /**
  105523. * Gets the delay loading state of the mesh (when delay loading is turned on)
  105524. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  105525. */
  105526. delayLoadState: number;
  105527. /**
  105528. * Gets the list of instances created from this mesh
  105529. * it is not supposed to be modified manually.
  105530. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  105531. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  105532. */
  105533. instances: InstancedMesh[];
  105534. /**
  105535. * Gets the file containing delay loading data for this mesh
  105536. */
  105537. delayLoadingFile: string;
  105538. /** @hidden */
  105539. _binaryInfo: any;
  105540. /**
  105541. * User defined function used to change how LOD level selection is done
  105542. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105543. */
  105544. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  105545. /**
  105546. * Gets or sets the morph target manager
  105547. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105548. */
  105549. get morphTargetManager(): Nullable<MorphTargetManager>;
  105550. set morphTargetManager(value: Nullable<MorphTargetManager>);
  105551. /** @hidden */
  105552. _creationDataStorage: Nullable<_CreationDataStorage>;
  105553. /** @hidden */
  105554. _geometry: Nullable<Geometry>;
  105555. /** @hidden */
  105556. _delayInfo: Array<string>;
  105557. /** @hidden */
  105558. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  105559. /** @hidden */
  105560. _instanceDataStorage: _InstanceDataStorage;
  105561. /** @hidden */
  105562. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  105563. private _effectiveMaterial;
  105564. /** @hidden */
  105565. _shouldGenerateFlatShading: boolean;
  105566. /** @hidden */
  105567. _originalBuilderSideOrientation: number;
  105568. /**
  105569. * Use this property to change the original side orientation defined at construction time
  105570. */
  105571. overrideMaterialSideOrientation: Nullable<number>;
  105572. /**
  105573. * Gets the source mesh (the one used to clone this one from)
  105574. */
  105575. get source(): Nullable<Mesh>;
  105576. /**
  105577. * Gets or sets a boolean indicating that this mesh does not use index buffer
  105578. */
  105579. get isUnIndexed(): boolean;
  105580. set isUnIndexed(value: boolean);
  105581. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  105582. get worldMatrixInstancedBuffer(): Float32Array;
  105583. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  105584. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  105585. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  105586. /**
  105587. * @constructor
  105588. * @param name The value used by scene.getMeshByName() to do a lookup.
  105589. * @param scene The scene to add this mesh to.
  105590. * @param parent The parent of this mesh, if it has one
  105591. * @param source An optional Mesh from which geometry is shared, cloned.
  105592. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  105593. * When false, achieved by calling a clone(), also passing False.
  105594. * This will make creation of children, recursive.
  105595. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  105596. */
  105597. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  105598. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  105599. doNotInstantiate: boolean;
  105600. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  105601. /**
  105602. * Gets the class name
  105603. * @returns the string "Mesh".
  105604. */
  105605. getClassName(): string;
  105606. /** @hidden */
  105607. get _isMesh(): boolean;
  105608. /**
  105609. * Returns a description of this mesh
  105610. * @param fullDetails define if full details about this mesh must be used
  105611. * @returns a descriptive string representing this mesh
  105612. */
  105613. toString(fullDetails?: boolean): string;
  105614. /** @hidden */
  105615. _unBindEffect(): void;
  105616. /**
  105617. * Gets a boolean indicating if this mesh has LOD
  105618. */
  105619. get hasLODLevels(): boolean;
  105620. /**
  105621. * Gets the list of MeshLODLevel associated with the current mesh
  105622. * @returns an array of MeshLODLevel
  105623. */
  105624. getLODLevels(): MeshLODLevel[];
  105625. private _sortLODLevels;
  105626. /**
  105627. * Add a mesh as LOD level triggered at the given distance.
  105628. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105629. * @param distance The distance from the center of the object to show this level
  105630. * @param mesh The mesh to be added as LOD level (can be null)
  105631. * @return This mesh (for chaining)
  105632. */
  105633. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  105634. /**
  105635. * Returns the LOD level mesh at the passed distance or null if not found.
  105636. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105637. * @param distance The distance from the center of the object to show this level
  105638. * @returns a Mesh or `null`
  105639. */
  105640. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  105641. /**
  105642. * Remove a mesh from the LOD array
  105643. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105644. * @param mesh defines the mesh to be removed
  105645. * @return This mesh (for chaining)
  105646. */
  105647. removeLODLevel(mesh: Mesh): Mesh;
  105648. /**
  105649. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  105650. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105651. * @param camera defines the camera to use to compute distance
  105652. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  105653. * @return This mesh (for chaining)
  105654. */
  105655. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  105656. /**
  105657. * Gets the mesh internal Geometry object
  105658. */
  105659. get geometry(): Nullable<Geometry>;
  105660. /**
  105661. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  105662. * @returns the total number of vertices
  105663. */
  105664. getTotalVertices(): number;
  105665. /**
  105666. * Returns the content of an associated vertex buffer
  105667. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105668. * - VertexBuffer.PositionKind
  105669. * - VertexBuffer.UVKind
  105670. * - VertexBuffer.UV2Kind
  105671. * - VertexBuffer.UV3Kind
  105672. * - VertexBuffer.UV4Kind
  105673. * - VertexBuffer.UV5Kind
  105674. * - VertexBuffer.UV6Kind
  105675. * - VertexBuffer.ColorKind
  105676. * - VertexBuffer.MatricesIndicesKind
  105677. * - VertexBuffer.MatricesIndicesExtraKind
  105678. * - VertexBuffer.MatricesWeightsKind
  105679. * - VertexBuffer.MatricesWeightsExtraKind
  105680. * @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
  105681. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  105682. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  105683. */
  105684. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105685. /**
  105686. * Returns the mesh VertexBuffer object from the requested `kind`
  105687. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105688. * - VertexBuffer.PositionKind
  105689. * - VertexBuffer.NormalKind
  105690. * - VertexBuffer.UVKind
  105691. * - VertexBuffer.UV2Kind
  105692. * - VertexBuffer.UV3Kind
  105693. * - VertexBuffer.UV4Kind
  105694. * - VertexBuffer.UV5Kind
  105695. * - VertexBuffer.UV6Kind
  105696. * - VertexBuffer.ColorKind
  105697. * - VertexBuffer.MatricesIndicesKind
  105698. * - VertexBuffer.MatricesIndicesExtraKind
  105699. * - VertexBuffer.MatricesWeightsKind
  105700. * - VertexBuffer.MatricesWeightsExtraKind
  105701. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  105702. */
  105703. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105704. /**
  105705. * Tests if a specific vertex buffer is associated with this mesh
  105706. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105707. * - VertexBuffer.PositionKind
  105708. * - VertexBuffer.NormalKind
  105709. * - VertexBuffer.UVKind
  105710. * - VertexBuffer.UV2Kind
  105711. * - VertexBuffer.UV3Kind
  105712. * - VertexBuffer.UV4Kind
  105713. * - VertexBuffer.UV5Kind
  105714. * - VertexBuffer.UV6Kind
  105715. * - VertexBuffer.ColorKind
  105716. * - VertexBuffer.MatricesIndicesKind
  105717. * - VertexBuffer.MatricesIndicesExtraKind
  105718. * - VertexBuffer.MatricesWeightsKind
  105719. * - VertexBuffer.MatricesWeightsExtraKind
  105720. * @returns a boolean
  105721. */
  105722. isVerticesDataPresent(kind: string): boolean;
  105723. /**
  105724. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  105725. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105726. * - VertexBuffer.PositionKind
  105727. * - VertexBuffer.UVKind
  105728. * - VertexBuffer.UV2Kind
  105729. * - VertexBuffer.UV3Kind
  105730. * - VertexBuffer.UV4Kind
  105731. * - VertexBuffer.UV5Kind
  105732. * - VertexBuffer.UV6Kind
  105733. * - VertexBuffer.ColorKind
  105734. * - VertexBuffer.MatricesIndicesKind
  105735. * - VertexBuffer.MatricesIndicesExtraKind
  105736. * - VertexBuffer.MatricesWeightsKind
  105737. * - VertexBuffer.MatricesWeightsExtraKind
  105738. * @returns a boolean
  105739. */
  105740. isVertexBufferUpdatable(kind: string): boolean;
  105741. /**
  105742. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  105743. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105744. * - VertexBuffer.PositionKind
  105745. * - VertexBuffer.NormalKind
  105746. * - VertexBuffer.UVKind
  105747. * - VertexBuffer.UV2Kind
  105748. * - VertexBuffer.UV3Kind
  105749. * - VertexBuffer.UV4Kind
  105750. * - VertexBuffer.UV5Kind
  105751. * - VertexBuffer.UV6Kind
  105752. * - VertexBuffer.ColorKind
  105753. * - VertexBuffer.MatricesIndicesKind
  105754. * - VertexBuffer.MatricesIndicesExtraKind
  105755. * - VertexBuffer.MatricesWeightsKind
  105756. * - VertexBuffer.MatricesWeightsExtraKind
  105757. * @returns an array of strings
  105758. */
  105759. getVerticesDataKinds(): string[];
  105760. /**
  105761. * Returns a positive integer : the total number of indices in this mesh geometry.
  105762. * @returns the numner of indices or zero if the mesh has no geometry.
  105763. */
  105764. getTotalIndices(): number;
  105765. /**
  105766. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105767. * @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.
  105768. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105769. * @returns the indices array or an empty array if the mesh has no geometry
  105770. */
  105771. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105772. get isBlocked(): boolean;
  105773. /**
  105774. * Determine if the current mesh is ready to be rendered
  105775. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105776. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  105777. * @returns true if all associated assets are ready (material, textures, shaders)
  105778. */
  105779. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  105780. /**
  105781. * 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.
  105782. */
  105783. get areNormalsFrozen(): boolean;
  105784. /**
  105785. * 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.
  105786. * @returns the current mesh
  105787. */
  105788. freezeNormals(): Mesh;
  105789. /**
  105790. * 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
  105791. * @returns the current mesh
  105792. */
  105793. unfreezeNormals(): Mesh;
  105794. /**
  105795. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  105796. */
  105797. set overridenInstanceCount(count: number);
  105798. /** @hidden */
  105799. _preActivate(): Mesh;
  105800. /** @hidden */
  105801. _preActivateForIntermediateRendering(renderId: number): Mesh;
  105802. /** @hidden */
  105803. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  105804. protected _afterComputeWorldMatrix(): void;
  105805. /** @hidden */
  105806. _postActivate(): void;
  105807. /**
  105808. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  105809. * This means the mesh underlying bounding box and sphere are recomputed.
  105810. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  105811. * @returns the current mesh
  105812. */
  105813. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  105814. /** @hidden */
  105815. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  105816. /**
  105817. * This function will subdivide the mesh into multiple submeshes
  105818. * @param count defines the expected number of submeshes
  105819. */
  105820. subdivide(count: number): void;
  105821. /**
  105822. * Copy a FloatArray into a specific associated vertex buffer
  105823. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105824. * - VertexBuffer.PositionKind
  105825. * - VertexBuffer.UVKind
  105826. * - VertexBuffer.UV2Kind
  105827. * - VertexBuffer.UV3Kind
  105828. * - VertexBuffer.UV4Kind
  105829. * - VertexBuffer.UV5Kind
  105830. * - VertexBuffer.UV6Kind
  105831. * - VertexBuffer.ColorKind
  105832. * - VertexBuffer.MatricesIndicesKind
  105833. * - VertexBuffer.MatricesIndicesExtraKind
  105834. * - VertexBuffer.MatricesWeightsKind
  105835. * - VertexBuffer.MatricesWeightsExtraKind
  105836. * @param data defines the data source
  105837. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105838. * @param stride defines the data stride size (can be null)
  105839. * @returns the current mesh
  105840. */
  105841. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  105842. /**
  105843. * Delete a vertex buffer associated with this mesh
  105844. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  105845. * - VertexBuffer.PositionKind
  105846. * - VertexBuffer.UVKind
  105847. * - VertexBuffer.UV2Kind
  105848. * - VertexBuffer.UV3Kind
  105849. * - VertexBuffer.UV4Kind
  105850. * - VertexBuffer.UV5Kind
  105851. * - VertexBuffer.UV6Kind
  105852. * - VertexBuffer.ColorKind
  105853. * - VertexBuffer.MatricesIndicesKind
  105854. * - VertexBuffer.MatricesIndicesExtraKind
  105855. * - VertexBuffer.MatricesWeightsKind
  105856. * - VertexBuffer.MatricesWeightsExtraKind
  105857. */
  105858. removeVerticesData(kind: string): void;
  105859. /**
  105860. * Flags an associated vertex buffer as updatable
  105861. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  105862. * - VertexBuffer.PositionKind
  105863. * - VertexBuffer.UVKind
  105864. * - VertexBuffer.UV2Kind
  105865. * - VertexBuffer.UV3Kind
  105866. * - VertexBuffer.UV4Kind
  105867. * - VertexBuffer.UV5Kind
  105868. * - VertexBuffer.UV6Kind
  105869. * - VertexBuffer.ColorKind
  105870. * - VertexBuffer.MatricesIndicesKind
  105871. * - VertexBuffer.MatricesIndicesExtraKind
  105872. * - VertexBuffer.MatricesWeightsKind
  105873. * - VertexBuffer.MatricesWeightsExtraKind
  105874. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105875. */
  105876. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  105877. /**
  105878. * Sets the mesh global Vertex Buffer
  105879. * @param buffer defines the buffer to use
  105880. * @returns the current mesh
  105881. */
  105882. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  105883. /**
  105884. * Update a specific associated vertex buffer
  105885. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105886. * - VertexBuffer.PositionKind
  105887. * - VertexBuffer.UVKind
  105888. * - VertexBuffer.UV2Kind
  105889. * - VertexBuffer.UV3Kind
  105890. * - VertexBuffer.UV4Kind
  105891. * - VertexBuffer.UV5Kind
  105892. * - VertexBuffer.UV6Kind
  105893. * - VertexBuffer.ColorKind
  105894. * - VertexBuffer.MatricesIndicesKind
  105895. * - VertexBuffer.MatricesIndicesExtraKind
  105896. * - VertexBuffer.MatricesWeightsKind
  105897. * - VertexBuffer.MatricesWeightsExtraKind
  105898. * @param data defines the data source
  105899. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105900. * @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)
  105901. * @returns the current mesh
  105902. */
  105903. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  105904. /**
  105905. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  105906. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  105907. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  105908. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  105909. * @returns the current mesh
  105910. */
  105911. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  105912. /**
  105913. * Creates a un-shared specific occurence of the geometry for the mesh.
  105914. * @returns the current mesh
  105915. */
  105916. makeGeometryUnique(): Mesh;
  105917. /**
  105918. * Set the index buffer of this mesh
  105919. * @param indices defines the source data
  105920. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  105921. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  105922. * @returns the current mesh
  105923. */
  105924. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  105925. /**
  105926. * Update the current index buffer
  105927. * @param indices defines the source data
  105928. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105929. * @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)
  105930. * @returns the current mesh
  105931. */
  105932. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105933. /**
  105934. * Invert the geometry to move from a right handed system to a left handed one.
  105935. * @returns the current mesh
  105936. */
  105937. toLeftHanded(): Mesh;
  105938. /** @hidden */
  105939. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  105940. /** @hidden */
  105941. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  105942. /**
  105943. * Registers for this mesh a javascript function called just before the rendering process
  105944. * @param func defines the function to call before rendering this mesh
  105945. * @returns the current mesh
  105946. */
  105947. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105948. /**
  105949. * Disposes a previously registered javascript function called before the rendering
  105950. * @param func defines the function to remove
  105951. * @returns the current mesh
  105952. */
  105953. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105954. /**
  105955. * Registers for this mesh a javascript function called just after the rendering is complete
  105956. * @param func defines the function to call after rendering this mesh
  105957. * @returns the current mesh
  105958. */
  105959. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105960. /**
  105961. * Disposes a previously registered javascript function called after the rendering.
  105962. * @param func defines the function to remove
  105963. * @returns the current mesh
  105964. */
  105965. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105966. /** @hidden */
  105967. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  105968. /** @hidden */
  105969. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  105970. /** @hidden */
  105971. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  105972. /** @hidden */
  105973. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  105974. /** @hidden */
  105975. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  105976. /** @hidden */
  105977. _rebuild(): void;
  105978. /** @hidden */
  105979. _freeze(): void;
  105980. /** @hidden */
  105981. _unFreeze(): void;
  105982. /**
  105983. * 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
  105984. * @param subMesh defines the subMesh to render
  105985. * @param enableAlphaMode defines if alpha mode can be changed
  105986. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  105987. * @returns the current mesh
  105988. */
  105989. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  105990. private _onBeforeDraw;
  105991. /**
  105992. * Renormalize the mesh and patch it up if there are no weights
  105993. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  105994. * However in the case of zero weights then we set just a single influence to 1.
  105995. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  105996. */
  105997. cleanMatrixWeights(): void;
  105998. private normalizeSkinFourWeights;
  105999. private normalizeSkinWeightsAndExtra;
  106000. /**
  106001. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  106002. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  106003. * the user know there was an issue with importing the mesh
  106004. * @returns a validation object with skinned, valid and report string
  106005. */
  106006. validateSkinning(): {
  106007. skinned: boolean;
  106008. valid: boolean;
  106009. report: string;
  106010. };
  106011. /** @hidden */
  106012. _checkDelayState(): Mesh;
  106013. private _queueLoad;
  106014. /**
  106015. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  106016. * A mesh is in the frustum if its bounding box intersects the frustum
  106017. * @param frustumPlanes defines the frustum to test
  106018. * @returns true if the mesh is in the frustum planes
  106019. */
  106020. isInFrustum(frustumPlanes: Plane[]): boolean;
  106021. /**
  106022. * Sets the mesh material by the material or multiMaterial `id` property
  106023. * @param id is a string identifying the material or the multiMaterial
  106024. * @returns the current mesh
  106025. */
  106026. setMaterialByID(id: string): Mesh;
  106027. /**
  106028. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  106029. * @returns an array of IAnimatable
  106030. */
  106031. getAnimatables(): IAnimatable[];
  106032. /**
  106033. * Modifies the mesh geometry according to the passed transformation matrix.
  106034. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  106035. * The mesh normals are modified using the same transformation.
  106036. * Note that, under the hood, this method sets a new VertexBuffer each call.
  106037. * @param transform defines the transform matrix to use
  106038. * @see https://doc.babylonjs.com/resources/baking_transformations
  106039. * @returns the current mesh
  106040. */
  106041. bakeTransformIntoVertices(transform: Matrix): Mesh;
  106042. /**
  106043. * Modifies the mesh geometry according to its own current World Matrix.
  106044. * The mesh World Matrix is then reset.
  106045. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  106046. * Note that, under the hood, this method sets a new VertexBuffer each call.
  106047. * @see https://doc.babylonjs.com/resources/baking_transformations
  106048. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  106049. * @returns the current mesh
  106050. */
  106051. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  106052. /** @hidden */
  106053. get _positions(): Nullable<Vector3[]>;
  106054. /** @hidden */
  106055. _resetPointsArrayCache(): Mesh;
  106056. /** @hidden */
  106057. _generatePointsArray(): boolean;
  106058. /**
  106059. * Returns a new Mesh object generated from the current mesh properties.
  106060. * This method must not get confused with createInstance()
  106061. * @param name is a string, the name given to the new mesh
  106062. * @param newParent can be any Node object (default `null`)
  106063. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  106064. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  106065. * @returns a new mesh
  106066. */
  106067. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  106068. /**
  106069. * Releases resources associated with this mesh.
  106070. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106071. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106072. */
  106073. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106074. /** @hidden */
  106075. _disposeInstanceSpecificData(): void;
  106076. /** @hidden */
  106077. _disposeThinInstanceSpecificData(): void;
  106078. /**
  106079. * Modifies the mesh geometry according to a displacement map.
  106080. * 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.
  106081. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  106082. * @param url is a string, the URL from the image file is to be downloaded.
  106083. * @param minHeight is the lower limit of the displacement.
  106084. * @param maxHeight is the upper limit of the displacement.
  106085. * @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.
  106086. * @param uvOffset is an optional vector2 used to offset UV.
  106087. * @param uvScale is an optional vector2 used to scale UV.
  106088. * @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.
  106089. * @returns the Mesh.
  106090. */
  106091. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  106092. /**
  106093. * Modifies the mesh geometry according to a displacementMap buffer.
  106094. * 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.
  106095. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  106096. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  106097. * @param heightMapWidth is the width of the buffer image.
  106098. * @param heightMapHeight is the height of the buffer image.
  106099. * @param minHeight is the lower limit of the displacement.
  106100. * @param maxHeight is the upper limit of the displacement.
  106101. * @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.
  106102. * @param uvOffset is an optional vector2 used to offset UV.
  106103. * @param uvScale is an optional vector2 used to scale UV.
  106104. * @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.
  106105. * @returns the Mesh.
  106106. */
  106107. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  106108. /**
  106109. * Modify the mesh to get a flat shading rendering.
  106110. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  106111. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  106112. * @returns current mesh
  106113. */
  106114. convertToFlatShadedMesh(): Mesh;
  106115. /**
  106116. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  106117. * In other words, more vertices, no more indices and a single bigger VBO.
  106118. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  106119. * @returns current mesh
  106120. */
  106121. convertToUnIndexedMesh(): Mesh;
  106122. /**
  106123. * Inverses facet orientations.
  106124. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106125. * @param flipNormals will also inverts the normals
  106126. * @returns current mesh
  106127. */
  106128. flipFaces(flipNormals?: boolean): Mesh;
  106129. /**
  106130. * Increase the number of facets and hence vertices in a mesh
  106131. * Vertex normals are interpolated from existing vertex normals
  106132. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106133. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  106134. */
  106135. increaseVertices(numberPerEdge: number): void;
  106136. /**
  106137. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  106138. * This will undo any application of covertToFlatShadedMesh
  106139. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106140. */
  106141. forceSharedVertices(): void;
  106142. /** @hidden */
  106143. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  106144. /** @hidden */
  106145. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  106146. /**
  106147. * Creates a new InstancedMesh object from the mesh model.
  106148. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  106149. * @param name defines the name of the new instance
  106150. * @returns a new InstancedMesh
  106151. */
  106152. createInstance(name: string): InstancedMesh;
  106153. /**
  106154. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  106155. * After this call, all the mesh instances have the same submeshes than the current mesh.
  106156. * @returns the current mesh
  106157. */
  106158. synchronizeInstances(): Mesh;
  106159. /**
  106160. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  106161. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  106162. * This should be used together with the simplification to avoid disappearing triangles.
  106163. * @param successCallback an optional success callback to be called after the optimization finished.
  106164. * @returns the current mesh
  106165. */
  106166. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  106167. /**
  106168. * Serialize current mesh
  106169. * @param serializationObject defines the object which will receive the serialization data
  106170. */
  106171. serialize(serializationObject: any): void;
  106172. /** @hidden */
  106173. _syncGeometryWithMorphTargetManager(): void;
  106174. /** @hidden */
  106175. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  106176. /**
  106177. * Returns a new Mesh object parsed from the source provided.
  106178. * @param parsedMesh is the source
  106179. * @param scene defines the hosting scene
  106180. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  106181. * @returns a new Mesh
  106182. */
  106183. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  106184. /**
  106185. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  106186. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106187. * @param name defines the name of the mesh to create
  106188. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  106189. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  106190. * @param closePath creates a seam between the first and the last points of each path of the path array
  106191. * @param offset is taken in account only if the `pathArray` is containing a single path
  106192. * @param scene defines the hosting scene
  106193. * @param updatable defines if the mesh must be flagged as updatable
  106194. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106195. * @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)
  106196. * @returns a new Mesh
  106197. */
  106198. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106199. /**
  106200. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  106201. * @param name defines the name of the mesh to create
  106202. * @param radius sets the radius size (float) of the polygon (default 0.5)
  106203. * @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
  106204. * @param scene defines the hosting scene
  106205. * @param updatable defines if the mesh must be flagged as updatable
  106206. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106207. * @returns a new Mesh
  106208. */
  106209. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  106210. /**
  106211. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  106212. * @param name defines the name of the mesh to create
  106213. * @param size sets the size (float) of each box side (default 1)
  106214. * @param scene defines the hosting scene
  106215. * @param updatable defines if the mesh must be flagged as updatable
  106216. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106217. * @returns a new Mesh
  106218. */
  106219. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  106220. /**
  106221. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  106222. * @param name defines the name of the mesh to create
  106223. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  106224. * @param diameter sets the diameter size (float) of the sphere (default 1)
  106225. * @param scene defines the hosting scene
  106226. * @param updatable defines if the mesh must be flagged as updatable
  106227. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106228. * @returns a new Mesh
  106229. */
  106230. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106231. /**
  106232. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  106233. * @param name defines the name of the mesh to create
  106234. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  106235. * @param diameter sets the diameter size (float) of the sphere (default 1)
  106236. * @param scene defines the hosting scene
  106237. * @returns a new Mesh
  106238. */
  106239. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  106240. /**
  106241. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  106242. * @param name defines the name of the mesh to create
  106243. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  106244. * @param diameterTop set the top cap diameter (floats, default 1)
  106245. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  106246. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  106247. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  106248. * @param scene defines the hosting scene
  106249. * @param updatable defines if the mesh must be flagged as updatable
  106250. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106251. * @returns a new Mesh
  106252. */
  106253. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  106254. /**
  106255. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  106256. * @param name defines the name of the mesh to create
  106257. * @param diameter sets the diameter size (float) of the torus (default 1)
  106258. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  106259. * @param tessellation sets the number of torus sides (postive integer, default 16)
  106260. * @param scene defines the hosting scene
  106261. * @param updatable defines if the mesh must be flagged as updatable
  106262. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106263. * @returns a new Mesh
  106264. */
  106265. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106266. /**
  106267. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  106268. * @param name defines the name of the mesh to create
  106269. * @param radius sets the global radius size (float) of the torus knot (default 2)
  106270. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  106271. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  106272. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  106273. * @param p the number of windings on X axis (positive integers, default 2)
  106274. * @param q the number of windings on Y axis (positive integers, default 3)
  106275. * @param scene defines the hosting scene
  106276. * @param updatable defines if the mesh must be flagged as updatable
  106277. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106278. * @returns a new Mesh
  106279. */
  106280. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106281. /**
  106282. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  106283. * @param name defines the name of the mesh to create
  106284. * @param points is an array successive Vector3
  106285. * @param scene defines the hosting scene
  106286. * @param updatable defines if the mesh must be flagged as updatable
  106287. * @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).
  106288. * @returns a new Mesh
  106289. */
  106290. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  106291. /**
  106292. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  106293. * @param name defines the name of the mesh to create
  106294. * @param points is an array successive Vector3
  106295. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  106296. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106297. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  106298. * @param scene defines the hosting scene
  106299. * @param updatable defines if the mesh must be flagged as updatable
  106300. * @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)
  106301. * @returns a new Mesh
  106302. */
  106303. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  106304. /**
  106305. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  106306. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  106307. * 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.
  106308. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106309. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106310. * Remember you can only change the shape positions, not their number when updating a polygon.
  106311. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  106312. * @param name defines the name of the mesh to create
  106313. * @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
  106314. * @param scene defines the hosting scene
  106315. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  106316. * @param updatable defines if the mesh must be flagged as updatable
  106317. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106318. * @param earcutInjection can be used to inject your own earcut reference
  106319. * @returns a new Mesh
  106320. */
  106321. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  106322. /**
  106323. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  106324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  106325. * @param name defines the name of the mesh to create
  106326. * @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
  106327. * @param depth defines the height of extrusion
  106328. * @param scene defines the hosting scene
  106329. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  106330. * @param updatable defines if the mesh must be flagged as updatable
  106331. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106332. * @param earcutInjection can be used to inject your own earcut reference
  106333. * @returns a new Mesh
  106334. */
  106335. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  106336. /**
  106337. * Creates an extruded shape mesh.
  106338. * 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
  106339. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106341. * @param name defines the name of the mesh to create
  106342. * @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
  106343. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  106344. * @param scale is the value to scale the shape
  106345. * @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
  106346. * @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
  106347. * @param scene defines the hosting scene
  106348. * @param updatable defines if the mesh must be flagged as updatable
  106349. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106350. * @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)
  106351. * @returns a new Mesh
  106352. */
  106353. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106354. /**
  106355. * Creates an custom extruded shape mesh.
  106356. * The custom extrusion is a parametric shape.
  106357. * It has no predefined shape. Its final shape will depend on the input parameters.
  106358. * Please consider using the same method from the MeshBuilder class instead
  106359. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106360. * @param name defines the name of the mesh to create
  106361. * @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
  106362. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  106363. * @param scaleFunction is a custom Javascript function called on each path point
  106364. * @param rotationFunction is a custom Javascript function called on each path point
  106365. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106366. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  106367. * @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
  106368. * @param scene defines the hosting scene
  106369. * @param updatable defines if the mesh must be flagged as updatable
  106370. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106371. * @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)
  106372. * @returns a new Mesh
  106373. */
  106374. 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;
  106375. /**
  106376. * Creates lathe mesh.
  106377. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  106378. * Please consider using the same method from the MeshBuilder class instead
  106379. * @param name defines the name of the mesh to create
  106380. * @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
  106381. * @param radius is the radius value of the lathe
  106382. * @param tessellation is the side number of the lathe.
  106383. * @param scene defines the hosting scene
  106384. * @param updatable defines if the mesh must be flagged as updatable
  106385. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106386. * @returns a new Mesh
  106387. */
  106388. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106389. /**
  106390. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  106391. * @param name defines the name of the mesh to create
  106392. * @param size sets the size (float) of both sides of the plane at once (default 1)
  106393. * @param scene defines the hosting scene
  106394. * @param updatable defines if the mesh must be flagged as updatable
  106395. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106396. * @returns a new Mesh
  106397. */
  106398. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106399. /**
  106400. * Creates a ground mesh.
  106401. * Please consider using the same method from the MeshBuilder class instead
  106402. * @param name defines the name of the mesh to create
  106403. * @param width set the width of the ground
  106404. * @param height set the height of the ground
  106405. * @param subdivisions sets the number of subdivisions per side
  106406. * @param scene defines the hosting scene
  106407. * @param updatable defines if the mesh must be flagged as updatable
  106408. * @returns a new Mesh
  106409. */
  106410. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  106411. /**
  106412. * Creates a tiled ground mesh.
  106413. * Please consider using the same method from the MeshBuilder class instead
  106414. * @param name defines the name of the mesh to create
  106415. * @param xmin set the ground minimum X coordinate
  106416. * @param zmin set the ground minimum Y coordinate
  106417. * @param xmax set the ground maximum X coordinate
  106418. * @param zmax set the ground maximum Z coordinate
  106419. * @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
  106420. * @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
  106421. * @param scene defines the hosting scene
  106422. * @param updatable defines if the mesh must be flagged as updatable
  106423. * @returns a new Mesh
  106424. */
  106425. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  106426. w: number;
  106427. h: number;
  106428. }, precision: {
  106429. w: number;
  106430. h: number;
  106431. }, scene: Scene, updatable?: boolean): Mesh;
  106432. /**
  106433. * Creates a ground mesh from a height map.
  106434. * Please consider using the same method from the MeshBuilder class instead
  106435. * @see https://doc.babylonjs.com/babylon101/height_map
  106436. * @param name defines the name of the mesh to create
  106437. * @param url sets the URL of the height map image resource
  106438. * @param width set the ground width size
  106439. * @param height set the ground height size
  106440. * @param subdivisions sets the number of subdivision per side
  106441. * @param minHeight is the minimum altitude on the ground
  106442. * @param maxHeight is the maximum altitude on the ground
  106443. * @param scene defines the hosting scene
  106444. * @param updatable defines if the mesh must be flagged as updatable
  106445. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  106446. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106447. * @returns a new Mesh
  106448. */
  106449. 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;
  106450. /**
  106451. * Creates a tube mesh.
  106452. * The tube is a parametric shape.
  106453. * It has no predefined shape. Its final shape will depend on the input parameters.
  106454. * Please consider using the same method from the MeshBuilder class instead
  106455. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106456. * @param name defines the name of the mesh to create
  106457. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  106458. * @param radius sets the tube radius size
  106459. * @param tessellation is the number of sides on the tubular surface
  106460. * @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
  106461. * @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
  106462. * @param scene defines the hosting scene
  106463. * @param updatable defines if the mesh must be flagged as updatable
  106464. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106465. * @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)
  106466. * @returns a new Mesh
  106467. */
  106468. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  106469. (i: number, distance: number): number;
  106470. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106471. /**
  106472. * Creates a polyhedron mesh.
  106473. * Please consider using the same method from the MeshBuilder class instead.
  106474. * * 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
  106475. * * The parameter `size` (positive float, default 1) sets the polygon size
  106476. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106477. * * 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`
  106478. * * 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
  106479. * * 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)`)
  106480. * * 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
  106481. * * 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
  106482. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106485. * @param name defines the name of the mesh to create
  106486. * @param options defines the options used to create the mesh
  106487. * @param scene defines the hosting scene
  106488. * @returns a new Mesh
  106489. */
  106490. static CreatePolyhedron(name: string, options: {
  106491. type?: number;
  106492. size?: number;
  106493. sizeX?: number;
  106494. sizeY?: number;
  106495. sizeZ?: number;
  106496. custom?: any;
  106497. faceUV?: Vector4[];
  106498. faceColors?: Color4[];
  106499. updatable?: boolean;
  106500. sideOrientation?: number;
  106501. }, scene: Scene): Mesh;
  106502. /**
  106503. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106504. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106505. * * 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`)
  106506. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106507. * * 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
  106508. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106509. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106511. * @param name defines the name of the mesh
  106512. * @param options defines the options used to create the mesh
  106513. * @param scene defines the hosting scene
  106514. * @returns a new Mesh
  106515. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106516. */
  106517. static CreateIcoSphere(name: string, options: {
  106518. radius?: number;
  106519. flat?: boolean;
  106520. subdivisions?: number;
  106521. sideOrientation?: number;
  106522. updatable?: boolean;
  106523. }, scene: Scene): Mesh;
  106524. /**
  106525. * Creates a decal mesh.
  106526. * Please consider using the same method from the MeshBuilder class instead.
  106527. * A decal is a mesh usually applied as a model onto the surface of another mesh
  106528. * @param name defines the name of the mesh
  106529. * @param sourceMesh defines the mesh receiving the decal
  106530. * @param position sets the position of the decal in world coordinates
  106531. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  106532. * @param size sets the decal scaling
  106533. * @param angle sets the angle to rotate the decal
  106534. * @returns a new Mesh
  106535. */
  106536. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  106537. /**
  106538. * Prepare internal position array for software CPU skinning
  106539. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  106540. */
  106541. setPositionsForCPUSkinning(): Float32Array;
  106542. /**
  106543. * Prepare internal normal array for software CPU skinning
  106544. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  106545. */
  106546. setNormalsForCPUSkinning(): Float32Array;
  106547. /**
  106548. * Updates the vertex buffer by applying transformation from the bones
  106549. * @param skeleton defines the skeleton to apply to current mesh
  106550. * @returns the current mesh
  106551. */
  106552. applySkeleton(skeleton: Skeleton): Mesh;
  106553. /**
  106554. * 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
  106555. * @param meshes defines the list of meshes to scan
  106556. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  106557. */
  106558. static MinMax(meshes: AbstractMesh[]): {
  106559. min: Vector3;
  106560. max: Vector3;
  106561. };
  106562. /**
  106563. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  106564. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  106565. * @returns a vector3
  106566. */
  106567. static Center(meshesOrMinMaxVector: {
  106568. min: Vector3;
  106569. max: Vector3;
  106570. } | AbstractMesh[]): Vector3;
  106571. /**
  106572. * Merge the array of meshes into a single mesh for performance reasons.
  106573. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  106574. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  106575. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  106576. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  106577. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  106578. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  106579. * @returns a new mesh
  106580. */
  106581. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  106582. /** @hidden */
  106583. addInstance(instance: InstancedMesh): void;
  106584. /** @hidden */
  106585. removeInstance(instance: InstancedMesh): void;
  106586. }
  106587. }
  106588. declare module BABYLON {
  106589. /**
  106590. * This is the base class of all the camera used in the application.
  106591. * @see https://doc.babylonjs.com/features/cameras
  106592. */
  106593. export class Camera extends Node {
  106594. /** @hidden */
  106595. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  106596. /**
  106597. * This is the default projection mode used by the cameras.
  106598. * It helps recreating a feeling of perspective and better appreciate depth.
  106599. * This is the best way to simulate real life cameras.
  106600. */
  106601. static readonly PERSPECTIVE_CAMERA: number;
  106602. /**
  106603. * This helps creating camera with an orthographic mode.
  106604. * 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.
  106605. */
  106606. static readonly ORTHOGRAPHIC_CAMERA: number;
  106607. /**
  106608. * This is the default FOV mode for perspective cameras.
  106609. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  106610. */
  106611. static readonly FOVMODE_VERTICAL_FIXED: number;
  106612. /**
  106613. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  106614. */
  106615. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  106616. /**
  106617. * This specifies ther is no need for a camera rig.
  106618. * Basically only one eye is rendered corresponding to the camera.
  106619. */
  106620. static readonly RIG_MODE_NONE: number;
  106621. /**
  106622. * Simulates a camera Rig with one blue eye and one red eye.
  106623. * This can be use with 3d blue and red glasses.
  106624. */
  106625. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  106626. /**
  106627. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  106628. */
  106629. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  106630. /**
  106631. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  106632. */
  106633. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  106634. /**
  106635. * Defines that both eyes of the camera will be rendered over under each other.
  106636. */
  106637. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  106638. /**
  106639. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  106640. */
  106641. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  106642. /**
  106643. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  106644. */
  106645. static readonly RIG_MODE_VR: number;
  106646. /**
  106647. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  106648. */
  106649. static readonly RIG_MODE_WEBVR: number;
  106650. /**
  106651. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  106652. */
  106653. static readonly RIG_MODE_CUSTOM: number;
  106654. /**
  106655. * Defines if by default attaching controls should prevent the default javascript event to continue.
  106656. */
  106657. static ForceAttachControlToAlwaysPreventDefault: boolean;
  106658. /**
  106659. * Define the input manager associated with the camera.
  106660. */
  106661. inputs: CameraInputsManager<Camera>;
  106662. /** @hidden */
  106663. _position: Vector3;
  106664. /**
  106665. * Define the current local position of the camera in the scene
  106666. */
  106667. get position(): Vector3;
  106668. set position(newPosition: Vector3);
  106669. /**
  106670. * The vector the camera should consider as up.
  106671. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  106672. */
  106673. upVector: Vector3;
  106674. /**
  106675. * Define the current limit on the left side for an orthographic camera
  106676. * In scene unit
  106677. */
  106678. orthoLeft: Nullable<number>;
  106679. /**
  106680. * Define the current limit on the right side for an orthographic camera
  106681. * In scene unit
  106682. */
  106683. orthoRight: Nullable<number>;
  106684. /**
  106685. * Define the current limit on the bottom side for an orthographic camera
  106686. * In scene unit
  106687. */
  106688. orthoBottom: Nullable<number>;
  106689. /**
  106690. * Define the current limit on the top side for an orthographic camera
  106691. * In scene unit
  106692. */
  106693. orthoTop: Nullable<number>;
  106694. /**
  106695. * Field Of View is set in Radians. (default is 0.8)
  106696. */
  106697. fov: number;
  106698. /**
  106699. * Define the minimum distance the camera can see from.
  106700. * This is important to note that the depth buffer are not infinite and the closer it starts
  106701. * the more your scene might encounter depth fighting issue.
  106702. */
  106703. minZ: number;
  106704. /**
  106705. * Define the maximum distance the camera can see to.
  106706. * This is important to note that the depth buffer are not infinite and the further it end
  106707. * the more your scene might encounter depth fighting issue.
  106708. */
  106709. maxZ: number;
  106710. /**
  106711. * Define the default inertia of the camera.
  106712. * This helps giving a smooth feeling to the camera movement.
  106713. */
  106714. inertia: number;
  106715. /**
  106716. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  106717. */
  106718. mode: number;
  106719. /**
  106720. * Define whether the camera is intermediate.
  106721. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  106722. */
  106723. isIntermediate: boolean;
  106724. /**
  106725. * Define the viewport of the camera.
  106726. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  106727. */
  106728. viewport: Viewport;
  106729. /**
  106730. * Restricts the camera to viewing objects with the same layerMask.
  106731. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  106732. */
  106733. layerMask: number;
  106734. /**
  106735. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  106736. */
  106737. fovMode: number;
  106738. /**
  106739. * Rig mode of the camera.
  106740. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  106741. * This is normally controlled byt the camera themselves as internal use.
  106742. */
  106743. cameraRigMode: number;
  106744. /**
  106745. * Defines the distance between both "eyes" in case of a RIG
  106746. */
  106747. interaxialDistance: number;
  106748. /**
  106749. * Defines if stereoscopic rendering is done side by side or over under.
  106750. */
  106751. isStereoscopicSideBySide: boolean;
  106752. /**
  106753. * 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
  106754. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  106755. * else in the scene. (Eg. security camera)
  106756. *
  106757. * 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)
  106758. */
  106759. customRenderTargets: RenderTargetTexture[];
  106760. /**
  106761. * When set, the camera will render to this render target instead of the default canvas
  106762. *
  106763. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  106764. */
  106765. outputRenderTarget: Nullable<RenderTargetTexture>;
  106766. /**
  106767. * Observable triggered when the camera view matrix has changed.
  106768. */
  106769. onViewMatrixChangedObservable: Observable<Camera>;
  106770. /**
  106771. * Observable triggered when the camera Projection matrix has changed.
  106772. */
  106773. onProjectionMatrixChangedObservable: Observable<Camera>;
  106774. /**
  106775. * Observable triggered when the inputs have been processed.
  106776. */
  106777. onAfterCheckInputsObservable: Observable<Camera>;
  106778. /**
  106779. * Observable triggered when reset has been called and applied to the camera.
  106780. */
  106781. onRestoreStateObservable: Observable<Camera>;
  106782. /**
  106783. * Is this camera a part of a rig system?
  106784. */
  106785. isRigCamera: boolean;
  106786. /**
  106787. * If isRigCamera set to true this will be set with the parent camera.
  106788. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  106789. */
  106790. rigParent?: Camera;
  106791. /** @hidden */
  106792. _cameraRigParams: any;
  106793. /** @hidden */
  106794. _rigCameras: Camera[];
  106795. /** @hidden */
  106796. _rigPostProcess: Nullable<PostProcess>;
  106797. protected _webvrViewMatrix: Matrix;
  106798. /** @hidden */
  106799. _skipRendering: boolean;
  106800. /** @hidden */
  106801. _projectionMatrix: Matrix;
  106802. /** @hidden */
  106803. _postProcesses: Nullable<PostProcess>[];
  106804. /** @hidden */
  106805. _activeMeshes: SmartArray<AbstractMesh>;
  106806. protected _globalPosition: Vector3;
  106807. /** @hidden */
  106808. _computedViewMatrix: Matrix;
  106809. private _doNotComputeProjectionMatrix;
  106810. private _transformMatrix;
  106811. private _frustumPlanes;
  106812. private _refreshFrustumPlanes;
  106813. private _storedFov;
  106814. private _stateStored;
  106815. /**
  106816. * Instantiates a new camera object.
  106817. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  106818. * @see https://doc.babylonjs.com/features/cameras
  106819. * @param name Defines the name of the camera in the scene
  106820. * @param position Defines the position of the camera
  106821. * @param scene Defines the scene the camera belongs too
  106822. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  106823. */
  106824. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106825. /**
  106826. * Store current camera state (fov, position, etc..)
  106827. * @returns the camera
  106828. */
  106829. storeState(): Camera;
  106830. /**
  106831. * Restores the camera state values if it has been stored. You must call storeState() first
  106832. */
  106833. protected _restoreStateValues(): boolean;
  106834. /**
  106835. * Restored camera state. You must call storeState() first.
  106836. * @returns true if restored and false otherwise
  106837. */
  106838. restoreState(): boolean;
  106839. /**
  106840. * Gets the class name of the camera.
  106841. * @returns the class name
  106842. */
  106843. getClassName(): string;
  106844. /** @hidden */
  106845. readonly _isCamera: boolean;
  106846. /**
  106847. * Gets a string representation of the camera useful for debug purpose.
  106848. * @param fullDetails Defines that a more verboe level of logging is required
  106849. * @returns the string representation
  106850. */
  106851. toString(fullDetails?: boolean): string;
  106852. /**
  106853. * Gets the current world space position of the camera.
  106854. */
  106855. get globalPosition(): Vector3;
  106856. /**
  106857. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  106858. * @returns the active meshe list
  106859. */
  106860. getActiveMeshes(): SmartArray<AbstractMesh>;
  106861. /**
  106862. * Check whether a mesh is part of the current active mesh list of the camera
  106863. * @param mesh Defines the mesh to check
  106864. * @returns true if active, false otherwise
  106865. */
  106866. isActiveMesh(mesh: Mesh): boolean;
  106867. /**
  106868. * Is this camera ready to be used/rendered
  106869. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  106870. * @return true if the camera is ready
  106871. */
  106872. isReady(completeCheck?: boolean): boolean;
  106873. /** @hidden */
  106874. _initCache(): void;
  106875. /** @hidden */
  106876. _updateCache(ignoreParentClass?: boolean): void;
  106877. /** @hidden */
  106878. _isSynchronized(): boolean;
  106879. /** @hidden */
  106880. _isSynchronizedViewMatrix(): boolean;
  106881. /** @hidden */
  106882. _isSynchronizedProjectionMatrix(): boolean;
  106883. /**
  106884. * Attach the input controls to a specific dom element to get the input from.
  106885. * @param element Defines the element the controls should be listened from
  106886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106887. */
  106888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106889. /**
  106890. * Detach the current controls from the specified dom element.
  106891. * @param element Defines the element to stop listening the inputs from
  106892. */
  106893. detachControl(element: HTMLElement): void;
  106894. /**
  106895. * Update the camera state according to the different inputs gathered during the frame.
  106896. */
  106897. update(): void;
  106898. /** @hidden */
  106899. _checkInputs(): void;
  106900. /** @hidden */
  106901. get rigCameras(): Camera[];
  106902. /**
  106903. * Gets the post process used by the rig cameras
  106904. */
  106905. get rigPostProcess(): Nullable<PostProcess>;
  106906. /**
  106907. * Internal, gets the first post proces.
  106908. * @returns the first post process to be run on this camera.
  106909. */
  106910. _getFirstPostProcess(): Nullable<PostProcess>;
  106911. private _cascadePostProcessesToRigCams;
  106912. /**
  106913. * Attach a post process to the camera.
  106914. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106915. * @param postProcess The post process to attach to the camera
  106916. * @param insertAt The position of the post process in case several of them are in use in the scene
  106917. * @returns the position the post process has been inserted at
  106918. */
  106919. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  106920. /**
  106921. * Detach a post process to the camera.
  106922. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106923. * @param postProcess The post process to detach from the camera
  106924. */
  106925. detachPostProcess(postProcess: PostProcess): void;
  106926. /**
  106927. * Gets the current world matrix of the camera
  106928. */
  106929. getWorldMatrix(): Matrix;
  106930. /** @hidden */
  106931. _getViewMatrix(): Matrix;
  106932. /**
  106933. * Gets the current view matrix of the camera.
  106934. * @param force forces the camera to recompute the matrix without looking at the cached state
  106935. * @returns the view matrix
  106936. */
  106937. getViewMatrix(force?: boolean): Matrix;
  106938. /**
  106939. * Freeze the projection matrix.
  106940. * It will prevent the cache check of the camera projection compute and can speed up perf
  106941. * if no parameter of the camera are meant to change
  106942. * @param projection Defines manually a projection if necessary
  106943. */
  106944. freezeProjectionMatrix(projection?: Matrix): void;
  106945. /**
  106946. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  106947. */
  106948. unfreezeProjectionMatrix(): void;
  106949. /**
  106950. * Gets the current projection matrix of the camera.
  106951. * @param force forces the camera to recompute the matrix without looking at the cached state
  106952. * @returns the projection matrix
  106953. */
  106954. getProjectionMatrix(force?: boolean): Matrix;
  106955. /**
  106956. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  106957. * @returns a Matrix
  106958. */
  106959. getTransformationMatrix(): Matrix;
  106960. private _updateFrustumPlanes;
  106961. /**
  106962. * Checks if a cullable object (mesh...) is in the camera frustum
  106963. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  106964. * @param target The object to check
  106965. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  106966. * @returns true if the object is in frustum otherwise false
  106967. */
  106968. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  106969. /**
  106970. * Checks if a cullable object (mesh...) is in the camera frustum
  106971. * Unlike isInFrustum this cheks the full bounding box
  106972. * @param target The object to check
  106973. * @returns true if the object is in frustum otherwise false
  106974. */
  106975. isCompletelyInFrustum(target: ICullable): boolean;
  106976. /**
  106977. * Gets a ray in the forward direction from the camera.
  106978. * @param length Defines the length of the ray to create
  106979. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  106980. * @param origin Defines the start point of the ray which defaults to the camera position
  106981. * @returns the forward ray
  106982. */
  106983. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  106984. /**
  106985. * Releases resources associated with this node.
  106986. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106987. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106988. */
  106989. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106990. /** @hidden */
  106991. _isLeftCamera: boolean;
  106992. /**
  106993. * Gets the left camera of a rig setup in case of Rigged Camera
  106994. */
  106995. get isLeftCamera(): boolean;
  106996. /** @hidden */
  106997. _isRightCamera: boolean;
  106998. /**
  106999. * Gets the right camera of a rig setup in case of Rigged Camera
  107000. */
  107001. get isRightCamera(): boolean;
  107002. /**
  107003. * Gets the left camera of a rig setup in case of Rigged Camera
  107004. */
  107005. get leftCamera(): Nullable<FreeCamera>;
  107006. /**
  107007. * Gets the right camera of a rig setup in case of Rigged Camera
  107008. */
  107009. get rightCamera(): Nullable<FreeCamera>;
  107010. /**
  107011. * Gets the left camera target of a rig setup in case of Rigged Camera
  107012. * @returns the target position
  107013. */
  107014. getLeftTarget(): Nullable<Vector3>;
  107015. /**
  107016. * Gets the right camera target of a rig setup in case of Rigged Camera
  107017. * @returns the target position
  107018. */
  107019. getRightTarget(): Nullable<Vector3>;
  107020. /**
  107021. * @hidden
  107022. */
  107023. setCameraRigMode(mode: number, rigParams: any): void;
  107024. /** @hidden */
  107025. static _setStereoscopicRigMode(camera: Camera): void;
  107026. /** @hidden */
  107027. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  107028. /** @hidden */
  107029. static _setVRRigMode(camera: Camera, rigParams: any): void;
  107030. /** @hidden */
  107031. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  107032. /** @hidden */
  107033. _getVRProjectionMatrix(): Matrix;
  107034. protected _updateCameraRotationMatrix(): void;
  107035. protected _updateWebVRCameraRotationMatrix(): void;
  107036. /**
  107037. * This function MUST be overwritten by the different WebVR cameras available.
  107038. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  107039. * @hidden
  107040. */
  107041. _getWebVRProjectionMatrix(): Matrix;
  107042. /**
  107043. * This function MUST be overwritten by the different WebVR cameras available.
  107044. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  107045. * @hidden
  107046. */
  107047. _getWebVRViewMatrix(): Matrix;
  107048. /** @hidden */
  107049. setCameraRigParameter(name: string, value: any): void;
  107050. /**
  107051. * needs to be overridden by children so sub has required properties to be copied
  107052. * @hidden
  107053. */
  107054. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  107055. /**
  107056. * May need to be overridden by children
  107057. * @hidden
  107058. */
  107059. _updateRigCameras(): void;
  107060. /** @hidden */
  107061. _setupInputs(): void;
  107062. /**
  107063. * Serialiaze the camera setup to a json represention
  107064. * @returns the JSON representation
  107065. */
  107066. serialize(): any;
  107067. /**
  107068. * Clones the current camera.
  107069. * @param name The cloned camera name
  107070. * @returns the cloned camera
  107071. */
  107072. clone(name: string): Camera;
  107073. /**
  107074. * Gets the direction of the camera relative to a given local axis.
  107075. * @param localAxis Defines the reference axis to provide a relative direction.
  107076. * @return the direction
  107077. */
  107078. getDirection(localAxis: Vector3): Vector3;
  107079. /**
  107080. * Returns the current camera absolute rotation
  107081. */
  107082. get absoluteRotation(): Quaternion;
  107083. /**
  107084. * Gets the direction of the camera relative to a given local axis into a passed vector.
  107085. * @param localAxis Defines the reference axis to provide a relative direction.
  107086. * @param result Defines the vector to store the result in
  107087. */
  107088. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  107089. /**
  107090. * Gets a camera constructor for a given camera type
  107091. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  107092. * @param name The name of the camera the result will be able to instantiate
  107093. * @param scene The scene the result will construct the camera in
  107094. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  107095. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  107096. * @returns a factory method to construc the camera
  107097. */
  107098. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  107099. /**
  107100. * Compute the world matrix of the camera.
  107101. * @returns the camera world matrix
  107102. */
  107103. computeWorldMatrix(): Matrix;
  107104. /**
  107105. * Parse a JSON and creates the camera from the parsed information
  107106. * @param parsedCamera The JSON to parse
  107107. * @param scene The scene to instantiate the camera in
  107108. * @returns the newly constructed camera
  107109. */
  107110. static Parse(parsedCamera: any, scene: Scene): Camera;
  107111. }
  107112. }
  107113. declare module BABYLON {
  107114. /**
  107115. * Class containing static functions to help procedurally build meshes
  107116. */
  107117. export class DiscBuilder {
  107118. /**
  107119. * Creates a plane polygonal mesh. By default, this is a disc
  107120. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107121. * * 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
  107122. * * 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
  107123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107126. * @param name defines the name of the mesh
  107127. * @param options defines the options used to create the mesh
  107128. * @param scene defines the hosting scene
  107129. * @returns the plane polygonal mesh
  107130. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107131. */
  107132. static CreateDisc(name: string, options: {
  107133. radius?: number;
  107134. tessellation?: number;
  107135. arc?: number;
  107136. updatable?: boolean;
  107137. sideOrientation?: number;
  107138. frontUVs?: Vector4;
  107139. backUVs?: Vector4;
  107140. }, scene?: Nullable<Scene>): Mesh;
  107141. }
  107142. }
  107143. declare module BABYLON {
  107144. /**
  107145. * Options to be used when creating a FresnelParameters.
  107146. */
  107147. export type IFresnelParametersCreationOptions = {
  107148. /**
  107149. * Define the color used on edges (grazing angle)
  107150. */
  107151. leftColor?: Color3;
  107152. /**
  107153. * Define the color used on center
  107154. */
  107155. rightColor?: Color3;
  107156. /**
  107157. * Define bias applied to computed fresnel term
  107158. */
  107159. bias?: number;
  107160. /**
  107161. * Defined the power exponent applied to fresnel term
  107162. */
  107163. power?: number;
  107164. /**
  107165. * Define if the fresnel effect is enable or not.
  107166. */
  107167. isEnabled?: boolean;
  107168. };
  107169. /**
  107170. * Serialized format for FresnelParameters.
  107171. */
  107172. export type IFresnelParametersSerialized = {
  107173. /**
  107174. * Define the color used on edges (grazing angle) [as an array]
  107175. */
  107176. leftColor: number[];
  107177. /**
  107178. * Define the color used on center [as an array]
  107179. */
  107180. rightColor: number[];
  107181. /**
  107182. * Define bias applied to computed fresnel term
  107183. */
  107184. bias: number;
  107185. /**
  107186. * Defined the power exponent applied to fresnel term
  107187. */
  107188. power?: number;
  107189. /**
  107190. * Define if the fresnel effect is enable or not.
  107191. */
  107192. isEnabled: boolean;
  107193. };
  107194. /**
  107195. * This represents all the required information to add a fresnel effect on a material:
  107196. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107197. */
  107198. export class FresnelParameters {
  107199. private _isEnabled;
  107200. /**
  107201. * Define if the fresnel effect is enable or not.
  107202. */
  107203. get isEnabled(): boolean;
  107204. set isEnabled(value: boolean);
  107205. /**
  107206. * Define the color used on edges (grazing angle)
  107207. */
  107208. leftColor: Color3;
  107209. /**
  107210. * Define the color used on center
  107211. */
  107212. rightColor: Color3;
  107213. /**
  107214. * Define bias applied to computed fresnel term
  107215. */
  107216. bias: number;
  107217. /**
  107218. * Defined the power exponent applied to fresnel term
  107219. */
  107220. power: number;
  107221. /**
  107222. * Creates a new FresnelParameters object.
  107223. *
  107224. * @param options provide your own settings to optionally to override defaults
  107225. */
  107226. constructor(options?: IFresnelParametersCreationOptions);
  107227. /**
  107228. * Clones the current fresnel and its valuues
  107229. * @returns a clone fresnel configuration
  107230. */
  107231. clone(): FresnelParameters;
  107232. /**
  107233. * Determines equality between FresnelParameters objects
  107234. * @param otherFresnelParameters defines the second operand
  107235. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  107236. */
  107237. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  107238. /**
  107239. * Serializes the current fresnel parameters to a JSON representation.
  107240. * @return the JSON serialization
  107241. */
  107242. serialize(): IFresnelParametersSerialized;
  107243. /**
  107244. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  107245. * @param parsedFresnelParameters Define the JSON representation
  107246. * @returns the parsed parameters
  107247. */
  107248. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  107249. }
  107250. }
  107251. declare module BABYLON {
  107252. /**
  107253. * This groups all the flags used to control the materials channel.
  107254. */
  107255. export class MaterialFlags {
  107256. private static _DiffuseTextureEnabled;
  107257. /**
  107258. * Are diffuse textures enabled in the application.
  107259. */
  107260. static get DiffuseTextureEnabled(): boolean;
  107261. static set DiffuseTextureEnabled(value: boolean);
  107262. private static _DetailTextureEnabled;
  107263. /**
  107264. * Are detail textures enabled in the application.
  107265. */
  107266. static get DetailTextureEnabled(): boolean;
  107267. static set DetailTextureEnabled(value: boolean);
  107268. private static _AmbientTextureEnabled;
  107269. /**
  107270. * Are ambient textures enabled in the application.
  107271. */
  107272. static get AmbientTextureEnabled(): boolean;
  107273. static set AmbientTextureEnabled(value: boolean);
  107274. private static _OpacityTextureEnabled;
  107275. /**
  107276. * Are opacity textures enabled in the application.
  107277. */
  107278. static get OpacityTextureEnabled(): boolean;
  107279. static set OpacityTextureEnabled(value: boolean);
  107280. private static _ReflectionTextureEnabled;
  107281. /**
  107282. * Are reflection textures enabled in the application.
  107283. */
  107284. static get ReflectionTextureEnabled(): boolean;
  107285. static set ReflectionTextureEnabled(value: boolean);
  107286. private static _EmissiveTextureEnabled;
  107287. /**
  107288. * Are emissive textures enabled in the application.
  107289. */
  107290. static get EmissiveTextureEnabled(): boolean;
  107291. static set EmissiveTextureEnabled(value: boolean);
  107292. private static _SpecularTextureEnabled;
  107293. /**
  107294. * Are specular textures enabled in the application.
  107295. */
  107296. static get SpecularTextureEnabled(): boolean;
  107297. static set SpecularTextureEnabled(value: boolean);
  107298. private static _BumpTextureEnabled;
  107299. /**
  107300. * Are bump textures enabled in the application.
  107301. */
  107302. static get BumpTextureEnabled(): boolean;
  107303. static set BumpTextureEnabled(value: boolean);
  107304. private static _LightmapTextureEnabled;
  107305. /**
  107306. * Are lightmap textures enabled in the application.
  107307. */
  107308. static get LightmapTextureEnabled(): boolean;
  107309. static set LightmapTextureEnabled(value: boolean);
  107310. private static _RefractionTextureEnabled;
  107311. /**
  107312. * Are refraction textures enabled in the application.
  107313. */
  107314. static get RefractionTextureEnabled(): boolean;
  107315. static set RefractionTextureEnabled(value: boolean);
  107316. private static _ColorGradingTextureEnabled;
  107317. /**
  107318. * Are color grading textures enabled in the application.
  107319. */
  107320. static get ColorGradingTextureEnabled(): boolean;
  107321. static set ColorGradingTextureEnabled(value: boolean);
  107322. private static _FresnelEnabled;
  107323. /**
  107324. * Are fresnels enabled in the application.
  107325. */
  107326. static get FresnelEnabled(): boolean;
  107327. static set FresnelEnabled(value: boolean);
  107328. private static _ClearCoatTextureEnabled;
  107329. /**
  107330. * Are clear coat textures enabled in the application.
  107331. */
  107332. static get ClearCoatTextureEnabled(): boolean;
  107333. static set ClearCoatTextureEnabled(value: boolean);
  107334. private static _ClearCoatBumpTextureEnabled;
  107335. /**
  107336. * Are clear coat bump textures enabled in the application.
  107337. */
  107338. static get ClearCoatBumpTextureEnabled(): boolean;
  107339. static set ClearCoatBumpTextureEnabled(value: boolean);
  107340. private static _ClearCoatTintTextureEnabled;
  107341. /**
  107342. * Are clear coat tint textures enabled in the application.
  107343. */
  107344. static get ClearCoatTintTextureEnabled(): boolean;
  107345. static set ClearCoatTintTextureEnabled(value: boolean);
  107346. private static _SheenTextureEnabled;
  107347. /**
  107348. * Are sheen textures enabled in the application.
  107349. */
  107350. static get SheenTextureEnabled(): boolean;
  107351. static set SheenTextureEnabled(value: boolean);
  107352. private static _AnisotropicTextureEnabled;
  107353. /**
  107354. * Are anisotropic textures enabled in the application.
  107355. */
  107356. static get AnisotropicTextureEnabled(): boolean;
  107357. static set AnisotropicTextureEnabled(value: boolean);
  107358. private static _ThicknessTextureEnabled;
  107359. /**
  107360. * Are thickness textures enabled in the application.
  107361. */
  107362. static get ThicknessTextureEnabled(): boolean;
  107363. static set ThicknessTextureEnabled(value: boolean);
  107364. }
  107365. }
  107366. declare module BABYLON {
  107367. /** @hidden */
  107368. export var defaultFragmentDeclaration: {
  107369. name: string;
  107370. shader: string;
  107371. };
  107372. }
  107373. declare module BABYLON {
  107374. /** @hidden */
  107375. export var defaultUboDeclaration: {
  107376. name: string;
  107377. shader: string;
  107378. };
  107379. }
  107380. declare module BABYLON {
  107381. /** @hidden */
  107382. export var lightFragmentDeclaration: {
  107383. name: string;
  107384. shader: string;
  107385. };
  107386. }
  107387. declare module BABYLON {
  107388. /** @hidden */
  107389. export var lightUboDeclaration: {
  107390. name: string;
  107391. shader: string;
  107392. };
  107393. }
  107394. declare module BABYLON {
  107395. /** @hidden */
  107396. export var lightsFragmentFunctions: {
  107397. name: string;
  107398. shader: string;
  107399. };
  107400. }
  107401. declare module BABYLON {
  107402. /** @hidden */
  107403. export var shadowsFragmentFunctions: {
  107404. name: string;
  107405. shader: string;
  107406. };
  107407. }
  107408. declare module BABYLON {
  107409. /** @hidden */
  107410. export var fresnelFunction: {
  107411. name: string;
  107412. shader: string;
  107413. };
  107414. }
  107415. declare module BABYLON {
  107416. /** @hidden */
  107417. export var bumpFragmentMainFunctions: {
  107418. name: string;
  107419. shader: string;
  107420. };
  107421. }
  107422. declare module BABYLON {
  107423. /** @hidden */
  107424. export var bumpFragmentFunctions: {
  107425. name: string;
  107426. shader: string;
  107427. };
  107428. }
  107429. declare module BABYLON {
  107430. /** @hidden */
  107431. export var logDepthDeclaration: {
  107432. name: string;
  107433. shader: string;
  107434. };
  107435. }
  107436. declare module BABYLON {
  107437. /** @hidden */
  107438. export var bumpFragment: {
  107439. name: string;
  107440. shader: string;
  107441. };
  107442. }
  107443. declare module BABYLON {
  107444. /** @hidden */
  107445. export var depthPrePass: {
  107446. name: string;
  107447. shader: string;
  107448. };
  107449. }
  107450. declare module BABYLON {
  107451. /** @hidden */
  107452. export var lightFragment: {
  107453. name: string;
  107454. shader: string;
  107455. };
  107456. }
  107457. declare module BABYLON {
  107458. /** @hidden */
  107459. export var logDepthFragment: {
  107460. name: string;
  107461. shader: string;
  107462. };
  107463. }
  107464. declare module BABYLON {
  107465. /** @hidden */
  107466. export var defaultPixelShader: {
  107467. name: string;
  107468. shader: string;
  107469. };
  107470. }
  107471. declare module BABYLON {
  107472. /** @hidden */
  107473. export var defaultVertexDeclaration: {
  107474. name: string;
  107475. shader: string;
  107476. };
  107477. }
  107478. declare module BABYLON {
  107479. /** @hidden */
  107480. export var bumpVertexDeclaration: {
  107481. name: string;
  107482. shader: string;
  107483. };
  107484. }
  107485. declare module BABYLON {
  107486. /** @hidden */
  107487. export var bumpVertex: {
  107488. name: string;
  107489. shader: string;
  107490. };
  107491. }
  107492. declare module BABYLON {
  107493. /** @hidden */
  107494. export var fogVertex: {
  107495. name: string;
  107496. shader: string;
  107497. };
  107498. }
  107499. declare module BABYLON {
  107500. /** @hidden */
  107501. export var shadowsVertex: {
  107502. name: string;
  107503. shader: string;
  107504. };
  107505. }
  107506. declare module BABYLON {
  107507. /** @hidden */
  107508. export var pointCloudVertex: {
  107509. name: string;
  107510. shader: string;
  107511. };
  107512. }
  107513. declare module BABYLON {
  107514. /** @hidden */
  107515. export var logDepthVertex: {
  107516. name: string;
  107517. shader: string;
  107518. };
  107519. }
  107520. declare module BABYLON {
  107521. /** @hidden */
  107522. export var defaultVertexShader: {
  107523. name: string;
  107524. shader: string;
  107525. };
  107526. }
  107527. declare module BABYLON {
  107528. /**
  107529. * @hidden
  107530. */
  107531. export interface IMaterialDetailMapDefines {
  107532. DETAIL: boolean;
  107533. DETAILDIRECTUV: number;
  107534. DETAIL_NORMALBLENDMETHOD: number;
  107535. /** @hidden */
  107536. _areTexturesDirty: boolean;
  107537. }
  107538. /**
  107539. * Define the code related to the detail map parameters of a material
  107540. *
  107541. * Inspired from:
  107542. * 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
  107543. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  107544. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  107545. */
  107546. export class DetailMapConfiguration {
  107547. private _texture;
  107548. /**
  107549. * The detail texture of the material.
  107550. */
  107551. texture: Nullable<BaseTexture>;
  107552. /**
  107553. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  107554. * Bigger values mean stronger blending
  107555. */
  107556. diffuseBlendLevel: number;
  107557. /**
  107558. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  107559. * Bigger values mean stronger blending. Only used with PBR materials
  107560. */
  107561. roughnessBlendLevel: number;
  107562. /**
  107563. * Defines how strong the bump effect from the detail map is
  107564. * Bigger values mean stronger effect
  107565. */
  107566. bumpLevel: number;
  107567. private _normalBlendMethod;
  107568. /**
  107569. * The method used to blend the bump and detail normals together
  107570. */
  107571. normalBlendMethod: number;
  107572. private _isEnabled;
  107573. /**
  107574. * Enable or disable the detail map on this material
  107575. */
  107576. isEnabled: boolean;
  107577. /** @hidden */
  107578. private _internalMarkAllSubMeshesAsTexturesDirty;
  107579. /** @hidden */
  107580. _markAllSubMeshesAsTexturesDirty(): void;
  107581. /**
  107582. * Instantiate a new detail map
  107583. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107584. */
  107585. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107586. /**
  107587. * Gets whether the submesh is ready to be used or not.
  107588. * @param defines the list of "defines" to update.
  107589. * @param scene defines the scene the material belongs to.
  107590. * @returns - boolean indicating that the submesh is ready or not.
  107591. */
  107592. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  107593. /**
  107594. * Update the defines for detail map usage
  107595. * @param defines the list of "defines" to update.
  107596. * @param scene defines the scene the material belongs to.
  107597. */
  107598. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  107599. /**
  107600. * Binds the material data.
  107601. * @param uniformBuffer defines the Uniform buffer to fill in.
  107602. * @param scene defines the scene the material belongs to.
  107603. * @param isFrozen defines whether the material is frozen or not.
  107604. */
  107605. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107606. /**
  107607. * Checks to see if a texture is used in the material.
  107608. * @param texture - Base texture to use.
  107609. * @returns - Boolean specifying if a texture is used in the material.
  107610. */
  107611. hasTexture(texture: BaseTexture): boolean;
  107612. /**
  107613. * Returns an array of the actively used textures.
  107614. * @param activeTextures Array of BaseTextures
  107615. */
  107616. getActiveTextures(activeTextures: BaseTexture[]): void;
  107617. /**
  107618. * Returns the animatable textures.
  107619. * @param animatables Array of animatable textures.
  107620. */
  107621. getAnimatables(animatables: IAnimatable[]): void;
  107622. /**
  107623. * Disposes the resources of the material.
  107624. * @param forceDisposeTextures - Forces the disposal of all textures.
  107625. */
  107626. dispose(forceDisposeTextures?: boolean): void;
  107627. /**
  107628. * Get the current class name useful for serialization or dynamic coding.
  107629. * @returns "DetailMap"
  107630. */
  107631. getClassName(): string;
  107632. /**
  107633. * Add the required uniforms to the current list.
  107634. * @param uniforms defines the current uniform list.
  107635. */
  107636. static AddUniforms(uniforms: string[]): void;
  107637. /**
  107638. * Add the required samplers to the current list.
  107639. * @param samplers defines the current sampler list.
  107640. */
  107641. static AddSamplers(samplers: string[]): void;
  107642. /**
  107643. * Add the required uniforms to the current buffer.
  107644. * @param uniformBuffer defines the current uniform buffer.
  107645. */
  107646. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107647. /**
  107648. * Makes a duplicate of the current instance into another one.
  107649. * @param detailMap define the instance where to copy the info
  107650. */
  107651. copyTo(detailMap: DetailMapConfiguration): void;
  107652. /**
  107653. * Serializes this detail map instance
  107654. * @returns - An object with the serialized instance.
  107655. */
  107656. serialize(): any;
  107657. /**
  107658. * Parses a detail map setting from a serialized object.
  107659. * @param source - Serialized object.
  107660. * @param scene Defines the scene we are parsing for
  107661. * @param rootUrl Defines the rootUrl to load from
  107662. */
  107663. parse(source: any, scene: Scene, rootUrl: string): void;
  107664. }
  107665. }
  107666. declare module BABYLON {
  107667. /** @hidden */
  107668. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  107669. MAINUV1: boolean;
  107670. MAINUV2: boolean;
  107671. DIFFUSE: boolean;
  107672. DIFFUSEDIRECTUV: number;
  107673. DETAIL: boolean;
  107674. DETAILDIRECTUV: number;
  107675. DETAIL_NORMALBLENDMETHOD: number;
  107676. AMBIENT: boolean;
  107677. AMBIENTDIRECTUV: number;
  107678. OPACITY: boolean;
  107679. OPACITYDIRECTUV: number;
  107680. OPACITYRGB: boolean;
  107681. REFLECTION: boolean;
  107682. EMISSIVE: boolean;
  107683. EMISSIVEDIRECTUV: number;
  107684. SPECULAR: boolean;
  107685. SPECULARDIRECTUV: number;
  107686. BUMP: boolean;
  107687. BUMPDIRECTUV: number;
  107688. PARALLAX: boolean;
  107689. PARALLAXOCCLUSION: boolean;
  107690. SPECULAROVERALPHA: boolean;
  107691. CLIPPLANE: boolean;
  107692. CLIPPLANE2: boolean;
  107693. CLIPPLANE3: boolean;
  107694. CLIPPLANE4: boolean;
  107695. CLIPPLANE5: boolean;
  107696. CLIPPLANE6: boolean;
  107697. ALPHATEST: boolean;
  107698. DEPTHPREPASS: boolean;
  107699. ALPHAFROMDIFFUSE: boolean;
  107700. POINTSIZE: boolean;
  107701. FOG: boolean;
  107702. SPECULARTERM: boolean;
  107703. DIFFUSEFRESNEL: boolean;
  107704. OPACITYFRESNEL: boolean;
  107705. REFLECTIONFRESNEL: boolean;
  107706. REFRACTIONFRESNEL: boolean;
  107707. EMISSIVEFRESNEL: boolean;
  107708. FRESNEL: boolean;
  107709. NORMAL: boolean;
  107710. UV1: boolean;
  107711. UV2: boolean;
  107712. VERTEXCOLOR: boolean;
  107713. VERTEXALPHA: boolean;
  107714. NUM_BONE_INFLUENCERS: number;
  107715. BonesPerMesh: number;
  107716. BONETEXTURE: boolean;
  107717. INSTANCES: boolean;
  107718. THIN_INSTANCES: boolean;
  107719. GLOSSINESS: boolean;
  107720. ROUGHNESS: boolean;
  107721. EMISSIVEASILLUMINATION: boolean;
  107722. LINKEMISSIVEWITHDIFFUSE: boolean;
  107723. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107724. LIGHTMAP: boolean;
  107725. LIGHTMAPDIRECTUV: number;
  107726. OBJECTSPACE_NORMALMAP: boolean;
  107727. USELIGHTMAPASSHADOWMAP: boolean;
  107728. REFLECTIONMAP_3D: boolean;
  107729. REFLECTIONMAP_SPHERICAL: boolean;
  107730. REFLECTIONMAP_PLANAR: boolean;
  107731. REFLECTIONMAP_CUBIC: boolean;
  107732. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107733. REFLECTIONMAP_PROJECTION: boolean;
  107734. REFLECTIONMAP_SKYBOX: boolean;
  107735. REFLECTIONMAP_EXPLICIT: boolean;
  107736. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107737. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107738. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107739. INVERTCUBICMAP: boolean;
  107740. LOGARITHMICDEPTH: boolean;
  107741. REFRACTION: boolean;
  107742. REFRACTIONMAP_3D: boolean;
  107743. REFLECTIONOVERALPHA: boolean;
  107744. TWOSIDEDLIGHTING: boolean;
  107745. SHADOWFLOAT: boolean;
  107746. MORPHTARGETS: boolean;
  107747. MORPHTARGETS_NORMAL: boolean;
  107748. MORPHTARGETS_TANGENT: boolean;
  107749. MORPHTARGETS_UV: boolean;
  107750. NUM_MORPH_INFLUENCERS: number;
  107751. NONUNIFORMSCALING: boolean;
  107752. PREMULTIPLYALPHA: boolean;
  107753. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  107754. ALPHABLEND: boolean;
  107755. PREPASS: boolean;
  107756. SCENE_MRT_COUNT: number;
  107757. RGBDLIGHTMAP: boolean;
  107758. RGBDREFLECTION: boolean;
  107759. RGBDREFRACTION: boolean;
  107760. IMAGEPROCESSING: boolean;
  107761. VIGNETTE: boolean;
  107762. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107763. VIGNETTEBLENDMODEOPAQUE: boolean;
  107764. TONEMAPPING: boolean;
  107765. TONEMAPPING_ACES: boolean;
  107766. CONTRAST: boolean;
  107767. COLORCURVES: boolean;
  107768. COLORGRADING: boolean;
  107769. COLORGRADING3D: boolean;
  107770. SAMPLER3DGREENDEPTH: boolean;
  107771. SAMPLER3DBGRMAP: boolean;
  107772. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107773. MULTIVIEW: boolean;
  107774. /**
  107775. * If the reflection texture on this material is in linear color space
  107776. * @hidden
  107777. */
  107778. IS_REFLECTION_LINEAR: boolean;
  107779. /**
  107780. * If the refraction texture on this material is in linear color space
  107781. * @hidden
  107782. */
  107783. IS_REFRACTION_LINEAR: boolean;
  107784. EXPOSURE: boolean;
  107785. constructor();
  107786. setReflectionMode(modeToEnable: string): void;
  107787. }
  107788. /**
  107789. * This is the default material used in Babylon. It is the best trade off between quality
  107790. * and performances.
  107791. * @see https://doc.babylonjs.com/babylon101/materials
  107792. */
  107793. export class StandardMaterial extends PushMaterial {
  107794. private _diffuseTexture;
  107795. /**
  107796. * The basic texture of the material as viewed under a light.
  107797. */
  107798. diffuseTexture: Nullable<BaseTexture>;
  107799. private _ambientTexture;
  107800. /**
  107801. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107802. */
  107803. ambientTexture: Nullable<BaseTexture>;
  107804. private _opacityTexture;
  107805. /**
  107806. * Define the transparency of the material from a texture.
  107807. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107808. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107809. */
  107810. opacityTexture: Nullable<BaseTexture>;
  107811. private _reflectionTexture;
  107812. /**
  107813. * Define the texture used to display the reflection.
  107814. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107815. */
  107816. reflectionTexture: Nullable<BaseTexture>;
  107817. private _emissiveTexture;
  107818. /**
  107819. * Define texture of the material as if self lit.
  107820. * This will be mixed in the final result even in the absence of light.
  107821. */
  107822. emissiveTexture: Nullable<BaseTexture>;
  107823. private _specularTexture;
  107824. /**
  107825. * Define how the color and intensity of the highlight given by the light in the material.
  107826. */
  107827. specularTexture: Nullable<BaseTexture>;
  107828. private _bumpTexture;
  107829. /**
  107830. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107831. * 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.
  107832. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  107833. */
  107834. bumpTexture: Nullable<BaseTexture>;
  107835. private _lightmapTexture;
  107836. /**
  107837. * Complex lighting can be computationally expensive to compute at runtime.
  107838. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107839. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  107840. */
  107841. lightmapTexture: Nullable<BaseTexture>;
  107842. private _refractionTexture;
  107843. /**
  107844. * Define the texture used to display the refraction.
  107845. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107846. */
  107847. refractionTexture: Nullable<BaseTexture>;
  107848. /**
  107849. * The color of the material lit by the environmental background lighting.
  107850. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107851. */
  107852. ambientColor: Color3;
  107853. /**
  107854. * The basic color of the material as viewed under a light.
  107855. */
  107856. diffuseColor: Color3;
  107857. /**
  107858. * Define how the color and intensity of the highlight given by the light in the material.
  107859. */
  107860. specularColor: Color3;
  107861. /**
  107862. * Define the color of the material as if self lit.
  107863. * This will be mixed in the final result even in the absence of light.
  107864. */
  107865. emissiveColor: Color3;
  107866. /**
  107867. * Defines how sharp are the highlights in the material.
  107868. * The bigger the value the sharper giving a more glossy feeling to the result.
  107869. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107870. */
  107871. specularPower: number;
  107872. private _useAlphaFromDiffuseTexture;
  107873. /**
  107874. * Does the transparency come from the diffuse texture alpha channel.
  107875. */
  107876. useAlphaFromDiffuseTexture: boolean;
  107877. private _useEmissiveAsIllumination;
  107878. /**
  107879. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107880. */
  107881. useEmissiveAsIllumination: boolean;
  107882. private _linkEmissiveWithDiffuse;
  107883. /**
  107884. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107885. * the emissive level when the final color is close to one.
  107886. */
  107887. linkEmissiveWithDiffuse: boolean;
  107888. private _useSpecularOverAlpha;
  107889. /**
  107890. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107891. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107892. */
  107893. useSpecularOverAlpha: boolean;
  107894. private _useReflectionOverAlpha;
  107895. /**
  107896. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107897. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107898. */
  107899. useReflectionOverAlpha: boolean;
  107900. private _disableLighting;
  107901. /**
  107902. * Does lights from the scene impacts this material.
  107903. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107904. */
  107905. disableLighting: boolean;
  107906. private _useObjectSpaceNormalMap;
  107907. /**
  107908. * Allows using an object space normal map (instead of tangent space).
  107909. */
  107910. useObjectSpaceNormalMap: boolean;
  107911. private _useParallax;
  107912. /**
  107913. * Is parallax enabled or not.
  107914. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  107915. */
  107916. useParallax: boolean;
  107917. private _useParallaxOcclusion;
  107918. /**
  107919. * Is parallax occlusion enabled or not.
  107920. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107921. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  107922. */
  107923. useParallaxOcclusion: boolean;
  107924. /**
  107925. * 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.
  107926. */
  107927. parallaxScaleBias: number;
  107928. private _roughness;
  107929. /**
  107930. * Helps to define how blurry the reflections should appears in the material.
  107931. */
  107932. roughness: number;
  107933. /**
  107934. * In case of refraction, define the value of the index of refraction.
  107935. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107936. */
  107937. indexOfRefraction: number;
  107938. /**
  107939. * Invert the refraction texture alongside the y axis.
  107940. * It can be useful with procedural textures or probe for instance.
  107941. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107942. */
  107943. invertRefractionY: boolean;
  107944. /**
  107945. * Defines the alpha limits in alpha test mode.
  107946. */
  107947. alphaCutOff: number;
  107948. private _useLightmapAsShadowmap;
  107949. /**
  107950. * In case of light mapping, define whether the map contains light or shadow informations.
  107951. */
  107952. useLightmapAsShadowmap: boolean;
  107953. private _diffuseFresnelParameters;
  107954. /**
  107955. * Define the diffuse fresnel parameters of the material.
  107956. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107957. */
  107958. diffuseFresnelParameters: FresnelParameters;
  107959. private _opacityFresnelParameters;
  107960. /**
  107961. * Define the opacity fresnel parameters of the material.
  107962. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107963. */
  107964. opacityFresnelParameters: FresnelParameters;
  107965. private _reflectionFresnelParameters;
  107966. /**
  107967. * Define the reflection fresnel parameters of the material.
  107968. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107969. */
  107970. reflectionFresnelParameters: FresnelParameters;
  107971. private _refractionFresnelParameters;
  107972. /**
  107973. * Define the refraction fresnel parameters of the material.
  107974. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107975. */
  107976. refractionFresnelParameters: FresnelParameters;
  107977. private _emissiveFresnelParameters;
  107978. /**
  107979. * Define the emissive fresnel parameters of the material.
  107980. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107981. */
  107982. emissiveFresnelParameters: FresnelParameters;
  107983. private _useReflectionFresnelFromSpecular;
  107984. /**
  107985. * If true automatically deducts the fresnels values from the material specularity.
  107986. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107987. */
  107988. useReflectionFresnelFromSpecular: boolean;
  107989. private _useGlossinessFromSpecularMapAlpha;
  107990. /**
  107991. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107992. */
  107993. useGlossinessFromSpecularMapAlpha: boolean;
  107994. private _maxSimultaneousLights;
  107995. /**
  107996. * Defines the maximum number of lights that can be used in the material
  107997. */
  107998. maxSimultaneousLights: number;
  107999. private _invertNormalMapX;
  108000. /**
  108001. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108002. */
  108003. invertNormalMapX: boolean;
  108004. private _invertNormalMapY;
  108005. /**
  108006. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108007. */
  108008. invertNormalMapY: boolean;
  108009. private _twoSidedLighting;
  108010. /**
  108011. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108012. */
  108013. twoSidedLighting: boolean;
  108014. /**
  108015. * Default configuration related to image processing available in the standard Material.
  108016. */
  108017. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108018. /**
  108019. * Gets the image processing configuration used either in this material.
  108020. */
  108021. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108022. /**
  108023. * Sets the Default image processing configuration used either in the this material.
  108024. *
  108025. * If sets to null, the scene one is in use.
  108026. */
  108027. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  108028. /**
  108029. * Keep track of the image processing observer to allow dispose and replace.
  108030. */
  108031. private _imageProcessingObserver;
  108032. /**
  108033. * Attaches a new image processing configuration to the Standard Material.
  108034. * @param configuration
  108035. */
  108036. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108037. /**
  108038. * Gets wether the color curves effect is enabled.
  108039. */
  108040. get cameraColorCurvesEnabled(): boolean;
  108041. /**
  108042. * Sets wether the color curves effect is enabled.
  108043. */
  108044. set cameraColorCurvesEnabled(value: boolean);
  108045. /**
  108046. * Gets wether the color grading effect is enabled.
  108047. */
  108048. get cameraColorGradingEnabled(): boolean;
  108049. /**
  108050. * Gets wether the color grading effect is enabled.
  108051. */
  108052. set cameraColorGradingEnabled(value: boolean);
  108053. /**
  108054. * Gets wether tonemapping is enabled or not.
  108055. */
  108056. get cameraToneMappingEnabled(): boolean;
  108057. /**
  108058. * Sets wether tonemapping is enabled or not
  108059. */
  108060. set cameraToneMappingEnabled(value: boolean);
  108061. /**
  108062. * The camera exposure used on this material.
  108063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108064. * This corresponds to a photographic exposure.
  108065. */
  108066. get cameraExposure(): number;
  108067. /**
  108068. * The camera exposure used on this material.
  108069. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108070. * This corresponds to a photographic exposure.
  108071. */
  108072. set cameraExposure(value: number);
  108073. /**
  108074. * Gets The camera contrast used on this material.
  108075. */
  108076. get cameraContrast(): number;
  108077. /**
  108078. * Sets The camera contrast used on this material.
  108079. */
  108080. set cameraContrast(value: number);
  108081. /**
  108082. * Gets the Color Grading 2D Lookup Texture.
  108083. */
  108084. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  108085. /**
  108086. * Sets the Color Grading 2D Lookup Texture.
  108087. */
  108088. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  108089. /**
  108090. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108091. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108092. * 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;
  108093. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108094. */
  108095. get cameraColorCurves(): Nullable<ColorCurves>;
  108096. /**
  108097. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108098. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108099. * 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;
  108100. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108101. */
  108102. set cameraColorCurves(value: Nullable<ColorCurves>);
  108103. /**
  108104. * Defines the detail map parameters for the material.
  108105. */
  108106. readonly detailMap: DetailMapConfiguration;
  108107. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108108. protected _worldViewProjectionMatrix: Matrix;
  108109. protected _globalAmbientColor: Color3;
  108110. protected _useLogarithmicDepth: boolean;
  108111. protected _rebuildInParallel: boolean;
  108112. /**
  108113. * Instantiates a new standard material.
  108114. * This is the default material used in Babylon. It is the best trade off between quality
  108115. * and performances.
  108116. * @see https://doc.babylonjs.com/babylon101/materials
  108117. * @param name Define the name of the material in the scene
  108118. * @param scene Define the scene the material belong to
  108119. */
  108120. constructor(name: string, scene: Scene);
  108121. /**
  108122. * Gets a boolean indicating that current material needs to register RTT
  108123. */
  108124. get hasRenderTargetTextures(): boolean;
  108125. /**
  108126. * Gets the current class name of the material e.g. "StandardMaterial"
  108127. * Mainly use in serialization.
  108128. * @returns the class name
  108129. */
  108130. getClassName(): string;
  108131. /**
  108132. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108133. * You can try switching to logarithmic depth.
  108134. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108135. */
  108136. get useLogarithmicDepth(): boolean;
  108137. set useLogarithmicDepth(value: boolean);
  108138. /**
  108139. * Specifies if the material will require alpha blending
  108140. * @returns a boolean specifying if alpha blending is needed
  108141. */
  108142. needAlphaBlending(): boolean;
  108143. /**
  108144. * Specifies if this material should be rendered in alpha test mode
  108145. * @returns a boolean specifying if an alpha test is needed.
  108146. */
  108147. needAlphaTesting(): boolean;
  108148. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108149. /**
  108150. * Get the texture used for alpha test purpose.
  108151. * @returns the diffuse texture in case of the standard material.
  108152. */
  108153. getAlphaTestTexture(): Nullable<BaseTexture>;
  108154. /**
  108155. * Get if the submesh is ready to be used and all its information available.
  108156. * Child classes can use it to update shaders
  108157. * @param mesh defines the mesh to check
  108158. * @param subMesh defines which submesh to check
  108159. * @param useInstances specifies that instances should be used
  108160. * @returns a boolean indicating that the submesh is ready or not
  108161. */
  108162. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108163. /**
  108164. * Builds the material UBO layouts.
  108165. * Used internally during the effect preparation.
  108166. */
  108167. buildUniformLayout(): void;
  108168. /**
  108169. * Unbinds the material from the mesh
  108170. */
  108171. unbind(): void;
  108172. /**
  108173. * Binds the submesh to this material by preparing the effect and shader to draw
  108174. * @param world defines the world transformation matrix
  108175. * @param mesh defines the mesh containing the submesh
  108176. * @param subMesh defines the submesh to bind the material to
  108177. */
  108178. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108179. /**
  108180. * Get the list of animatables in the material.
  108181. * @returns the list of animatables object used in the material
  108182. */
  108183. getAnimatables(): IAnimatable[];
  108184. /**
  108185. * Gets the active textures from the material
  108186. * @returns an array of textures
  108187. */
  108188. getActiveTextures(): BaseTexture[];
  108189. /**
  108190. * Specifies if the material uses a texture
  108191. * @param texture defines the texture to check against the material
  108192. * @returns a boolean specifying if the material uses the texture
  108193. */
  108194. hasTexture(texture: BaseTexture): boolean;
  108195. /**
  108196. * Disposes the material
  108197. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108198. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108199. */
  108200. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108201. /**
  108202. * Makes a duplicate of the material, and gives it a new name
  108203. * @param name defines the new name for the duplicated material
  108204. * @returns the cloned material
  108205. */
  108206. clone(name: string): StandardMaterial;
  108207. /**
  108208. * Serializes this material in a JSON representation
  108209. * @returns the serialized material object
  108210. */
  108211. serialize(): any;
  108212. /**
  108213. * Creates a standard material from parsed material data
  108214. * @param source defines the JSON representation of the material
  108215. * @param scene defines the hosting scene
  108216. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108217. * @returns a new standard material
  108218. */
  108219. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108220. /**
  108221. * Are diffuse textures enabled in the application.
  108222. */
  108223. static get DiffuseTextureEnabled(): boolean;
  108224. static set DiffuseTextureEnabled(value: boolean);
  108225. /**
  108226. * Are detail textures enabled in the application.
  108227. */
  108228. static get DetailTextureEnabled(): boolean;
  108229. static set DetailTextureEnabled(value: boolean);
  108230. /**
  108231. * Are ambient textures enabled in the application.
  108232. */
  108233. static get AmbientTextureEnabled(): boolean;
  108234. static set AmbientTextureEnabled(value: boolean);
  108235. /**
  108236. * Are opacity textures enabled in the application.
  108237. */
  108238. static get OpacityTextureEnabled(): boolean;
  108239. static set OpacityTextureEnabled(value: boolean);
  108240. /**
  108241. * Are reflection textures enabled in the application.
  108242. */
  108243. static get ReflectionTextureEnabled(): boolean;
  108244. static set ReflectionTextureEnabled(value: boolean);
  108245. /**
  108246. * Are emissive textures enabled in the application.
  108247. */
  108248. static get EmissiveTextureEnabled(): boolean;
  108249. static set EmissiveTextureEnabled(value: boolean);
  108250. /**
  108251. * Are specular textures enabled in the application.
  108252. */
  108253. static get SpecularTextureEnabled(): boolean;
  108254. static set SpecularTextureEnabled(value: boolean);
  108255. /**
  108256. * Are bump textures enabled in the application.
  108257. */
  108258. static get BumpTextureEnabled(): boolean;
  108259. static set BumpTextureEnabled(value: boolean);
  108260. /**
  108261. * Are lightmap textures enabled in the application.
  108262. */
  108263. static get LightmapTextureEnabled(): boolean;
  108264. static set LightmapTextureEnabled(value: boolean);
  108265. /**
  108266. * Are refraction textures enabled in the application.
  108267. */
  108268. static get RefractionTextureEnabled(): boolean;
  108269. static set RefractionTextureEnabled(value: boolean);
  108270. /**
  108271. * Are color grading textures enabled in the application.
  108272. */
  108273. static get ColorGradingTextureEnabled(): boolean;
  108274. static set ColorGradingTextureEnabled(value: boolean);
  108275. /**
  108276. * Are fresnels enabled in the application.
  108277. */
  108278. static get FresnelEnabled(): boolean;
  108279. static set FresnelEnabled(value: boolean);
  108280. }
  108281. }
  108282. declare module BABYLON {
  108283. /**
  108284. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  108285. *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.
  108286. * The SPS is also a particle system. It provides some methods to manage the particles.
  108287. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  108288. *
  108289. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  108290. */
  108291. export class SolidParticleSystem implements IDisposable {
  108292. /**
  108293. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  108294. * Example : var p = SPS.particles[i];
  108295. */
  108296. particles: SolidParticle[];
  108297. /**
  108298. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  108299. */
  108300. nbParticles: number;
  108301. /**
  108302. * If the particles must ever face the camera (default false). Useful for planar particles.
  108303. */
  108304. billboard: boolean;
  108305. /**
  108306. * Recompute normals when adding a shape
  108307. */
  108308. recomputeNormals: boolean;
  108309. /**
  108310. * This a counter ofr your own usage. It's not set by any SPS functions.
  108311. */
  108312. counter: number;
  108313. /**
  108314. * The SPS name. This name is also given to the underlying mesh.
  108315. */
  108316. name: string;
  108317. /**
  108318. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  108319. */
  108320. mesh: Mesh;
  108321. /**
  108322. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  108323. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  108324. */
  108325. vars: any;
  108326. /**
  108327. * This array is populated when the SPS is set as 'pickable'.
  108328. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  108329. * Each element of this array is an object `{idx: int, faceId: int}`.
  108330. * `idx` is the picked particle index in the `SPS.particles` array
  108331. * `faceId` is the picked face index counted within this particle.
  108332. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  108333. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  108334. * Use the method SPS.pickedParticle(pickingInfo) instead.
  108335. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  108336. */
  108337. pickedParticles: {
  108338. idx: number;
  108339. faceId: number;
  108340. }[];
  108341. /**
  108342. * This array is populated when the SPS is set as 'pickable'
  108343. * Each key of this array is a submesh index.
  108344. * Each element of this array is a second array defined like this :
  108345. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  108346. * Each element of this second array is an object `{idx: int, faceId: int}`.
  108347. * `idx` is the picked particle index in the `SPS.particles` array
  108348. * `faceId` is the picked face index counted within this particle.
  108349. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  108350. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  108351. */
  108352. pickedBySubMesh: {
  108353. idx: number;
  108354. faceId: number;
  108355. }[][];
  108356. /**
  108357. * This array is populated when `enableDepthSort` is set to true.
  108358. * Each element of this array is an instance of the class DepthSortedParticle.
  108359. */
  108360. depthSortedParticles: DepthSortedParticle[];
  108361. /**
  108362. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  108363. * @hidden
  108364. */
  108365. _bSphereOnly: boolean;
  108366. /**
  108367. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  108368. * @hidden
  108369. */
  108370. _bSphereRadiusFactor: number;
  108371. private _scene;
  108372. private _positions;
  108373. private _indices;
  108374. private _normals;
  108375. private _colors;
  108376. private _uvs;
  108377. private _indices32;
  108378. private _positions32;
  108379. private _normals32;
  108380. private _fixedNormal32;
  108381. private _colors32;
  108382. private _uvs32;
  108383. private _index;
  108384. private _updatable;
  108385. private _pickable;
  108386. private _isVisibilityBoxLocked;
  108387. private _alwaysVisible;
  108388. private _depthSort;
  108389. private _expandable;
  108390. private _shapeCounter;
  108391. private _copy;
  108392. private _color;
  108393. private _computeParticleColor;
  108394. private _computeParticleTexture;
  108395. private _computeParticleRotation;
  108396. private _computeParticleVertex;
  108397. private _computeBoundingBox;
  108398. private _depthSortParticles;
  108399. private _camera;
  108400. private _mustUnrotateFixedNormals;
  108401. private _particlesIntersect;
  108402. private _needs32Bits;
  108403. private _isNotBuilt;
  108404. private _lastParticleId;
  108405. private _idxOfId;
  108406. private _multimaterialEnabled;
  108407. private _useModelMaterial;
  108408. private _indicesByMaterial;
  108409. private _materialIndexes;
  108410. private _depthSortFunction;
  108411. private _materialSortFunction;
  108412. private _materials;
  108413. private _multimaterial;
  108414. private _materialIndexesById;
  108415. private _defaultMaterial;
  108416. private _autoUpdateSubMeshes;
  108417. private _tmpVertex;
  108418. /**
  108419. * Creates a SPS (Solid Particle System) object.
  108420. * @param name (String) is the SPS name, this will be the underlying mesh name.
  108421. * @param scene (Scene) is the scene in which the SPS is added.
  108422. * @param options defines the options of the sps e.g.
  108423. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  108424. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  108425. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  108426. * * 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.
  108427. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  108428. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  108429. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  108430. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  108431. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  108432. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  108433. */
  108434. constructor(name: string, scene: Scene, options?: {
  108435. updatable?: boolean;
  108436. isPickable?: boolean;
  108437. enableDepthSort?: boolean;
  108438. particleIntersection?: boolean;
  108439. boundingSphereOnly?: boolean;
  108440. bSphereRadiusFactor?: number;
  108441. expandable?: boolean;
  108442. useModelMaterial?: boolean;
  108443. enableMultiMaterial?: boolean;
  108444. });
  108445. /**
  108446. * Builds the SPS underlying mesh. Returns a standard Mesh.
  108447. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  108448. * @returns the created mesh
  108449. */
  108450. buildMesh(): Mesh;
  108451. /**
  108452. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108453. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108454. * Thus the particles generated from `digest()` have their property `position` set yet.
  108455. * @param mesh ( Mesh ) is the mesh to be digested
  108456. * @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
  108457. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108458. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108459. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108460. * @returns the current SPS
  108461. */
  108462. digest(mesh: Mesh, options?: {
  108463. facetNb?: number;
  108464. number?: number;
  108465. delta?: number;
  108466. storage?: [];
  108467. }): SolidParticleSystem;
  108468. /**
  108469. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108470. * @hidden
  108471. */
  108472. private _unrotateFixedNormals;
  108473. /**
  108474. * Resets the temporary working copy particle
  108475. * @hidden
  108476. */
  108477. private _resetCopy;
  108478. /**
  108479. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  108480. * @param p the current index in the positions array to be updated
  108481. * @param ind the current index in the indices array
  108482. * @param shape a Vector3 array, the shape geometry
  108483. * @param positions the positions array to be updated
  108484. * @param meshInd the shape indices array
  108485. * @param indices the indices array to be updated
  108486. * @param meshUV the shape uv array
  108487. * @param uvs the uv array to be updated
  108488. * @param meshCol the shape color array
  108489. * @param colors the color array to be updated
  108490. * @param meshNor the shape normals array
  108491. * @param normals the normals array to be updated
  108492. * @param idx the particle index
  108493. * @param idxInShape the particle index in its shape
  108494. * @param options the addShape() method passed options
  108495. * @model the particle model
  108496. * @hidden
  108497. */
  108498. private _meshBuilder;
  108499. /**
  108500. * Returns a shape Vector3 array from positions float array
  108501. * @param positions float array
  108502. * @returns a vector3 array
  108503. * @hidden
  108504. */
  108505. private _posToShape;
  108506. /**
  108507. * Returns a shapeUV array from a float uvs (array deep copy)
  108508. * @param uvs as a float array
  108509. * @returns a shapeUV array
  108510. * @hidden
  108511. */
  108512. private _uvsToShapeUV;
  108513. /**
  108514. * Adds a new particle object in the particles array
  108515. * @param idx particle index in particles array
  108516. * @param id particle id
  108517. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  108518. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  108519. * @param model particle ModelShape object
  108520. * @param shapeId model shape identifier
  108521. * @param idxInShape index of the particle in the current model
  108522. * @param bInfo model bounding info object
  108523. * @param storage target storage array, if any
  108524. * @hidden
  108525. */
  108526. private _addParticle;
  108527. /**
  108528. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108529. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  108530. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108531. * @param nb (positive integer) the number of particles to be created from this model
  108532. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108533. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108534. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108535. * @returns the number of shapes in the system
  108536. */
  108537. addShape(mesh: Mesh, nb: number, options?: {
  108538. positionFunction?: any;
  108539. vertexFunction?: any;
  108540. storage?: [];
  108541. }): number;
  108542. /**
  108543. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108544. * @hidden
  108545. */
  108546. private _rebuildParticle;
  108547. /**
  108548. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108549. * @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.
  108550. * @returns the SPS.
  108551. */
  108552. rebuildMesh(reset?: boolean): SolidParticleSystem;
  108553. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  108554. * Returns an array with the removed particles.
  108555. * 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.
  108556. * The SPS can't be empty so at least one particle needs to remain in place.
  108557. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  108558. * @param start index of the first particle to remove
  108559. * @param end index of the last particle to remove (included)
  108560. * @returns an array populated with the removed particles
  108561. */
  108562. removeParticles(start: number, end: number): SolidParticle[];
  108563. /**
  108564. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  108565. * @param solidParticleArray an array populated with Solid Particles objects
  108566. * @returns the SPS
  108567. */
  108568. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  108569. /**
  108570. * Creates a new particle and modifies the SPS mesh geometry :
  108571. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  108572. * - calls _addParticle() to populate the particle array
  108573. * factorized code from addShape() and insertParticlesFromArray()
  108574. * @param idx particle index in the particles array
  108575. * @param i particle index in its shape
  108576. * @param modelShape particle ModelShape object
  108577. * @param shape shape vertex array
  108578. * @param meshInd shape indices array
  108579. * @param meshUV shape uv array
  108580. * @param meshCol shape color array
  108581. * @param meshNor shape normals array
  108582. * @param bbInfo shape bounding info
  108583. * @param storage target particle storage
  108584. * @options addShape() passed options
  108585. * @hidden
  108586. */
  108587. private _insertNewParticle;
  108588. /**
  108589. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108590. * This method calls `updateParticle()` for each particle of the SPS.
  108591. * For an animated SPS, it is usually called within the render loop.
  108592. * 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.
  108593. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108594. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108595. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108596. * @returns the SPS.
  108597. */
  108598. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  108599. /**
  108600. * Disposes the SPS.
  108601. */
  108602. dispose(): void;
  108603. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  108604. * idx is the particle index in the SPS
  108605. * faceId is the picked face index counted within this particle.
  108606. * Returns null if the pickInfo can't identify a picked particle.
  108607. * @param pickingInfo (PickingInfo object)
  108608. * @returns {idx: number, faceId: number} or null
  108609. */
  108610. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  108611. idx: number;
  108612. faceId: number;
  108613. }>;
  108614. /**
  108615. * Returns a SolidParticle object from its identifier : particle.id
  108616. * @param id (integer) the particle Id
  108617. * @returns the searched particle or null if not found in the SPS.
  108618. */
  108619. getParticleById(id: number): Nullable<SolidParticle>;
  108620. /**
  108621. * Returns a new array populated with the particles having the passed shapeId.
  108622. * @param shapeId (integer) the shape identifier
  108623. * @returns a new solid particle array
  108624. */
  108625. getParticlesByShapeId(shapeId: number): SolidParticle[];
  108626. /**
  108627. * Populates the passed array "ref" with the particles having the passed shapeId.
  108628. * @param shapeId the shape identifier
  108629. * @returns the SPS
  108630. * @param ref
  108631. */
  108632. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  108633. /**
  108634. * Computes the required SubMeshes according the materials assigned to the particles.
  108635. * @returns the solid particle system.
  108636. * Does nothing if called before the SPS mesh is built.
  108637. */
  108638. computeSubMeshes(): SolidParticleSystem;
  108639. /**
  108640. * Sorts the solid particles by material when MultiMaterial is enabled.
  108641. * Updates the indices32 array.
  108642. * Updates the indicesByMaterial array.
  108643. * Updates the mesh indices array.
  108644. * @returns the SPS
  108645. * @hidden
  108646. */
  108647. private _sortParticlesByMaterial;
  108648. /**
  108649. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  108650. * @hidden
  108651. */
  108652. private _setMaterialIndexesById;
  108653. /**
  108654. * Returns an array with unique values of Materials from the passed array
  108655. * @param array the material array to be checked and filtered
  108656. * @hidden
  108657. */
  108658. private _filterUniqueMaterialId;
  108659. /**
  108660. * Sets a new Standard Material as _defaultMaterial if not already set.
  108661. * @hidden
  108662. */
  108663. private _setDefaultMaterial;
  108664. /**
  108665. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108666. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108667. * @returns the SPS.
  108668. */
  108669. refreshVisibleSize(): SolidParticleSystem;
  108670. /**
  108671. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108672. * @param size the size (float) of the visibility box
  108673. * note : this doesn't lock the SPS mesh bounding box.
  108674. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108675. */
  108676. setVisibilityBox(size: number): void;
  108677. /**
  108678. * Gets whether the SPS as always visible or not
  108679. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108680. */
  108681. get isAlwaysVisible(): boolean;
  108682. /**
  108683. * Sets the SPS as always visible or not
  108684. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108685. */
  108686. set isAlwaysVisible(val: boolean);
  108687. /**
  108688. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108689. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108690. */
  108691. set isVisibilityBoxLocked(val: boolean);
  108692. /**
  108693. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108694. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108695. */
  108696. get isVisibilityBoxLocked(): boolean;
  108697. /**
  108698. * Tells to `setParticles()` to compute the particle rotations or not.
  108699. * Default value : true. The SPS is faster when it's set to false.
  108700. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108701. */
  108702. set computeParticleRotation(val: boolean);
  108703. /**
  108704. * Tells to `setParticles()` to compute the particle colors or not.
  108705. * Default value : true. The SPS is faster when it's set to false.
  108706. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108707. */
  108708. set computeParticleColor(val: boolean);
  108709. set computeParticleTexture(val: boolean);
  108710. /**
  108711. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108712. * Default value : false. The SPS is faster when it's set to false.
  108713. * Note : the particle custom vertex positions aren't stored values.
  108714. */
  108715. set computeParticleVertex(val: boolean);
  108716. /**
  108717. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108718. */
  108719. set computeBoundingBox(val: boolean);
  108720. /**
  108721. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108722. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108723. * Default : `true`
  108724. */
  108725. set depthSortParticles(val: boolean);
  108726. /**
  108727. * Gets if `setParticles()` computes the particle rotations or not.
  108728. * Default value : true. The SPS is faster when it's set to false.
  108729. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108730. */
  108731. get computeParticleRotation(): boolean;
  108732. /**
  108733. * Gets if `setParticles()` computes the particle colors or not.
  108734. * Default value : true. The SPS is faster when it's set to false.
  108735. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108736. */
  108737. get computeParticleColor(): boolean;
  108738. /**
  108739. * Gets if `setParticles()` computes the particle textures or not.
  108740. * Default value : true. The SPS is faster when it's set to false.
  108741. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108742. */
  108743. get computeParticleTexture(): boolean;
  108744. /**
  108745. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108746. * Default value : false. The SPS is faster when it's set to false.
  108747. * Note : the particle custom vertex positions aren't stored values.
  108748. */
  108749. get computeParticleVertex(): boolean;
  108750. /**
  108751. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108752. */
  108753. get computeBoundingBox(): boolean;
  108754. /**
  108755. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108756. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108757. * Default : `true`
  108758. */
  108759. get depthSortParticles(): boolean;
  108760. /**
  108761. * Gets if the SPS is created as expandable at construction time.
  108762. * Default : `false`
  108763. */
  108764. get expandable(): boolean;
  108765. /**
  108766. * Gets if the SPS supports the Multi Materials
  108767. */
  108768. get multimaterialEnabled(): boolean;
  108769. /**
  108770. * Gets if the SPS uses the model materials for its own multimaterial.
  108771. */
  108772. get useModelMaterial(): boolean;
  108773. /**
  108774. * The SPS used material array.
  108775. */
  108776. get materials(): Material[];
  108777. /**
  108778. * Sets the SPS MultiMaterial from the passed materials.
  108779. * Note : the passed array is internally copied and not used then by reference.
  108780. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  108781. */
  108782. setMultiMaterial(materials: Material[]): void;
  108783. /**
  108784. * The SPS computed multimaterial object
  108785. */
  108786. get multimaterial(): MultiMaterial;
  108787. set multimaterial(mm: MultiMaterial);
  108788. /**
  108789. * If the subMeshes must be updated on the next call to setParticles()
  108790. */
  108791. get autoUpdateSubMeshes(): boolean;
  108792. set autoUpdateSubMeshes(val: boolean);
  108793. /**
  108794. * This function does nothing. It may be overwritten to set all the particle first values.
  108795. * The SPS doesn't call this function, you may have to call it by your own.
  108796. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108797. */
  108798. initParticles(): void;
  108799. /**
  108800. * This function does nothing. It may be overwritten to recycle a particle.
  108801. * The SPS doesn't call this function, you may have to call it by your own.
  108802. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108803. * @param particle The particle to recycle
  108804. * @returns the recycled particle
  108805. */
  108806. recycleParticle(particle: SolidParticle): SolidParticle;
  108807. /**
  108808. * Updates a particle : this function should be overwritten by the user.
  108809. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108810. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108811. * @example : just set a particle position or velocity and recycle conditions
  108812. * @param particle The particle to update
  108813. * @returns the updated particle
  108814. */
  108815. updateParticle(particle: SolidParticle): SolidParticle;
  108816. /**
  108817. * Updates a vertex of a particle : it can be overwritten by the user.
  108818. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108819. * @param particle the current particle
  108820. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  108821. * @param pt the index of the current vertex in the particle shape
  108822. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  108823. * @example : just set a vertex particle position or color
  108824. * @returns the sps
  108825. */
  108826. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  108827. /**
  108828. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108829. * This does nothing and may be overwritten by the user.
  108830. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108831. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108832. * @param update the boolean update value actually passed to setParticles()
  108833. */
  108834. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108835. /**
  108836. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108837. * This will be passed three parameters.
  108838. * This does nothing and may be overwritten by the user.
  108839. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108840. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108841. * @param update the boolean update value actually passed to setParticles()
  108842. */
  108843. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108844. }
  108845. }
  108846. declare module BABYLON {
  108847. /**
  108848. * Represents one particle of a solid particle system.
  108849. */
  108850. export class SolidParticle {
  108851. /**
  108852. * particle global index
  108853. */
  108854. idx: number;
  108855. /**
  108856. * particle identifier
  108857. */
  108858. id: number;
  108859. /**
  108860. * The color of the particle
  108861. */
  108862. color: Nullable<Color4>;
  108863. /**
  108864. * The world space position of the particle.
  108865. */
  108866. position: Vector3;
  108867. /**
  108868. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  108869. */
  108870. rotation: Vector3;
  108871. /**
  108872. * The world space rotation quaternion of the particle.
  108873. */
  108874. rotationQuaternion: Nullable<Quaternion>;
  108875. /**
  108876. * The scaling of the particle.
  108877. */
  108878. scaling: Vector3;
  108879. /**
  108880. * The uvs of the particle.
  108881. */
  108882. uvs: Vector4;
  108883. /**
  108884. * The current speed of the particle.
  108885. */
  108886. velocity: Vector3;
  108887. /**
  108888. * The pivot point in the particle local space.
  108889. */
  108890. pivot: Vector3;
  108891. /**
  108892. * Must the particle be translated from its pivot point in its local space ?
  108893. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  108894. * Default : false
  108895. */
  108896. translateFromPivot: boolean;
  108897. /**
  108898. * Is the particle active or not ?
  108899. */
  108900. alive: boolean;
  108901. /**
  108902. * Is the particle visible or not ?
  108903. */
  108904. isVisible: boolean;
  108905. /**
  108906. * Index of this particle in the global "positions" array (Internal use)
  108907. * @hidden
  108908. */
  108909. _pos: number;
  108910. /**
  108911. * @hidden Index of this particle in the global "indices" array (Internal use)
  108912. */
  108913. _ind: number;
  108914. /**
  108915. * @hidden ModelShape of this particle (Internal use)
  108916. */
  108917. _model: ModelShape;
  108918. /**
  108919. * ModelShape id of this particle
  108920. */
  108921. shapeId: number;
  108922. /**
  108923. * Index of the particle in its shape id
  108924. */
  108925. idxInShape: number;
  108926. /**
  108927. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  108928. */
  108929. _modelBoundingInfo: BoundingInfo;
  108930. /**
  108931. * @hidden Particle BoundingInfo object (Internal use)
  108932. */
  108933. _boundingInfo: BoundingInfo;
  108934. /**
  108935. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  108936. */
  108937. _sps: SolidParticleSystem;
  108938. /**
  108939. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  108940. */
  108941. _stillInvisible: boolean;
  108942. /**
  108943. * @hidden Last computed particle rotation matrix
  108944. */
  108945. _rotationMatrix: number[];
  108946. /**
  108947. * Parent particle Id, if any.
  108948. * Default null.
  108949. */
  108950. parentId: Nullable<number>;
  108951. /**
  108952. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  108953. */
  108954. materialIndex: Nullable<number>;
  108955. /**
  108956. * Custom object or properties.
  108957. */
  108958. props: Nullable<any>;
  108959. /**
  108960. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  108961. * The possible values are :
  108962. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108963. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108964. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108965. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108966. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108967. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  108968. * */
  108969. cullingStrategy: number;
  108970. /**
  108971. * @hidden Internal global position in the SPS.
  108972. */
  108973. _globalPosition: Vector3;
  108974. /**
  108975. * Creates a Solid Particle object.
  108976. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  108977. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  108978. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  108979. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  108980. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  108981. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  108982. * @param shapeId (integer) is the model shape identifier in the SPS.
  108983. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  108984. * @param sps defines the sps it is associated to
  108985. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  108986. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  108987. */
  108988. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  108989. /**
  108990. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  108991. * @param target the particle target
  108992. * @returns the current particle
  108993. */
  108994. copyToRef(target: SolidParticle): SolidParticle;
  108995. /**
  108996. * Legacy support, changed scale to scaling
  108997. */
  108998. get scale(): Vector3;
  108999. /**
  109000. * Legacy support, changed scale to scaling
  109001. */
  109002. set scale(scale: Vector3);
  109003. /**
  109004. * Legacy support, changed quaternion to rotationQuaternion
  109005. */
  109006. get quaternion(): Nullable<Quaternion>;
  109007. /**
  109008. * Legacy support, changed quaternion to rotationQuaternion
  109009. */
  109010. set quaternion(q: Nullable<Quaternion>);
  109011. /**
  109012. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  109013. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  109014. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  109015. * @returns true if it intersects
  109016. */
  109017. intersectsMesh(target: Mesh | SolidParticle): boolean;
  109018. /**
  109019. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  109020. * A particle is in the frustum if its bounding box intersects the frustum
  109021. * @param frustumPlanes defines the frustum to test
  109022. * @returns true if the particle is in the frustum planes
  109023. */
  109024. isInFrustum(frustumPlanes: Plane[]): boolean;
  109025. /**
  109026. * get the rotation matrix of the particle
  109027. * @hidden
  109028. */
  109029. getRotationMatrix(m: Matrix): void;
  109030. }
  109031. /**
  109032. * Represents the shape of the model used by one particle of a solid particle system.
  109033. * SPS internal tool, don't use it manually.
  109034. */
  109035. export class ModelShape {
  109036. /**
  109037. * The shape id
  109038. * @hidden
  109039. */
  109040. shapeID: number;
  109041. /**
  109042. * flat array of model positions (internal use)
  109043. * @hidden
  109044. */
  109045. _shape: Vector3[];
  109046. /**
  109047. * flat array of model UVs (internal use)
  109048. * @hidden
  109049. */
  109050. _shapeUV: number[];
  109051. /**
  109052. * color array of the model
  109053. * @hidden
  109054. */
  109055. _shapeColors: number[];
  109056. /**
  109057. * indices array of the model
  109058. * @hidden
  109059. */
  109060. _indices: number[];
  109061. /**
  109062. * normals array of the model
  109063. * @hidden
  109064. */
  109065. _normals: number[];
  109066. /**
  109067. * length of the shape in the model indices array (internal use)
  109068. * @hidden
  109069. */
  109070. _indicesLength: number;
  109071. /**
  109072. * Custom position function (internal use)
  109073. * @hidden
  109074. */
  109075. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  109076. /**
  109077. * Custom vertex function (internal use)
  109078. * @hidden
  109079. */
  109080. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  109081. /**
  109082. * Model material (internal use)
  109083. * @hidden
  109084. */
  109085. _material: Nullable<Material>;
  109086. /**
  109087. * 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.
  109088. * SPS internal tool, don't use it manually.
  109089. * @hidden
  109090. */
  109091. 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>);
  109092. }
  109093. /**
  109094. * Represents a Depth Sorted Particle in the solid particle system.
  109095. * @hidden
  109096. */
  109097. export class DepthSortedParticle {
  109098. /**
  109099. * Particle index
  109100. */
  109101. idx: number;
  109102. /**
  109103. * Index of the particle in the "indices" array
  109104. */
  109105. ind: number;
  109106. /**
  109107. * Length of the particle shape in the "indices" array
  109108. */
  109109. indicesLength: number;
  109110. /**
  109111. * Squared distance from the particle to the camera
  109112. */
  109113. sqDistance: number;
  109114. /**
  109115. * Material index when used with MultiMaterials
  109116. */
  109117. materialIndex: number;
  109118. /**
  109119. * Creates a new sorted particle
  109120. * @param materialIndex
  109121. */
  109122. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  109123. }
  109124. /**
  109125. * Represents a solid particle vertex
  109126. */
  109127. export class SolidParticleVertex {
  109128. /**
  109129. * Vertex position
  109130. */
  109131. position: Vector3;
  109132. /**
  109133. * Vertex color
  109134. */
  109135. color: Color4;
  109136. /**
  109137. * Vertex UV
  109138. */
  109139. uv: Vector2;
  109140. /**
  109141. * Creates a new solid particle vertex
  109142. */
  109143. constructor();
  109144. /** Vertex x coordinate */
  109145. get x(): number;
  109146. set x(val: number);
  109147. /** Vertex y coordinate */
  109148. get y(): number;
  109149. set y(val: number);
  109150. /** Vertex z coordinate */
  109151. get z(): number;
  109152. set z(val: number);
  109153. }
  109154. }
  109155. declare module BABYLON {
  109156. /**
  109157. * @hidden
  109158. */
  109159. export class _MeshCollisionData {
  109160. _checkCollisions: boolean;
  109161. _collisionMask: number;
  109162. _collisionGroup: number;
  109163. _surroundingMeshes: Nullable<AbstractMesh[]>;
  109164. _collider: Nullable<Collider>;
  109165. _oldPositionForCollisions: Vector3;
  109166. _diffPositionForCollisions: Vector3;
  109167. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  109168. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  109169. }
  109170. }
  109171. declare module BABYLON {
  109172. /** @hidden */
  109173. class _FacetDataStorage {
  109174. facetPositions: Vector3[];
  109175. facetNormals: Vector3[];
  109176. facetPartitioning: number[][];
  109177. facetNb: number;
  109178. partitioningSubdivisions: number;
  109179. partitioningBBoxRatio: number;
  109180. facetDataEnabled: boolean;
  109181. facetParameters: any;
  109182. bbSize: Vector3;
  109183. subDiv: {
  109184. max: number;
  109185. X: number;
  109186. Y: number;
  109187. Z: number;
  109188. };
  109189. facetDepthSort: boolean;
  109190. facetDepthSortEnabled: boolean;
  109191. depthSortedIndices: IndicesArray;
  109192. depthSortedFacets: {
  109193. ind: number;
  109194. sqDistance: number;
  109195. }[];
  109196. facetDepthSortFunction: (f1: {
  109197. ind: number;
  109198. sqDistance: number;
  109199. }, f2: {
  109200. ind: number;
  109201. sqDistance: number;
  109202. }) => number;
  109203. facetDepthSortFrom: Vector3;
  109204. facetDepthSortOrigin: Vector3;
  109205. invertedMatrix: Matrix;
  109206. }
  109207. /**
  109208. * @hidden
  109209. **/
  109210. class _InternalAbstractMeshDataInfo {
  109211. _hasVertexAlpha: boolean;
  109212. _useVertexColors: boolean;
  109213. _numBoneInfluencers: number;
  109214. _applyFog: boolean;
  109215. _receiveShadows: boolean;
  109216. _facetData: _FacetDataStorage;
  109217. _visibility: number;
  109218. _skeleton: Nullable<Skeleton>;
  109219. _layerMask: number;
  109220. _computeBonesUsingShaders: boolean;
  109221. _isActive: boolean;
  109222. _onlyForInstances: boolean;
  109223. _isActiveIntermediate: boolean;
  109224. _onlyForInstancesIntermediate: boolean;
  109225. _actAsRegularMesh: boolean;
  109226. }
  109227. /**
  109228. * Class used to store all common mesh properties
  109229. */
  109230. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  109231. /** No occlusion */
  109232. static OCCLUSION_TYPE_NONE: number;
  109233. /** Occlusion set to optimisitic */
  109234. static OCCLUSION_TYPE_OPTIMISTIC: number;
  109235. /** Occlusion set to strict */
  109236. static OCCLUSION_TYPE_STRICT: number;
  109237. /** Use an accurante occlusion algorithm */
  109238. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  109239. /** Use a conservative occlusion algorithm */
  109240. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  109241. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  109242. * Test order :
  109243. * Is the bounding sphere outside the frustum ?
  109244. * If not, are the bounding box vertices outside the frustum ?
  109245. * It not, then the cullable object is in the frustum.
  109246. */
  109247. static readonly CULLINGSTRATEGY_STANDARD: number;
  109248. /** Culling strategy : Bounding Sphere Only.
  109249. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  109250. * It's also less accurate than the standard because some not visible objects can still be selected.
  109251. * Test : is the bounding sphere outside the frustum ?
  109252. * If not, then the cullable object is in the frustum.
  109253. */
  109254. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  109255. /** Culling strategy : Optimistic Inclusion.
  109256. * This in an inclusion test first, then the standard exclusion test.
  109257. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  109258. * 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.
  109259. * Anyway, it's as accurate as the standard strategy.
  109260. * Test :
  109261. * Is the cullable object bounding sphere center in the frustum ?
  109262. * If not, apply the default culling strategy.
  109263. */
  109264. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  109265. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  109266. * This in an inclusion test first, then the bounding sphere only exclusion test.
  109267. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  109268. * 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.
  109269. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  109270. * Test :
  109271. * Is the cullable object bounding sphere center in the frustum ?
  109272. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  109273. */
  109274. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  109275. /**
  109276. * No billboard
  109277. */
  109278. static get BILLBOARDMODE_NONE(): number;
  109279. /** Billboard on X axis */
  109280. static get BILLBOARDMODE_X(): number;
  109281. /** Billboard on Y axis */
  109282. static get BILLBOARDMODE_Y(): number;
  109283. /** Billboard on Z axis */
  109284. static get BILLBOARDMODE_Z(): number;
  109285. /** Billboard on all axes */
  109286. static get BILLBOARDMODE_ALL(): number;
  109287. /** Billboard on using position instead of orientation */
  109288. static get BILLBOARDMODE_USE_POSITION(): number;
  109289. /** @hidden */
  109290. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  109291. /**
  109292. * The culling strategy to use to check whether the mesh must be rendered or not.
  109293. * This value can be changed at any time and will be used on the next render mesh selection.
  109294. * The possible values are :
  109295. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  109296. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109297. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  109298. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  109299. * Please read each static variable documentation to get details about the culling process.
  109300. * */
  109301. cullingStrategy: number;
  109302. /**
  109303. * Gets the number of facets in the mesh
  109304. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  109305. */
  109306. get facetNb(): number;
  109307. /**
  109308. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  109309. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  109310. */
  109311. get partitioningSubdivisions(): number;
  109312. set partitioningSubdivisions(nb: number);
  109313. /**
  109314. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  109315. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  109316. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  109317. */
  109318. get partitioningBBoxRatio(): number;
  109319. set partitioningBBoxRatio(ratio: number);
  109320. /**
  109321. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  109322. * Works only for updatable meshes.
  109323. * Doesn't work with multi-materials
  109324. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  109325. */
  109326. get mustDepthSortFacets(): boolean;
  109327. set mustDepthSortFacets(sort: boolean);
  109328. /**
  109329. * The location (Vector3) where the facet depth sort must be computed from.
  109330. * By default, the active camera position.
  109331. * Used only when facet depth sort is enabled
  109332. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  109333. */
  109334. get facetDepthSortFrom(): Vector3;
  109335. set facetDepthSortFrom(location: Vector3);
  109336. /**
  109337. * gets a boolean indicating if facetData is enabled
  109338. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  109339. */
  109340. get isFacetDataEnabled(): boolean;
  109341. /** @hidden */
  109342. _updateNonUniformScalingState(value: boolean): boolean;
  109343. /**
  109344. * An event triggered when this mesh collides with another one
  109345. */
  109346. onCollideObservable: Observable<AbstractMesh>;
  109347. /** Set a function to call when this mesh collides with another one */
  109348. set onCollide(callback: () => void);
  109349. /**
  109350. * An event triggered when the collision's position changes
  109351. */
  109352. onCollisionPositionChangeObservable: Observable<Vector3>;
  109353. /** Set a function to call when the collision's position changes */
  109354. set onCollisionPositionChange(callback: () => void);
  109355. /**
  109356. * An event triggered when material is changed
  109357. */
  109358. onMaterialChangedObservable: Observable<AbstractMesh>;
  109359. /**
  109360. * Gets or sets the orientation for POV movement & rotation
  109361. */
  109362. definedFacingForward: boolean;
  109363. /** @hidden */
  109364. _occlusionQuery: Nullable<WebGLQuery>;
  109365. /** @hidden */
  109366. _renderingGroup: Nullable<RenderingGroup>;
  109367. /**
  109368. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  109369. */
  109370. get visibility(): number;
  109371. /**
  109372. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  109373. */
  109374. set visibility(value: number);
  109375. /** Gets or sets the alpha index used to sort transparent meshes
  109376. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  109377. */
  109378. alphaIndex: number;
  109379. /**
  109380. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  109381. */
  109382. isVisible: boolean;
  109383. /**
  109384. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  109385. */
  109386. isPickable: boolean;
  109387. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  109388. showSubMeshesBoundingBox: boolean;
  109389. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  109390. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  109391. */
  109392. isBlocker: boolean;
  109393. /**
  109394. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  109395. */
  109396. enablePointerMoveEvents: boolean;
  109397. /**
  109398. * Specifies the rendering group id for this mesh (0 by default)
  109399. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  109400. */
  109401. renderingGroupId: number;
  109402. private _material;
  109403. /** Gets or sets current material */
  109404. get material(): Nullable<Material>;
  109405. set material(value: Nullable<Material>);
  109406. /**
  109407. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  109408. * @see https://doc.babylonjs.com/babylon101/shadows
  109409. */
  109410. get receiveShadows(): boolean;
  109411. set receiveShadows(value: boolean);
  109412. /** Defines color to use when rendering outline */
  109413. outlineColor: Color3;
  109414. /** Define width to use when rendering outline */
  109415. outlineWidth: number;
  109416. /** Defines color to use when rendering overlay */
  109417. overlayColor: Color3;
  109418. /** Defines alpha to use when rendering overlay */
  109419. overlayAlpha: number;
  109420. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  109421. get hasVertexAlpha(): boolean;
  109422. set hasVertexAlpha(value: boolean);
  109423. /** 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) */
  109424. get useVertexColors(): boolean;
  109425. set useVertexColors(value: boolean);
  109426. /**
  109427. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  109428. */
  109429. get computeBonesUsingShaders(): boolean;
  109430. set computeBonesUsingShaders(value: boolean);
  109431. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  109432. get numBoneInfluencers(): number;
  109433. set numBoneInfluencers(value: number);
  109434. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  109435. get applyFog(): boolean;
  109436. set applyFog(value: boolean);
  109437. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  109438. useOctreeForRenderingSelection: boolean;
  109439. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  109440. useOctreeForPicking: boolean;
  109441. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  109442. useOctreeForCollisions: boolean;
  109443. /**
  109444. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  109445. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  109446. */
  109447. get layerMask(): number;
  109448. set layerMask(value: number);
  109449. /**
  109450. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  109451. */
  109452. alwaysSelectAsActiveMesh: boolean;
  109453. /**
  109454. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  109455. */
  109456. doNotSyncBoundingInfo: boolean;
  109457. /**
  109458. * Gets or sets the current action manager
  109459. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  109460. */
  109461. actionManager: Nullable<AbstractActionManager>;
  109462. private _meshCollisionData;
  109463. /**
  109464. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  109465. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109466. */
  109467. ellipsoid: Vector3;
  109468. /**
  109469. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  109470. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109471. */
  109472. ellipsoidOffset: Vector3;
  109473. /**
  109474. * Gets or sets a collision mask used to mask collisions (default is -1).
  109475. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109476. */
  109477. get collisionMask(): number;
  109478. set collisionMask(mask: number);
  109479. /**
  109480. * Gets or sets the current collision group mask (-1 by default).
  109481. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109482. */
  109483. get collisionGroup(): number;
  109484. set collisionGroup(mask: number);
  109485. /**
  109486. * Gets or sets current surrounding meshes (null by default).
  109487. *
  109488. * By default collision detection is tested against every mesh in the scene.
  109489. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  109490. * meshes will be tested for the collision.
  109491. *
  109492. * Note: if set to an empty array no collision will happen when this mesh is moved.
  109493. */
  109494. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  109495. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  109496. /**
  109497. * Defines edge width used when edgesRenderer is enabled
  109498. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109499. */
  109500. edgesWidth: number;
  109501. /**
  109502. * Defines edge color used when edgesRenderer is enabled
  109503. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109504. */
  109505. edgesColor: Color4;
  109506. /** @hidden */
  109507. _edgesRenderer: Nullable<IEdgesRenderer>;
  109508. /** @hidden */
  109509. _masterMesh: Nullable<AbstractMesh>;
  109510. /** @hidden */
  109511. _boundingInfo: Nullable<BoundingInfo>;
  109512. /** @hidden */
  109513. _renderId: number;
  109514. /**
  109515. * Gets or sets the list of subMeshes
  109516. * @see https://doc.babylonjs.com/how_to/multi_materials
  109517. */
  109518. subMeshes: SubMesh[];
  109519. /** @hidden */
  109520. _intersectionsInProgress: AbstractMesh[];
  109521. /** @hidden */
  109522. _unIndexed: boolean;
  109523. /** @hidden */
  109524. _lightSources: Light[];
  109525. /** Gets the list of lights affecting that mesh */
  109526. get lightSources(): Light[];
  109527. /** @hidden */
  109528. get _positions(): Nullable<Vector3[]>;
  109529. /** @hidden */
  109530. _waitingData: {
  109531. lods: Nullable<any>;
  109532. actions: Nullable<any>;
  109533. freezeWorldMatrix: Nullable<boolean>;
  109534. };
  109535. /** @hidden */
  109536. _bonesTransformMatrices: Nullable<Float32Array>;
  109537. /** @hidden */
  109538. _transformMatrixTexture: Nullable<RawTexture>;
  109539. /**
  109540. * Gets or sets a skeleton to apply skining transformations
  109541. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109542. */
  109543. set skeleton(value: Nullable<Skeleton>);
  109544. get skeleton(): Nullable<Skeleton>;
  109545. /**
  109546. * An event triggered when the mesh is rebuilt.
  109547. */
  109548. onRebuildObservable: Observable<AbstractMesh>;
  109549. /**
  109550. * Creates a new AbstractMesh
  109551. * @param name defines the name of the mesh
  109552. * @param scene defines the hosting scene
  109553. */
  109554. constructor(name: string, scene?: Nullable<Scene>);
  109555. /**
  109556. * Returns the string "AbstractMesh"
  109557. * @returns "AbstractMesh"
  109558. */
  109559. getClassName(): string;
  109560. /**
  109561. * Gets a string representation of the current mesh
  109562. * @param fullDetails defines a boolean indicating if full details must be included
  109563. * @returns a string representation of the current mesh
  109564. */
  109565. toString(fullDetails?: boolean): string;
  109566. /**
  109567. * @hidden
  109568. */
  109569. protected _getEffectiveParent(): Nullable<Node>;
  109570. /** @hidden */
  109571. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109572. /** @hidden */
  109573. _rebuild(): void;
  109574. /** @hidden */
  109575. _resyncLightSources(): void;
  109576. /** @hidden */
  109577. _resyncLightSource(light: Light): void;
  109578. /** @hidden */
  109579. _unBindEffect(): void;
  109580. /** @hidden */
  109581. _removeLightSource(light: Light, dispose: boolean): void;
  109582. private _markSubMeshesAsDirty;
  109583. /** @hidden */
  109584. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  109585. /** @hidden */
  109586. _markSubMeshesAsAttributesDirty(): void;
  109587. /** @hidden */
  109588. _markSubMeshesAsMiscDirty(): void;
  109589. /**
  109590. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  109591. */
  109592. get scaling(): Vector3;
  109593. set scaling(newScaling: Vector3);
  109594. /**
  109595. * Returns true if the mesh is blocked. Implemented by child classes
  109596. */
  109597. get isBlocked(): boolean;
  109598. /**
  109599. * Returns the mesh itself by default. Implemented by child classes
  109600. * @param camera defines the camera to use to pick the right LOD level
  109601. * @returns the currentAbstractMesh
  109602. */
  109603. getLOD(camera: Camera): Nullable<AbstractMesh>;
  109604. /**
  109605. * Returns 0 by default. Implemented by child classes
  109606. * @returns an integer
  109607. */
  109608. getTotalVertices(): number;
  109609. /**
  109610. * Returns a positive integer : the total number of indices in this mesh geometry.
  109611. * @returns the numner of indices or zero if the mesh has no geometry.
  109612. */
  109613. getTotalIndices(): number;
  109614. /**
  109615. * Returns null by default. Implemented by child classes
  109616. * @returns null
  109617. */
  109618. getIndices(): Nullable<IndicesArray>;
  109619. /**
  109620. * Returns the array of the requested vertex data kind. Implemented by child classes
  109621. * @param kind defines the vertex data kind to use
  109622. * @returns null
  109623. */
  109624. getVerticesData(kind: string): Nullable<FloatArray>;
  109625. /**
  109626. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109627. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109628. * Note that a new underlying VertexBuffer object is created each call.
  109629. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109630. * @param kind defines vertex data kind:
  109631. * * VertexBuffer.PositionKind
  109632. * * VertexBuffer.UVKind
  109633. * * VertexBuffer.UV2Kind
  109634. * * VertexBuffer.UV3Kind
  109635. * * VertexBuffer.UV4Kind
  109636. * * VertexBuffer.UV5Kind
  109637. * * VertexBuffer.UV6Kind
  109638. * * VertexBuffer.ColorKind
  109639. * * VertexBuffer.MatricesIndicesKind
  109640. * * VertexBuffer.MatricesIndicesExtraKind
  109641. * * VertexBuffer.MatricesWeightsKind
  109642. * * VertexBuffer.MatricesWeightsExtraKind
  109643. * @param data defines the data source
  109644. * @param updatable defines if the data must be flagged as updatable (or static)
  109645. * @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
  109646. * @returns the current mesh
  109647. */
  109648. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109649. /**
  109650. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109651. * If the mesh has no geometry, it is simply returned as it is.
  109652. * @param kind defines vertex data kind:
  109653. * * VertexBuffer.PositionKind
  109654. * * VertexBuffer.UVKind
  109655. * * VertexBuffer.UV2Kind
  109656. * * VertexBuffer.UV3Kind
  109657. * * VertexBuffer.UV4Kind
  109658. * * VertexBuffer.UV5Kind
  109659. * * VertexBuffer.UV6Kind
  109660. * * VertexBuffer.ColorKind
  109661. * * VertexBuffer.MatricesIndicesKind
  109662. * * VertexBuffer.MatricesIndicesExtraKind
  109663. * * VertexBuffer.MatricesWeightsKind
  109664. * * VertexBuffer.MatricesWeightsExtraKind
  109665. * @param data defines the data source
  109666. * @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
  109667. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  109668. * @returns the current mesh
  109669. */
  109670. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109671. /**
  109672. * Sets the mesh indices,
  109673. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109674. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  109675. * @param totalVertices Defines the total number of vertices
  109676. * @returns the current mesh
  109677. */
  109678. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  109679. /**
  109680. * Gets a boolean indicating if specific vertex data is present
  109681. * @param kind defines the vertex data kind to use
  109682. * @returns true is data kind is present
  109683. */
  109684. isVerticesDataPresent(kind: string): boolean;
  109685. /**
  109686. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  109687. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  109688. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  109689. * @returns a BoundingInfo
  109690. */
  109691. getBoundingInfo(): BoundingInfo;
  109692. /**
  109693. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  109694. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  109695. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  109696. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  109697. * @returns the current mesh
  109698. */
  109699. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  109700. /**
  109701. * Overwrite the current bounding info
  109702. * @param boundingInfo defines the new bounding info
  109703. * @returns the current mesh
  109704. */
  109705. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  109706. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  109707. get useBones(): boolean;
  109708. /** @hidden */
  109709. _preActivate(): void;
  109710. /** @hidden */
  109711. _preActivateForIntermediateRendering(renderId: number): void;
  109712. /** @hidden */
  109713. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109714. /** @hidden */
  109715. _postActivate(): void;
  109716. /** @hidden */
  109717. _freeze(): void;
  109718. /** @hidden */
  109719. _unFreeze(): void;
  109720. /**
  109721. * Gets the current world matrix
  109722. * @returns a Matrix
  109723. */
  109724. getWorldMatrix(): Matrix;
  109725. /** @hidden */
  109726. _getWorldMatrixDeterminant(): number;
  109727. /**
  109728. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  109729. */
  109730. get isAnInstance(): boolean;
  109731. /**
  109732. * Gets a boolean indicating if this mesh has instances
  109733. */
  109734. get hasInstances(): boolean;
  109735. /**
  109736. * Gets a boolean indicating if this mesh has thin instances
  109737. */
  109738. get hasThinInstances(): boolean;
  109739. /**
  109740. * Perform relative position change from the point of view of behind the front of the mesh.
  109741. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109742. * Supports definition of mesh facing forward or backward
  109743. * @param amountRight defines the distance on the right axis
  109744. * @param amountUp defines the distance on the up axis
  109745. * @param amountForward defines the distance on the forward axis
  109746. * @returns the current mesh
  109747. */
  109748. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  109749. /**
  109750. * Calculate relative position change from the point of view of behind the front of the mesh.
  109751. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109752. * Supports definition of mesh facing forward or backward
  109753. * @param amountRight defines the distance on the right axis
  109754. * @param amountUp defines the distance on the up axis
  109755. * @param amountForward defines the distance on the forward axis
  109756. * @returns the new displacement vector
  109757. */
  109758. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  109759. /**
  109760. * Perform relative rotation change from the point of view of behind the front of the mesh.
  109761. * Supports definition of mesh facing forward or backward
  109762. * @param flipBack defines the flip
  109763. * @param twirlClockwise defines the twirl
  109764. * @param tiltRight defines the tilt
  109765. * @returns the current mesh
  109766. */
  109767. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  109768. /**
  109769. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  109770. * Supports definition of mesh facing forward or backward.
  109771. * @param flipBack defines the flip
  109772. * @param twirlClockwise defines the twirl
  109773. * @param tiltRight defines the tilt
  109774. * @returns the new rotation vector
  109775. */
  109776. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  109777. /**
  109778. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109779. * This means the mesh underlying bounding box and sphere are recomputed.
  109780. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109781. * @returns the current mesh
  109782. */
  109783. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  109784. /** @hidden */
  109785. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  109786. /** @hidden */
  109787. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  109788. /** @hidden */
  109789. _updateBoundingInfo(): AbstractMesh;
  109790. /** @hidden */
  109791. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  109792. /** @hidden */
  109793. protected _afterComputeWorldMatrix(): void;
  109794. /** @hidden */
  109795. get _effectiveMesh(): AbstractMesh;
  109796. /**
  109797. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109798. * A mesh is in the frustum if its bounding box intersects the frustum
  109799. * @param frustumPlanes defines the frustum to test
  109800. * @returns true if the mesh is in the frustum planes
  109801. */
  109802. isInFrustum(frustumPlanes: Plane[]): boolean;
  109803. /**
  109804. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  109805. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  109806. * @param frustumPlanes defines the frustum to test
  109807. * @returns true if the mesh is completely in the frustum planes
  109808. */
  109809. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  109810. /**
  109811. * True if the mesh intersects another mesh or a SolidParticle object
  109812. * @param mesh defines a target mesh or SolidParticle to test
  109813. * @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)
  109814. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  109815. * @returns true if there is an intersection
  109816. */
  109817. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  109818. /**
  109819. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  109820. * @param point defines the point to test
  109821. * @returns true if there is an intersection
  109822. */
  109823. intersectsPoint(point: Vector3): boolean;
  109824. /**
  109825. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  109826. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109827. */
  109828. get checkCollisions(): boolean;
  109829. set checkCollisions(collisionEnabled: boolean);
  109830. /**
  109831. * Gets Collider object used to compute collisions (not physics)
  109832. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109833. */
  109834. get collider(): Nullable<Collider>;
  109835. /**
  109836. * Move the mesh using collision engine
  109837. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109838. * @param displacement defines the requested displacement vector
  109839. * @returns the current mesh
  109840. */
  109841. moveWithCollisions(displacement: Vector3): AbstractMesh;
  109842. private _onCollisionPositionChange;
  109843. /** @hidden */
  109844. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  109845. /** @hidden */
  109846. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  109847. /** @hidden */
  109848. _checkCollision(collider: Collider): AbstractMesh;
  109849. /** @hidden */
  109850. _generatePointsArray(): boolean;
  109851. /**
  109852. * Checks if the passed Ray intersects with the mesh
  109853. * @param ray defines the ray to use
  109854. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  109855. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109856. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  109857. * @returns the picking info
  109858. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  109859. */
  109860. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  109861. /**
  109862. * Clones the current mesh
  109863. * @param name defines the mesh name
  109864. * @param newParent defines the new mesh parent
  109865. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  109866. * @returns the new mesh
  109867. */
  109868. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  109869. /**
  109870. * Disposes all the submeshes of the current meshnp
  109871. * @returns the current mesh
  109872. */
  109873. releaseSubMeshes(): AbstractMesh;
  109874. /**
  109875. * Releases resources associated with this abstract mesh.
  109876. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109877. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109878. */
  109879. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109880. /**
  109881. * Adds the passed mesh as a child to the current mesh
  109882. * @param mesh defines the child mesh
  109883. * @returns the current mesh
  109884. */
  109885. addChild(mesh: AbstractMesh): AbstractMesh;
  109886. /**
  109887. * Removes the passed mesh from the current mesh children list
  109888. * @param mesh defines the child mesh
  109889. * @returns the current mesh
  109890. */
  109891. removeChild(mesh: AbstractMesh): AbstractMesh;
  109892. /** @hidden */
  109893. private _initFacetData;
  109894. /**
  109895. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  109896. * This method can be called within the render loop.
  109897. * 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
  109898. * @returns the current mesh
  109899. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109900. */
  109901. updateFacetData(): AbstractMesh;
  109902. /**
  109903. * Returns the facetLocalNormals array.
  109904. * The normals are expressed in the mesh local spac
  109905. * @returns an array of Vector3
  109906. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109907. */
  109908. getFacetLocalNormals(): Vector3[];
  109909. /**
  109910. * Returns the facetLocalPositions array.
  109911. * The facet positions are expressed in the mesh local space
  109912. * @returns an array of Vector3
  109913. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109914. */
  109915. getFacetLocalPositions(): Vector3[];
  109916. /**
  109917. * Returns the facetLocalPartioning array
  109918. * @returns an array of array of numbers
  109919. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109920. */
  109921. getFacetLocalPartitioning(): number[][];
  109922. /**
  109923. * Returns the i-th facet position in the world system.
  109924. * This method allocates a new Vector3 per call
  109925. * @param i defines the facet index
  109926. * @returns a new Vector3
  109927. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109928. */
  109929. getFacetPosition(i: number): Vector3;
  109930. /**
  109931. * Sets the reference Vector3 with the i-th facet position in the world system
  109932. * @param i defines the facet index
  109933. * @param ref defines the target vector
  109934. * @returns the current mesh
  109935. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109936. */
  109937. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  109938. /**
  109939. * Returns the i-th facet normal in the world system.
  109940. * This method allocates a new Vector3 per call
  109941. * @param i defines the facet index
  109942. * @returns a new Vector3
  109943. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109944. */
  109945. getFacetNormal(i: number): Vector3;
  109946. /**
  109947. * Sets the reference Vector3 with the i-th facet normal in the world system
  109948. * @param i defines the facet index
  109949. * @param ref defines the target vector
  109950. * @returns the current mesh
  109951. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109952. */
  109953. getFacetNormalToRef(i: number, ref: Vector3): this;
  109954. /**
  109955. * 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)
  109956. * @param x defines x coordinate
  109957. * @param y defines y coordinate
  109958. * @param z defines z coordinate
  109959. * @returns the array of facet indexes
  109960. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109961. */
  109962. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  109963. /**
  109964. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  109965. * @param projected sets as the (x,y,z) world projection on the facet
  109966. * @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
  109967. * @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
  109968. * @param x defines x coordinate
  109969. * @param y defines y coordinate
  109970. * @param z defines z coordinate
  109971. * @returns the face index if found (or null instead)
  109972. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109973. */
  109974. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109975. /**
  109976. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  109977. * @param projected sets as the (x,y,z) local projection on the facet
  109978. * @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
  109979. * @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
  109980. * @param x defines x coordinate
  109981. * @param y defines y coordinate
  109982. * @param z defines z coordinate
  109983. * @returns the face index if found (or null instead)
  109984. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109985. */
  109986. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109987. /**
  109988. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  109989. * @returns the parameters
  109990. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109991. */
  109992. getFacetDataParameters(): any;
  109993. /**
  109994. * Disables the feature FacetData and frees the related memory
  109995. * @returns the current mesh
  109996. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109997. */
  109998. disableFacetData(): AbstractMesh;
  109999. /**
  110000. * Updates the AbstractMesh indices array
  110001. * @param indices defines the data source
  110002. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  110003. * @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)
  110004. * @returns the current mesh
  110005. */
  110006. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  110007. /**
  110008. * Creates new normals data for the mesh
  110009. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  110010. * @returns the current mesh
  110011. */
  110012. createNormals(updatable: boolean): AbstractMesh;
  110013. /**
  110014. * Align the mesh with a normal
  110015. * @param normal defines the normal to use
  110016. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  110017. * @returns the current mesh
  110018. */
  110019. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  110020. /** @hidden */
  110021. _checkOcclusionQuery(): boolean;
  110022. /**
  110023. * Disables the mesh edge rendering mode
  110024. * @returns the currentAbstractMesh
  110025. */
  110026. disableEdgesRendering(): AbstractMesh;
  110027. /**
  110028. * Enables the edge rendering mode on the mesh.
  110029. * This mode makes the mesh edges visible
  110030. * @param epsilon defines the maximal distance between two angles to detect a face
  110031. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  110032. * @returns the currentAbstractMesh
  110033. * @see https://www.babylonjs-playground.com/#19O9TU#0
  110034. */
  110035. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  110036. /**
  110037. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  110038. * @returns an array of particle systems in the scene that use the mesh as an emitter
  110039. */
  110040. getConnectedParticleSystems(): IParticleSystem[];
  110041. }
  110042. }
  110043. declare module BABYLON {
  110044. /**
  110045. * Interface used to define ActionEvent
  110046. */
  110047. export interface IActionEvent {
  110048. /** The mesh or sprite that triggered the action */
  110049. source: any;
  110050. /** The X mouse cursor position at the time of the event */
  110051. pointerX: number;
  110052. /** The Y mouse cursor position at the time of the event */
  110053. pointerY: number;
  110054. /** The mesh that is currently pointed at (can be null) */
  110055. meshUnderPointer: Nullable<AbstractMesh>;
  110056. /** the original (browser) event that triggered the ActionEvent */
  110057. sourceEvent?: any;
  110058. /** additional data for the event */
  110059. additionalData?: any;
  110060. }
  110061. /**
  110062. * ActionEvent is the event being sent when an action is triggered.
  110063. */
  110064. export class ActionEvent implements IActionEvent {
  110065. /** The mesh or sprite that triggered the action */
  110066. source: any;
  110067. /** The X mouse cursor position at the time of the event */
  110068. pointerX: number;
  110069. /** The Y mouse cursor position at the time of the event */
  110070. pointerY: number;
  110071. /** The mesh that is currently pointed at (can be null) */
  110072. meshUnderPointer: Nullable<AbstractMesh>;
  110073. /** the original (browser) event that triggered the ActionEvent */
  110074. sourceEvent?: any;
  110075. /** additional data for the event */
  110076. additionalData?: any;
  110077. /**
  110078. * Creates a new ActionEvent
  110079. * @param source The mesh or sprite that triggered the action
  110080. * @param pointerX The X mouse cursor position at the time of the event
  110081. * @param pointerY The Y mouse cursor position at the time of the event
  110082. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  110083. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  110084. * @param additionalData additional data for the event
  110085. */
  110086. constructor(
  110087. /** The mesh or sprite that triggered the action */
  110088. source: any,
  110089. /** The X mouse cursor position at the time of the event */
  110090. pointerX: number,
  110091. /** The Y mouse cursor position at the time of the event */
  110092. pointerY: number,
  110093. /** The mesh that is currently pointed at (can be null) */
  110094. meshUnderPointer: Nullable<AbstractMesh>,
  110095. /** the original (browser) event that triggered the ActionEvent */
  110096. sourceEvent?: any,
  110097. /** additional data for the event */
  110098. additionalData?: any);
  110099. /**
  110100. * Helper function to auto-create an ActionEvent from a source mesh.
  110101. * @param source The source mesh that triggered the event
  110102. * @param evt The original (browser) event
  110103. * @param additionalData additional data for the event
  110104. * @returns the new ActionEvent
  110105. */
  110106. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  110107. /**
  110108. * Helper function to auto-create an ActionEvent from a source sprite
  110109. * @param source The source sprite that triggered the event
  110110. * @param scene Scene associated with the sprite
  110111. * @param evt The original (browser) event
  110112. * @param additionalData additional data for the event
  110113. * @returns the new ActionEvent
  110114. */
  110115. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  110116. /**
  110117. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  110118. * @param scene the scene where the event occurred
  110119. * @param evt The original (browser) event
  110120. * @returns the new ActionEvent
  110121. */
  110122. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  110123. /**
  110124. * Helper function to auto-create an ActionEvent from a primitive
  110125. * @param prim defines the target primitive
  110126. * @param pointerPos defines the pointer position
  110127. * @param evt The original (browser) event
  110128. * @param additionalData additional data for the event
  110129. * @returns the new ActionEvent
  110130. */
  110131. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  110132. }
  110133. }
  110134. declare module BABYLON {
  110135. /**
  110136. * Abstract class used to decouple action Manager from scene and meshes.
  110137. * Do not instantiate.
  110138. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  110139. */
  110140. export abstract class AbstractActionManager implements IDisposable {
  110141. /** Gets the list of active triggers */
  110142. static Triggers: {
  110143. [key: string]: number;
  110144. };
  110145. /** Gets the cursor to use when hovering items */
  110146. hoverCursor: string;
  110147. /** Gets the list of actions */
  110148. actions: IAction[];
  110149. /**
  110150. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  110151. */
  110152. isRecursive: boolean;
  110153. /**
  110154. * Releases all associated resources
  110155. */
  110156. abstract dispose(): void;
  110157. /**
  110158. * Does this action manager has pointer triggers
  110159. */
  110160. abstract get hasPointerTriggers(): boolean;
  110161. /**
  110162. * Does this action manager has pick triggers
  110163. */
  110164. abstract get hasPickTriggers(): boolean;
  110165. /**
  110166. * Process a specific trigger
  110167. * @param trigger defines the trigger to process
  110168. * @param evt defines the event details to be processed
  110169. */
  110170. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  110171. /**
  110172. * Does this action manager handles actions of any of the given triggers
  110173. * @param triggers defines the triggers to be tested
  110174. * @return a boolean indicating whether one (or more) of the triggers is handled
  110175. */
  110176. abstract hasSpecificTriggers(triggers: number[]): boolean;
  110177. /**
  110178. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  110179. * speed.
  110180. * @param triggerA defines the trigger to be tested
  110181. * @param triggerB defines the trigger to be tested
  110182. * @return a boolean indicating whether one (or more) of the triggers is handled
  110183. */
  110184. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  110185. /**
  110186. * Does this action manager handles actions of a given trigger
  110187. * @param trigger defines the trigger to be tested
  110188. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  110189. * @return whether the trigger is handled
  110190. */
  110191. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  110192. /**
  110193. * Serialize this manager to a JSON object
  110194. * @param name defines the property name to store this manager
  110195. * @returns a JSON representation of this manager
  110196. */
  110197. abstract serialize(name: string): any;
  110198. /**
  110199. * Registers an action to this action manager
  110200. * @param action defines the action to be registered
  110201. * @return the action amended (prepared) after registration
  110202. */
  110203. abstract registerAction(action: IAction): Nullable<IAction>;
  110204. /**
  110205. * Unregisters an action to this action manager
  110206. * @param action defines the action to be unregistered
  110207. * @return a boolean indicating whether the action has been unregistered
  110208. */
  110209. abstract unregisterAction(action: IAction): Boolean;
  110210. /**
  110211. * Does exist one action manager with at least one trigger
  110212. **/
  110213. static get HasTriggers(): boolean;
  110214. /**
  110215. * Does exist one action manager with at least one pick trigger
  110216. **/
  110217. static get HasPickTriggers(): boolean;
  110218. /**
  110219. * Does exist one action manager that handles actions of a given trigger
  110220. * @param trigger defines the trigger to be tested
  110221. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  110222. **/
  110223. static HasSpecificTrigger(trigger: number): boolean;
  110224. }
  110225. }
  110226. declare module BABYLON {
  110227. /**
  110228. * Defines how a node can be built from a string name.
  110229. */
  110230. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  110231. /**
  110232. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  110233. */
  110234. export class Node implements IBehaviorAware<Node> {
  110235. /** @hidden */
  110236. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  110237. private static _NodeConstructors;
  110238. /**
  110239. * Add a new node constructor
  110240. * @param type defines the type name of the node to construct
  110241. * @param constructorFunc defines the constructor function
  110242. */
  110243. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  110244. /**
  110245. * Returns a node constructor based on type name
  110246. * @param type defines the type name
  110247. * @param name defines the new node name
  110248. * @param scene defines the hosting scene
  110249. * @param options defines optional options to transmit to constructors
  110250. * @returns the new constructor or null
  110251. */
  110252. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  110253. /**
  110254. * Gets or sets the name of the node
  110255. */
  110256. name: string;
  110257. /**
  110258. * Gets or sets the id of the node
  110259. */
  110260. id: string;
  110261. /**
  110262. * Gets or sets the unique id of the node
  110263. */
  110264. uniqueId: number;
  110265. /**
  110266. * Gets or sets a string used to store user defined state for the node
  110267. */
  110268. state: string;
  110269. /**
  110270. * Gets or sets an object used to store user defined information for the node
  110271. */
  110272. metadata: any;
  110273. /**
  110274. * For internal use only. Please do not use.
  110275. */
  110276. reservedDataStore: any;
  110277. /**
  110278. * List of inspectable custom properties (used by the Inspector)
  110279. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110280. */
  110281. inspectableCustomProperties: IInspectable[];
  110282. private _doNotSerialize;
  110283. /**
  110284. * Gets or sets a boolean used to define if the node must be serialized
  110285. */
  110286. get doNotSerialize(): boolean;
  110287. set doNotSerialize(value: boolean);
  110288. /** @hidden */
  110289. _isDisposed: boolean;
  110290. /**
  110291. * Gets a list of Animations associated with the node
  110292. */
  110293. animations: Animation[];
  110294. protected _ranges: {
  110295. [name: string]: Nullable<AnimationRange>;
  110296. };
  110297. /**
  110298. * Callback raised when the node is ready to be used
  110299. */
  110300. onReady: Nullable<(node: Node) => void>;
  110301. private _isEnabled;
  110302. private _isParentEnabled;
  110303. private _isReady;
  110304. /** @hidden */
  110305. _currentRenderId: number;
  110306. private _parentUpdateId;
  110307. /** @hidden */
  110308. _childUpdateId: number;
  110309. /** @hidden */
  110310. _waitingParentId: Nullable<string>;
  110311. /** @hidden */
  110312. _scene: Scene;
  110313. /** @hidden */
  110314. _cache: any;
  110315. private _parentNode;
  110316. private _children;
  110317. /** @hidden */
  110318. _worldMatrix: Matrix;
  110319. /** @hidden */
  110320. _worldMatrixDeterminant: number;
  110321. /** @hidden */
  110322. _worldMatrixDeterminantIsDirty: boolean;
  110323. /** @hidden */
  110324. private _sceneRootNodesIndex;
  110325. /**
  110326. * Gets a boolean indicating if the node has been disposed
  110327. * @returns true if the node was disposed
  110328. */
  110329. isDisposed(): boolean;
  110330. /**
  110331. * Gets or sets the parent of the node (without keeping the current position in the scene)
  110332. * @see https://doc.babylonjs.com/how_to/parenting
  110333. */
  110334. set parent(parent: Nullable<Node>);
  110335. get parent(): Nullable<Node>;
  110336. /** @hidden */
  110337. _addToSceneRootNodes(): void;
  110338. /** @hidden */
  110339. _removeFromSceneRootNodes(): void;
  110340. private _animationPropertiesOverride;
  110341. /**
  110342. * Gets or sets the animation properties override
  110343. */
  110344. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  110345. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  110346. /**
  110347. * Gets a string idenfifying the name of the class
  110348. * @returns "Node" string
  110349. */
  110350. getClassName(): string;
  110351. /** @hidden */
  110352. readonly _isNode: boolean;
  110353. /**
  110354. * An event triggered when the mesh is disposed
  110355. */
  110356. onDisposeObservable: Observable<Node>;
  110357. private _onDisposeObserver;
  110358. /**
  110359. * Sets a callback that will be raised when the node will be disposed
  110360. */
  110361. set onDispose(callback: () => void);
  110362. /**
  110363. * Creates a new Node
  110364. * @param name the name and id to be given to this node
  110365. * @param scene the scene this node will be added to
  110366. */
  110367. constructor(name: string, scene?: Nullable<Scene>);
  110368. /**
  110369. * Gets the scene of the node
  110370. * @returns a scene
  110371. */
  110372. getScene(): Scene;
  110373. /**
  110374. * Gets the engine of the node
  110375. * @returns a Engine
  110376. */
  110377. getEngine(): Engine;
  110378. private _behaviors;
  110379. /**
  110380. * Attach a behavior to the node
  110381. * @see https://doc.babylonjs.com/features/behaviour
  110382. * @param behavior defines the behavior to attach
  110383. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  110384. * @returns the current Node
  110385. */
  110386. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  110387. /**
  110388. * Remove an attached behavior
  110389. * @see https://doc.babylonjs.com/features/behaviour
  110390. * @param behavior defines the behavior to attach
  110391. * @returns the current Node
  110392. */
  110393. removeBehavior(behavior: Behavior<Node>): Node;
  110394. /**
  110395. * Gets the list of attached behaviors
  110396. * @see https://doc.babylonjs.com/features/behaviour
  110397. */
  110398. get behaviors(): Behavior<Node>[];
  110399. /**
  110400. * Gets an attached behavior by name
  110401. * @param name defines the name of the behavior to look for
  110402. * @see https://doc.babylonjs.com/features/behaviour
  110403. * @returns null if behavior was not found else the requested behavior
  110404. */
  110405. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  110406. /**
  110407. * Returns the latest update of the World matrix
  110408. * @returns a Matrix
  110409. */
  110410. getWorldMatrix(): Matrix;
  110411. /** @hidden */
  110412. _getWorldMatrixDeterminant(): number;
  110413. /**
  110414. * Returns directly the latest state of the mesh World matrix.
  110415. * A Matrix is returned.
  110416. */
  110417. get worldMatrixFromCache(): Matrix;
  110418. /** @hidden */
  110419. _initCache(): void;
  110420. /** @hidden */
  110421. updateCache(force?: boolean): void;
  110422. /** @hidden */
  110423. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  110424. /** @hidden */
  110425. _updateCache(ignoreParentClass?: boolean): void;
  110426. /** @hidden */
  110427. _isSynchronized(): boolean;
  110428. /** @hidden */
  110429. _markSyncedWithParent(): void;
  110430. /** @hidden */
  110431. isSynchronizedWithParent(): boolean;
  110432. /** @hidden */
  110433. isSynchronized(): boolean;
  110434. /**
  110435. * Is this node ready to be used/rendered
  110436. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  110437. * @return true if the node is ready
  110438. */
  110439. isReady(completeCheck?: boolean): boolean;
  110440. /**
  110441. * Is this node enabled?
  110442. * 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
  110443. * @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
  110444. * @return whether this node (and its parent) is enabled
  110445. */
  110446. isEnabled(checkAncestors?: boolean): boolean;
  110447. /** @hidden */
  110448. protected _syncParentEnabledState(): void;
  110449. /**
  110450. * Set the enabled state of this node
  110451. * @param value defines the new enabled state
  110452. */
  110453. setEnabled(value: boolean): void;
  110454. /**
  110455. * Is this node a descendant of the given node?
  110456. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  110457. * @param ancestor defines the parent node to inspect
  110458. * @returns a boolean indicating if this node is a descendant of the given node
  110459. */
  110460. isDescendantOf(ancestor: Node): boolean;
  110461. /** @hidden */
  110462. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  110463. /**
  110464. * Will return all nodes that have this node as ascendant
  110465. * @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
  110466. * @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
  110467. * @return all children nodes of all types
  110468. */
  110469. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  110470. /**
  110471. * Get all child-meshes of this node
  110472. * @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)
  110473. * @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
  110474. * @returns an array of AbstractMesh
  110475. */
  110476. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  110477. /**
  110478. * Get all direct children of this node
  110479. * @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
  110480. * @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)
  110481. * @returns an array of Node
  110482. */
  110483. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  110484. /** @hidden */
  110485. _setReady(state: boolean): void;
  110486. /**
  110487. * Get an animation by name
  110488. * @param name defines the name of the animation to look for
  110489. * @returns null if not found else the requested animation
  110490. */
  110491. getAnimationByName(name: string): Nullable<Animation>;
  110492. /**
  110493. * Creates an animation range for this node
  110494. * @param name defines the name of the range
  110495. * @param from defines the starting key
  110496. * @param to defines the end key
  110497. */
  110498. createAnimationRange(name: string, from: number, to: number): void;
  110499. /**
  110500. * Delete a specific animation range
  110501. * @param name defines the name of the range to delete
  110502. * @param deleteFrames defines if animation frames from the range must be deleted as well
  110503. */
  110504. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  110505. /**
  110506. * Get an animation range by name
  110507. * @param name defines the name of the animation range to look for
  110508. * @returns null if not found else the requested animation range
  110509. */
  110510. getAnimationRange(name: string): Nullable<AnimationRange>;
  110511. /**
  110512. * Gets the list of all animation ranges defined on this node
  110513. * @returns an array
  110514. */
  110515. getAnimationRanges(): Nullable<AnimationRange>[];
  110516. /**
  110517. * Will start the animation sequence
  110518. * @param name defines the range frames for animation sequence
  110519. * @param loop defines if the animation should loop (false by default)
  110520. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  110521. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  110522. * @returns the object created for this animation. If range does not exist, it will return null
  110523. */
  110524. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  110525. /**
  110526. * Serialize animation ranges into a JSON compatible object
  110527. * @returns serialization object
  110528. */
  110529. serializeAnimationRanges(): any;
  110530. /**
  110531. * Computes the world matrix of the node
  110532. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  110533. * @returns the world matrix
  110534. */
  110535. computeWorldMatrix(force?: boolean): Matrix;
  110536. /**
  110537. * Releases resources associated with this node.
  110538. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110539. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110540. */
  110541. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110542. /**
  110543. * Parse animation range data from a serialization object and store them into a given node
  110544. * @param node defines where to store the animation ranges
  110545. * @param parsedNode defines the serialization object to read data from
  110546. * @param scene defines the hosting scene
  110547. */
  110548. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  110549. /**
  110550. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  110551. * @param includeDescendants Include bounding info from descendants as well (true by default)
  110552. * @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
  110553. * @returns the new bounding vectors
  110554. */
  110555. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  110556. min: Vector3;
  110557. max: Vector3;
  110558. };
  110559. }
  110560. }
  110561. declare module BABYLON {
  110562. /**
  110563. * @hidden
  110564. */
  110565. export class _IAnimationState {
  110566. key: number;
  110567. repeatCount: number;
  110568. workValue?: any;
  110569. loopMode?: number;
  110570. offsetValue?: any;
  110571. highLimitValue?: any;
  110572. }
  110573. /**
  110574. * Class used to store any kind of animation
  110575. */
  110576. export class Animation {
  110577. /**Name of the animation */
  110578. name: string;
  110579. /**Property to animate */
  110580. targetProperty: string;
  110581. /**The frames per second of the animation */
  110582. framePerSecond: number;
  110583. /**The data type of the animation */
  110584. dataType: number;
  110585. /**The loop mode of the animation */
  110586. loopMode?: number | undefined;
  110587. /**Specifies if blending should be enabled */
  110588. enableBlending?: boolean | undefined;
  110589. /**
  110590. * Use matrix interpolation instead of using direct key value when animating matrices
  110591. */
  110592. static AllowMatricesInterpolation: boolean;
  110593. /**
  110594. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  110595. */
  110596. static AllowMatrixDecomposeForInterpolation: boolean;
  110597. /** Define the Url to load snippets */
  110598. static SnippetUrl: string;
  110599. /** Snippet ID if the animation was created from the snippet server */
  110600. snippetId: string;
  110601. /**
  110602. * Stores the key frames of the animation
  110603. */
  110604. private _keys;
  110605. /**
  110606. * Stores the easing function of the animation
  110607. */
  110608. private _easingFunction;
  110609. /**
  110610. * @hidden Internal use only
  110611. */
  110612. _runtimeAnimations: RuntimeAnimation[];
  110613. /**
  110614. * The set of event that will be linked to this animation
  110615. */
  110616. private _events;
  110617. /**
  110618. * Stores an array of target property paths
  110619. */
  110620. targetPropertyPath: string[];
  110621. /**
  110622. * Stores the blending speed of the animation
  110623. */
  110624. blendingSpeed: number;
  110625. /**
  110626. * Stores the animation ranges for the animation
  110627. */
  110628. private _ranges;
  110629. /**
  110630. * @hidden Internal use
  110631. */
  110632. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  110633. /**
  110634. * Sets up an animation
  110635. * @param property The property to animate
  110636. * @param animationType The animation type to apply
  110637. * @param framePerSecond The frames per second of the animation
  110638. * @param easingFunction The easing function used in the animation
  110639. * @returns The created animation
  110640. */
  110641. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  110642. /**
  110643. * Create and start an animation on a node
  110644. * @param name defines the name of the global animation that will be run on all nodes
  110645. * @param node defines the root node where the animation will take place
  110646. * @param targetProperty defines property to animate
  110647. * @param framePerSecond defines the number of frame per second yo use
  110648. * @param totalFrame defines the number of frames in total
  110649. * @param from defines the initial value
  110650. * @param to defines the final value
  110651. * @param loopMode defines which loop mode you want to use (off by default)
  110652. * @param easingFunction defines the easing function to use (linear by default)
  110653. * @param onAnimationEnd defines the callback to call when animation end
  110654. * @returns the animatable created for this animation
  110655. */
  110656. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110657. /**
  110658. * Create and start an animation on a node and its descendants
  110659. * @param name defines the name of the global animation that will be run on all nodes
  110660. * @param node defines the root node where the animation will take place
  110661. * @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
  110662. * @param targetProperty defines property to animate
  110663. * @param framePerSecond defines the number of frame per second to use
  110664. * @param totalFrame defines the number of frames in total
  110665. * @param from defines the initial value
  110666. * @param to defines the final value
  110667. * @param loopMode defines which loop mode you want to use (off by default)
  110668. * @param easingFunction defines the easing function to use (linear by default)
  110669. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110670. * @returns the list of animatables created for all nodes
  110671. * @example https://www.babylonjs-playground.com/#MH0VLI
  110672. */
  110673. 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[]>;
  110674. /**
  110675. * Creates a new animation, merges it with the existing animations and starts it
  110676. * @param name Name of the animation
  110677. * @param node Node which contains the scene that begins the animations
  110678. * @param targetProperty Specifies which property to animate
  110679. * @param framePerSecond The frames per second of the animation
  110680. * @param totalFrame The total number of frames
  110681. * @param from The frame at the beginning of the animation
  110682. * @param to The frame at the end of the animation
  110683. * @param loopMode Specifies the loop mode of the animation
  110684. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  110685. * @param onAnimationEnd Callback to run once the animation is complete
  110686. * @returns Nullable animation
  110687. */
  110688. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110689. /**
  110690. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  110691. * @param sourceAnimation defines the Animation containing keyframes to convert
  110692. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110693. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  110694. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  110695. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  110696. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  110697. */
  110698. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  110699. /**
  110700. * Transition property of an host to the target Value
  110701. * @param property The property to transition
  110702. * @param targetValue The target Value of the property
  110703. * @param host The object where the property to animate belongs
  110704. * @param scene Scene used to run the animation
  110705. * @param frameRate Framerate (in frame/s) to use
  110706. * @param transition The transition type we want to use
  110707. * @param duration The duration of the animation, in milliseconds
  110708. * @param onAnimationEnd Callback trigger at the end of the animation
  110709. * @returns Nullable animation
  110710. */
  110711. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  110712. /**
  110713. * Return the array of runtime animations currently using this animation
  110714. */
  110715. get runtimeAnimations(): RuntimeAnimation[];
  110716. /**
  110717. * Specifies if any of the runtime animations are currently running
  110718. */
  110719. get hasRunningRuntimeAnimations(): boolean;
  110720. /**
  110721. * Initializes the animation
  110722. * @param name Name of the animation
  110723. * @param targetProperty Property to animate
  110724. * @param framePerSecond The frames per second of the animation
  110725. * @param dataType The data type of the animation
  110726. * @param loopMode The loop mode of the animation
  110727. * @param enableBlending Specifies if blending should be enabled
  110728. */
  110729. constructor(
  110730. /**Name of the animation */
  110731. name: string,
  110732. /**Property to animate */
  110733. targetProperty: string,
  110734. /**The frames per second of the animation */
  110735. framePerSecond: number,
  110736. /**The data type of the animation */
  110737. dataType: number,
  110738. /**The loop mode of the animation */
  110739. loopMode?: number | undefined,
  110740. /**Specifies if blending should be enabled */
  110741. enableBlending?: boolean | undefined);
  110742. /**
  110743. * Converts the animation to a string
  110744. * @param fullDetails support for multiple levels of logging within scene loading
  110745. * @returns String form of the animation
  110746. */
  110747. toString(fullDetails?: boolean): string;
  110748. /**
  110749. * Add an event to this animation
  110750. * @param event Event to add
  110751. */
  110752. addEvent(event: AnimationEvent): void;
  110753. /**
  110754. * Remove all events found at the given frame
  110755. * @param frame The frame to remove events from
  110756. */
  110757. removeEvents(frame: number): void;
  110758. /**
  110759. * Retrieves all the events from the animation
  110760. * @returns Events from the animation
  110761. */
  110762. getEvents(): AnimationEvent[];
  110763. /**
  110764. * Creates an animation range
  110765. * @param name Name of the animation range
  110766. * @param from Starting frame of the animation range
  110767. * @param to Ending frame of the animation
  110768. */
  110769. createRange(name: string, from: number, to: number): void;
  110770. /**
  110771. * Deletes an animation range by name
  110772. * @param name Name of the animation range to delete
  110773. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  110774. */
  110775. deleteRange(name: string, deleteFrames?: boolean): void;
  110776. /**
  110777. * Gets the animation range by name, or null if not defined
  110778. * @param name Name of the animation range
  110779. * @returns Nullable animation range
  110780. */
  110781. getRange(name: string): Nullable<AnimationRange>;
  110782. /**
  110783. * Gets the key frames from the animation
  110784. * @returns The key frames of the animation
  110785. */
  110786. getKeys(): Array<IAnimationKey>;
  110787. /**
  110788. * Gets the highest frame rate of the animation
  110789. * @returns Highest frame rate of the animation
  110790. */
  110791. getHighestFrame(): number;
  110792. /**
  110793. * Gets the easing function of the animation
  110794. * @returns Easing function of the animation
  110795. */
  110796. getEasingFunction(): IEasingFunction;
  110797. /**
  110798. * Sets the easing function of the animation
  110799. * @param easingFunction A custom mathematical formula for animation
  110800. */
  110801. setEasingFunction(easingFunction: EasingFunction): void;
  110802. /**
  110803. * Interpolates a scalar linearly
  110804. * @param startValue Start value of the animation curve
  110805. * @param endValue End value of the animation curve
  110806. * @param gradient Scalar amount to interpolate
  110807. * @returns Interpolated scalar value
  110808. */
  110809. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  110810. /**
  110811. * Interpolates a scalar cubically
  110812. * @param startValue Start value of the animation curve
  110813. * @param outTangent End tangent of the animation
  110814. * @param endValue End value of the animation curve
  110815. * @param inTangent Start tangent of the animation curve
  110816. * @param gradient Scalar amount to interpolate
  110817. * @returns Interpolated scalar value
  110818. */
  110819. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  110820. /**
  110821. * Interpolates a quaternion using a spherical linear interpolation
  110822. * @param startValue Start value of the animation curve
  110823. * @param endValue End value of the animation curve
  110824. * @param gradient Scalar amount to interpolate
  110825. * @returns Interpolated quaternion value
  110826. */
  110827. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  110828. /**
  110829. * Interpolates a quaternion cubically
  110830. * @param startValue Start value of the animation curve
  110831. * @param outTangent End tangent of the animation curve
  110832. * @param endValue End value of the animation curve
  110833. * @param inTangent Start tangent of the animation curve
  110834. * @param gradient Scalar amount to interpolate
  110835. * @returns Interpolated quaternion value
  110836. */
  110837. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  110838. /**
  110839. * Interpolates a Vector3 linearl
  110840. * @param startValue Start value of the animation curve
  110841. * @param endValue End value of the animation curve
  110842. * @param gradient Scalar amount to interpolate
  110843. * @returns Interpolated scalar value
  110844. */
  110845. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  110846. /**
  110847. * Interpolates a Vector3 cubically
  110848. * @param startValue Start value of the animation curve
  110849. * @param outTangent End tangent of the animation
  110850. * @param endValue End value of the animation curve
  110851. * @param inTangent Start tangent of the animation curve
  110852. * @param gradient Scalar amount to interpolate
  110853. * @returns InterpolatedVector3 value
  110854. */
  110855. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  110856. /**
  110857. * Interpolates a Vector2 linearly
  110858. * @param startValue Start value of the animation curve
  110859. * @param endValue End value of the animation curve
  110860. * @param gradient Scalar amount to interpolate
  110861. * @returns Interpolated Vector2 value
  110862. */
  110863. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  110864. /**
  110865. * Interpolates a Vector2 cubically
  110866. * @param startValue Start value of the animation curve
  110867. * @param outTangent End tangent of the animation
  110868. * @param endValue End value of the animation curve
  110869. * @param inTangent Start tangent of the animation curve
  110870. * @param gradient Scalar amount to interpolate
  110871. * @returns Interpolated Vector2 value
  110872. */
  110873. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  110874. /**
  110875. * Interpolates a size linearly
  110876. * @param startValue Start value of the animation curve
  110877. * @param endValue End value of the animation curve
  110878. * @param gradient Scalar amount to interpolate
  110879. * @returns Interpolated Size value
  110880. */
  110881. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  110882. /**
  110883. * Interpolates a Color3 linearly
  110884. * @param startValue Start value of the animation curve
  110885. * @param endValue End value of the animation curve
  110886. * @param gradient Scalar amount to interpolate
  110887. * @returns Interpolated Color3 value
  110888. */
  110889. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  110890. /**
  110891. * Interpolates a Color4 linearly
  110892. * @param startValue Start value of the animation curve
  110893. * @param endValue End value of the animation curve
  110894. * @param gradient Scalar amount to interpolate
  110895. * @returns Interpolated Color3 value
  110896. */
  110897. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  110898. /**
  110899. * @hidden Internal use only
  110900. */
  110901. _getKeyValue(value: any): any;
  110902. /**
  110903. * @hidden Internal use only
  110904. */
  110905. _interpolate(currentFrame: number, state: _IAnimationState): any;
  110906. /**
  110907. * Defines the function to use to interpolate matrices
  110908. * @param startValue defines the start matrix
  110909. * @param endValue defines the end matrix
  110910. * @param gradient defines the gradient between both matrices
  110911. * @param result defines an optional target matrix where to store the interpolation
  110912. * @returns the interpolated matrix
  110913. */
  110914. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  110915. /**
  110916. * Makes a copy of the animation
  110917. * @returns Cloned animation
  110918. */
  110919. clone(): Animation;
  110920. /**
  110921. * Sets the key frames of the animation
  110922. * @param values The animation key frames to set
  110923. */
  110924. setKeys(values: Array<IAnimationKey>): void;
  110925. /**
  110926. * Serializes the animation to an object
  110927. * @returns Serialized object
  110928. */
  110929. serialize(): any;
  110930. /**
  110931. * Float animation type
  110932. */
  110933. static readonly ANIMATIONTYPE_FLOAT: number;
  110934. /**
  110935. * Vector3 animation type
  110936. */
  110937. static readonly ANIMATIONTYPE_VECTOR3: number;
  110938. /**
  110939. * Quaternion animation type
  110940. */
  110941. static readonly ANIMATIONTYPE_QUATERNION: number;
  110942. /**
  110943. * Matrix animation type
  110944. */
  110945. static readonly ANIMATIONTYPE_MATRIX: number;
  110946. /**
  110947. * Color3 animation type
  110948. */
  110949. static readonly ANIMATIONTYPE_COLOR3: number;
  110950. /**
  110951. * Color3 animation type
  110952. */
  110953. static readonly ANIMATIONTYPE_COLOR4: number;
  110954. /**
  110955. * Vector2 animation type
  110956. */
  110957. static readonly ANIMATIONTYPE_VECTOR2: number;
  110958. /**
  110959. * Size animation type
  110960. */
  110961. static readonly ANIMATIONTYPE_SIZE: number;
  110962. /**
  110963. * Relative Loop Mode
  110964. */
  110965. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  110966. /**
  110967. * Cycle Loop Mode
  110968. */
  110969. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  110970. /**
  110971. * Constant Loop Mode
  110972. */
  110973. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  110974. /** @hidden */
  110975. static _UniversalLerp(left: any, right: any, amount: number): any;
  110976. /**
  110977. * Parses an animation object and creates an animation
  110978. * @param parsedAnimation Parsed animation object
  110979. * @returns Animation object
  110980. */
  110981. static Parse(parsedAnimation: any): Animation;
  110982. /**
  110983. * Appends the serialized animations from the source animations
  110984. * @param source Source containing the animations
  110985. * @param destination Target to store the animations
  110986. */
  110987. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110988. /**
  110989. * Creates a new animation or an array of animations from a snippet saved in a remote file
  110990. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  110991. * @param url defines the url to load from
  110992. * @returns a promise that will resolve to the new animation or an array of animations
  110993. */
  110994. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  110995. /**
  110996. * Creates an animation or an array of animations from a snippet saved by the Inspector
  110997. * @param snippetId defines the snippet to load
  110998. * @returns a promise that will resolve to the new animation or a new array of animations
  110999. */
  111000. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  111001. }
  111002. }
  111003. declare module BABYLON {
  111004. /**
  111005. * Interface containing an array of animations
  111006. */
  111007. export interface IAnimatable {
  111008. /**
  111009. * Array of animations
  111010. */
  111011. animations: Nullable<Array<Animation>>;
  111012. }
  111013. }
  111014. declare module BABYLON {
  111015. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  111016. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111017. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111018. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111019. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111020. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111021. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111022. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111023. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111024. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111025. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111026. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111027. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111028. /**
  111029. * Decorator used to define property that can be serialized as reference to a camera
  111030. * @param sourceName defines the name of the property to decorate
  111031. */
  111032. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111033. /**
  111034. * Class used to help serialization objects
  111035. */
  111036. export class SerializationHelper {
  111037. /** @hidden */
  111038. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  111039. /** @hidden */
  111040. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  111041. /** @hidden */
  111042. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  111043. /** @hidden */
  111044. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  111045. /**
  111046. * Appends the serialized animations from the source animations
  111047. * @param source Source containing the animations
  111048. * @param destination Target to store the animations
  111049. */
  111050. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  111051. /**
  111052. * Static function used to serialized a specific entity
  111053. * @param entity defines the entity to serialize
  111054. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  111055. * @returns a JSON compatible object representing the serialization of the entity
  111056. */
  111057. static Serialize<T>(entity: T, serializationObject?: any): any;
  111058. /**
  111059. * Creates a new entity from a serialization data object
  111060. * @param creationFunction defines a function used to instanciated the new entity
  111061. * @param source defines the source serialization data
  111062. * @param scene defines the hosting scene
  111063. * @param rootUrl defines the root url for resources
  111064. * @returns a new entity
  111065. */
  111066. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  111067. /**
  111068. * Clones an object
  111069. * @param creationFunction defines the function used to instanciate the new object
  111070. * @param source defines the source object
  111071. * @returns the cloned object
  111072. */
  111073. static Clone<T>(creationFunction: () => T, source: T): T;
  111074. /**
  111075. * Instanciates a new object based on a source one (some data will be shared between both object)
  111076. * @param creationFunction defines the function used to instanciate the new object
  111077. * @param source defines the source object
  111078. * @returns the new object
  111079. */
  111080. static Instanciate<T>(creationFunction: () => T, source: T): T;
  111081. }
  111082. }
  111083. declare module BABYLON {
  111084. /**
  111085. * Base class of all the textures in babylon.
  111086. * It groups all the common properties the materials, post process, lights... might need
  111087. * in order to make a correct use of the texture.
  111088. */
  111089. export class BaseTexture implements IAnimatable {
  111090. /**
  111091. * Default anisotropic filtering level for the application.
  111092. * It is set to 4 as a good tradeoff between perf and quality.
  111093. */
  111094. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  111095. /**
  111096. * Gets or sets the unique id of the texture
  111097. */
  111098. uniqueId: number;
  111099. /**
  111100. * Define the name of the texture.
  111101. */
  111102. name: string;
  111103. /**
  111104. * Gets or sets an object used to store user defined information.
  111105. */
  111106. metadata: any;
  111107. /**
  111108. * For internal use only. Please do not use.
  111109. */
  111110. reservedDataStore: any;
  111111. private _hasAlpha;
  111112. /**
  111113. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  111114. */
  111115. set hasAlpha(value: boolean);
  111116. get hasAlpha(): boolean;
  111117. /**
  111118. * Defines if the alpha value should be determined via the rgb values.
  111119. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  111120. */
  111121. getAlphaFromRGB: boolean;
  111122. /**
  111123. * Intensity or strength of the texture.
  111124. * It is commonly used by materials to fine tune the intensity of the texture
  111125. */
  111126. level: number;
  111127. /**
  111128. * Define the UV chanel to use starting from 0 and defaulting to 0.
  111129. * This is part of the texture as textures usually maps to one uv set.
  111130. */
  111131. coordinatesIndex: number;
  111132. private _coordinatesMode;
  111133. /**
  111134. * How a texture is mapped.
  111135. *
  111136. * | Value | Type | Description |
  111137. * | ----- | ----------------------------------- | ----------- |
  111138. * | 0 | EXPLICIT_MODE | |
  111139. * | 1 | SPHERICAL_MODE | |
  111140. * | 2 | PLANAR_MODE | |
  111141. * | 3 | CUBIC_MODE | |
  111142. * | 4 | PROJECTION_MODE | |
  111143. * | 5 | SKYBOX_MODE | |
  111144. * | 6 | INVCUBIC_MODE | |
  111145. * | 7 | EQUIRECTANGULAR_MODE | |
  111146. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  111147. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  111148. */
  111149. set coordinatesMode(value: number);
  111150. get coordinatesMode(): number;
  111151. /**
  111152. * | Value | Type | Description |
  111153. * | ----- | ------------------ | ----------- |
  111154. * | 0 | CLAMP_ADDRESSMODE | |
  111155. * | 1 | WRAP_ADDRESSMODE | |
  111156. * | 2 | MIRROR_ADDRESSMODE | |
  111157. */
  111158. wrapU: number;
  111159. /**
  111160. * | Value | Type | Description |
  111161. * | ----- | ------------------ | ----------- |
  111162. * | 0 | CLAMP_ADDRESSMODE | |
  111163. * | 1 | WRAP_ADDRESSMODE | |
  111164. * | 2 | MIRROR_ADDRESSMODE | |
  111165. */
  111166. wrapV: number;
  111167. /**
  111168. * | Value | Type | Description |
  111169. * | ----- | ------------------ | ----------- |
  111170. * | 0 | CLAMP_ADDRESSMODE | |
  111171. * | 1 | WRAP_ADDRESSMODE | |
  111172. * | 2 | MIRROR_ADDRESSMODE | |
  111173. */
  111174. wrapR: number;
  111175. /**
  111176. * With compliant hardware and browser (supporting anisotropic filtering)
  111177. * this defines the level of anisotropic filtering in the texture.
  111178. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  111179. */
  111180. anisotropicFilteringLevel: number;
  111181. /**
  111182. * Define if the texture is a cube texture or if false a 2d texture.
  111183. */
  111184. get isCube(): boolean;
  111185. set isCube(value: boolean);
  111186. /**
  111187. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  111188. */
  111189. get is3D(): boolean;
  111190. set is3D(value: boolean);
  111191. /**
  111192. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  111193. */
  111194. get is2DArray(): boolean;
  111195. set is2DArray(value: boolean);
  111196. /**
  111197. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  111198. * HDR texture are usually stored in linear space.
  111199. * This only impacts the PBR and Background materials
  111200. */
  111201. gammaSpace: boolean;
  111202. /**
  111203. * Gets or sets whether or not the texture contains RGBD data.
  111204. */
  111205. get isRGBD(): boolean;
  111206. set isRGBD(value: boolean);
  111207. /**
  111208. * Is Z inverted in the texture (useful in a cube texture).
  111209. */
  111210. invertZ: boolean;
  111211. /**
  111212. * Are mip maps generated for this texture or not.
  111213. */
  111214. get noMipmap(): boolean;
  111215. /**
  111216. * @hidden
  111217. */
  111218. lodLevelInAlpha: boolean;
  111219. /**
  111220. * With prefiltered texture, defined the offset used during the prefiltering steps.
  111221. */
  111222. get lodGenerationOffset(): number;
  111223. set lodGenerationOffset(value: number);
  111224. /**
  111225. * With prefiltered texture, defined the scale used during the prefiltering steps.
  111226. */
  111227. get lodGenerationScale(): number;
  111228. set lodGenerationScale(value: number);
  111229. /**
  111230. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  111231. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  111232. * average roughness values.
  111233. */
  111234. get linearSpecularLOD(): boolean;
  111235. set linearSpecularLOD(value: boolean);
  111236. /**
  111237. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  111238. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  111239. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  111240. */
  111241. get irradianceTexture(): Nullable<BaseTexture>;
  111242. set irradianceTexture(value: Nullable<BaseTexture>);
  111243. /**
  111244. * Define if the texture is a render target.
  111245. */
  111246. isRenderTarget: boolean;
  111247. /**
  111248. * Define the unique id of the texture in the scene.
  111249. */
  111250. get uid(): string;
  111251. /** @hidden */
  111252. _prefiltered: boolean;
  111253. /**
  111254. * Return a string representation of the texture.
  111255. * @returns the texture as a string
  111256. */
  111257. toString(): string;
  111258. /**
  111259. * Get the class name of the texture.
  111260. * @returns "BaseTexture"
  111261. */
  111262. getClassName(): string;
  111263. /**
  111264. * Define the list of animation attached to the texture.
  111265. */
  111266. animations: Animation[];
  111267. /**
  111268. * An event triggered when the texture is disposed.
  111269. */
  111270. onDisposeObservable: Observable<BaseTexture>;
  111271. private _onDisposeObserver;
  111272. /**
  111273. * Callback triggered when the texture has been disposed.
  111274. * Kept for back compatibility, you can use the onDisposeObservable instead.
  111275. */
  111276. set onDispose(callback: () => void);
  111277. /**
  111278. * Define the current state of the loading sequence when in delayed load mode.
  111279. */
  111280. delayLoadState: number;
  111281. private _scene;
  111282. private _engine;
  111283. /** @hidden */
  111284. _texture: Nullable<InternalTexture>;
  111285. private _uid;
  111286. /**
  111287. * Define if the texture is preventinga material to render or not.
  111288. * If not and the texture is not ready, the engine will use a default black texture instead.
  111289. */
  111290. get isBlocking(): boolean;
  111291. /**
  111292. * Instantiates a new BaseTexture.
  111293. * Base class of all the textures in babylon.
  111294. * It groups all the common properties the materials, post process, lights... might need
  111295. * in order to make a correct use of the texture.
  111296. * @param sceneOrEngine Define the scene or engine the texture blongs to
  111297. */
  111298. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  111299. /**
  111300. * Get the scene the texture belongs to.
  111301. * @returns the scene or null if undefined
  111302. */
  111303. getScene(): Nullable<Scene>;
  111304. /** @hidden */
  111305. protected _getEngine(): Nullable<ThinEngine>;
  111306. /**
  111307. * Get the texture transform matrix used to offset tile the texture for istance.
  111308. * @returns the transformation matrix
  111309. */
  111310. getTextureMatrix(): Matrix;
  111311. /**
  111312. * Get the texture reflection matrix used to rotate/transform the reflection.
  111313. * @returns the reflection matrix
  111314. */
  111315. getReflectionTextureMatrix(): Matrix;
  111316. /**
  111317. * Get the underlying lower level texture from Babylon.
  111318. * @returns the insternal texture
  111319. */
  111320. getInternalTexture(): Nullable<InternalTexture>;
  111321. /**
  111322. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  111323. * @returns true if ready or not blocking
  111324. */
  111325. isReadyOrNotBlocking(): boolean;
  111326. /**
  111327. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  111328. * @returns true if fully ready
  111329. */
  111330. isReady(): boolean;
  111331. private _cachedSize;
  111332. /**
  111333. * Get the size of the texture.
  111334. * @returns the texture size.
  111335. */
  111336. getSize(): ISize;
  111337. /**
  111338. * Get the base size of the texture.
  111339. * It can be different from the size if the texture has been resized for POT for instance
  111340. * @returns the base size
  111341. */
  111342. getBaseSize(): ISize;
  111343. /**
  111344. * Update the sampling mode of the texture.
  111345. * Default is Trilinear mode.
  111346. *
  111347. * | Value | Type | Description |
  111348. * | ----- | ------------------ | ----------- |
  111349. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  111350. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  111351. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  111352. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  111353. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  111354. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  111355. * | 7 | NEAREST_LINEAR | |
  111356. * | 8 | NEAREST_NEAREST | |
  111357. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  111358. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  111359. * | 11 | LINEAR_LINEAR | |
  111360. * | 12 | LINEAR_NEAREST | |
  111361. *
  111362. * > _mag_: magnification filter (close to the viewer)
  111363. * > _min_: minification filter (far from the viewer)
  111364. * > _mip_: filter used between mip map levels
  111365. *@param samplingMode Define the new sampling mode of the texture
  111366. */
  111367. updateSamplingMode(samplingMode: number): void;
  111368. /**
  111369. * Scales the texture if is `canRescale()`
  111370. * @param ratio the resize factor we want to use to rescale
  111371. */
  111372. scale(ratio: number): void;
  111373. /**
  111374. * Get if the texture can rescale.
  111375. */
  111376. get canRescale(): boolean;
  111377. /** @hidden */
  111378. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  111379. /** @hidden */
  111380. _rebuild(): void;
  111381. /**
  111382. * Triggers the load sequence in delayed load mode.
  111383. */
  111384. delayLoad(): void;
  111385. /**
  111386. * Clones the texture.
  111387. * @returns the cloned texture
  111388. */
  111389. clone(): Nullable<BaseTexture>;
  111390. /**
  111391. * Get the texture underlying type (INT, FLOAT...)
  111392. */
  111393. get textureType(): number;
  111394. /**
  111395. * Get the texture underlying format (RGB, RGBA...)
  111396. */
  111397. get textureFormat(): number;
  111398. /**
  111399. * Indicates that textures need to be re-calculated for all materials
  111400. */
  111401. protected _markAllSubMeshesAsTexturesDirty(): void;
  111402. /**
  111403. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  111404. * This will returns an RGBA array buffer containing either in values (0-255) or
  111405. * float values (0-1) depending of the underlying buffer type.
  111406. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  111407. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  111408. * @param buffer defines a user defined buffer to fill with data (can be null)
  111409. * @returns The Array buffer containing the pixels data.
  111410. */
  111411. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  111412. /**
  111413. * Release and destroy the underlying lower level texture aka internalTexture.
  111414. */
  111415. releaseInternalTexture(): void;
  111416. /** @hidden */
  111417. get _lodTextureHigh(): Nullable<BaseTexture>;
  111418. /** @hidden */
  111419. get _lodTextureMid(): Nullable<BaseTexture>;
  111420. /** @hidden */
  111421. get _lodTextureLow(): Nullable<BaseTexture>;
  111422. /**
  111423. * Dispose the texture and release its associated resources.
  111424. */
  111425. dispose(): void;
  111426. /**
  111427. * Serialize the texture into a JSON representation that can be parsed later on.
  111428. * @returns the JSON representation of the texture
  111429. */
  111430. serialize(): any;
  111431. /**
  111432. * Helper function to be called back once a list of texture contains only ready textures.
  111433. * @param textures Define the list of textures to wait for
  111434. * @param callback Define the callback triggered once the entire list will be ready
  111435. */
  111436. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  111437. private static _isScene;
  111438. }
  111439. }
  111440. declare module BABYLON {
  111441. /**
  111442. * Options to be used when creating an effect.
  111443. */
  111444. export interface IEffectCreationOptions {
  111445. /**
  111446. * Atrributes that will be used in the shader.
  111447. */
  111448. attributes: string[];
  111449. /**
  111450. * Uniform varible names that will be set in the shader.
  111451. */
  111452. uniformsNames: string[];
  111453. /**
  111454. * Uniform buffer variable names that will be set in the shader.
  111455. */
  111456. uniformBuffersNames: string[];
  111457. /**
  111458. * Sampler texture variable names that will be set in the shader.
  111459. */
  111460. samplers: string[];
  111461. /**
  111462. * Define statements that will be set in the shader.
  111463. */
  111464. defines: any;
  111465. /**
  111466. * Possible fallbacks for this effect to improve performance when needed.
  111467. */
  111468. fallbacks: Nullable<IEffectFallbacks>;
  111469. /**
  111470. * Callback that will be called when the shader is compiled.
  111471. */
  111472. onCompiled: Nullable<(effect: Effect) => void>;
  111473. /**
  111474. * Callback that will be called if an error occurs during shader compilation.
  111475. */
  111476. onError: Nullable<(effect: Effect, errors: string) => void>;
  111477. /**
  111478. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111479. */
  111480. indexParameters?: any;
  111481. /**
  111482. * Max number of lights that can be used in the shader.
  111483. */
  111484. maxSimultaneousLights?: number;
  111485. /**
  111486. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  111487. */
  111488. transformFeedbackVaryings?: Nullable<string[]>;
  111489. /**
  111490. * 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
  111491. */
  111492. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  111493. /**
  111494. * Is this effect rendering to several color attachments ?
  111495. */
  111496. multiTarget?: boolean;
  111497. }
  111498. /**
  111499. * Effect containing vertex and fragment shader that can be executed on an object.
  111500. */
  111501. export class Effect implements IDisposable {
  111502. /**
  111503. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111504. */
  111505. static ShadersRepository: string;
  111506. /**
  111507. * Enable logging of the shader code when a compilation error occurs
  111508. */
  111509. static LogShaderCodeOnCompilationError: boolean;
  111510. /**
  111511. * Name of the effect.
  111512. */
  111513. name: any;
  111514. /**
  111515. * String container all the define statements that should be set on the shader.
  111516. */
  111517. defines: string;
  111518. /**
  111519. * Callback that will be called when the shader is compiled.
  111520. */
  111521. onCompiled: Nullable<(effect: Effect) => void>;
  111522. /**
  111523. * Callback that will be called if an error occurs during shader compilation.
  111524. */
  111525. onError: Nullable<(effect: Effect, errors: string) => void>;
  111526. /**
  111527. * Callback that will be called when effect is bound.
  111528. */
  111529. onBind: Nullable<(effect: Effect) => void>;
  111530. /**
  111531. * Unique ID of the effect.
  111532. */
  111533. uniqueId: number;
  111534. /**
  111535. * Observable that will be called when the shader is compiled.
  111536. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  111537. */
  111538. onCompileObservable: Observable<Effect>;
  111539. /**
  111540. * Observable that will be called if an error occurs during shader compilation.
  111541. */
  111542. onErrorObservable: Observable<Effect>;
  111543. /** @hidden */
  111544. _onBindObservable: Nullable<Observable<Effect>>;
  111545. /**
  111546. * @hidden
  111547. * Specifies if the effect was previously ready
  111548. */
  111549. _wasPreviouslyReady: boolean;
  111550. /**
  111551. * Observable that will be called when effect is bound.
  111552. */
  111553. get onBindObservable(): Observable<Effect>;
  111554. /** @hidden */
  111555. _bonesComputationForcedToCPU: boolean;
  111556. /** @hidden */
  111557. _multiTarget: boolean;
  111558. private static _uniqueIdSeed;
  111559. private _engine;
  111560. private _uniformBuffersNames;
  111561. private _uniformBuffersNamesList;
  111562. private _uniformsNames;
  111563. private _samplerList;
  111564. private _samplers;
  111565. private _isReady;
  111566. private _compilationError;
  111567. private _allFallbacksProcessed;
  111568. private _attributesNames;
  111569. private _attributes;
  111570. private _attributeLocationByName;
  111571. private _uniforms;
  111572. /**
  111573. * Key for the effect.
  111574. * @hidden
  111575. */
  111576. _key: string;
  111577. private _indexParameters;
  111578. private _fallbacks;
  111579. private _vertexSourceCode;
  111580. private _fragmentSourceCode;
  111581. private _vertexSourceCodeOverride;
  111582. private _fragmentSourceCodeOverride;
  111583. private _transformFeedbackVaryings;
  111584. /**
  111585. * Compiled shader to webGL program.
  111586. * @hidden
  111587. */
  111588. _pipelineContext: Nullable<IPipelineContext>;
  111589. private _valueCache;
  111590. private static _baseCache;
  111591. /**
  111592. * Instantiates an effect.
  111593. * An effect can be used to create/manage/execute vertex and fragment shaders.
  111594. * @param baseName Name of the effect.
  111595. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  111596. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  111597. * @param samplers List of sampler variables that will be passed to the shader.
  111598. * @param engine Engine to be used to render the effect
  111599. * @param defines Define statements to be added to the shader.
  111600. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  111601. * @param onCompiled Callback that will be called when the shader is compiled.
  111602. * @param onError Callback that will be called if an error occurs during shader compilation.
  111603. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111604. */
  111605. 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);
  111606. private _useFinalCode;
  111607. /**
  111608. * Unique key for this effect
  111609. */
  111610. get key(): string;
  111611. /**
  111612. * If the effect has been compiled and prepared.
  111613. * @returns if the effect is compiled and prepared.
  111614. */
  111615. isReady(): boolean;
  111616. private _isReadyInternal;
  111617. /**
  111618. * The engine the effect was initialized with.
  111619. * @returns the engine.
  111620. */
  111621. getEngine(): Engine;
  111622. /**
  111623. * The pipeline context for this effect
  111624. * @returns the associated pipeline context
  111625. */
  111626. getPipelineContext(): Nullable<IPipelineContext>;
  111627. /**
  111628. * The set of names of attribute variables for the shader.
  111629. * @returns An array of attribute names.
  111630. */
  111631. getAttributesNames(): string[];
  111632. /**
  111633. * Returns the attribute at the given index.
  111634. * @param index The index of the attribute.
  111635. * @returns The location of the attribute.
  111636. */
  111637. getAttributeLocation(index: number): number;
  111638. /**
  111639. * Returns the attribute based on the name of the variable.
  111640. * @param name of the attribute to look up.
  111641. * @returns the attribute location.
  111642. */
  111643. getAttributeLocationByName(name: string): number;
  111644. /**
  111645. * The number of attributes.
  111646. * @returns the numnber of attributes.
  111647. */
  111648. getAttributesCount(): number;
  111649. /**
  111650. * Gets the index of a uniform variable.
  111651. * @param uniformName of the uniform to look up.
  111652. * @returns the index.
  111653. */
  111654. getUniformIndex(uniformName: string): number;
  111655. /**
  111656. * Returns the attribute based on the name of the variable.
  111657. * @param uniformName of the uniform to look up.
  111658. * @returns the location of the uniform.
  111659. */
  111660. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  111661. /**
  111662. * Returns an array of sampler variable names
  111663. * @returns The array of sampler variable names.
  111664. */
  111665. getSamplers(): string[];
  111666. /**
  111667. * Returns an array of uniform variable names
  111668. * @returns The array of uniform variable names.
  111669. */
  111670. getUniformNames(): string[];
  111671. /**
  111672. * Returns an array of uniform buffer variable names
  111673. * @returns The array of uniform buffer variable names.
  111674. */
  111675. getUniformBuffersNames(): string[];
  111676. /**
  111677. * Returns the index parameters used to create the effect
  111678. * @returns The index parameters object
  111679. */
  111680. getIndexParameters(): any;
  111681. /**
  111682. * The error from the last compilation.
  111683. * @returns the error string.
  111684. */
  111685. getCompilationError(): string;
  111686. /**
  111687. * Gets a boolean indicating that all fallbacks were used during compilation
  111688. * @returns true if all fallbacks were used
  111689. */
  111690. allFallbacksProcessed(): boolean;
  111691. /**
  111692. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  111693. * @param func The callback to be used.
  111694. */
  111695. executeWhenCompiled(func: (effect: Effect) => void): void;
  111696. private _checkIsReady;
  111697. private _loadShader;
  111698. /**
  111699. * Gets the vertex shader source code of this effect
  111700. */
  111701. get vertexSourceCode(): string;
  111702. /**
  111703. * Gets the fragment shader source code of this effect
  111704. */
  111705. get fragmentSourceCode(): string;
  111706. /**
  111707. * Recompiles the webGL program
  111708. * @param vertexSourceCode The source code for the vertex shader.
  111709. * @param fragmentSourceCode The source code for the fragment shader.
  111710. * @param onCompiled Callback called when completed.
  111711. * @param onError Callback called on error.
  111712. * @hidden
  111713. */
  111714. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  111715. /**
  111716. * Prepares the effect
  111717. * @hidden
  111718. */
  111719. _prepareEffect(): void;
  111720. private _getShaderCodeAndErrorLine;
  111721. private _processCompilationErrors;
  111722. /**
  111723. * Checks if the effect is supported. (Must be called after compilation)
  111724. */
  111725. get isSupported(): boolean;
  111726. /**
  111727. * Binds a texture to the engine to be used as output of the shader.
  111728. * @param channel Name of the output variable.
  111729. * @param texture Texture to bind.
  111730. * @hidden
  111731. */
  111732. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  111733. /**
  111734. * Sets a texture on the engine to be used in the shader.
  111735. * @param channel Name of the sampler variable.
  111736. * @param texture Texture to set.
  111737. */
  111738. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  111739. /**
  111740. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  111741. * @param channel Name of the sampler variable.
  111742. * @param texture Texture to set.
  111743. */
  111744. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  111745. /**
  111746. * Sets an array of textures on the engine to be used in the shader.
  111747. * @param channel Name of the variable.
  111748. * @param textures Textures to set.
  111749. */
  111750. setTextureArray(channel: string, textures: BaseTexture[]): void;
  111751. /**
  111752. * 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)
  111753. * @param channel Name of the sampler variable.
  111754. * @param postProcess Post process to get the input texture from.
  111755. */
  111756. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  111757. /**
  111758. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  111759. * 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)
  111760. * @param channel Name of the sampler variable.
  111761. * @param postProcess Post process to get the output texture from.
  111762. */
  111763. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  111764. /** @hidden */
  111765. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  111766. /** @hidden */
  111767. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  111768. /** @hidden */
  111769. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  111770. /** @hidden */
  111771. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  111772. /**
  111773. * Binds a buffer to a uniform.
  111774. * @param buffer Buffer to bind.
  111775. * @param name Name of the uniform variable to bind to.
  111776. */
  111777. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  111778. /**
  111779. * Binds block to a uniform.
  111780. * @param blockName Name of the block to bind.
  111781. * @param index Index to bind.
  111782. */
  111783. bindUniformBlock(blockName: string, index: number): void;
  111784. /**
  111785. * Sets an interger value on a uniform variable.
  111786. * @param uniformName Name of the variable.
  111787. * @param value Value to be set.
  111788. * @returns this effect.
  111789. */
  111790. setInt(uniformName: string, value: number): Effect;
  111791. /**
  111792. * Sets an int array on a uniform variable.
  111793. * @param uniformName Name of the variable.
  111794. * @param array array to be set.
  111795. * @returns this effect.
  111796. */
  111797. setIntArray(uniformName: string, array: Int32Array): Effect;
  111798. /**
  111799. * 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)
  111800. * @param uniformName Name of the variable.
  111801. * @param array array to be set.
  111802. * @returns this effect.
  111803. */
  111804. setIntArray2(uniformName: string, array: Int32Array): Effect;
  111805. /**
  111806. * 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)
  111807. * @param uniformName Name of the variable.
  111808. * @param array array to be set.
  111809. * @returns this effect.
  111810. */
  111811. setIntArray3(uniformName: string, array: Int32Array): Effect;
  111812. /**
  111813. * 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)
  111814. * @param uniformName Name of the variable.
  111815. * @param array array to be set.
  111816. * @returns this effect.
  111817. */
  111818. setIntArray4(uniformName: string, array: Int32Array): Effect;
  111819. /**
  111820. * Sets an float array on a uniform variable.
  111821. * @param uniformName Name of the variable.
  111822. * @param array array to be set.
  111823. * @returns this effect.
  111824. */
  111825. setFloatArray(uniformName: string, array: Float32Array): Effect;
  111826. /**
  111827. * 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)
  111828. * @param uniformName Name of the variable.
  111829. * @param array array to be set.
  111830. * @returns this effect.
  111831. */
  111832. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  111833. /**
  111834. * 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)
  111835. * @param uniformName Name of the variable.
  111836. * @param array array to be set.
  111837. * @returns this effect.
  111838. */
  111839. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  111840. /**
  111841. * 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)
  111842. * @param uniformName Name of the variable.
  111843. * @param array array to be set.
  111844. * @returns this effect.
  111845. */
  111846. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  111847. /**
  111848. * Sets an array on a uniform variable.
  111849. * @param uniformName Name of the variable.
  111850. * @param array array to be set.
  111851. * @returns this effect.
  111852. */
  111853. setArray(uniformName: string, array: number[]): Effect;
  111854. /**
  111855. * 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)
  111856. * @param uniformName Name of the variable.
  111857. * @param array array to be set.
  111858. * @returns this effect.
  111859. */
  111860. setArray2(uniformName: string, array: number[]): Effect;
  111861. /**
  111862. * 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)
  111863. * @param uniformName Name of the variable.
  111864. * @param array array to be set.
  111865. * @returns this effect.
  111866. */
  111867. setArray3(uniformName: string, array: number[]): Effect;
  111868. /**
  111869. * 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)
  111870. * @param uniformName Name of the variable.
  111871. * @param array array to be set.
  111872. * @returns this effect.
  111873. */
  111874. setArray4(uniformName: string, array: number[]): Effect;
  111875. /**
  111876. * Sets matrices on a uniform variable.
  111877. * @param uniformName Name of the variable.
  111878. * @param matrices matrices to be set.
  111879. * @returns this effect.
  111880. */
  111881. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  111882. /**
  111883. * Sets matrix on a uniform variable.
  111884. * @param uniformName Name of the variable.
  111885. * @param matrix matrix to be set.
  111886. * @returns this effect.
  111887. */
  111888. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  111889. /**
  111890. * 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)
  111891. * @param uniformName Name of the variable.
  111892. * @param matrix matrix to be set.
  111893. * @returns this effect.
  111894. */
  111895. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  111896. /**
  111897. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  111898. * @param uniformName Name of the variable.
  111899. * @param matrix matrix to be set.
  111900. * @returns this effect.
  111901. */
  111902. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  111903. /**
  111904. * Sets a float on a uniform variable.
  111905. * @param uniformName Name of the variable.
  111906. * @param value value to be set.
  111907. * @returns this effect.
  111908. */
  111909. setFloat(uniformName: string, value: number): Effect;
  111910. /**
  111911. * Sets a boolean on a uniform variable.
  111912. * @param uniformName Name of the variable.
  111913. * @param bool value to be set.
  111914. * @returns this effect.
  111915. */
  111916. setBool(uniformName: string, bool: boolean): Effect;
  111917. /**
  111918. * Sets a Vector2 on a uniform variable.
  111919. * @param uniformName Name of the variable.
  111920. * @param vector2 vector2 to be set.
  111921. * @returns this effect.
  111922. */
  111923. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  111924. /**
  111925. * Sets a float2 on a uniform variable.
  111926. * @param uniformName Name of the variable.
  111927. * @param x First float in float2.
  111928. * @param y Second float in float2.
  111929. * @returns this effect.
  111930. */
  111931. setFloat2(uniformName: string, x: number, y: number): Effect;
  111932. /**
  111933. * Sets a Vector3 on a uniform variable.
  111934. * @param uniformName Name of the variable.
  111935. * @param vector3 Value to be set.
  111936. * @returns this effect.
  111937. */
  111938. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  111939. /**
  111940. * Sets a float3 on a uniform variable.
  111941. * @param uniformName Name of the variable.
  111942. * @param x First float in float3.
  111943. * @param y Second float in float3.
  111944. * @param z Third float in float3.
  111945. * @returns this effect.
  111946. */
  111947. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  111948. /**
  111949. * Sets a Vector4 on a uniform variable.
  111950. * @param uniformName Name of the variable.
  111951. * @param vector4 Value to be set.
  111952. * @returns this effect.
  111953. */
  111954. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  111955. /**
  111956. * Sets a float4 on a uniform variable.
  111957. * @param uniformName Name of the variable.
  111958. * @param x First float in float4.
  111959. * @param y Second float in float4.
  111960. * @param z Third float in float4.
  111961. * @param w Fourth float in float4.
  111962. * @returns this effect.
  111963. */
  111964. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  111965. /**
  111966. * Sets a Color3 on a uniform variable.
  111967. * @param uniformName Name of the variable.
  111968. * @param color3 Value to be set.
  111969. * @returns this effect.
  111970. */
  111971. setColor3(uniformName: string, color3: IColor3Like): Effect;
  111972. /**
  111973. * Sets a Color4 on a uniform variable.
  111974. * @param uniformName Name of the variable.
  111975. * @param color3 Value to be set.
  111976. * @param alpha Alpha value to be set.
  111977. * @returns this effect.
  111978. */
  111979. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  111980. /**
  111981. * Sets a Color4 on a uniform variable
  111982. * @param uniformName defines the name of the variable
  111983. * @param color4 defines the value to be set
  111984. * @returns this effect.
  111985. */
  111986. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  111987. /** Release all associated resources */
  111988. dispose(): void;
  111989. /**
  111990. * This function will add a new shader to the shader store
  111991. * @param name the name of the shader
  111992. * @param pixelShader optional pixel shader content
  111993. * @param vertexShader optional vertex shader content
  111994. */
  111995. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  111996. /**
  111997. * Store of each shader (The can be looked up using effect.key)
  111998. */
  111999. static ShadersStore: {
  112000. [key: string]: string;
  112001. };
  112002. /**
  112003. * Store of each included file for a shader (The can be looked up using effect.key)
  112004. */
  112005. static IncludesShadersStore: {
  112006. [key: string]: string;
  112007. };
  112008. /**
  112009. * Resets the cache of effects.
  112010. */
  112011. static ResetCache(): void;
  112012. }
  112013. }
  112014. declare module BABYLON {
  112015. /**
  112016. * Interface used to describe the capabilities of the engine relatively to the current browser
  112017. */
  112018. export interface EngineCapabilities {
  112019. /** Maximum textures units per fragment shader */
  112020. maxTexturesImageUnits: number;
  112021. /** Maximum texture units per vertex shader */
  112022. maxVertexTextureImageUnits: number;
  112023. /** Maximum textures units in the entire pipeline */
  112024. maxCombinedTexturesImageUnits: number;
  112025. /** Maximum texture size */
  112026. maxTextureSize: number;
  112027. /** Maximum texture samples */
  112028. maxSamples?: number;
  112029. /** Maximum cube texture size */
  112030. maxCubemapTextureSize: number;
  112031. /** Maximum render texture size */
  112032. maxRenderTextureSize: number;
  112033. /** Maximum number of vertex attributes */
  112034. maxVertexAttribs: number;
  112035. /** Maximum number of varyings */
  112036. maxVaryingVectors: number;
  112037. /** Maximum number of uniforms per vertex shader */
  112038. maxVertexUniformVectors: number;
  112039. /** Maximum number of uniforms per fragment shader */
  112040. maxFragmentUniformVectors: number;
  112041. /** Defines if standard derivates (dx/dy) are supported */
  112042. standardDerivatives: boolean;
  112043. /** Defines if s3tc texture compression is supported */
  112044. s3tc?: WEBGL_compressed_texture_s3tc;
  112045. /** Defines if pvrtc texture compression is supported */
  112046. pvrtc: any;
  112047. /** Defines if etc1 texture compression is supported */
  112048. etc1: any;
  112049. /** Defines if etc2 texture compression is supported */
  112050. etc2: any;
  112051. /** Defines if astc texture compression is supported */
  112052. astc: any;
  112053. /** Defines if float textures are supported */
  112054. textureFloat: boolean;
  112055. /** Defines if vertex array objects are supported */
  112056. vertexArrayObject: boolean;
  112057. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  112058. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  112059. /** Gets the maximum level of anisotropy supported */
  112060. maxAnisotropy: number;
  112061. /** Defines if instancing is supported */
  112062. instancedArrays: boolean;
  112063. /** Defines if 32 bits indices are supported */
  112064. uintIndices: boolean;
  112065. /** Defines if high precision shaders are supported */
  112066. highPrecisionShaderSupported: boolean;
  112067. /** Defines if depth reading in the fragment shader is supported */
  112068. fragmentDepthSupported: boolean;
  112069. /** Defines if float texture linear filtering is supported*/
  112070. textureFloatLinearFiltering: boolean;
  112071. /** Defines if rendering to float textures is supported */
  112072. textureFloatRender: boolean;
  112073. /** Defines if half float textures are supported*/
  112074. textureHalfFloat: boolean;
  112075. /** Defines if half float texture linear filtering is supported*/
  112076. textureHalfFloatLinearFiltering: boolean;
  112077. /** Defines if rendering to half float textures is supported */
  112078. textureHalfFloatRender: boolean;
  112079. /** Defines if textureLOD shader command is supported */
  112080. textureLOD: boolean;
  112081. /** Defines if draw buffers extension is supported */
  112082. drawBuffersExtension: boolean;
  112083. /** Defines if depth textures are supported */
  112084. depthTextureExtension: boolean;
  112085. /** Defines if float color buffer are supported */
  112086. colorBufferFloat: boolean;
  112087. /** Gets disjoint timer query extension (null if not supported) */
  112088. timerQuery?: EXT_disjoint_timer_query;
  112089. /** Defines if timestamp can be used with timer query */
  112090. canUseTimestampForTimerQuery: boolean;
  112091. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  112092. multiview?: any;
  112093. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  112094. oculusMultiview?: any;
  112095. /** Function used to let the system compiles shaders in background */
  112096. parallelShaderCompile?: {
  112097. COMPLETION_STATUS_KHR: number;
  112098. };
  112099. /** Max number of texture samples for MSAA */
  112100. maxMSAASamples: number;
  112101. /** Defines if the blend min max extension is supported */
  112102. blendMinMax: boolean;
  112103. }
  112104. }
  112105. declare module BABYLON {
  112106. /**
  112107. * @hidden
  112108. **/
  112109. export class DepthCullingState {
  112110. private _isDepthTestDirty;
  112111. private _isDepthMaskDirty;
  112112. private _isDepthFuncDirty;
  112113. private _isCullFaceDirty;
  112114. private _isCullDirty;
  112115. private _isZOffsetDirty;
  112116. private _isFrontFaceDirty;
  112117. private _depthTest;
  112118. private _depthMask;
  112119. private _depthFunc;
  112120. private _cull;
  112121. private _cullFace;
  112122. private _zOffset;
  112123. private _frontFace;
  112124. /**
  112125. * Initializes the state.
  112126. */
  112127. constructor();
  112128. get isDirty(): boolean;
  112129. get zOffset(): number;
  112130. set zOffset(value: number);
  112131. get cullFace(): Nullable<number>;
  112132. set cullFace(value: Nullable<number>);
  112133. get cull(): Nullable<boolean>;
  112134. set cull(value: Nullable<boolean>);
  112135. get depthFunc(): Nullable<number>;
  112136. set depthFunc(value: Nullable<number>);
  112137. get depthMask(): boolean;
  112138. set depthMask(value: boolean);
  112139. get depthTest(): boolean;
  112140. set depthTest(value: boolean);
  112141. get frontFace(): Nullable<number>;
  112142. set frontFace(value: Nullable<number>);
  112143. reset(): void;
  112144. apply(gl: WebGLRenderingContext): void;
  112145. }
  112146. }
  112147. declare module BABYLON {
  112148. /**
  112149. * @hidden
  112150. **/
  112151. export class StencilState {
  112152. /** 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 */
  112153. static readonly ALWAYS: number;
  112154. /** Passed to stencilOperation to specify that stencil value must be kept */
  112155. static readonly KEEP: number;
  112156. /** Passed to stencilOperation to specify that stencil value must be replaced */
  112157. static readonly REPLACE: number;
  112158. private _isStencilTestDirty;
  112159. private _isStencilMaskDirty;
  112160. private _isStencilFuncDirty;
  112161. private _isStencilOpDirty;
  112162. private _stencilTest;
  112163. private _stencilMask;
  112164. private _stencilFunc;
  112165. private _stencilFuncRef;
  112166. private _stencilFuncMask;
  112167. private _stencilOpStencilFail;
  112168. private _stencilOpDepthFail;
  112169. private _stencilOpStencilDepthPass;
  112170. get isDirty(): boolean;
  112171. get stencilFunc(): number;
  112172. set stencilFunc(value: number);
  112173. get stencilFuncRef(): number;
  112174. set stencilFuncRef(value: number);
  112175. get stencilFuncMask(): number;
  112176. set stencilFuncMask(value: number);
  112177. get stencilOpStencilFail(): number;
  112178. set stencilOpStencilFail(value: number);
  112179. get stencilOpDepthFail(): number;
  112180. set stencilOpDepthFail(value: number);
  112181. get stencilOpStencilDepthPass(): number;
  112182. set stencilOpStencilDepthPass(value: number);
  112183. get stencilMask(): number;
  112184. set stencilMask(value: number);
  112185. get stencilTest(): boolean;
  112186. set stencilTest(value: boolean);
  112187. constructor();
  112188. reset(): void;
  112189. apply(gl: WebGLRenderingContext): void;
  112190. }
  112191. }
  112192. declare module BABYLON {
  112193. /**
  112194. * @hidden
  112195. **/
  112196. export class AlphaState {
  112197. private _isAlphaBlendDirty;
  112198. private _isBlendFunctionParametersDirty;
  112199. private _isBlendEquationParametersDirty;
  112200. private _isBlendConstantsDirty;
  112201. private _alphaBlend;
  112202. private _blendFunctionParameters;
  112203. private _blendEquationParameters;
  112204. private _blendConstants;
  112205. /**
  112206. * Initializes the state.
  112207. */
  112208. constructor();
  112209. get isDirty(): boolean;
  112210. get alphaBlend(): boolean;
  112211. set alphaBlend(value: boolean);
  112212. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  112213. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  112214. setAlphaEquationParameters(rgb: number, alpha: number): void;
  112215. reset(): void;
  112216. apply(gl: WebGLRenderingContext): void;
  112217. }
  112218. }
  112219. declare module BABYLON {
  112220. /** @hidden */
  112221. export class WebGL2ShaderProcessor implements IShaderProcessor {
  112222. attributeProcessor(attribute: string): string;
  112223. varyingProcessor(varying: string, isFragment: boolean): string;
  112224. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112225. }
  112226. }
  112227. declare module BABYLON {
  112228. /**
  112229. * Interface for attribute information associated with buffer instanciation
  112230. */
  112231. export interface InstancingAttributeInfo {
  112232. /**
  112233. * Name of the GLSL attribute
  112234. * if attribute index is not specified, this is used to retrieve the index from the effect
  112235. */
  112236. attributeName: string;
  112237. /**
  112238. * Index/offset of the attribute in the vertex shader
  112239. * if not specified, this will be computes from the name.
  112240. */
  112241. index?: number;
  112242. /**
  112243. * size of the attribute, 1, 2, 3 or 4
  112244. */
  112245. attributeSize: number;
  112246. /**
  112247. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  112248. */
  112249. offset: number;
  112250. /**
  112251. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  112252. * default to 1
  112253. */
  112254. divisor?: number;
  112255. /**
  112256. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  112257. * default is FLOAT
  112258. */
  112259. attributeType?: number;
  112260. /**
  112261. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  112262. */
  112263. normalized?: boolean;
  112264. }
  112265. }
  112266. declare module BABYLON {
  112267. interface ThinEngine {
  112268. /**
  112269. * Update a video texture
  112270. * @param texture defines the texture to update
  112271. * @param video defines the video element to use
  112272. * @param invertY defines if data must be stored with Y axis inverted
  112273. */
  112274. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  112275. }
  112276. }
  112277. declare module BABYLON {
  112278. interface ThinEngine {
  112279. /**
  112280. * Creates a dynamic texture
  112281. * @param width defines the width of the texture
  112282. * @param height defines the height of the texture
  112283. * @param generateMipMaps defines if the engine should generate the mip levels
  112284. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  112285. * @returns the dynamic texture inside an InternalTexture
  112286. */
  112287. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  112288. /**
  112289. * Update the content of a dynamic texture
  112290. * @param texture defines the texture to update
  112291. * @param canvas defines the canvas containing the source
  112292. * @param invertY defines if data must be stored with Y axis inverted
  112293. * @param premulAlpha defines if alpha is stored as premultiplied
  112294. * @param format defines the format of the data
  112295. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112296. */
  112297. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  112298. }
  112299. }
  112300. declare module BABYLON {
  112301. /**
  112302. * Settings for finer control over video usage
  112303. */
  112304. export interface VideoTextureSettings {
  112305. /**
  112306. * Applies `autoplay` to video, if specified
  112307. */
  112308. autoPlay?: boolean;
  112309. /**
  112310. * Applies `loop` to video, if specified
  112311. */
  112312. loop?: boolean;
  112313. /**
  112314. * Automatically updates internal texture from video at every frame in the render loop
  112315. */
  112316. autoUpdateTexture: boolean;
  112317. /**
  112318. * Image src displayed during the video loading or until the user interacts with the video.
  112319. */
  112320. poster?: string;
  112321. }
  112322. /**
  112323. * If you want to display a video in your scene, this is the special texture for that.
  112324. * This special texture works similar to other textures, with the exception of a few parameters.
  112325. * @see https://doc.babylonjs.com/how_to/video_texture
  112326. */
  112327. export class VideoTexture extends Texture {
  112328. /**
  112329. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  112330. */
  112331. readonly autoUpdateTexture: boolean;
  112332. /**
  112333. * The video instance used by the texture internally
  112334. */
  112335. readonly video: HTMLVideoElement;
  112336. private _onUserActionRequestedObservable;
  112337. /**
  112338. * Event triggerd when a dom action is required by the user to play the video.
  112339. * This happens due to recent changes in browser policies preventing video to auto start.
  112340. */
  112341. get onUserActionRequestedObservable(): Observable<Texture>;
  112342. private _generateMipMaps;
  112343. private _stillImageCaptured;
  112344. private _displayingPosterTexture;
  112345. private _settings;
  112346. private _createInternalTextureOnEvent;
  112347. private _frameId;
  112348. private _currentSrc;
  112349. /**
  112350. * Creates a video texture.
  112351. * If you want to display a video in your scene, this is the special texture for that.
  112352. * This special texture works similar to other textures, with the exception of a few parameters.
  112353. * @see https://doc.babylonjs.com/how_to/video_texture
  112354. * @param name optional name, will detect from video source, if not defined
  112355. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  112356. * @param scene is obviously the current scene.
  112357. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  112358. * @param invertY is false by default but can be used to invert video on Y axis
  112359. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  112360. * @param settings allows finer control over video usage
  112361. */
  112362. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  112363. private _getName;
  112364. private _getVideo;
  112365. private _createInternalTexture;
  112366. private reset;
  112367. /**
  112368. * @hidden Internal method to initiate `update`.
  112369. */
  112370. _rebuild(): void;
  112371. /**
  112372. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  112373. */
  112374. update(): void;
  112375. /**
  112376. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  112377. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  112378. */
  112379. updateTexture(isVisible: boolean): void;
  112380. protected _updateInternalTexture: () => void;
  112381. /**
  112382. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  112383. * @param url New url.
  112384. */
  112385. updateURL(url: string): void;
  112386. /**
  112387. * Clones the texture.
  112388. * @returns the cloned texture
  112389. */
  112390. clone(): VideoTexture;
  112391. /**
  112392. * Dispose the texture and release its associated resources.
  112393. */
  112394. dispose(): void;
  112395. /**
  112396. * Creates a video texture straight from a stream.
  112397. * @param scene Define the scene the texture should be created in
  112398. * @param stream Define the stream the texture should be created from
  112399. * @returns The created video texture as a promise
  112400. */
  112401. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  112402. /**
  112403. * Creates a video texture straight from your WebCam video feed.
  112404. * @param scene Define the scene the texture should be created in
  112405. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  112406. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  112407. * @returns The created video texture as a promise
  112408. */
  112409. static CreateFromWebCamAsync(scene: Scene, constraints: {
  112410. minWidth: number;
  112411. maxWidth: number;
  112412. minHeight: number;
  112413. maxHeight: number;
  112414. deviceId: string;
  112415. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  112416. /**
  112417. * Creates a video texture straight from your WebCam video feed.
  112418. * @param scene Define the scene the texture should be created in
  112419. * @param onReady Define a callback to triggered once the texture will be ready
  112420. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  112421. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  112422. */
  112423. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  112424. minWidth: number;
  112425. maxWidth: number;
  112426. minHeight: number;
  112427. maxHeight: number;
  112428. deviceId: string;
  112429. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  112430. }
  112431. }
  112432. declare module BABYLON {
  112433. /**
  112434. * Defines the interface used by objects working like Scene
  112435. * @hidden
  112436. */
  112437. export interface ISceneLike {
  112438. _addPendingData(data: any): void;
  112439. _removePendingData(data: any): void;
  112440. offlineProvider: IOfflineProvider;
  112441. }
  112442. /** Interface defining initialization parameters for Engine class */
  112443. export interface EngineOptions extends WebGLContextAttributes {
  112444. /**
  112445. * Defines if the engine should no exceed a specified device ratio
  112446. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  112447. */
  112448. limitDeviceRatio?: number;
  112449. /**
  112450. * Defines if webvr should be enabled automatically
  112451. * @see https://doc.babylonjs.com/how_to/webvr_camera
  112452. */
  112453. autoEnableWebVR?: boolean;
  112454. /**
  112455. * Defines if webgl2 should be turned off even if supported
  112456. * @see https://doc.babylonjs.com/features/webgl2
  112457. */
  112458. disableWebGL2Support?: boolean;
  112459. /**
  112460. * Defines if webaudio should be initialized as well
  112461. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  112462. */
  112463. audioEngine?: boolean;
  112464. /**
  112465. * Defines if animations should run using a deterministic lock step
  112466. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112467. */
  112468. deterministicLockstep?: boolean;
  112469. /** Defines the maximum steps to use with deterministic lock step mode */
  112470. lockstepMaxSteps?: number;
  112471. /** Defines the seconds between each deterministic lock step */
  112472. timeStep?: number;
  112473. /**
  112474. * Defines that engine should ignore context lost events
  112475. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  112476. */
  112477. doNotHandleContextLost?: boolean;
  112478. /**
  112479. * Defines that engine should ignore modifying touch action attribute and style
  112480. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  112481. */
  112482. doNotHandleTouchAction?: boolean;
  112483. /**
  112484. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  112485. */
  112486. useHighPrecisionFloats?: boolean;
  112487. /**
  112488. * Make the canvas XR Compatible for XR sessions
  112489. */
  112490. xrCompatible?: boolean;
  112491. }
  112492. /**
  112493. * The base engine class (root of all engines)
  112494. */
  112495. export class ThinEngine {
  112496. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  112497. static ExceptionList: ({
  112498. key: string;
  112499. capture: string;
  112500. captureConstraint: number;
  112501. targets: string[];
  112502. } | {
  112503. key: string;
  112504. capture: null;
  112505. captureConstraint: null;
  112506. targets: string[];
  112507. })[];
  112508. /** @hidden */
  112509. static _TextureLoaders: IInternalTextureLoader[];
  112510. /**
  112511. * Returns the current npm package of the sdk
  112512. */
  112513. static get NpmPackage(): string;
  112514. /**
  112515. * Returns the current version of the framework
  112516. */
  112517. static get Version(): string;
  112518. /**
  112519. * Returns a string describing the current engine
  112520. */
  112521. get description(): string;
  112522. /**
  112523. * Gets or sets the epsilon value used by collision engine
  112524. */
  112525. static CollisionsEpsilon: number;
  112526. /**
  112527. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112528. */
  112529. static get ShadersRepository(): string;
  112530. static set ShadersRepository(value: string);
  112531. /** @hidden */
  112532. _shaderProcessor: IShaderProcessor;
  112533. /**
  112534. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  112535. */
  112536. forcePOTTextures: boolean;
  112537. /**
  112538. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  112539. */
  112540. isFullscreen: boolean;
  112541. /**
  112542. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  112543. */
  112544. cullBackFaces: boolean;
  112545. /**
  112546. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  112547. */
  112548. renderEvenInBackground: boolean;
  112549. /**
  112550. * Gets or sets a boolean indicating that cache can be kept between frames
  112551. */
  112552. preventCacheWipeBetweenFrames: boolean;
  112553. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  112554. validateShaderPrograms: boolean;
  112555. /**
  112556. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  112557. * This can provide greater z depth for distant objects.
  112558. */
  112559. useReverseDepthBuffer: boolean;
  112560. /**
  112561. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  112562. */
  112563. disableUniformBuffers: boolean;
  112564. /** @hidden */
  112565. _uniformBuffers: UniformBuffer[];
  112566. /**
  112567. * Gets a boolean indicating that the engine supports uniform buffers
  112568. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  112569. */
  112570. get supportsUniformBuffers(): boolean;
  112571. /** @hidden */
  112572. _gl: WebGLRenderingContext;
  112573. /** @hidden */
  112574. _webGLVersion: number;
  112575. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  112576. protected _windowIsBackground: boolean;
  112577. protected _creationOptions: EngineOptions;
  112578. protected _highPrecisionShadersAllowed: boolean;
  112579. /** @hidden */
  112580. get _shouldUseHighPrecisionShader(): boolean;
  112581. /**
  112582. * Gets a boolean indicating that only power of 2 textures are supported
  112583. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  112584. */
  112585. get needPOTTextures(): boolean;
  112586. /** @hidden */
  112587. _badOS: boolean;
  112588. /** @hidden */
  112589. _badDesktopOS: boolean;
  112590. private _hardwareScalingLevel;
  112591. /** @hidden */
  112592. _caps: EngineCapabilities;
  112593. private _isStencilEnable;
  112594. private _glVersion;
  112595. private _glRenderer;
  112596. private _glVendor;
  112597. /** @hidden */
  112598. _videoTextureSupported: boolean;
  112599. protected _renderingQueueLaunched: boolean;
  112600. protected _activeRenderLoops: (() => void)[];
  112601. /**
  112602. * Observable signaled when a context lost event is raised
  112603. */
  112604. onContextLostObservable: Observable<ThinEngine>;
  112605. /**
  112606. * Observable signaled when a context restored event is raised
  112607. */
  112608. onContextRestoredObservable: Observable<ThinEngine>;
  112609. private _onContextLost;
  112610. private _onContextRestored;
  112611. protected _contextWasLost: boolean;
  112612. /** @hidden */
  112613. _doNotHandleContextLost: boolean;
  112614. /**
  112615. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  112616. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  112617. */
  112618. get doNotHandleContextLost(): boolean;
  112619. set doNotHandleContextLost(value: boolean);
  112620. /**
  112621. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  112622. */
  112623. disableVertexArrayObjects: boolean;
  112624. /** @hidden */
  112625. protected _colorWrite: boolean;
  112626. /** @hidden */
  112627. protected _colorWriteChanged: boolean;
  112628. /** @hidden */
  112629. protected _depthCullingState: DepthCullingState;
  112630. /** @hidden */
  112631. protected _stencilState: StencilState;
  112632. /** @hidden */
  112633. _alphaState: AlphaState;
  112634. /** @hidden */
  112635. _alphaMode: number;
  112636. /** @hidden */
  112637. _alphaEquation: number;
  112638. /** @hidden */
  112639. _internalTexturesCache: InternalTexture[];
  112640. /** @hidden */
  112641. protected _activeChannel: number;
  112642. private _currentTextureChannel;
  112643. /** @hidden */
  112644. protected _boundTexturesCache: {
  112645. [key: string]: Nullable<InternalTexture>;
  112646. };
  112647. /** @hidden */
  112648. protected _currentEffect: Nullable<Effect>;
  112649. /** @hidden */
  112650. protected _currentProgram: Nullable<WebGLProgram>;
  112651. private _compiledEffects;
  112652. private _vertexAttribArraysEnabled;
  112653. /** @hidden */
  112654. protected _cachedViewport: Nullable<IViewportLike>;
  112655. private _cachedVertexArrayObject;
  112656. /** @hidden */
  112657. protected _cachedVertexBuffers: any;
  112658. /** @hidden */
  112659. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  112660. /** @hidden */
  112661. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  112662. /** @hidden */
  112663. _currentRenderTarget: Nullable<InternalTexture>;
  112664. private _uintIndicesCurrentlySet;
  112665. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  112666. /** @hidden */
  112667. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  112668. /** @hidden */
  112669. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  112670. private _currentBufferPointers;
  112671. private _currentInstanceLocations;
  112672. private _currentInstanceBuffers;
  112673. private _textureUnits;
  112674. /** @hidden */
  112675. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112676. /** @hidden */
  112677. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112678. /** @hidden */
  112679. _boundRenderFunction: any;
  112680. private _vaoRecordInProgress;
  112681. private _mustWipeVertexAttributes;
  112682. private _emptyTexture;
  112683. private _emptyCubeTexture;
  112684. private _emptyTexture3D;
  112685. private _emptyTexture2DArray;
  112686. /** @hidden */
  112687. _frameHandler: number;
  112688. private _nextFreeTextureSlots;
  112689. private _maxSimultaneousTextures;
  112690. private _activeRequests;
  112691. /** @hidden */
  112692. _transformTextureUrl: Nullable<(url: string) => string>;
  112693. protected get _supportsHardwareTextureRescaling(): boolean;
  112694. private _framebufferDimensionsObject;
  112695. /**
  112696. * sets the object from which width and height will be taken from when getting render width and height
  112697. * Will fallback to the gl object
  112698. * @param dimensions the framebuffer width and height that will be used.
  112699. */
  112700. set framebufferDimensionsObject(dimensions: Nullable<{
  112701. framebufferWidth: number;
  112702. framebufferHeight: number;
  112703. }>);
  112704. /**
  112705. * Gets the current viewport
  112706. */
  112707. get currentViewport(): Nullable<IViewportLike>;
  112708. /**
  112709. * Gets the default empty texture
  112710. */
  112711. get emptyTexture(): InternalTexture;
  112712. /**
  112713. * Gets the default empty 3D texture
  112714. */
  112715. get emptyTexture3D(): InternalTexture;
  112716. /**
  112717. * Gets the default empty 2D array texture
  112718. */
  112719. get emptyTexture2DArray(): InternalTexture;
  112720. /**
  112721. * Gets the default empty cube texture
  112722. */
  112723. get emptyCubeTexture(): InternalTexture;
  112724. /**
  112725. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  112726. */
  112727. readonly premultipliedAlpha: boolean;
  112728. /**
  112729. * Observable event triggered before each texture is initialized
  112730. */
  112731. onBeforeTextureInitObservable: Observable<Texture>;
  112732. /**
  112733. * Creates a new engine
  112734. * @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
  112735. * @param antialias defines enable antialiasing (default: false)
  112736. * @param options defines further options to be sent to the getContext() function
  112737. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  112738. */
  112739. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  112740. private _rebuildInternalTextures;
  112741. private _rebuildEffects;
  112742. /**
  112743. * Gets a boolean indicating if all created effects are ready
  112744. * @returns true if all effects are ready
  112745. */
  112746. areAllEffectsReady(): boolean;
  112747. protected _rebuildBuffers(): void;
  112748. protected _initGLContext(): void;
  112749. /**
  112750. * Gets version of the current webGL context
  112751. */
  112752. get webGLVersion(): number;
  112753. /**
  112754. * Gets a string idenfifying the name of the class
  112755. * @returns "Engine" string
  112756. */
  112757. getClassName(): string;
  112758. /**
  112759. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  112760. */
  112761. get isStencilEnable(): boolean;
  112762. /** @hidden */
  112763. _prepareWorkingCanvas(): void;
  112764. /**
  112765. * Reset the texture cache to empty state
  112766. */
  112767. resetTextureCache(): void;
  112768. /**
  112769. * Gets an object containing information about the current webGL context
  112770. * @returns an object containing the vender, the renderer and the version of the current webGL context
  112771. */
  112772. getGlInfo(): {
  112773. vendor: string;
  112774. renderer: string;
  112775. version: string;
  112776. };
  112777. /**
  112778. * Defines the hardware scaling level.
  112779. * By default the hardware scaling level is computed from the window device ratio.
  112780. * 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.
  112781. * @param level defines the level to use
  112782. */
  112783. setHardwareScalingLevel(level: number): void;
  112784. /**
  112785. * Gets the current hardware scaling level.
  112786. * By default the hardware scaling level is computed from the window device ratio.
  112787. * 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.
  112788. * @returns a number indicating the current hardware scaling level
  112789. */
  112790. getHardwareScalingLevel(): number;
  112791. /**
  112792. * Gets the list of loaded textures
  112793. * @returns an array containing all loaded textures
  112794. */
  112795. getLoadedTexturesCache(): InternalTexture[];
  112796. /**
  112797. * Gets the object containing all engine capabilities
  112798. * @returns the EngineCapabilities object
  112799. */
  112800. getCaps(): EngineCapabilities;
  112801. /**
  112802. * stop executing a render loop function and remove it from the execution array
  112803. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  112804. */
  112805. stopRenderLoop(renderFunction?: () => void): void;
  112806. /** @hidden */
  112807. _renderLoop(): void;
  112808. /**
  112809. * Gets the HTML canvas attached with the current webGL context
  112810. * @returns a HTML canvas
  112811. */
  112812. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  112813. /**
  112814. * Gets host window
  112815. * @returns the host window object
  112816. */
  112817. getHostWindow(): Nullable<Window>;
  112818. /**
  112819. * Gets the current render width
  112820. * @param useScreen defines if screen size must be used (or the current render target if any)
  112821. * @returns a number defining the current render width
  112822. */
  112823. getRenderWidth(useScreen?: boolean): number;
  112824. /**
  112825. * Gets the current render height
  112826. * @param useScreen defines if screen size must be used (or the current render target if any)
  112827. * @returns a number defining the current render height
  112828. */
  112829. getRenderHeight(useScreen?: boolean): number;
  112830. /**
  112831. * Can be used to override the current requestAnimationFrame requester.
  112832. * @hidden
  112833. */
  112834. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  112835. /**
  112836. * Register and execute a render loop. The engine can have more than one render function
  112837. * @param renderFunction defines the function to continuously execute
  112838. */
  112839. runRenderLoop(renderFunction: () => void): void;
  112840. /**
  112841. * Clear the current render buffer or the current render target (if any is set up)
  112842. * @param color defines the color to use
  112843. * @param backBuffer defines if the back buffer must be cleared
  112844. * @param depth defines if the depth buffer must be cleared
  112845. * @param stencil defines if the stencil buffer must be cleared
  112846. */
  112847. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112848. private _viewportCached;
  112849. /** @hidden */
  112850. _viewport(x: number, y: number, width: number, height: number): void;
  112851. /**
  112852. * Set the WebGL's viewport
  112853. * @param viewport defines the viewport element to be used
  112854. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112855. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112856. */
  112857. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112858. /**
  112859. * Begin a new frame
  112860. */
  112861. beginFrame(): void;
  112862. /**
  112863. * Enf the current frame
  112864. */
  112865. endFrame(): void;
  112866. /**
  112867. * Resize the view according to the canvas' size
  112868. */
  112869. resize(): void;
  112870. /**
  112871. * Force a specific size of the canvas
  112872. * @param width defines the new canvas' width
  112873. * @param height defines the new canvas' height
  112874. * @returns true if the size was changed
  112875. */
  112876. setSize(width: number, height: number): boolean;
  112877. /**
  112878. * Binds the frame buffer to the specified texture.
  112879. * @param texture The texture to render to or null for the default canvas
  112880. * @param faceIndex The face of the texture to render to in case of cube texture
  112881. * @param requiredWidth The width of the target to render to
  112882. * @param requiredHeight The height of the target to render to
  112883. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112884. * @param lodLevel defines the lod level to bind to the frame buffer
  112885. * @param layer defines the 2d array index to bind to frame buffer to
  112886. */
  112887. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  112888. /** @hidden */
  112889. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  112890. /**
  112891. * Unbind the current render target texture from the webGL context
  112892. * @param texture defines the render target texture to unbind
  112893. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112894. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112895. */
  112896. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112897. /**
  112898. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  112899. */
  112900. flushFramebuffer(): void;
  112901. /**
  112902. * Unbind the current render target and bind the default framebuffer
  112903. */
  112904. restoreDefaultFramebuffer(): void;
  112905. /** @hidden */
  112906. protected _resetVertexBufferBinding(): void;
  112907. /**
  112908. * Creates a vertex buffer
  112909. * @param data the data for the vertex buffer
  112910. * @returns the new WebGL static buffer
  112911. */
  112912. createVertexBuffer(data: DataArray): DataBuffer;
  112913. private _createVertexBuffer;
  112914. /**
  112915. * Creates a dynamic vertex buffer
  112916. * @param data the data for the dynamic vertex buffer
  112917. * @returns the new WebGL dynamic buffer
  112918. */
  112919. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112920. protected _resetIndexBufferBinding(): void;
  112921. /**
  112922. * Creates a new index buffer
  112923. * @param indices defines the content of the index buffer
  112924. * @param updatable defines if the index buffer must be updatable
  112925. * @returns a new webGL buffer
  112926. */
  112927. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  112928. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  112929. /**
  112930. * Bind a webGL buffer to the webGL context
  112931. * @param buffer defines the buffer to bind
  112932. */
  112933. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  112934. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  112935. private bindBuffer;
  112936. /**
  112937. * update the bound buffer with the given data
  112938. * @param data defines the data to update
  112939. */
  112940. updateArrayBuffer(data: Float32Array): void;
  112941. private _vertexAttribPointer;
  112942. /** @hidden */
  112943. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  112944. private _bindVertexBuffersAttributes;
  112945. /**
  112946. * Records a vertex array object
  112947. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112948. * @param vertexBuffers defines the list of vertex buffers to store
  112949. * @param indexBuffer defines the index buffer to store
  112950. * @param effect defines the effect to store
  112951. * @returns the new vertex array object
  112952. */
  112953. recordVertexArrayObject(vertexBuffers: {
  112954. [key: string]: VertexBuffer;
  112955. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112956. /**
  112957. * Bind a specific vertex array object
  112958. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112959. * @param vertexArrayObject defines the vertex array object to bind
  112960. * @param indexBuffer defines the index buffer to bind
  112961. */
  112962. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  112963. /**
  112964. * Bind webGl buffers directly to the webGL context
  112965. * @param vertexBuffer defines the vertex buffer to bind
  112966. * @param indexBuffer defines the index buffer to bind
  112967. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112968. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112969. * @param effect defines the effect associated with the vertex buffer
  112970. */
  112971. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  112972. private _unbindVertexArrayObject;
  112973. /**
  112974. * Bind a list of vertex buffers to the webGL context
  112975. * @param vertexBuffers defines the list of vertex buffers to bind
  112976. * @param indexBuffer defines the index buffer to bind
  112977. * @param effect defines the effect associated with the vertex buffers
  112978. */
  112979. bindBuffers(vertexBuffers: {
  112980. [key: string]: Nullable<VertexBuffer>;
  112981. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  112982. /**
  112983. * Unbind all instance attributes
  112984. */
  112985. unbindInstanceAttributes(): void;
  112986. /**
  112987. * Release and free the memory of a vertex array object
  112988. * @param vao defines the vertex array object to delete
  112989. */
  112990. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  112991. /** @hidden */
  112992. _releaseBuffer(buffer: DataBuffer): boolean;
  112993. protected _deleteBuffer(buffer: DataBuffer): void;
  112994. /**
  112995. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  112996. * @param instancesBuffer defines the webGL buffer to update and bind
  112997. * @param data defines the data to store in the buffer
  112998. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  112999. */
  113000. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  113001. /**
  113002. * Bind the content of a webGL buffer used with instantiation
  113003. * @param instancesBuffer defines the webGL buffer to bind
  113004. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  113005. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  113006. */
  113007. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  113008. /**
  113009. * Disable the instance attribute corresponding to the name in parameter
  113010. * @param name defines the name of the attribute to disable
  113011. */
  113012. disableInstanceAttributeByName(name: string): void;
  113013. /**
  113014. * Disable the instance attribute corresponding to the location in parameter
  113015. * @param attributeLocation defines the attribute location of the attribute to disable
  113016. */
  113017. disableInstanceAttribute(attributeLocation: number): void;
  113018. /**
  113019. * Disable the attribute corresponding to the location in parameter
  113020. * @param attributeLocation defines the attribute location of the attribute to disable
  113021. */
  113022. disableAttributeByIndex(attributeLocation: number): void;
  113023. /**
  113024. * Send a draw order
  113025. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113026. * @param indexStart defines the starting index
  113027. * @param indexCount defines the number of index to draw
  113028. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113029. */
  113030. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  113031. /**
  113032. * Draw a list of points
  113033. * @param verticesStart defines the index of first vertex to draw
  113034. * @param verticesCount defines the count of vertices to draw
  113035. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113036. */
  113037. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113038. /**
  113039. * Draw a list of unindexed primitives
  113040. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113041. * @param verticesStart defines the index of first vertex to draw
  113042. * @param verticesCount defines the count of vertices to draw
  113043. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113044. */
  113045. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113046. /**
  113047. * Draw a list of indexed primitives
  113048. * @param fillMode defines the primitive to use
  113049. * @param indexStart defines the starting index
  113050. * @param indexCount defines the number of index to draw
  113051. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113052. */
  113053. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113054. /**
  113055. * Draw a list of unindexed primitives
  113056. * @param fillMode defines the primitive to use
  113057. * @param verticesStart defines the index of first vertex to draw
  113058. * @param verticesCount defines the count of vertices to draw
  113059. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113060. */
  113061. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113062. private _drawMode;
  113063. /** @hidden */
  113064. protected _reportDrawCall(): void;
  113065. /** @hidden */
  113066. _releaseEffect(effect: Effect): void;
  113067. /** @hidden */
  113068. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113069. /**
  113070. * Create a new effect (used to store vertex/fragment shaders)
  113071. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  113072. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  113073. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  113074. * @param samplers defines an array of string used to represent textures
  113075. * @param defines defines the string containing the defines to use to compile the shaders
  113076. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  113077. * @param onCompiled defines a function to call when the effect creation is successful
  113078. * @param onError defines a function to call when the effect creation has failed
  113079. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  113080. * @returns the new Effect
  113081. */
  113082. 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;
  113083. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  113084. private _compileShader;
  113085. private _compileRawShader;
  113086. /** @hidden */
  113087. _getShaderSource(shader: WebGLShader): Nullable<string>;
  113088. /**
  113089. * Directly creates a webGL program
  113090. * @param pipelineContext defines the pipeline context to attach to
  113091. * @param vertexCode defines the vertex shader code to use
  113092. * @param fragmentCode defines the fragment shader code to use
  113093. * @param context defines the webGL context to use (if not set, the current one will be used)
  113094. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  113095. * @returns the new webGL program
  113096. */
  113097. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113098. /**
  113099. * Creates a webGL program
  113100. * @param pipelineContext defines the pipeline context to attach to
  113101. * @param vertexCode defines the vertex shader code to use
  113102. * @param fragmentCode defines the fragment shader code to use
  113103. * @param defines defines the string containing the defines to use to compile the shaders
  113104. * @param context defines the webGL context to use (if not set, the current one will be used)
  113105. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  113106. * @returns the new webGL program
  113107. */
  113108. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113109. /**
  113110. * Creates a new pipeline context
  113111. * @returns the new pipeline
  113112. */
  113113. createPipelineContext(): IPipelineContext;
  113114. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113115. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  113116. /** @hidden */
  113117. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113118. /** @hidden */
  113119. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113120. /** @hidden */
  113121. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113122. /**
  113123. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  113124. * @param pipelineContext defines the pipeline context to use
  113125. * @param uniformsNames defines the list of uniform names
  113126. * @returns an array of webGL uniform locations
  113127. */
  113128. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  113129. /**
  113130. * Gets the lsit of active attributes for a given webGL program
  113131. * @param pipelineContext defines the pipeline context to use
  113132. * @param attributesNames defines the list of attribute names to get
  113133. * @returns an array of indices indicating the offset of each attribute
  113134. */
  113135. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113136. /**
  113137. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  113138. * @param effect defines the effect to activate
  113139. */
  113140. enableEffect(effect: Nullable<Effect>): void;
  113141. /**
  113142. * Set the value of an uniform to a number (int)
  113143. * @param uniform defines the webGL uniform location where to store the value
  113144. * @param value defines the int number to store
  113145. */
  113146. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  113147. /**
  113148. * Set the value of an uniform to an array of int32
  113149. * @param uniform defines the webGL uniform location where to store the value
  113150. * @param array defines the array of int32 to store
  113151. */
  113152. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113153. /**
  113154. * Set the value of an uniform to an array of int32 (stored as vec2)
  113155. * @param uniform defines the webGL uniform location where to store the value
  113156. * @param array defines the array of int32 to store
  113157. */
  113158. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113159. /**
  113160. * Set the value of an uniform to an array of int32 (stored as vec3)
  113161. * @param uniform defines the webGL uniform location where to store the value
  113162. * @param array defines the array of int32 to store
  113163. */
  113164. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113165. /**
  113166. * Set the value of an uniform to an array of int32 (stored as vec4)
  113167. * @param uniform defines the webGL uniform location where to store the value
  113168. * @param array defines the array of int32 to store
  113169. */
  113170. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113171. /**
  113172. * Set the value of an uniform to an array of number
  113173. * @param uniform defines the webGL uniform location where to store the value
  113174. * @param array defines the array of number to store
  113175. */
  113176. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113177. /**
  113178. * Set the value of an uniform to an array of number (stored as vec2)
  113179. * @param uniform defines the webGL uniform location where to store the value
  113180. * @param array defines the array of number to store
  113181. */
  113182. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113183. /**
  113184. * Set the value of an uniform to an array of number (stored as vec3)
  113185. * @param uniform defines the webGL uniform location where to store the value
  113186. * @param array defines the array of number to store
  113187. */
  113188. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113189. /**
  113190. * Set the value of an uniform to an array of number (stored as vec4)
  113191. * @param uniform defines the webGL uniform location where to store the value
  113192. * @param array defines the array of number to store
  113193. */
  113194. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113195. /**
  113196. * Set the value of an uniform to an array of float32 (stored as matrices)
  113197. * @param uniform defines the webGL uniform location where to store the value
  113198. * @param matrices defines the array of float32 to store
  113199. */
  113200. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  113201. /**
  113202. * Set the value of an uniform to a matrix (3x3)
  113203. * @param uniform defines the webGL uniform location where to store the value
  113204. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  113205. */
  113206. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  113207. /**
  113208. * Set the value of an uniform to a matrix (2x2)
  113209. * @param uniform defines the webGL uniform location where to store the value
  113210. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  113211. */
  113212. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  113213. /**
  113214. * Set the value of an uniform to a number (float)
  113215. * @param uniform defines the webGL uniform location where to store the value
  113216. * @param value defines the float number to store
  113217. */
  113218. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  113219. /**
  113220. * Set the value of an uniform to a vec2
  113221. * @param uniform defines the webGL uniform location where to store the value
  113222. * @param x defines the 1st component of the value
  113223. * @param y defines the 2nd component of the value
  113224. */
  113225. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  113226. /**
  113227. * Set the value of an uniform to a vec3
  113228. * @param uniform defines the webGL uniform location where to store the value
  113229. * @param x defines the 1st component of the value
  113230. * @param y defines the 2nd component of the value
  113231. * @param z defines the 3rd component of the value
  113232. */
  113233. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  113234. /**
  113235. * Set the value of an uniform to a vec4
  113236. * @param uniform defines the webGL uniform location where to store the value
  113237. * @param x defines the 1st component of the value
  113238. * @param y defines the 2nd component of the value
  113239. * @param z defines the 3rd component of the value
  113240. * @param w defines the 4th component of the value
  113241. */
  113242. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  113243. /**
  113244. * Apply all cached states (depth, culling, stencil and alpha)
  113245. */
  113246. applyStates(): void;
  113247. /**
  113248. * Enable or disable color writing
  113249. * @param enable defines the state to set
  113250. */
  113251. setColorWrite(enable: boolean): void;
  113252. /**
  113253. * Gets a boolean indicating if color writing is enabled
  113254. * @returns the current color writing state
  113255. */
  113256. getColorWrite(): boolean;
  113257. /**
  113258. * Gets the depth culling state manager
  113259. */
  113260. get depthCullingState(): DepthCullingState;
  113261. /**
  113262. * Gets the alpha state manager
  113263. */
  113264. get alphaState(): AlphaState;
  113265. /**
  113266. * Gets the stencil state manager
  113267. */
  113268. get stencilState(): StencilState;
  113269. /**
  113270. * Clears the list of texture accessible through engine.
  113271. * This can help preventing texture load conflict due to name collision.
  113272. */
  113273. clearInternalTexturesCache(): void;
  113274. /**
  113275. * Force the entire cache to be cleared
  113276. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  113277. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  113278. */
  113279. wipeCaches(bruteForce?: boolean): void;
  113280. /** @hidden */
  113281. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  113282. min: number;
  113283. mag: number;
  113284. };
  113285. /** @hidden */
  113286. _createTexture(): WebGLTexture;
  113287. /**
  113288. * Usually called from Texture.ts.
  113289. * Passed information to create a WebGLTexture
  113290. * @param url defines a value which contains one of the following:
  113291. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113292. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113293. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113294. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113295. * @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)
  113296. * @param scene needed for loading to the correct scene
  113297. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  113298. * @param onLoad optional callback to be called upon successful completion
  113299. * @param onError optional callback to be called upon failure
  113300. * @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
  113301. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113302. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113303. * @param forcedExtension defines the extension to use to pick the right loader
  113304. * @param mimeType defines an optional mime type
  113305. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113306. */
  113307. 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;
  113308. /**
  113309. * Loads an image as an HTMLImageElement.
  113310. * @param input url string, ArrayBuffer, or Blob to load
  113311. * @param onLoad callback called when the image successfully loads
  113312. * @param onError callback called when the image fails to load
  113313. * @param offlineProvider offline provider for caching
  113314. * @param mimeType optional mime type
  113315. * @returns the HTMLImageElement of the loaded image
  113316. * @hidden
  113317. */
  113318. 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>;
  113319. /**
  113320. * @hidden
  113321. */
  113322. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  113323. private _unpackFlipYCached;
  113324. /**
  113325. * In case you are sharing the context with other applications, it might
  113326. * be interested to not cache the unpack flip y state to ensure a consistent
  113327. * value would be set.
  113328. */
  113329. enableUnpackFlipYCached: boolean;
  113330. /** @hidden */
  113331. _unpackFlipY(value: boolean): void;
  113332. /** @hidden */
  113333. _getUnpackAlignement(): number;
  113334. private _getTextureTarget;
  113335. /**
  113336. * Update the sampling mode of a given texture
  113337. * @param samplingMode defines the required sampling mode
  113338. * @param texture defines the texture to update
  113339. * @param generateMipMaps defines whether to generate mipmaps for the texture
  113340. */
  113341. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  113342. /**
  113343. * Update the sampling mode of a given texture
  113344. * @param texture defines the texture to update
  113345. * @param wrapU defines the texture wrap mode of the u coordinates
  113346. * @param wrapV defines the texture wrap mode of the v coordinates
  113347. * @param wrapR defines the texture wrap mode of the r coordinates
  113348. */
  113349. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  113350. /** @hidden */
  113351. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  113352. width: number;
  113353. height: number;
  113354. layers?: number;
  113355. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  113356. /** @hidden */
  113357. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113358. /** @hidden */
  113359. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  113360. /**
  113361. * Update a portion of an internal texture
  113362. * @param texture defines the texture to update
  113363. * @param imageData defines the data to store into the texture
  113364. * @param xOffset defines the x coordinates of the update rectangle
  113365. * @param yOffset defines the y coordinates of the update rectangle
  113366. * @param width defines the width of the update rectangle
  113367. * @param height defines the height of the update rectangle
  113368. * @param faceIndex defines the face index if texture is a cube (0 by default)
  113369. * @param lod defines the lod level to update (0 by default)
  113370. */
  113371. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  113372. /** @hidden */
  113373. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113374. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  113375. private _prepareWebGLTexture;
  113376. /** @hidden */
  113377. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  113378. private _getDepthStencilBuffer;
  113379. /** @hidden */
  113380. _releaseFramebufferObjects(texture: InternalTexture): void;
  113381. /** @hidden */
  113382. _releaseTexture(texture: InternalTexture): void;
  113383. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113384. protected _setProgram(program: WebGLProgram): void;
  113385. protected _boundUniforms: {
  113386. [key: number]: WebGLUniformLocation;
  113387. };
  113388. /**
  113389. * Binds an effect to the webGL context
  113390. * @param effect defines the effect to bind
  113391. */
  113392. bindSamplers(effect: Effect): void;
  113393. private _activateCurrentTexture;
  113394. /** @hidden */
  113395. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  113396. /** @hidden */
  113397. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  113398. /**
  113399. * Unbind all textures from the webGL context
  113400. */
  113401. unbindAllTextures(): void;
  113402. /**
  113403. * Sets a texture to the according uniform.
  113404. * @param channel The texture channel
  113405. * @param uniform The uniform to set
  113406. * @param texture The texture to apply
  113407. */
  113408. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  113409. private _bindSamplerUniformToChannel;
  113410. private _getTextureWrapMode;
  113411. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113412. /**
  113413. * Sets an array of texture to the webGL context
  113414. * @param channel defines the channel where the texture array must be set
  113415. * @param uniform defines the associated uniform location
  113416. * @param textures defines the array of textures to bind
  113417. */
  113418. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  113419. /** @hidden */
  113420. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  113421. private _setTextureParameterFloat;
  113422. private _setTextureParameterInteger;
  113423. /**
  113424. * Unbind all vertex attributes from the webGL context
  113425. */
  113426. unbindAllAttributes(): void;
  113427. /**
  113428. * 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
  113429. */
  113430. releaseEffects(): void;
  113431. /**
  113432. * Dispose and release all associated resources
  113433. */
  113434. dispose(): void;
  113435. /**
  113436. * Attach a new callback raised when context lost event is fired
  113437. * @param callback defines the callback to call
  113438. */
  113439. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113440. /**
  113441. * Attach a new callback raised when context restored event is fired
  113442. * @param callback defines the callback to call
  113443. */
  113444. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113445. /**
  113446. * Get the current error code of the webGL context
  113447. * @returns the error code
  113448. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113449. */
  113450. getError(): number;
  113451. private _canRenderToFloatFramebuffer;
  113452. private _canRenderToHalfFloatFramebuffer;
  113453. private _canRenderToFramebuffer;
  113454. /** @hidden */
  113455. _getWebGLTextureType(type: number): number;
  113456. /** @hidden */
  113457. _getInternalFormat(format: number): number;
  113458. /** @hidden */
  113459. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  113460. /** @hidden */
  113461. _getRGBAMultiSampleBufferFormat(type: number): number;
  113462. /** @hidden */
  113463. _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;
  113464. /**
  113465. * Loads a file from a url
  113466. * @param url url to load
  113467. * @param onSuccess callback called when the file successfully loads
  113468. * @param onProgress callback called while file is loading (if the server supports this mode)
  113469. * @param offlineProvider defines the offline provider for caching
  113470. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113471. * @param onError callback called when the file fails to load
  113472. * @returns a file request object
  113473. * @hidden
  113474. */
  113475. 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;
  113476. /**
  113477. * Reads pixels from the current frame buffer. Please note that this function can be slow
  113478. * @param x defines the x coordinate of the rectangle where pixels must be read
  113479. * @param y defines the y coordinate of the rectangle where pixels must be read
  113480. * @param width defines the width of the rectangle where pixels must be read
  113481. * @param height defines the height of the rectangle where pixels must be read
  113482. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  113483. * @returns a Uint8Array containing RGBA colors
  113484. */
  113485. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  113486. private static _isSupported;
  113487. /**
  113488. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  113489. * @returns true if the engine can be created
  113490. * @ignorenaming
  113491. */
  113492. static isSupported(): boolean;
  113493. /**
  113494. * Find the next highest power of two.
  113495. * @param x Number to start search from.
  113496. * @return Next highest power of two.
  113497. */
  113498. static CeilingPOT(x: number): number;
  113499. /**
  113500. * Find the next lowest power of two.
  113501. * @param x Number to start search from.
  113502. * @return Next lowest power of two.
  113503. */
  113504. static FloorPOT(x: number): number;
  113505. /**
  113506. * Find the nearest power of two.
  113507. * @param x Number to start search from.
  113508. * @return Next nearest power of two.
  113509. */
  113510. static NearestPOT(x: number): number;
  113511. /**
  113512. * Get the closest exponent of two
  113513. * @param value defines the value to approximate
  113514. * @param max defines the maximum value to return
  113515. * @param mode defines how to define the closest value
  113516. * @returns closest exponent of two of the given value
  113517. */
  113518. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  113519. /**
  113520. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  113521. * @param func - the function to be called
  113522. * @param requester - the object that will request the next frame. Falls back to window.
  113523. * @returns frame number
  113524. */
  113525. static QueueNewFrame(func: () => void, requester?: any): number;
  113526. /**
  113527. * Gets host document
  113528. * @returns the host document object
  113529. */
  113530. getHostDocument(): Nullable<Document>;
  113531. }
  113532. }
  113533. declare module BABYLON {
  113534. /**
  113535. * Class representing spherical harmonics coefficients to the 3rd degree
  113536. */
  113537. export class SphericalHarmonics {
  113538. /**
  113539. * Defines whether or not the harmonics have been prescaled for rendering.
  113540. */
  113541. preScaled: boolean;
  113542. /**
  113543. * The l0,0 coefficients of the spherical harmonics
  113544. */
  113545. l00: Vector3;
  113546. /**
  113547. * The l1,-1 coefficients of the spherical harmonics
  113548. */
  113549. l1_1: Vector3;
  113550. /**
  113551. * The l1,0 coefficients of the spherical harmonics
  113552. */
  113553. l10: Vector3;
  113554. /**
  113555. * The l1,1 coefficients of the spherical harmonics
  113556. */
  113557. l11: Vector3;
  113558. /**
  113559. * The l2,-2 coefficients of the spherical harmonics
  113560. */
  113561. l2_2: Vector3;
  113562. /**
  113563. * The l2,-1 coefficients of the spherical harmonics
  113564. */
  113565. l2_1: Vector3;
  113566. /**
  113567. * The l2,0 coefficients of the spherical harmonics
  113568. */
  113569. l20: Vector3;
  113570. /**
  113571. * The l2,1 coefficients of the spherical harmonics
  113572. */
  113573. l21: Vector3;
  113574. /**
  113575. * The l2,2 coefficients of the spherical harmonics
  113576. */
  113577. l22: Vector3;
  113578. /**
  113579. * Adds a light to the spherical harmonics
  113580. * @param direction the direction of the light
  113581. * @param color the color of the light
  113582. * @param deltaSolidAngle the delta solid angle of the light
  113583. */
  113584. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  113585. /**
  113586. * Scales the spherical harmonics by the given amount
  113587. * @param scale the amount to scale
  113588. */
  113589. scaleInPlace(scale: number): void;
  113590. /**
  113591. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  113592. *
  113593. * ```
  113594. * E_lm = A_l * L_lm
  113595. * ```
  113596. *
  113597. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  113598. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  113599. * the scaling factors are given in equation 9.
  113600. */
  113601. convertIncidentRadianceToIrradiance(): void;
  113602. /**
  113603. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  113604. *
  113605. * ```
  113606. * L = (1/pi) * E * rho
  113607. * ```
  113608. *
  113609. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  113610. */
  113611. convertIrradianceToLambertianRadiance(): void;
  113612. /**
  113613. * Integrates the reconstruction coefficients directly in to the SH preventing further
  113614. * required operations at run time.
  113615. *
  113616. * This is simply done by scaling back the SH with Ylm constants parameter.
  113617. * The trigonometric part being applied by the shader at run time.
  113618. */
  113619. preScaleForRendering(): void;
  113620. /**
  113621. * Constructs a spherical harmonics from an array.
  113622. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  113623. * @returns the spherical harmonics
  113624. */
  113625. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  113626. /**
  113627. * Gets the spherical harmonics from polynomial
  113628. * @param polynomial the spherical polynomial
  113629. * @returns the spherical harmonics
  113630. */
  113631. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  113632. }
  113633. /**
  113634. * Class representing spherical polynomial coefficients to the 3rd degree
  113635. */
  113636. export class SphericalPolynomial {
  113637. private _harmonics;
  113638. /**
  113639. * The spherical harmonics used to create the polynomials.
  113640. */
  113641. get preScaledHarmonics(): SphericalHarmonics;
  113642. /**
  113643. * The x coefficients of the spherical polynomial
  113644. */
  113645. x: Vector3;
  113646. /**
  113647. * The y coefficients of the spherical polynomial
  113648. */
  113649. y: Vector3;
  113650. /**
  113651. * The z coefficients of the spherical polynomial
  113652. */
  113653. z: Vector3;
  113654. /**
  113655. * The xx coefficients of the spherical polynomial
  113656. */
  113657. xx: Vector3;
  113658. /**
  113659. * The yy coefficients of the spherical polynomial
  113660. */
  113661. yy: Vector3;
  113662. /**
  113663. * The zz coefficients of the spherical polynomial
  113664. */
  113665. zz: Vector3;
  113666. /**
  113667. * The xy coefficients of the spherical polynomial
  113668. */
  113669. xy: Vector3;
  113670. /**
  113671. * The yz coefficients of the spherical polynomial
  113672. */
  113673. yz: Vector3;
  113674. /**
  113675. * The zx coefficients of the spherical polynomial
  113676. */
  113677. zx: Vector3;
  113678. /**
  113679. * Adds an ambient color to the spherical polynomial
  113680. * @param color the color to add
  113681. */
  113682. addAmbient(color: Color3): void;
  113683. /**
  113684. * Scales the spherical polynomial by the given amount
  113685. * @param scale the amount to scale
  113686. */
  113687. scaleInPlace(scale: number): void;
  113688. /**
  113689. * Gets the spherical polynomial from harmonics
  113690. * @param harmonics the spherical harmonics
  113691. * @returns the spherical polynomial
  113692. */
  113693. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  113694. /**
  113695. * Constructs a spherical polynomial from an array.
  113696. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  113697. * @returns the spherical polynomial
  113698. */
  113699. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  113700. }
  113701. }
  113702. declare module BABYLON {
  113703. /**
  113704. * Defines the source of the internal texture
  113705. */
  113706. export enum InternalTextureSource {
  113707. /**
  113708. * The source of the texture data is unknown
  113709. */
  113710. Unknown = 0,
  113711. /**
  113712. * Texture data comes from an URL
  113713. */
  113714. Url = 1,
  113715. /**
  113716. * Texture data is only used for temporary storage
  113717. */
  113718. Temp = 2,
  113719. /**
  113720. * Texture data comes from raw data (ArrayBuffer)
  113721. */
  113722. Raw = 3,
  113723. /**
  113724. * Texture content is dynamic (video or dynamic texture)
  113725. */
  113726. Dynamic = 4,
  113727. /**
  113728. * Texture content is generated by rendering to it
  113729. */
  113730. RenderTarget = 5,
  113731. /**
  113732. * Texture content is part of a multi render target process
  113733. */
  113734. MultiRenderTarget = 6,
  113735. /**
  113736. * Texture data comes from a cube data file
  113737. */
  113738. Cube = 7,
  113739. /**
  113740. * Texture data comes from a raw cube data
  113741. */
  113742. CubeRaw = 8,
  113743. /**
  113744. * Texture data come from a prefiltered cube data file
  113745. */
  113746. CubePrefiltered = 9,
  113747. /**
  113748. * Texture content is raw 3D data
  113749. */
  113750. Raw3D = 10,
  113751. /**
  113752. * Texture content is raw 2D array data
  113753. */
  113754. Raw2DArray = 11,
  113755. /**
  113756. * Texture content is a depth texture
  113757. */
  113758. Depth = 12,
  113759. /**
  113760. * Texture data comes from a raw cube data encoded with RGBD
  113761. */
  113762. CubeRawRGBD = 13
  113763. }
  113764. /**
  113765. * Class used to store data associated with WebGL texture data for the engine
  113766. * This class should not be used directly
  113767. */
  113768. export class InternalTexture {
  113769. /** @hidden */
  113770. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  113771. /**
  113772. * Defines if the texture is ready
  113773. */
  113774. isReady: boolean;
  113775. /**
  113776. * Defines if the texture is a cube texture
  113777. */
  113778. isCube: boolean;
  113779. /**
  113780. * Defines if the texture contains 3D data
  113781. */
  113782. is3D: boolean;
  113783. /**
  113784. * Defines if the texture contains 2D array data
  113785. */
  113786. is2DArray: boolean;
  113787. /**
  113788. * Defines if the texture contains multiview data
  113789. */
  113790. isMultiview: boolean;
  113791. /**
  113792. * Gets the URL used to load this texture
  113793. */
  113794. url: string;
  113795. /**
  113796. * Gets the sampling mode of the texture
  113797. */
  113798. samplingMode: number;
  113799. /**
  113800. * Gets a boolean indicating if the texture needs mipmaps generation
  113801. */
  113802. generateMipMaps: boolean;
  113803. /**
  113804. * Gets the number of samples used by the texture (WebGL2+ only)
  113805. */
  113806. samples: number;
  113807. /**
  113808. * Gets the type of the texture (int, float...)
  113809. */
  113810. type: number;
  113811. /**
  113812. * Gets the format of the texture (RGB, RGBA...)
  113813. */
  113814. format: number;
  113815. /**
  113816. * Observable called when the texture is loaded
  113817. */
  113818. onLoadedObservable: Observable<InternalTexture>;
  113819. /**
  113820. * Gets the width of the texture
  113821. */
  113822. width: number;
  113823. /**
  113824. * Gets the height of the texture
  113825. */
  113826. height: number;
  113827. /**
  113828. * Gets the depth of the texture
  113829. */
  113830. depth: number;
  113831. /**
  113832. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  113833. */
  113834. baseWidth: number;
  113835. /**
  113836. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  113837. */
  113838. baseHeight: number;
  113839. /**
  113840. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  113841. */
  113842. baseDepth: number;
  113843. /**
  113844. * Gets a boolean indicating if the texture is inverted on Y axis
  113845. */
  113846. invertY: boolean;
  113847. /** @hidden */
  113848. _invertVScale: boolean;
  113849. /** @hidden */
  113850. _associatedChannel: number;
  113851. /** @hidden */
  113852. _source: InternalTextureSource;
  113853. /** @hidden */
  113854. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  113855. /** @hidden */
  113856. _bufferView: Nullable<ArrayBufferView>;
  113857. /** @hidden */
  113858. _bufferViewArray: Nullable<ArrayBufferView[]>;
  113859. /** @hidden */
  113860. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  113861. /** @hidden */
  113862. _size: number;
  113863. /** @hidden */
  113864. _extension: string;
  113865. /** @hidden */
  113866. _files: Nullable<string[]>;
  113867. /** @hidden */
  113868. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  113869. /** @hidden */
  113870. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  113871. /** @hidden */
  113872. _framebuffer: Nullable<WebGLFramebuffer>;
  113873. /** @hidden */
  113874. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  113875. /** @hidden */
  113876. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  113877. /** @hidden */
  113878. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  113879. /** @hidden */
  113880. _attachments: Nullable<number[]>;
  113881. /** @hidden */
  113882. _textureArray: Nullable<InternalTexture[]>;
  113883. /** @hidden */
  113884. _cachedCoordinatesMode: Nullable<number>;
  113885. /** @hidden */
  113886. _cachedWrapU: Nullable<number>;
  113887. /** @hidden */
  113888. _cachedWrapV: Nullable<number>;
  113889. /** @hidden */
  113890. _cachedWrapR: Nullable<number>;
  113891. /** @hidden */
  113892. _cachedAnisotropicFilteringLevel: Nullable<number>;
  113893. /** @hidden */
  113894. _isDisabled: boolean;
  113895. /** @hidden */
  113896. _compression: Nullable<string>;
  113897. /** @hidden */
  113898. _generateStencilBuffer: boolean;
  113899. /** @hidden */
  113900. _generateDepthBuffer: boolean;
  113901. /** @hidden */
  113902. _comparisonFunction: number;
  113903. /** @hidden */
  113904. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  113905. /** @hidden */
  113906. _lodGenerationScale: number;
  113907. /** @hidden */
  113908. _lodGenerationOffset: number;
  113909. /** @hidden */
  113910. _depthStencilTexture: Nullable<InternalTexture>;
  113911. /** @hidden */
  113912. _colorTextureArray: Nullable<WebGLTexture>;
  113913. /** @hidden */
  113914. _depthStencilTextureArray: Nullable<WebGLTexture>;
  113915. /** @hidden */
  113916. _lodTextureHigh: Nullable<BaseTexture>;
  113917. /** @hidden */
  113918. _lodTextureMid: Nullable<BaseTexture>;
  113919. /** @hidden */
  113920. _lodTextureLow: Nullable<BaseTexture>;
  113921. /** @hidden */
  113922. _isRGBD: boolean;
  113923. /** @hidden */
  113924. _linearSpecularLOD: boolean;
  113925. /** @hidden */
  113926. _irradianceTexture: Nullable<BaseTexture>;
  113927. /** @hidden */
  113928. _webGLTexture: Nullable<WebGLTexture>;
  113929. /** @hidden */
  113930. _references: number;
  113931. private _engine;
  113932. /**
  113933. * Gets the Engine the texture belongs to.
  113934. * @returns The babylon engine
  113935. */
  113936. getEngine(): ThinEngine;
  113937. /**
  113938. * Gets the data source type of the texture
  113939. */
  113940. get source(): InternalTextureSource;
  113941. /**
  113942. * Creates a new InternalTexture
  113943. * @param engine defines the engine to use
  113944. * @param source defines the type of data that will be used
  113945. * @param delayAllocation if the texture allocation should be delayed (default: false)
  113946. */
  113947. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  113948. /**
  113949. * Increments the number of references (ie. the number of Texture that point to it)
  113950. */
  113951. incrementReferences(): void;
  113952. /**
  113953. * Change the size of the texture (not the size of the content)
  113954. * @param width defines the new width
  113955. * @param height defines the new height
  113956. * @param depth defines the new depth (1 by default)
  113957. */
  113958. updateSize(width: int, height: int, depth?: int): void;
  113959. /** @hidden */
  113960. _rebuild(): void;
  113961. /** @hidden */
  113962. _swapAndDie(target: InternalTexture): void;
  113963. /**
  113964. * Dispose the current allocated resources
  113965. */
  113966. dispose(): void;
  113967. }
  113968. }
  113969. declare module BABYLON {
  113970. /**
  113971. * Class used to work with sound analyzer using fast fourier transform (FFT)
  113972. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  113973. */
  113974. export class Analyser {
  113975. /**
  113976. * Gets or sets the smoothing
  113977. * @ignorenaming
  113978. */
  113979. SMOOTHING: number;
  113980. /**
  113981. * Gets or sets the FFT table size
  113982. * @ignorenaming
  113983. */
  113984. FFT_SIZE: number;
  113985. /**
  113986. * Gets or sets the bar graph amplitude
  113987. * @ignorenaming
  113988. */
  113989. BARGRAPHAMPLITUDE: number;
  113990. /**
  113991. * Gets or sets the position of the debug canvas
  113992. * @ignorenaming
  113993. */
  113994. DEBUGCANVASPOS: {
  113995. x: number;
  113996. y: number;
  113997. };
  113998. /**
  113999. * Gets or sets the debug canvas size
  114000. * @ignorenaming
  114001. */
  114002. DEBUGCANVASSIZE: {
  114003. width: number;
  114004. height: number;
  114005. };
  114006. private _byteFreqs;
  114007. private _byteTime;
  114008. private _floatFreqs;
  114009. private _webAudioAnalyser;
  114010. private _debugCanvas;
  114011. private _debugCanvasContext;
  114012. private _scene;
  114013. private _registerFunc;
  114014. private _audioEngine;
  114015. /**
  114016. * Creates a new analyser
  114017. * @param scene defines hosting scene
  114018. */
  114019. constructor(scene: Scene);
  114020. /**
  114021. * Get the number of data values you will have to play with for the visualization
  114022. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  114023. * @returns a number
  114024. */
  114025. getFrequencyBinCount(): number;
  114026. /**
  114027. * Gets the current frequency data as a byte array
  114028. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  114029. * @returns a Uint8Array
  114030. */
  114031. getByteFrequencyData(): Uint8Array;
  114032. /**
  114033. * Gets the current waveform as a byte array
  114034. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  114035. * @returns a Uint8Array
  114036. */
  114037. getByteTimeDomainData(): Uint8Array;
  114038. /**
  114039. * Gets the current frequency data as a float array
  114040. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  114041. * @returns a Float32Array
  114042. */
  114043. getFloatFrequencyData(): Float32Array;
  114044. /**
  114045. * Renders the debug canvas
  114046. */
  114047. drawDebugCanvas(): void;
  114048. /**
  114049. * Stops rendering the debug canvas and removes it
  114050. */
  114051. stopDebugCanvas(): void;
  114052. /**
  114053. * Connects two audio nodes
  114054. * @param inputAudioNode defines first node to connect
  114055. * @param outputAudioNode defines second node to connect
  114056. */
  114057. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  114058. /**
  114059. * Releases all associated resources
  114060. */
  114061. dispose(): void;
  114062. }
  114063. }
  114064. declare module BABYLON {
  114065. /**
  114066. * This represents an audio engine and it is responsible
  114067. * to play, synchronize and analyse sounds throughout the application.
  114068. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114069. */
  114070. export interface IAudioEngine extends IDisposable {
  114071. /**
  114072. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  114073. */
  114074. readonly canUseWebAudio: boolean;
  114075. /**
  114076. * Gets the current AudioContext if available.
  114077. */
  114078. readonly audioContext: Nullable<AudioContext>;
  114079. /**
  114080. * The master gain node defines the global audio volume of your audio engine.
  114081. */
  114082. readonly masterGain: GainNode;
  114083. /**
  114084. * Gets whether or not mp3 are supported by your browser.
  114085. */
  114086. readonly isMP3supported: boolean;
  114087. /**
  114088. * Gets whether or not ogg are supported by your browser.
  114089. */
  114090. readonly isOGGsupported: boolean;
  114091. /**
  114092. * Defines if Babylon should emit a warning if WebAudio is not supported.
  114093. * @ignoreNaming
  114094. */
  114095. WarnedWebAudioUnsupported: boolean;
  114096. /**
  114097. * Defines if the audio engine relies on a custom unlocked button.
  114098. * In this case, the embedded button will not be displayed.
  114099. */
  114100. useCustomUnlockedButton: boolean;
  114101. /**
  114102. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  114103. */
  114104. readonly unlocked: boolean;
  114105. /**
  114106. * Event raised when audio has been unlocked on the browser.
  114107. */
  114108. onAudioUnlockedObservable: Observable<AudioEngine>;
  114109. /**
  114110. * Event raised when audio has been locked on the browser.
  114111. */
  114112. onAudioLockedObservable: Observable<AudioEngine>;
  114113. /**
  114114. * Flags the audio engine in Locked state.
  114115. * This happens due to new browser policies preventing audio to autoplay.
  114116. */
  114117. lock(): void;
  114118. /**
  114119. * Unlocks the audio engine once a user action has been done on the dom.
  114120. * This is helpful to resume play once browser policies have been satisfied.
  114121. */
  114122. unlock(): void;
  114123. /**
  114124. * Gets the global volume sets on the master gain.
  114125. * @returns the global volume if set or -1 otherwise
  114126. */
  114127. getGlobalVolume(): number;
  114128. /**
  114129. * Sets the global volume of your experience (sets on the master gain).
  114130. * @param newVolume Defines the new global volume of the application
  114131. */
  114132. setGlobalVolume(newVolume: number): void;
  114133. /**
  114134. * Connect the audio engine to an audio analyser allowing some amazing
  114135. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114136. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114137. * @param analyser The analyser to connect to the engine
  114138. */
  114139. connectToAnalyser(analyser: Analyser): void;
  114140. }
  114141. /**
  114142. * This represents the default audio engine used in babylon.
  114143. * It is responsible to play, synchronize and analyse sounds throughout the application.
  114144. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114145. */
  114146. export class AudioEngine implements IAudioEngine {
  114147. private _audioContext;
  114148. private _audioContextInitialized;
  114149. private _muteButton;
  114150. private _hostElement;
  114151. /**
  114152. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  114153. */
  114154. canUseWebAudio: boolean;
  114155. /**
  114156. * The master gain node defines the global audio volume of your audio engine.
  114157. */
  114158. masterGain: GainNode;
  114159. /**
  114160. * Defines if Babylon should emit a warning if WebAudio is not supported.
  114161. * @ignoreNaming
  114162. */
  114163. WarnedWebAudioUnsupported: boolean;
  114164. /**
  114165. * Gets whether or not mp3 are supported by your browser.
  114166. */
  114167. isMP3supported: boolean;
  114168. /**
  114169. * Gets whether or not ogg are supported by your browser.
  114170. */
  114171. isOGGsupported: boolean;
  114172. /**
  114173. * Gets whether audio has been unlocked on the device.
  114174. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  114175. * a user interaction has happened.
  114176. */
  114177. unlocked: boolean;
  114178. /**
  114179. * Defines if the audio engine relies on a custom unlocked button.
  114180. * In this case, the embedded button will not be displayed.
  114181. */
  114182. useCustomUnlockedButton: boolean;
  114183. /**
  114184. * Event raised when audio has been unlocked on the browser.
  114185. */
  114186. onAudioUnlockedObservable: Observable<AudioEngine>;
  114187. /**
  114188. * Event raised when audio has been locked on the browser.
  114189. */
  114190. onAudioLockedObservable: Observable<AudioEngine>;
  114191. /**
  114192. * Gets the current AudioContext if available.
  114193. */
  114194. get audioContext(): Nullable<AudioContext>;
  114195. private _connectedAnalyser;
  114196. /**
  114197. * Instantiates a new audio engine.
  114198. *
  114199. * There should be only one per page as some browsers restrict the number
  114200. * of audio contexts you can create.
  114201. * @param hostElement defines the host element where to display the mute icon if necessary
  114202. */
  114203. constructor(hostElement?: Nullable<HTMLElement>);
  114204. /**
  114205. * Flags the audio engine in Locked state.
  114206. * This happens due to new browser policies preventing audio to autoplay.
  114207. */
  114208. lock(): void;
  114209. /**
  114210. * Unlocks the audio engine once a user action has been done on the dom.
  114211. * This is helpful to resume play once browser policies have been satisfied.
  114212. */
  114213. unlock(): void;
  114214. private _resumeAudioContext;
  114215. private _initializeAudioContext;
  114216. private _tryToRun;
  114217. private _triggerRunningState;
  114218. private _triggerSuspendedState;
  114219. private _displayMuteButton;
  114220. private _moveButtonToTopLeft;
  114221. private _onResize;
  114222. private _hideMuteButton;
  114223. /**
  114224. * Destroy and release the resources associated with the audio ccontext.
  114225. */
  114226. dispose(): void;
  114227. /**
  114228. * Gets the global volume sets on the master gain.
  114229. * @returns the global volume if set or -1 otherwise
  114230. */
  114231. getGlobalVolume(): number;
  114232. /**
  114233. * Sets the global volume of your experience (sets on the master gain).
  114234. * @param newVolume Defines the new global volume of the application
  114235. */
  114236. setGlobalVolume(newVolume: number): void;
  114237. /**
  114238. * Connect the audio engine to an audio analyser allowing some amazing
  114239. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114240. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114241. * @param analyser The analyser to connect to the engine
  114242. */
  114243. connectToAnalyser(analyser: Analyser): void;
  114244. }
  114245. }
  114246. declare module BABYLON {
  114247. /**
  114248. * Interface used to present a loading screen while loading a scene
  114249. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114250. */
  114251. export interface ILoadingScreen {
  114252. /**
  114253. * Function called to display the loading screen
  114254. */
  114255. displayLoadingUI: () => void;
  114256. /**
  114257. * Function called to hide the loading screen
  114258. */
  114259. hideLoadingUI: () => void;
  114260. /**
  114261. * Gets or sets the color to use for the background
  114262. */
  114263. loadingUIBackgroundColor: string;
  114264. /**
  114265. * Gets or sets the text to display while loading
  114266. */
  114267. loadingUIText: string;
  114268. }
  114269. /**
  114270. * Class used for the default loading screen
  114271. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114272. */
  114273. export class DefaultLoadingScreen implements ILoadingScreen {
  114274. private _renderingCanvas;
  114275. private _loadingText;
  114276. private _loadingDivBackgroundColor;
  114277. private _loadingDiv;
  114278. private _loadingTextDiv;
  114279. /** Gets or sets the logo url to use for the default loading screen */
  114280. static DefaultLogoUrl: string;
  114281. /** Gets or sets the spinner url to use for the default loading screen */
  114282. static DefaultSpinnerUrl: string;
  114283. /**
  114284. * Creates a new default loading screen
  114285. * @param _renderingCanvas defines the canvas used to render the scene
  114286. * @param _loadingText defines the default text to display
  114287. * @param _loadingDivBackgroundColor defines the default background color
  114288. */
  114289. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  114290. /**
  114291. * Function called to display the loading screen
  114292. */
  114293. displayLoadingUI(): void;
  114294. /**
  114295. * Function called to hide the loading screen
  114296. */
  114297. hideLoadingUI(): void;
  114298. /**
  114299. * Gets or sets the text to display while loading
  114300. */
  114301. set loadingUIText(text: string);
  114302. get loadingUIText(): string;
  114303. /**
  114304. * Gets or sets the color to use for the background
  114305. */
  114306. get loadingUIBackgroundColor(): string;
  114307. set loadingUIBackgroundColor(color: string);
  114308. private _resizeLoadingUI;
  114309. }
  114310. }
  114311. declare module BABYLON {
  114312. /**
  114313. * Interface for any object that can request an animation frame
  114314. */
  114315. export interface ICustomAnimationFrameRequester {
  114316. /**
  114317. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  114318. */
  114319. renderFunction?: Function;
  114320. /**
  114321. * Called to request the next frame to render to
  114322. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  114323. */
  114324. requestAnimationFrame: Function;
  114325. /**
  114326. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  114327. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  114328. */
  114329. requestID?: number;
  114330. }
  114331. }
  114332. declare module BABYLON {
  114333. /**
  114334. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  114335. */
  114336. export class PerformanceMonitor {
  114337. private _enabled;
  114338. private _rollingFrameTime;
  114339. private _lastFrameTimeMs;
  114340. /**
  114341. * constructor
  114342. * @param frameSampleSize The number of samples required to saturate the sliding window
  114343. */
  114344. constructor(frameSampleSize?: number);
  114345. /**
  114346. * Samples current frame
  114347. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  114348. */
  114349. sampleFrame(timeMs?: number): void;
  114350. /**
  114351. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  114352. */
  114353. get averageFrameTime(): number;
  114354. /**
  114355. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  114356. */
  114357. get averageFrameTimeVariance(): number;
  114358. /**
  114359. * Returns the frame time of the most recent frame
  114360. */
  114361. get instantaneousFrameTime(): number;
  114362. /**
  114363. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  114364. */
  114365. get averageFPS(): number;
  114366. /**
  114367. * Returns the average framerate in frames per second using the most recent frame time
  114368. */
  114369. get instantaneousFPS(): number;
  114370. /**
  114371. * Returns true if enough samples have been taken to completely fill the sliding window
  114372. */
  114373. get isSaturated(): boolean;
  114374. /**
  114375. * Enables contributions to the sliding window sample set
  114376. */
  114377. enable(): void;
  114378. /**
  114379. * Disables contributions to the sliding window sample set
  114380. * Samples will not be interpolated over the disabled period
  114381. */
  114382. disable(): void;
  114383. /**
  114384. * Returns true if sampling is enabled
  114385. */
  114386. get isEnabled(): boolean;
  114387. /**
  114388. * Resets performance monitor
  114389. */
  114390. reset(): void;
  114391. }
  114392. /**
  114393. * RollingAverage
  114394. *
  114395. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  114396. */
  114397. export class RollingAverage {
  114398. /**
  114399. * Current average
  114400. */
  114401. average: number;
  114402. /**
  114403. * Current variance
  114404. */
  114405. variance: number;
  114406. protected _samples: Array<number>;
  114407. protected _sampleCount: number;
  114408. protected _pos: number;
  114409. protected _m2: number;
  114410. /**
  114411. * constructor
  114412. * @param length The number of samples required to saturate the sliding window
  114413. */
  114414. constructor(length: number);
  114415. /**
  114416. * Adds a sample to the sample set
  114417. * @param v The sample value
  114418. */
  114419. add(v: number): void;
  114420. /**
  114421. * Returns previously added values or null if outside of history or outside the sliding window domain
  114422. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  114423. * @return Value previously recorded with add() or null if outside of range
  114424. */
  114425. history(i: number): number;
  114426. /**
  114427. * Returns true if enough samples have been taken to completely fill the sliding window
  114428. * @return true if sample-set saturated
  114429. */
  114430. isSaturated(): boolean;
  114431. /**
  114432. * Resets the rolling average (equivalent to 0 samples taken so far)
  114433. */
  114434. reset(): void;
  114435. /**
  114436. * Wraps a value around the sample range boundaries
  114437. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  114438. * @return Wrapped position in sample range
  114439. */
  114440. protected _wrapPosition(i: number): number;
  114441. }
  114442. }
  114443. declare module BABYLON {
  114444. /**
  114445. * This class is used to track a performance counter which is number based.
  114446. * The user has access to many properties which give statistics of different nature.
  114447. *
  114448. * The implementer can track two kinds of Performance Counter: time and count.
  114449. * 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.
  114450. * 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.
  114451. */
  114452. export class PerfCounter {
  114453. /**
  114454. * Gets or sets a global boolean to turn on and off all the counters
  114455. */
  114456. static Enabled: boolean;
  114457. /**
  114458. * Returns the smallest value ever
  114459. */
  114460. get min(): number;
  114461. /**
  114462. * Returns the biggest value ever
  114463. */
  114464. get max(): number;
  114465. /**
  114466. * Returns the average value since the performance counter is running
  114467. */
  114468. get average(): number;
  114469. /**
  114470. * Returns the average value of the last second the counter was monitored
  114471. */
  114472. get lastSecAverage(): number;
  114473. /**
  114474. * Returns the current value
  114475. */
  114476. get current(): number;
  114477. /**
  114478. * Gets the accumulated total
  114479. */
  114480. get total(): number;
  114481. /**
  114482. * Gets the total value count
  114483. */
  114484. get count(): number;
  114485. /**
  114486. * Creates a new counter
  114487. */
  114488. constructor();
  114489. /**
  114490. * Call this method to start monitoring a new frame.
  114491. * 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.
  114492. */
  114493. fetchNewFrame(): void;
  114494. /**
  114495. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  114496. * @param newCount the count value to add to the monitored count
  114497. * @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.
  114498. */
  114499. addCount(newCount: number, fetchResult: boolean): void;
  114500. /**
  114501. * Start monitoring this performance counter
  114502. */
  114503. beginMonitoring(): void;
  114504. /**
  114505. * Compute the time lapsed since the previous beginMonitoring() call.
  114506. * @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
  114507. */
  114508. endMonitoring(newFrame?: boolean): void;
  114509. private _fetchResult;
  114510. private _startMonitoringTime;
  114511. private _min;
  114512. private _max;
  114513. private _average;
  114514. private _current;
  114515. private _totalValueCount;
  114516. private _totalAccumulated;
  114517. private _lastSecAverage;
  114518. private _lastSecAccumulated;
  114519. private _lastSecTime;
  114520. private _lastSecValueCount;
  114521. }
  114522. }
  114523. declare module BABYLON {
  114524. interface ThinEngine {
  114525. /**
  114526. * Sets alpha constants used by some alpha blending modes
  114527. * @param r defines the red component
  114528. * @param g defines the green component
  114529. * @param b defines the blue component
  114530. * @param a defines the alpha component
  114531. */
  114532. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114533. /**
  114534. * Sets the current alpha mode
  114535. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  114536. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114537. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114538. */
  114539. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114540. /**
  114541. * Gets the current alpha mode
  114542. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114543. * @returns the current alpha mode
  114544. */
  114545. getAlphaMode(): number;
  114546. /**
  114547. * Sets the current alpha equation
  114548. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  114549. */
  114550. setAlphaEquation(equation: number): void;
  114551. /**
  114552. * Gets the current alpha equation.
  114553. * @returns the current alpha equation
  114554. */
  114555. getAlphaEquation(): number;
  114556. }
  114557. }
  114558. declare module BABYLON {
  114559. interface ThinEngine {
  114560. /** @hidden */
  114561. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  114562. }
  114563. }
  114564. declare module BABYLON {
  114565. /**
  114566. * Defines the interface used by display changed events
  114567. */
  114568. export interface IDisplayChangedEventArgs {
  114569. /** Gets the vrDisplay object (if any) */
  114570. vrDisplay: Nullable<any>;
  114571. /** Gets a boolean indicating if webVR is supported */
  114572. vrSupported: boolean;
  114573. }
  114574. /**
  114575. * Defines the interface used by objects containing a viewport (like a camera)
  114576. */
  114577. interface IViewportOwnerLike {
  114578. /**
  114579. * Gets or sets the viewport
  114580. */
  114581. viewport: IViewportLike;
  114582. }
  114583. /**
  114584. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  114585. */
  114586. export class Engine extends ThinEngine {
  114587. /** Defines that alpha blending is disabled */
  114588. static readonly ALPHA_DISABLE: number;
  114589. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  114590. static readonly ALPHA_ADD: number;
  114591. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  114592. static readonly ALPHA_COMBINE: number;
  114593. /** Defines that alpha blending to DEST - SRC * DEST */
  114594. static readonly ALPHA_SUBTRACT: number;
  114595. /** Defines that alpha blending to SRC * DEST */
  114596. static readonly ALPHA_MULTIPLY: number;
  114597. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  114598. static readonly ALPHA_MAXIMIZED: number;
  114599. /** Defines that alpha blending to SRC + DEST */
  114600. static readonly ALPHA_ONEONE: number;
  114601. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  114602. static readonly ALPHA_PREMULTIPLIED: number;
  114603. /**
  114604. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  114605. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  114606. */
  114607. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  114608. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  114609. static readonly ALPHA_INTERPOLATE: number;
  114610. /**
  114611. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  114612. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  114613. */
  114614. static readonly ALPHA_SCREENMODE: number;
  114615. /** Defines that the ressource is not delayed*/
  114616. static readonly DELAYLOADSTATE_NONE: number;
  114617. /** Defines that the ressource was successfully delay loaded */
  114618. static readonly DELAYLOADSTATE_LOADED: number;
  114619. /** Defines that the ressource is currently delay loading */
  114620. static readonly DELAYLOADSTATE_LOADING: number;
  114621. /** Defines that the ressource is delayed and has not started loading */
  114622. static readonly DELAYLOADSTATE_NOTLOADED: number;
  114623. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  114624. static readonly NEVER: number;
  114625. /** 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 */
  114626. static readonly ALWAYS: number;
  114627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  114628. static readonly LESS: number;
  114629. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  114630. static readonly EQUAL: number;
  114631. /** 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 */
  114632. static readonly LEQUAL: number;
  114633. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  114634. static readonly GREATER: number;
  114635. /** 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 */
  114636. static readonly GEQUAL: number;
  114637. /** 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 */
  114638. static readonly NOTEQUAL: number;
  114639. /** Passed to stencilOperation to specify that stencil value must be kept */
  114640. static readonly KEEP: number;
  114641. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114642. static readonly REPLACE: number;
  114643. /** Passed to stencilOperation to specify that stencil value must be incremented */
  114644. static readonly INCR: number;
  114645. /** Passed to stencilOperation to specify that stencil value must be decremented */
  114646. static readonly DECR: number;
  114647. /** Passed to stencilOperation to specify that stencil value must be inverted */
  114648. static readonly INVERT: number;
  114649. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  114650. static readonly INCR_WRAP: number;
  114651. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  114652. static readonly DECR_WRAP: number;
  114653. /** Texture is not repeating outside of 0..1 UVs */
  114654. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  114655. /** Texture is repeating outside of 0..1 UVs */
  114656. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  114657. /** Texture is repeating and mirrored */
  114658. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  114659. /** ALPHA */
  114660. static readonly TEXTUREFORMAT_ALPHA: number;
  114661. /** LUMINANCE */
  114662. static readonly TEXTUREFORMAT_LUMINANCE: number;
  114663. /** LUMINANCE_ALPHA */
  114664. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  114665. /** RGB */
  114666. static readonly TEXTUREFORMAT_RGB: number;
  114667. /** RGBA */
  114668. static readonly TEXTUREFORMAT_RGBA: number;
  114669. /** RED */
  114670. static readonly TEXTUREFORMAT_RED: number;
  114671. /** RED (2nd reference) */
  114672. static readonly TEXTUREFORMAT_R: number;
  114673. /** RG */
  114674. static readonly TEXTUREFORMAT_RG: number;
  114675. /** RED_INTEGER */
  114676. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  114677. /** RED_INTEGER (2nd reference) */
  114678. static readonly TEXTUREFORMAT_R_INTEGER: number;
  114679. /** RG_INTEGER */
  114680. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  114681. /** RGB_INTEGER */
  114682. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  114683. /** RGBA_INTEGER */
  114684. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  114685. /** UNSIGNED_BYTE */
  114686. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  114687. /** UNSIGNED_BYTE (2nd reference) */
  114688. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  114689. /** FLOAT */
  114690. static readonly TEXTURETYPE_FLOAT: number;
  114691. /** HALF_FLOAT */
  114692. static readonly TEXTURETYPE_HALF_FLOAT: number;
  114693. /** BYTE */
  114694. static readonly TEXTURETYPE_BYTE: number;
  114695. /** SHORT */
  114696. static readonly TEXTURETYPE_SHORT: number;
  114697. /** UNSIGNED_SHORT */
  114698. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  114699. /** INT */
  114700. static readonly TEXTURETYPE_INT: number;
  114701. /** UNSIGNED_INT */
  114702. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  114703. /** UNSIGNED_SHORT_4_4_4_4 */
  114704. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  114705. /** UNSIGNED_SHORT_5_5_5_1 */
  114706. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  114707. /** UNSIGNED_SHORT_5_6_5 */
  114708. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  114709. /** UNSIGNED_INT_2_10_10_10_REV */
  114710. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  114711. /** UNSIGNED_INT_24_8 */
  114712. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  114713. /** UNSIGNED_INT_10F_11F_11F_REV */
  114714. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  114715. /** UNSIGNED_INT_5_9_9_9_REV */
  114716. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  114717. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  114718. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114719. /** nearest is mag = nearest and min = nearest and mip = linear */
  114720. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  114721. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114722. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  114723. /** Trilinear is mag = linear and min = linear and mip = linear */
  114724. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  114725. /** nearest is mag = nearest and min = nearest and mip = linear */
  114726. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  114727. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114728. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  114729. /** Trilinear is mag = linear and min = linear and mip = linear */
  114730. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  114731. /** mag = nearest and min = nearest and mip = nearest */
  114732. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  114733. /** mag = nearest and min = linear and mip = nearest */
  114734. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  114735. /** mag = nearest and min = linear and mip = linear */
  114736. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  114737. /** mag = nearest and min = linear and mip = none */
  114738. static readonly TEXTURE_NEAREST_LINEAR: number;
  114739. /** mag = nearest and min = nearest and mip = none */
  114740. static readonly TEXTURE_NEAREST_NEAREST: number;
  114741. /** mag = linear and min = nearest and mip = nearest */
  114742. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  114743. /** mag = linear and min = nearest and mip = linear */
  114744. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  114745. /** mag = linear and min = linear and mip = none */
  114746. static readonly TEXTURE_LINEAR_LINEAR: number;
  114747. /** mag = linear and min = nearest and mip = none */
  114748. static readonly TEXTURE_LINEAR_NEAREST: number;
  114749. /** Explicit coordinates mode */
  114750. static readonly TEXTURE_EXPLICIT_MODE: number;
  114751. /** Spherical coordinates mode */
  114752. static readonly TEXTURE_SPHERICAL_MODE: number;
  114753. /** Planar coordinates mode */
  114754. static readonly TEXTURE_PLANAR_MODE: number;
  114755. /** Cubic coordinates mode */
  114756. static readonly TEXTURE_CUBIC_MODE: number;
  114757. /** Projection coordinates mode */
  114758. static readonly TEXTURE_PROJECTION_MODE: number;
  114759. /** Skybox coordinates mode */
  114760. static readonly TEXTURE_SKYBOX_MODE: number;
  114761. /** Inverse Cubic coordinates mode */
  114762. static readonly TEXTURE_INVCUBIC_MODE: number;
  114763. /** Equirectangular coordinates mode */
  114764. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  114765. /** Equirectangular Fixed coordinates mode */
  114766. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  114767. /** Equirectangular Fixed Mirrored coordinates mode */
  114768. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  114769. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  114770. static readonly SCALEMODE_FLOOR: number;
  114771. /** Defines that texture rescaling will look for the nearest power of 2 size */
  114772. static readonly SCALEMODE_NEAREST: number;
  114773. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  114774. static readonly SCALEMODE_CEILING: number;
  114775. /**
  114776. * Returns the current npm package of the sdk
  114777. */
  114778. static get NpmPackage(): string;
  114779. /**
  114780. * Returns the current version of the framework
  114781. */
  114782. static get Version(): string;
  114783. /** Gets the list of created engines */
  114784. static get Instances(): Engine[];
  114785. /**
  114786. * Gets the latest created engine
  114787. */
  114788. static get LastCreatedEngine(): Nullable<Engine>;
  114789. /**
  114790. * Gets the latest created scene
  114791. */
  114792. static get LastCreatedScene(): Nullable<Scene>;
  114793. /**
  114794. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  114795. * @param flag defines which part of the materials must be marked as dirty
  114796. * @param predicate defines a predicate used to filter which materials should be affected
  114797. */
  114798. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  114799. /**
  114800. * Method called to create the default loading screen.
  114801. * This can be overriden in your own app.
  114802. * @param canvas The rendering canvas element
  114803. * @returns The loading screen
  114804. */
  114805. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  114806. /**
  114807. * Method called to create the default rescale post process on each engine.
  114808. */
  114809. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  114810. /**
  114811. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  114812. **/
  114813. enableOfflineSupport: boolean;
  114814. /**
  114815. * 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)
  114816. **/
  114817. disableManifestCheck: boolean;
  114818. /**
  114819. * Gets the list of created scenes
  114820. */
  114821. scenes: Scene[];
  114822. /**
  114823. * Event raised when a new scene is created
  114824. */
  114825. onNewSceneAddedObservable: Observable<Scene>;
  114826. /**
  114827. * Gets the list of created postprocesses
  114828. */
  114829. postProcesses: PostProcess[];
  114830. /**
  114831. * Gets a boolean indicating if the pointer is currently locked
  114832. */
  114833. isPointerLock: boolean;
  114834. /**
  114835. * Observable event triggered each time the rendering canvas is resized
  114836. */
  114837. onResizeObservable: Observable<Engine>;
  114838. /**
  114839. * Observable event triggered each time the canvas loses focus
  114840. */
  114841. onCanvasBlurObservable: Observable<Engine>;
  114842. /**
  114843. * Observable event triggered each time the canvas gains focus
  114844. */
  114845. onCanvasFocusObservable: Observable<Engine>;
  114846. /**
  114847. * Observable event triggered each time the canvas receives pointerout event
  114848. */
  114849. onCanvasPointerOutObservable: Observable<PointerEvent>;
  114850. /**
  114851. * Observable raised when the engine begins a new frame
  114852. */
  114853. onBeginFrameObservable: Observable<Engine>;
  114854. /**
  114855. * If set, will be used to request the next animation frame for the render loop
  114856. */
  114857. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  114858. /**
  114859. * Observable raised when the engine ends the current frame
  114860. */
  114861. onEndFrameObservable: Observable<Engine>;
  114862. /**
  114863. * Observable raised when the engine is about to compile a shader
  114864. */
  114865. onBeforeShaderCompilationObservable: Observable<Engine>;
  114866. /**
  114867. * Observable raised when the engine has jsut compiled a shader
  114868. */
  114869. onAfterShaderCompilationObservable: Observable<Engine>;
  114870. /**
  114871. * Gets the audio engine
  114872. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114873. * @ignorenaming
  114874. */
  114875. static audioEngine: IAudioEngine;
  114876. /**
  114877. * Default AudioEngine factory responsible of creating the Audio Engine.
  114878. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  114879. */
  114880. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  114881. /**
  114882. * Default offline support factory responsible of creating a tool used to store data locally.
  114883. * By default, this will create a Database object if the workload has been embedded.
  114884. */
  114885. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  114886. private _loadingScreen;
  114887. private _pointerLockRequested;
  114888. private _rescalePostProcess;
  114889. private _deterministicLockstep;
  114890. private _lockstepMaxSteps;
  114891. private _timeStep;
  114892. protected get _supportsHardwareTextureRescaling(): boolean;
  114893. private _fps;
  114894. private _deltaTime;
  114895. /** @hidden */
  114896. _drawCalls: PerfCounter;
  114897. /** 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 */
  114898. canvasTabIndex: number;
  114899. /**
  114900. * Turn this value on if you want to pause FPS computation when in background
  114901. */
  114902. disablePerformanceMonitorInBackground: boolean;
  114903. private _performanceMonitor;
  114904. /**
  114905. * Gets the performance monitor attached to this engine
  114906. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114907. */
  114908. get performanceMonitor(): PerformanceMonitor;
  114909. private _onFocus;
  114910. private _onBlur;
  114911. private _onCanvasPointerOut;
  114912. private _onCanvasBlur;
  114913. private _onCanvasFocus;
  114914. private _onFullscreenChange;
  114915. private _onPointerLockChange;
  114916. /**
  114917. * Gets the HTML element used to attach event listeners
  114918. * @returns a HTML element
  114919. */
  114920. getInputElement(): Nullable<HTMLElement>;
  114921. /**
  114922. * Creates a new engine
  114923. * @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
  114924. * @param antialias defines enable antialiasing (default: false)
  114925. * @param options defines further options to be sent to the getContext() function
  114926. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114927. */
  114928. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114929. /**
  114930. * Gets current aspect ratio
  114931. * @param viewportOwner defines the camera to use to get the aspect ratio
  114932. * @param useScreen defines if screen size must be used (or the current render target if any)
  114933. * @returns a number defining the aspect ratio
  114934. */
  114935. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  114936. /**
  114937. * Gets current screen aspect ratio
  114938. * @returns a number defining the aspect ratio
  114939. */
  114940. getScreenAspectRatio(): number;
  114941. /**
  114942. * Gets the client rect of the HTML canvas attached with the current webGL context
  114943. * @returns a client rectanglee
  114944. */
  114945. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  114946. /**
  114947. * Gets the client rect of the HTML element used for events
  114948. * @returns a client rectanglee
  114949. */
  114950. getInputElementClientRect(): Nullable<ClientRect>;
  114951. /**
  114952. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  114953. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114954. * @returns true if engine is in deterministic lock step mode
  114955. */
  114956. isDeterministicLockStep(): boolean;
  114957. /**
  114958. * Gets the max steps when engine is running in deterministic lock step
  114959. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114960. * @returns the max steps
  114961. */
  114962. getLockstepMaxSteps(): number;
  114963. /**
  114964. * Returns the time in ms between steps when using deterministic lock step.
  114965. * @returns time step in (ms)
  114966. */
  114967. getTimeStep(): number;
  114968. /**
  114969. * Force the mipmap generation for the given render target texture
  114970. * @param texture defines the render target texture to use
  114971. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  114972. */
  114973. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  114974. /** States */
  114975. /**
  114976. * Set various states to the webGL context
  114977. * @param culling defines backface culling state
  114978. * @param zOffset defines the value to apply to zOffset (0 by default)
  114979. * @param force defines if states must be applied even if cache is up to date
  114980. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  114981. */
  114982. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114983. /**
  114984. * Set the z offset to apply to current rendering
  114985. * @param value defines the offset to apply
  114986. */
  114987. setZOffset(value: number): void;
  114988. /**
  114989. * Gets the current value of the zOffset
  114990. * @returns the current zOffset state
  114991. */
  114992. getZOffset(): number;
  114993. /**
  114994. * Enable or disable depth buffering
  114995. * @param enable defines the state to set
  114996. */
  114997. setDepthBuffer(enable: boolean): void;
  114998. /**
  114999. * Gets a boolean indicating if depth writing is enabled
  115000. * @returns the current depth writing state
  115001. */
  115002. getDepthWrite(): boolean;
  115003. /**
  115004. * Enable or disable depth writing
  115005. * @param enable defines the state to set
  115006. */
  115007. setDepthWrite(enable: boolean): void;
  115008. /**
  115009. * Gets a boolean indicating if stencil buffer is enabled
  115010. * @returns the current stencil buffer state
  115011. */
  115012. getStencilBuffer(): boolean;
  115013. /**
  115014. * Enable or disable the stencil buffer
  115015. * @param enable defines if the stencil buffer must be enabled or disabled
  115016. */
  115017. setStencilBuffer(enable: boolean): void;
  115018. /**
  115019. * Gets the current stencil mask
  115020. * @returns a number defining the new stencil mask to use
  115021. */
  115022. getStencilMask(): number;
  115023. /**
  115024. * Sets the current stencil mask
  115025. * @param mask defines the new stencil mask to use
  115026. */
  115027. setStencilMask(mask: number): void;
  115028. /**
  115029. * Gets the current stencil function
  115030. * @returns a number defining the stencil function to use
  115031. */
  115032. getStencilFunction(): number;
  115033. /**
  115034. * Gets the current stencil reference value
  115035. * @returns a number defining the stencil reference value to use
  115036. */
  115037. getStencilFunctionReference(): number;
  115038. /**
  115039. * Gets the current stencil mask
  115040. * @returns a number defining the stencil mask to use
  115041. */
  115042. getStencilFunctionMask(): number;
  115043. /**
  115044. * Sets the current stencil function
  115045. * @param stencilFunc defines the new stencil function to use
  115046. */
  115047. setStencilFunction(stencilFunc: number): void;
  115048. /**
  115049. * Sets the current stencil reference
  115050. * @param reference defines the new stencil reference to use
  115051. */
  115052. setStencilFunctionReference(reference: number): void;
  115053. /**
  115054. * Sets the current stencil mask
  115055. * @param mask defines the new stencil mask to use
  115056. */
  115057. setStencilFunctionMask(mask: number): void;
  115058. /**
  115059. * Gets the current stencil operation when stencil fails
  115060. * @returns a number defining stencil operation to use when stencil fails
  115061. */
  115062. getStencilOperationFail(): number;
  115063. /**
  115064. * Gets the current stencil operation when depth fails
  115065. * @returns a number defining stencil operation to use when depth fails
  115066. */
  115067. getStencilOperationDepthFail(): number;
  115068. /**
  115069. * Gets the current stencil operation when stencil passes
  115070. * @returns a number defining stencil operation to use when stencil passes
  115071. */
  115072. getStencilOperationPass(): number;
  115073. /**
  115074. * Sets the stencil operation to use when stencil fails
  115075. * @param operation defines the stencil operation to use when stencil fails
  115076. */
  115077. setStencilOperationFail(operation: number): void;
  115078. /**
  115079. * Sets the stencil operation to use when depth fails
  115080. * @param operation defines the stencil operation to use when depth fails
  115081. */
  115082. setStencilOperationDepthFail(operation: number): void;
  115083. /**
  115084. * Sets the stencil operation to use when stencil passes
  115085. * @param operation defines the stencil operation to use when stencil passes
  115086. */
  115087. setStencilOperationPass(operation: number): void;
  115088. /**
  115089. * Sets a boolean indicating if the dithering state is enabled or disabled
  115090. * @param value defines the dithering state
  115091. */
  115092. setDitheringState(value: boolean): void;
  115093. /**
  115094. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  115095. * @param value defines the rasterizer state
  115096. */
  115097. setRasterizerState(value: boolean): void;
  115098. /**
  115099. * Gets the current depth function
  115100. * @returns a number defining the depth function
  115101. */
  115102. getDepthFunction(): Nullable<number>;
  115103. /**
  115104. * Sets the current depth function
  115105. * @param depthFunc defines the function to use
  115106. */
  115107. setDepthFunction(depthFunc: number): void;
  115108. /**
  115109. * Sets the current depth function to GREATER
  115110. */
  115111. setDepthFunctionToGreater(): void;
  115112. /**
  115113. * Sets the current depth function to GEQUAL
  115114. */
  115115. setDepthFunctionToGreaterOrEqual(): void;
  115116. /**
  115117. * Sets the current depth function to LESS
  115118. */
  115119. setDepthFunctionToLess(): void;
  115120. /**
  115121. * Sets the current depth function to LEQUAL
  115122. */
  115123. setDepthFunctionToLessOrEqual(): void;
  115124. private _cachedStencilBuffer;
  115125. private _cachedStencilFunction;
  115126. private _cachedStencilMask;
  115127. private _cachedStencilOperationPass;
  115128. private _cachedStencilOperationFail;
  115129. private _cachedStencilOperationDepthFail;
  115130. private _cachedStencilReference;
  115131. /**
  115132. * Caches the the state of the stencil buffer
  115133. */
  115134. cacheStencilState(): void;
  115135. /**
  115136. * Restores the state of the stencil buffer
  115137. */
  115138. restoreStencilState(): void;
  115139. /**
  115140. * Directly set the WebGL Viewport
  115141. * @param x defines the x coordinate of the viewport (in screen space)
  115142. * @param y defines the y coordinate of the viewport (in screen space)
  115143. * @param width defines the width of the viewport (in screen space)
  115144. * @param height defines the height of the viewport (in screen space)
  115145. * @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
  115146. */
  115147. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  115148. /**
  115149. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  115150. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  115151. * @param y defines the y-coordinate of the corner of the clear rectangle
  115152. * @param width defines the width of the clear rectangle
  115153. * @param height defines the height of the clear rectangle
  115154. * @param clearColor defines the clear color
  115155. */
  115156. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  115157. /**
  115158. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  115159. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  115160. * @param y defines the y-coordinate of the corner of the clear rectangle
  115161. * @param width defines the width of the clear rectangle
  115162. * @param height defines the height of the clear rectangle
  115163. */
  115164. enableScissor(x: number, y: number, width: number, height: number): void;
  115165. /**
  115166. * Disable previously set scissor test rectangle
  115167. */
  115168. disableScissor(): void;
  115169. protected _reportDrawCall(): void;
  115170. /**
  115171. * Initializes a webVR display and starts listening to display change events
  115172. * The onVRDisplayChangedObservable will be notified upon these changes
  115173. * @returns The onVRDisplayChangedObservable
  115174. */
  115175. initWebVR(): Observable<IDisplayChangedEventArgs>;
  115176. /** @hidden */
  115177. _prepareVRComponent(): void;
  115178. /** @hidden */
  115179. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  115180. /** @hidden */
  115181. _submitVRFrame(): void;
  115182. /**
  115183. * Call this function to leave webVR mode
  115184. * Will do nothing if webVR is not supported or if there is no webVR device
  115185. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115186. */
  115187. disableVR(): void;
  115188. /**
  115189. * Gets a boolean indicating that the system is in VR mode and is presenting
  115190. * @returns true if VR mode is engaged
  115191. */
  115192. isVRPresenting(): boolean;
  115193. /** @hidden */
  115194. _requestVRFrame(): void;
  115195. /** @hidden */
  115196. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  115197. /**
  115198. * Gets the source code of the vertex shader associated with a specific webGL program
  115199. * @param program defines the program to use
  115200. * @returns a string containing the source code of the vertex shader associated with the program
  115201. */
  115202. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  115203. /**
  115204. * Gets the source code of the fragment shader associated with a specific webGL program
  115205. * @param program defines the program to use
  115206. * @returns a string containing the source code of the fragment shader associated with the program
  115207. */
  115208. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  115209. /**
  115210. * Sets a depth stencil texture from a render target to the according uniform.
  115211. * @param channel The texture channel
  115212. * @param uniform The uniform to set
  115213. * @param texture The render target texture containing the depth stencil texture to apply
  115214. */
  115215. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  115216. /**
  115217. * Sets a texture to the webGL context from a postprocess
  115218. * @param channel defines the channel to use
  115219. * @param postProcess defines the source postprocess
  115220. */
  115221. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  115222. /**
  115223. * Binds the output of the passed in post process to the texture channel specified
  115224. * @param channel The channel the texture should be bound to
  115225. * @param postProcess The post process which's output should be bound
  115226. */
  115227. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  115228. protected _rebuildBuffers(): void;
  115229. /** @hidden */
  115230. _renderFrame(): void;
  115231. _renderLoop(): void;
  115232. /** @hidden */
  115233. _renderViews(): boolean;
  115234. /**
  115235. * Toggle full screen mode
  115236. * @param requestPointerLock defines if a pointer lock should be requested from the user
  115237. */
  115238. switchFullscreen(requestPointerLock: boolean): void;
  115239. /**
  115240. * Enters full screen mode
  115241. * @param requestPointerLock defines if a pointer lock should be requested from the user
  115242. */
  115243. enterFullscreen(requestPointerLock: boolean): void;
  115244. /**
  115245. * Exits full screen mode
  115246. */
  115247. exitFullscreen(): void;
  115248. /**
  115249. * Enters Pointerlock mode
  115250. */
  115251. enterPointerlock(): void;
  115252. /**
  115253. * Exits Pointerlock mode
  115254. */
  115255. exitPointerlock(): void;
  115256. /**
  115257. * Begin a new frame
  115258. */
  115259. beginFrame(): void;
  115260. /**
  115261. * Enf the current frame
  115262. */
  115263. endFrame(): void;
  115264. resize(): void;
  115265. /**
  115266. * Force a specific size of the canvas
  115267. * @param width defines the new canvas' width
  115268. * @param height defines the new canvas' height
  115269. * @returns true if the size was changed
  115270. */
  115271. setSize(width: number, height: number): boolean;
  115272. /**
  115273. * Updates a dynamic vertex buffer.
  115274. * @param vertexBuffer the vertex buffer to update
  115275. * @param data the data used to update the vertex buffer
  115276. * @param byteOffset the byte offset of the data
  115277. * @param byteLength the byte length of the data
  115278. */
  115279. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  115280. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115281. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115282. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115283. _releaseTexture(texture: InternalTexture): void;
  115284. /**
  115285. * @hidden
  115286. * Rescales a texture
  115287. * @param source input texutre
  115288. * @param destination destination texture
  115289. * @param scene scene to use to render the resize
  115290. * @param internalFormat format to use when resizing
  115291. * @param onComplete callback to be called when resize has completed
  115292. */
  115293. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  115294. /**
  115295. * Gets the current framerate
  115296. * @returns a number representing the framerate
  115297. */
  115298. getFps(): number;
  115299. /**
  115300. * Gets the time spent between current and previous frame
  115301. * @returns a number representing the delta time in ms
  115302. */
  115303. getDeltaTime(): number;
  115304. private _measureFps;
  115305. /** @hidden */
  115306. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  115307. /**
  115308. * Update a dynamic index buffer
  115309. * @param indexBuffer defines the target index buffer
  115310. * @param indices defines the data to update
  115311. * @param offset defines the offset in the target index buffer where update should start
  115312. */
  115313. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  115314. /**
  115315. * Updates the sample count of a render target texture
  115316. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  115317. * @param texture defines the texture to update
  115318. * @param samples defines the sample count to set
  115319. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  115320. */
  115321. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  115322. /**
  115323. * Updates a depth texture Comparison Mode and Function.
  115324. * If the comparison Function is equal to 0, the mode will be set to none.
  115325. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  115326. * @param texture The texture to set the comparison function for
  115327. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  115328. */
  115329. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  115330. /**
  115331. * Creates a webGL buffer to use with instanciation
  115332. * @param capacity defines the size of the buffer
  115333. * @returns the webGL buffer
  115334. */
  115335. createInstancesBuffer(capacity: number): DataBuffer;
  115336. /**
  115337. * Delete a webGL buffer used with instanciation
  115338. * @param buffer defines the webGL buffer to delete
  115339. */
  115340. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  115341. private _clientWaitAsync;
  115342. /** @hidden */
  115343. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  115344. dispose(): void;
  115345. private _disableTouchAction;
  115346. /**
  115347. * Display the loading screen
  115348. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115349. */
  115350. displayLoadingUI(): void;
  115351. /**
  115352. * Hide the loading screen
  115353. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115354. */
  115355. hideLoadingUI(): void;
  115356. /**
  115357. * Gets the current loading screen object
  115358. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115359. */
  115360. get loadingScreen(): ILoadingScreen;
  115361. /**
  115362. * Sets the current loading screen object
  115363. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115364. */
  115365. set loadingScreen(loadingScreen: ILoadingScreen);
  115366. /**
  115367. * Sets the current loading screen text
  115368. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115369. */
  115370. set loadingUIText(text: string);
  115371. /**
  115372. * Sets the current loading screen background color
  115373. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115374. */
  115375. set loadingUIBackgroundColor(color: string);
  115376. /** Pointerlock and fullscreen */
  115377. /**
  115378. * Ask the browser to promote the current element to pointerlock mode
  115379. * @param element defines the DOM element to promote
  115380. */
  115381. static _RequestPointerlock(element: HTMLElement): void;
  115382. /**
  115383. * Asks the browser to exit pointerlock mode
  115384. */
  115385. static _ExitPointerlock(): void;
  115386. /**
  115387. * Ask the browser to promote the current element to fullscreen rendering mode
  115388. * @param element defines the DOM element to promote
  115389. */
  115390. static _RequestFullscreen(element: HTMLElement): void;
  115391. /**
  115392. * Asks the browser to exit fullscreen mode
  115393. */
  115394. static _ExitFullscreen(): void;
  115395. }
  115396. }
  115397. declare module BABYLON {
  115398. /**
  115399. * The engine store class is responsible to hold all the instances of Engine and Scene created
  115400. * during the life time of the application.
  115401. */
  115402. export class EngineStore {
  115403. /** Gets the list of created engines */
  115404. static Instances: Engine[];
  115405. /** @hidden */
  115406. static _LastCreatedScene: Nullable<Scene>;
  115407. /**
  115408. * Gets the latest created engine
  115409. */
  115410. static get LastCreatedEngine(): Nullable<Engine>;
  115411. /**
  115412. * Gets the latest created scene
  115413. */
  115414. static get LastCreatedScene(): Nullable<Scene>;
  115415. /**
  115416. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115417. * @ignorenaming
  115418. */
  115419. static UseFallbackTexture: boolean;
  115420. /**
  115421. * Texture content used if a texture cannot loaded
  115422. * @ignorenaming
  115423. */
  115424. static FallbackTexture: string;
  115425. }
  115426. }
  115427. declare module BABYLON {
  115428. /**
  115429. * Helper class that provides a small promise polyfill
  115430. */
  115431. export class PromisePolyfill {
  115432. /**
  115433. * Static function used to check if the polyfill is required
  115434. * If this is the case then the function will inject the polyfill to window.Promise
  115435. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  115436. */
  115437. static Apply(force?: boolean): void;
  115438. }
  115439. }
  115440. declare module BABYLON {
  115441. /**
  115442. * Interface for screenshot methods with describe argument called `size` as object with options
  115443. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  115444. */
  115445. export interface IScreenshotSize {
  115446. /**
  115447. * number in pixels for canvas height
  115448. */
  115449. height?: number;
  115450. /**
  115451. * multiplier allowing render at a higher or lower resolution
  115452. * If value is defined then height and width will be ignored and taken from camera
  115453. */
  115454. precision?: number;
  115455. /**
  115456. * number in pixels for canvas width
  115457. */
  115458. width?: number;
  115459. }
  115460. }
  115461. declare module BABYLON {
  115462. interface IColor4Like {
  115463. r: float;
  115464. g: float;
  115465. b: float;
  115466. a: float;
  115467. }
  115468. /**
  115469. * Class containing a set of static utilities functions
  115470. */
  115471. export class Tools {
  115472. /**
  115473. * Gets or sets the base URL to use to load assets
  115474. */
  115475. static get BaseUrl(): string;
  115476. static set BaseUrl(value: string);
  115477. /**
  115478. * Enable/Disable Custom HTTP Request Headers globally.
  115479. * default = false
  115480. * @see CustomRequestHeaders
  115481. */
  115482. static UseCustomRequestHeaders: boolean;
  115483. /**
  115484. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  115485. * i.e. when loading files, where the server/service expects an Authorization header
  115486. */
  115487. static CustomRequestHeaders: {
  115488. [key: string]: string;
  115489. };
  115490. /**
  115491. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  115492. */
  115493. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  115494. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  115495. /**
  115496. * Default behaviour for cors in the application.
  115497. * It can be a string if the expected behavior is identical in the entire app.
  115498. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  115499. */
  115500. static get CorsBehavior(): string | ((url: string | string[]) => string);
  115501. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  115502. /**
  115503. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115504. * @ignorenaming
  115505. */
  115506. static get UseFallbackTexture(): boolean;
  115507. static set UseFallbackTexture(value: boolean);
  115508. /**
  115509. * Use this object to register external classes like custom textures or material
  115510. * to allow the laoders to instantiate them
  115511. */
  115512. static get RegisteredExternalClasses(): {
  115513. [key: string]: Object;
  115514. };
  115515. static set RegisteredExternalClasses(classes: {
  115516. [key: string]: Object;
  115517. });
  115518. /**
  115519. * Texture content used if a texture cannot loaded
  115520. * @ignorenaming
  115521. */
  115522. static get fallbackTexture(): string;
  115523. static set fallbackTexture(value: string);
  115524. /**
  115525. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  115526. * @param u defines the coordinate on X axis
  115527. * @param v defines the coordinate on Y axis
  115528. * @param width defines the width of the source data
  115529. * @param height defines the height of the source data
  115530. * @param pixels defines the source byte array
  115531. * @param color defines the output color
  115532. */
  115533. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  115534. /**
  115535. * Interpolates between a and b via alpha
  115536. * @param a The lower value (returned when alpha = 0)
  115537. * @param b The upper value (returned when alpha = 1)
  115538. * @param alpha The interpolation-factor
  115539. * @return The mixed value
  115540. */
  115541. static Mix(a: number, b: number, alpha: number): number;
  115542. /**
  115543. * Tries to instantiate a new object from a given class name
  115544. * @param className defines the class name to instantiate
  115545. * @returns the new object or null if the system was not able to do the instantiation
  115546. */
  115547. static Instantiate(className: string): any;
  115548. /**
  115549. * Provides a slice function that will work even on IE
  115550. * @param data defines the array to slice
  115551. * @param start defines the start of the data (optional)
  115552. * @param end defines the end of the data (optional)
  115553. * @returns the new sliced array
  115554. */
  115555. static Slice<T>(data: T, start?: number, end?: number): T;
  115556. /**
  115557. * Polyfill for setImmediate
  115558. * @param action defines the action to execute after the current execution block
  115559. */
  115560. static SetImmediate(action: () => void): void;
  115561. /**
  115562. * Function indicating if a number is an exponent of 2
  115563. * @param value defines the value to test
  115564. * @returns true if the value is an exponent of 2
  115565. */
  115566. static IsExponentOfTwo(value: number): boolean;
  115567. private static _tmpFloatArray;
  115568. /**
  115569. * Returns the nearest 32-bit single precision float representation of a Number
  115570. * @param value A Number. If the parameter is of a different type, it will get converted
  115571. * to a number or to NaN if it cannot be converted
  115572. * @returns number
  115573. */
  115574. static FloatRound(value: number): number;
  115575. /**
  115576. * Extracts the filename from a path
  115577. * @param path defines the path to use
  115578. * @returns the filename
  115579. */
  115580. static GetFilename(path: string): string;
  115581. /**
  115582. * Extracts the "folder" part of a path (everything before the filename).
  115583. * @param uri The URI to extract the info from
  115584. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  115585. * @returns The "folder" part of the path
  115586. */
  115587. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  115588. /**
  115589. * Extracts text content from a DOM element hierarchy
  115590. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  115591. */
  115592. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  115593. /**
  115594. * Convert an angle in radians to degrees
  115595. * @param angle defines the angle to convert
  115596. * @returns the angle in degrees
  115597. */
  115598. static ToDegrees(angle: number): number;
  115599. /**
  115600. * Convert an angle in degrees to radians
  115601. * @param angle defines the angle to convert
  115602. * @returns the angle in radians
  115603. */
  115604. static ToRadians(angle: number): number;
  115605. /**
  115606. * Returns an array if obj is not an array
  115607. * @param obj defines the object to evaluate as an array
  115608. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  115609. * @returns either obj directly if obj is an array or a new array containing obj
  115610. */
  115611. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  115612. /**
  115613. * Gets the pointer prefix to use
  115614. * @param engine defines the engine we are finding the prefix for
  115615. * @returns "pointer" if touch is enabled. Else returns "mouse"
  115616. */
  115617. static GetPointerPrefix(engine: Engine): string;
  115618. /**
  115619. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  115620. * @param url define the url we are trying
  115621. * @param element define the dom element where to configure the cors policy
  115622. */
  115623. static SetCorsBehavior(url: string | string[], element: {
  115624. crossOrigin: string | null;
  115625. }): void;
  115626. /**
  115627. * Removes unwanted characters from an url
  115628. * @param url defines the url to clean
  115629. * @returns the cleaned url
  115630. */
  115631. static CleanUrl(url: string): string;
  115632. /**
  115633. * Gets or sets a function used to pre-process url before using them to load assets
  115634. */
  115635. static get PreprocessUrl(): (url: string) => string;
  115636. static set PreprocessUrl(processor: (url: string) => string);
  115637. /**
  115638. * Loads an image as an HTMLImageElement.
  115639. * @param input url string, ArrayBuffer, or Blob to load
  115640. * @param onLoad callback called when the image successfully loads
  115641. * @param onError callback called when the image fails to load
  115642. * @param offlineProvider offline provider for caching
  115643. * @param mimeType optional mime type
  115644. * @returns the HTMLImageElement of the loaded image
  115645. */
  115646. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  115647. /**
  115648. * Loads a file from a url
  115649. * @param url url string, ArrayBuffer, or Blob to load
  115650. * @param onSuccess callback called when the file successfully loads
  115651. * @param onProgress callback called while file is loading (if the server supports this mode)
  115652. * @param offlineProvider defines the offline provider for caching
  115653. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115654. * @param onError callback called when the file fails to load
  115655. * @returns a file request object
  115656. */
  115657. 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;
  115658. /**
  115659. * Loads a file from a url
  115660. * @param url the file url to load
  115661. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115662. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  115663. */
  115664. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  115665. /**
  115666. * Load a script (identified by an url). When the url returns, the
  115667. * content of this file is added into a new script element, attached to the DOM (body element)
  115668. * @param scriptUrl defines the url of the script to laod
  115669. * @param onSuccess defines the callback called when the script is loaded
  115670. * @param onError defines the callback to call if an error occurs
  115671. * @param scriptId defines the id of the script element
  115672. */
  115673. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  115674. /**
  115675. * Load an asynchronous script (identified by an url). When the url returns, the
  115676. * content of this file is added into a new script element, attached to the DOM (body element)
  115677. * @param scriptUrl defines the url of the script to laod
  115678. * @param scriptId defines the id of the script element
  115679. * @returns a promise request object
  115680. */
  115681. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  115682. /**
  115683. * Loads a file from a blob
  115684. * @param fileToLoad defines the blob to use
  115685. * @param callback defines the callback to call when data is loaded
  115686. * @param progressCallback defines the callback to call during loading process
  115687. * @returns a file request object
  115688. */
  115689. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  115690. /**
  115691. * Reads a file from a File object
  115692. * @param file defines the file to load
  115693. * @param onSuccess defines the callback to call when data is loaded
  115694. * @param onProgress defines the callback to call during loading process
  115695. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115696. * @param onError defines the callback to call when an error occurs
  115697. * @returns a file request object
  115698. */
  115699. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  115700. /**
  115701. * Creates a data url from a given string content
  115702. * @param content defines the content to convert
  115703. * @returns the new data url link
  115704. */
  115705. static FileAsURL(content: string): string;
  115706. /**
  115707. * Format the given number to a specific decimal format
  115708. * @param value defines the number to format
  115709. * @param decimals defines the number of decimals to use
  115710. * @returns the formatted string
  115711. */
  115712. static Format(value: number, decimals?: number): string;
  115713. /**
  115714. * Tries to copy an object by duplicating every property
  115715. * @param source defines the source object
  115716. * @param destination defines the target object
  115717. * @param doNotCopyList defines a list of properties to avoid
  115718. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  115719. */
  115720. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  115721. /**
  115722. * Gets a boolean indicating if the given object has no own property
  115723. * @param obj defines the object to test
  115724. * @returns true if object has no own property
  115725. */
  115726. static IsEmpty(obj: any): boolean;
  115727. /**
  115728. * Function used to register events at window level
  115729. * @param windowElement defines the Window object to use
  115730. * @param events defines the events to register
  115731. */
  115732. static RegisterTopRootEvents(windowElement: Window, events: {
  115733. name: string;
  115734. handler: Nullable<(e: FocusEvent) => any>;
  115735. }[]): void;
  115736. /**
  115737. * Function used to unregister events from window level
  115738. * @param windowElement defines the Window object to use
  115739. * @param events defines the events to unregister
  115740. */
  115741. static UnregisterTopRootEvents(windowElement: Window, events: {
  115742. name: string;
  115743. handler: Nullable<(e: FocusEvent) => any>;
  115744. }[]): void;
  115745. /**
  115746. * @ignore
  115747. */
  115748. static _ScreenshotCanvas: HTMLCanvasElement;
  115749. /**
  115750. * Dumps the current bound framebuffer
  115751. * @param width defines the rendering width
  115752. * @param height defines the rendering height
  115753. * @param engine defines the hosting engine
  115754. * @param successCallback defines the callback triggered once the data are available
  115755. * @param mimeType defines the mime type of the result
  115756. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  115757. */
  115758. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115759. /**
  115760. * Converts the canvas data to blob.
  115761. * This acts as a polyfill for browsers not supporting the to blob function.
  115762. * @param canvas Defines the canvas to extract the data from
  115763. * @param successCallback Defines the callback triggered once the data are available
  115764. * @param mimeType Defines the mime type of the result
  115765. */
  115766. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  115767. /**
  115768. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  115769. * @param successCallback defines the callback triggered once the data are available
  115770. * @param mimeType defines the mime type of the result
  115771. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  115772. */
  115773. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115774. /**
  115775. * Downloads a blob in the browser
  115776. * @param blob defines the blob to download
  115777. * @param fileName defines the name of the downloaded file
  115778. */
  115779. static Download(blob: Blob, fileName: string): void;
  115780. /**
  115781. * Captures a screenshot of the current rendering
  115782. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115783. * @param engine defines the rendering engine
  115784. * @param camera defines the source camera
  115785. * @param size This parameter can be set to a single number or to an object with the
  115786. * following (optional) properties: precision, width, height. If a single number is passed,
  115787. * it will be used for both width and height. If an object is passed, the screenshot size
  115788. * will be derived from the parameters. The precision property is a multiplier allowing
  115789. * rendering at a higher or lower resolution
  115790. * @param successCallback defines the callback receives a single parameter which contains the
  115791. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115792. * src parameter of an <img> to display it
  115793. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115794. * Check your browser for supported MIME types
  115795. */
  115796. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  115797. /**
  115798. * Captures a screenshot of the current rendering
  115799. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115800. * @param engine defines the rendering engine
  115801. * @param camera defines the source camera
  115802. * @param size This parameter can be set to a single number or to an object with the
  115803. * following (optional) properties: precision, width, height. If a single number is passed,
  115804. * it will be used for both width and height. If an object is passed, the screenshot size
  115805. * will be derived from the parameters. The precision property is a multiplier allowing
  115806. * rendering at a higher or lower resolution
  115807. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115808. * Check your browser for supported MIME types
  115809. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115810. * to the src parameter of an <img> to display it
  115811. */
  115812. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  115813. /**
  115814. * Generates an image screenshot from the specified camera.
  115815. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115816. * @param engine The engine to use for rendering
  115817. * @param camera The camera to use for rendering
  115818. * @param size This parameter can be set to a single number or to an object with the
  115819. * following (optional) properties: precision, width, height. If a single number is passed,
  115820. * it will be used for both width and height. If an object is passed, the screenshot size
  115821. * will be derived from the parameters. The precision property is a multiplier allowing
  115822. * rendering at a higher or lower resolution
  115823. * @param successCallback The callback receives a single parameter which contains the
  115824. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115825. * src parameter of an <img> to display it
  115826. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115827. * Check your browser for supported MIME types
  115828. * @param samples Texture samples (default: 1)
  115829. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115830. * @param fileName A name for for the downloaded file.
  115831. */
  115832. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115833. /**
  115834. * Generates an image screenshot from the specified camera.
  115835. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115836. * @param engine The engine to use for rendering
  115837. * @param camera The camera to use for rendering
  115838. * @param size This parameter can be set to a single number or to an object with the
  115839. * following (optional) properties: precision, width, height. If a single number is passed,
  115840. * it will be used for both width and height. If an object is passed, the screenshot size
  115841. * will be derived from the parameters. The precision property is a multiplier allowing
  115842. * rendering at a higher or lower resolution
  115843. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115844. * Check your browser for supported MIME types
  115845. * @param samples Texture samples (default: 1)
  115846. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115847. * @param fileName A name for for the downloaded file.
  115848. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115849. * to the src parameter of an <img> to display it
  115850. */
  115851. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  115852. /**
  115853. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  115854. * Be aware Math.random() could cause collisions, but:
  115855. * "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"
  115856. * @returns a pseudo random id
  115857. */
  115858. static RandomId(): string;
  115859. /**
  115860. * Test if the given uri is a base64 string
  115861. * @param uri The uri to test
  115862. * @return True if the uri is a base64 string or false otherwise
  115863. */
  115864. static IsBase64(uri: string): boolean;
  115865. /**
  115866. * Decode the given base64 uri.
  115867. * @param uri The uri to decode
  115868. * @return The decoded base64 data.
  115869. */
  115870. static DecodeBase64(uri: string): ArrayBuffer;
  115871. /**
  115872. * Gets the absolute url.
  115873. * @param url the input url
  115874. * @return the absolute url
  115875. */
  115876. static GetAbsoluteUrl(url: string): string;
  115877. /**
  115878. * No log
  115879. */
  115880. static readonly NoneLogLevel: number;
  115881. /**
  115882. * Only message logs
  115883. */
  115884. static readonly MessageLogLevel: number;
  115885. /**
  115886. * Only warning logs
  115887. */
  115888. static readonly WarningLogLevel: number;
  115889. /**
  115890. * Only error logs
  115891. */
  115892. static readonly ErrorLogLevel: number;
  115893. /**
  115894. * All logs
  115895. */
  115896. static readonly AllLogLevel: number;
  115897. /**
  115898. * Gets a value indicating the number of loading errors
  115899. * @ignorenaming
  115900. */
  115901. static get errorsCount(): number;
  115902. /**
  115903. * Callback called when a new log is added
  115904. */
  115905. static OnNewCacheEntry: (entry: string) => void;
  115906. /**
  115907. * Log a message to the console
  115908. * @param message defines the message to log
  115909. */
  115910. static Log(message: string): void;
  115911. /**
  115912. * Write a warning message to the console
  115913. * @param message defines the message to log
  115914. */
  115915. static Warn(message: string): void;
  115916. /**
  115917. * Write an error message to the console
  115918. * @param message defines the message to log
  115919. */
  115920. static Error(message: string): void;
  115921. /**
  115922. * Gets current log cache (list of logs)
  115923. */
  115924. static get LogCache(): string;
  115925. /**
  115926. * Clears the log cache
  115927. */
  115928. static ClearLogCache(): void;
  115929. /**
  115930. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  115931. */
  115932. static set LogLevels(level: number);
  115933. /**
  115934. * Checks if the window object exists
  115935. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  115936. */
  115937. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  115938. /**
  115939. * No performance log
  115940. */
  115941. static readonly PerformanceNoneLogLevel: number;
  115942. /**
  115943. * Use user marks to log performance
  115944. */
  115945. static readonly PerformanceUserMarkLogLevel: number;
  115946. /**
  115947. * Log performance to the console
  115948. */
  115949. static readonly PerformanceConsoleLogLevel: number;
  115950. private static _performance;
  115951. /**
  115952. * Sets the current performance log level
  115953. */
  115954. static set PerformanceLogLevel(level: number);
  115955. private static _StartPerformanceCounterDisabled;
  115956. private static _EndPerformanceCounterDisabled;
  115957. private static _StartUserMark;
  115958. private static _EndUserMark;
  115959. private static _StartPerformanceConsole;
  115960. private static _EndPerformanceConsole;
  115961. /**
  115962. * Starts a performance counter
  115963. */
  115964. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115965. /**
  115966. * Ends a specific performance coutner
  115967. */
  115968. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115969. /**
  115970. * Gets either window.performance.now() if supported or Date.now() else
  115971. */
  115972. static get Now(): number;
  115973. /**
  115974. * This method will return the name of the class used to create the instance of the given object.
  115975. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  115976. * @param object the object to get the class name from
  115977. * @param isType defines if the object is actually a type
  115978. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  115979. */
  115980. static GetClassName(object: any, isType?: boolean): string;
  115981. /**
  115982. * Gets the first element of an array satisfying a given predicate
  115983. * @param array defines the array to browse
  115984. * @param predicate defines the predicate to use
  115985. * @returns null if not found or the element
  115986. */
  115987. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  115988. /**
  115989. * This method will return the name of the full name of the class, including its owning module (if any).
  115990. * 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).
  115991. * @param object the object to get the class name from
  115992. * @param isType defines if the object is actually a type
  115993. * @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.
  115994. * @ignorenaming
  115995. */
  115996. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  115997. /**
  115998. * Returns a promise that resolves after the given amount of time.
  115999. * @param delay Number of milliseconds to delay
  116000. * @returns Promise that resolves after the given amount of time
  116001. */
  116002. static DelayAsync(delay: number): Promise<void>;
  116003. /**
  116004. * Utility function to detect if the current user agent is Safari
  116005. * @returns whether or not the current user agent is safari
  116006. */
  116007. static IsSafari(): boolean;
  116008. }
  116009. /**
  116010. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  116011. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  116012. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  116013. * @param name The name of the class, case should be preserved
  116014. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  116015. */
  116016. export function className(name: string, module?: string): (target: Object) => void;
  116017. /**
  116018. * An implementation of a loop for asynchronous functions.
  116019. */
  116020. export class AsyncLoop {
  116021. /**
  116022. * Defines the number of iterations for the loop
  116023. */
  116024. iterations: number;
  116025. /**
  116026. * Defines the current index of the loop.
  116027. */
  116028. index: number;
  116029. private _done;
  116030. private _fn;
  116031. private _successCallback;
  116032. /**
  116033. * Constructor.
  116034. * @param iterations the number of iterations.
  116035. * @param func the function to run each iteration
  116036. * @param successCallback the callback that will be called upon succesful execution
  116037. * @param offset starting offset.
  116038. */
  116039. constructor(
  116040. /**
  116041. * Defines the number of iterations for the loop
  116042. */
  116043. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  116044. /**
  116045. * Execute the next iteration. Must be called after the last iteration was finished.
  116046. */
  116047. executeNext(): void;
  116048. /**
  116049. * Break the loop and run the success callback.
  116050. */
  116051. breakLoop(): void;
  116052. /**
  116053. * Create and run an async loop.
  116054. * @param iterations the number of iterations.
  116055. * @param fn the function to run each iteration
  116056. * @param successCallback the callback that will be called upon succesful execution
  116057. * @param offset starting offset.
  116058. * @returns the created async loop object
  116059. */
  116060. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  116061. /**
  116062. * A for-loop that will run a given number of iterations synchronous and the rest async.
  116063. * @param iterations total number of iterations
  116064. * @param syncedIterations number of synchronous iterations in each async iteration.
  116065. * @param fn the function to call each iteration.
  116066. * @param callback a success call back that will be called when iterating stops.
  116067. * @param breakFunction a break condition (optional)
  116068. * @param timeout timeout settings for the setTimeout function. default - 0.
  116069. * @returns the created async loop object
  116070. */
  116071. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  116072. }
  116073. }
  116074. declare module BABYLON {
  116075. /**
  116076. * This class implement a typical dictionary using a string as key and the generic type T as value.
  116077. * The underlying implementation relies on an associative array to ensure the best performances.
  116078. * The value can be anything including 'null' but except 'undefined'
  116079. */
  116080. export class StringDictionary<T> {
  116081. /**
  116082. * This will clear this dictionary and copy the content from the 'source' one.
  116083. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  116084. * @param source the dictionary to take the content from and copy to this dictionary
  116085. */
  116086. copyFrom(source: StringDictionary<T>): void;
  116087. /**
  116088. * Get a value based from its key
  116089. * @param key the given key to get the matching value from
  116090. * @return the value if found, otherwise undefined is returned
  116091. */
  116092. get(key: string): T | undefined;
  116093. /**
  116094. * Get a value from its key or add it if it doesn't exist.
  116095. * This method will ensure you that a given key/data will be present in the dictionary.
  116096. * @param key the given key to get the matching value from
  116097. * @param factory the factory that will create the value if the key is not present in the dictionary.
  116098. * The factory will only be invoked if there's no data for the given key.
  116099. * @return the value corresponding to the key.
  116100. */
  116101. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  116102. /**
  116103. * Get a value from its key if present in the dictionary otherwise add it
  116104. * @param key the key to get the value from
  116105. * @param val if there's no such key/value pair in the dictionary add it with this value
  116106. * @return the value corresponding to the key
  116107. */
  116108. getOrAdd(key: string, val: T): T;
  116109. /**
  116110. * Check if there's a given key in the dictionary
  116111. * @param key the key to check for
  116112. * @return true if the key is present, false otherwise
  116113. */
  116114. contains(key: string): boolean;
  116115. /**
  116116. * Add a new key and its corresponding value
  116117. * @param key the key to add
  116118. * @param value the value corresponding to the key
  116119. * @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
  116120. */
  116121. add(key: string, value: T): boolean;
  116122. /**
  116123. * Update a specific value associated to a key
  116124. * @param key defines the key to use
  116125. * @param value defines the value to store
  116126. * @returns true if the value was updated (or false if the key was not found)
  116127. */
  116128. set(key: string, value: T): boolean;
  116129. /**
  116130. * Get the element of the given key and remove it from the dictionary
  116131. * @param key defines the key to search
  116132. * @returns the value associated with the key or null if not found
  116133. */
  116134. getAndRemove(key: string): Nullable<T>;
  116135. /**
  116136. * Remove a key/value from the dictionary.
  116137. * @param key the key to remove
  116138. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  116139. */
  116140. remove(key: string): boolean;
  116141. /**
  116142. * Clear the whole content of the dictionary
  116143. */
  116144. clear(): void;
  116145. /**
  116146. * Gets the current count
  116147. */
  116148. get count(): number;
  116149. /**
  116150. * Execute a callback on each key/val of the dictionary.
  116151. * Note that you can remove any element in this dictionary in the callback implementation
  116152. * @param callback the callback to execute on a given key/value pair
  116153. */
  116154. forEach(callback: (key: string, val: T) => void): void;
  116155. /**
  116156. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  116157. * If the callback returns null or undefined the method will iterate to the next key/value pair
  116158. * Note that you can remove any element in this dictionary in the callback implementation
  116159. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  116160. * @returns the first item
  116161. */
  116162. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  116163. private _count;
  116164. private _data;
  116165. }
  116166. }
  116167. declare module BABYLON {
  116168. /** @hidden */
  116169. export interface ICollisionCoordinator {
  116170. createCollider(): Collider;
  116171. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  116172. init(scene: Scene): void;
  116173. }
  116174. /** @hidden */
  116175. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  116176. private _scene;
  116177. private _scaledPosition;
  116178. private _scaledVelocity;
  116179. private _finalPosition;
  116180. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  116181. createCollider(): Collider;
  116182. init(scene: Scene): void;
  116183. private _collideWithWorld;
  116184. }
  116185. }
  116186. declare module BABYLON {
  116187. /**
  116188. * Class used to manage all inputs for the scene.
  116189. */
  116190. export class InputManager {
  116191. /** The distance in pixel that you have to move to prevent some events */
  116192. static DragMovementThreshold: number;
  116193. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  116194. static LongPressDelay: number;
  116195. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  116196. static DoubleClickDelay: number;
  116197. /** If you need to check double click without raising a single click at first click, enable this flag */
  116198. static ExclusiveDoubleClickMode: boolean;
  116199. private _wheelEventName;
  116200. private _onPointerMove;
  116201. private _onPointerDown;
  116202. private _onPointerUp;
  116203. private _initClickEvent;
  116204. private _initActionManager;
  116205. private _delayedSimpleClick;
  116206. private _delayedSimpleClickTimeout;
  116207. private _previousDelayedSimpleClickTimeout;
  116208. private _meshPickProceed;
  116209. private _previousButtonPressed;
  116210. private _currentPickResult;
  116211. private _previousPickResult;
  116212. private _totalPointersPressed;
  116213. private _doubleClickOccured;
  116214. private _pointerOverMesh;
  116215. private _pickedDownMesh;
  116216. private _pickedUpMesh;
  116217. private _pointerX;
  116218. private _pointerY;
  116219. private _unTranslatedPointerX;
  116220. private _unTranslatedPointerY;
  116221. private _startingPointerPosition;
  116222. private _previousStartingPointerPosition;
  116223. private _startingPointerTime;
  116224. private _previousStartingPointerTime;
  116225. private _pointerCaptures;
  116226. private _onKeyDown;
  116227. private _onKeyUp;
  116228. private _onCanvasFocusObserver;
  116229. private _onCanvasBlurObserver;
  116230. private _scene;
  116231. /**
  116232. * Creates a new InputManager
  116233. * @param scene defines the hosting scene
  116234. */
  116235. constructor(scene: Scene);
  116236. /**
  116237. * Gets the mesh that is currently under the pointer
  116238. */
  116239. get meshUnderPointer(): Nullable<AbstractMesh>;
  116240. /**
  116241. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  116242. */
  116243. get unTranslatedPointer(): Vector2;
  116244. /**
  116245. * Gets or sets the current on-screen X position of the pointer
  116246. */
  116247. get pointerX(): number;
  116248. set pointerX(value: number);
  116249. /**
  116250. * Gets or sets the current on-screen Y position of the pointer
  116251. */
  116252. get pointerY(): number;
  116253. set pointerY(value: number);
  116254. private _updatePointerPosition;
  116255. private _processPointerMove;
  116256. private _setRayOnPointerInfo;
  116257. private _checkPrePointerObservable;
  116258. /**
  116259. * Use this method to simulate a pointer move on a mesh
  116260. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116261. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116262. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116263. */
  116264. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  116265. /**
  116266. * Use this method to simulate a pointer down on a mesh
  116267. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116268. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116269. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116270. */
  116271. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  116272. private _processPointerDown;
  116273. /** @hidden */
  116274. _isPointerSwiping(): boolean;
  116275. /**
  116276. * Use this method to simulate a pointer up on a mesh
  116277. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116278. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116279. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116280. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  116281. */
  116282. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  116283. private _processPointerUp;
  116284. /**
  116285. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  116286. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  116287. * @returns true if the pointer was captured
  116288. */
  116289. isPointerCaptured(pointerId?: number): boolean;
  116290. /**
  116291. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  116292. * @param attachUp defines if you want to attach events to pointerup
  116293. * @param attachDown defines if you want to attach events to pointerdown
  116294. * @param attachMove defines if you want to attach events to pointermove
  116295. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  116296. */
  116297. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  116298. /**
  116299. * Detaches all event handlers
  116300. */
  116301. detachControl(): void;
  116302. /**
  116303. * Force the value of meshUnderPointer
  116304. * @param mesh defines the mesh to use
  116305. */
  116306. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  116307. /**
  116308. * Gets the mesh under the pointer
  116309. * @returns a Mesh or null if no mesh is under the pointer
  116310. */
  116311. getPointerOverMesh(): Nullable<AbstractMesh>;
  116312. }
  116313. }
  116314. declare module BABYLON {
  116315. /**
  116316. * This class defines the direct association between an animation and a target
  116317. */
  116318. export class TargetedAnimation {
  116319. /**
  116320. * Animation to perform
  116321. */
  116322. animation: Animation;
  116323. /**
  116324. * Target to animate
  116325. */
  116326. target: any;
  116327. /**
  116328. * Returns the string "TargetedAnimation"
  116329. * @returns "TargetedAnimation"
  116330. */
  116331. getClassName(): string;
  116332. /**
  116333. * Serialize the object
  116334. * @returns the JSON object representing the current entity
  116335. */
  116336. serialize(): any;
  116337. }
  116338. /**
  116339. * Use this class to create coordinated animations on multiple targets
  116340. */
  116341. export class AnimationGroup implements IDisposable {
  116342. /** The name of the animation group */
  116343. name: string;
  116344. private _scene;
  116345. private _targetedAnimations;
  116346. private _animatables;
  116347. private _from;
  116348. private _to;
  116349. private _isStarted;
  116350. private _isPaused;
  116351. private _speedRatio;
  116352. private _loopAnimation;
  116353. private _isAdditive;
  116354. /**
  116355. * Gets or sets the unique id of the node
  116356. */
  116357. uniqueId: number;
  116358. /**
  116359. * This observable will notify when one animation have ended
  116360. */
  116361. onAnimationEndObservable: Observable<TargetedAnimation>;
  116362. /**
  116363. * Observer raised when one animation loops
  116364. */
  116365. onAnimationLoopObservable: Observable<TargetedAnimation>;
  116366. /**
  116367. * Observer raised when all animations have looped
  116368. */
  116369. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  116370. /**
  116371. * This observable will notify when all animations have ended.
  116372. */
  116373. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  116374. /**
  116375. * This observable will notify when all animations have paused.
  116376. */
  116377. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  116378. /**
  116379. * This observable will notify when all animations are playing.
  116380. */
  116381. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  116382. /**
  116383. * Gets the first frame
  116384. */
  116385. get from(): number;
  116386. /**
  116387. * Gets the last frame
  116388. */
  116389. get to(): number;
  116390. /**
  116391. * Define if the animations are started
  116392. */
  116393. get isStarted(): boolean;
  116394. /**
  116395. * Gets a value indicating that the current group is playing
  116396. */
  116397. get isPlaying(): boolean;
  116398. /**
  116399. * Gets or sets the speed ratio to use for all animations
  116400. */
  116401. get speedRatio(): number;
  116402. /**
  116403. * Gets or sets the speed ratio to use for all animations
  116404. */
  116405. set speedRatio(value: number);
  116406. /**
  116407. * Gets or sets if all animations should loop or not
  116408. */
  116409. get loopAnimation(): boolean;
  116410. set loopAnimation(value: boolean);
  116411. /**
  116412. * Gets or sets if all animations should be evaluated additively
  116413. */
  116414. get isAdditive(): boolean;
  116415. set isAdditive(value: boolean);
  116416. /**
  116417. * Gets the targeted animations for this animation group
  116418. */
  116419. get targetedAnimations(): Array<TargetedAnimation>;
  116420. /**
  116421. * returning the list of animatables controlled by this animation group.
  116422. */
  116423. get animatables(): Array<Animatable>;
  116424. /**
  116425. * Gets the list of target animations
  116426. */
  116427. get children(): TargetedAnimation[];
  116428. /**
  116429. * Instantiates a new Animation Group.
  116430. * This helps managing several animations at once.
  116431. * @see https://doc.babylonjs.com/how_to/group
  116432. * @param name Defines the name of the group
  116433. * @param scene Defines the scene the group belongs to
  116434. */
  116435. constructor(
  116436. /** The name of the animation group */
  116437. name: string, scene?: Nullable<Scene>);
  116438. /**
  116439. * Add an animation (with its target) in the group
  116440. * @param animation defines the animation we want to add
  116441. * @param target defines the target of the animation
  116442. * @returns the TargetedAnimation object
  116443. */
  116444. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  116445. /**
  116446. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  116447. * It can add constant keys at begin or end
  116448. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  116449. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  116450. * @returns the animation group
  116451. */
  116452. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  116453. private _animationLoopCount;
  116454. private _animationLoopFlags;
  116455. private _processLoop;
  116456. /**
  116457. * Start all animations on given targets
  116458. * @param loop defines if animations must loop
  116459. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  116460. * @param from defines the from key (optional)
  116461. * @param to defines the to key (optional)
  116462. * @param isAdditive defines the additive state for the resulting animatables (optional)
  116463. * @returns the current animation group
  116464. */
  116465. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  116466. /**
  116467. * Pause all animations
  116468. * @returns the animation group
  116469. */
  116470. pause(): AnimationGroup;
  116471. /**
  116472. * Play all animations to initial state
  116473. * This function will start() the animations if they were not started or will restart() them if they were paused
  116474. * @param loop defines if animations must loop
  116475. * @returns the animation group
  116476. */
  116477. play(loop?: boolean): AnimationGroup;
  116478. /**
  116479. * Reset all animations to initial state
  116480. * @returns the animation group
  116481. */
  116482. reset(): AnimationGroup;
  116483. /**
  116484. * Restart animations from key 0
  116485. * @returns the animation group
  116486. */
  116487. restart(): AnimationGroup;
  116488. /**
  116489. * Stop all animations
  116490. * @returns the animation group
  116491. */
  116492. stop(): AnimationGroup;
  116493. /**
  116494. * Set animation weight for all animatables
  116495. * @param weight defines the weight to use
  116496. * @return the animationGroup
  116497. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  116498. */
  116499. setWeightForAllAnimatables(weight: number): AnimationGroup;
  116500. /**
  116501. * Synchronize and normalize all animatables with a source animatable
  116502. * @param root defines the root animatable to synchronize with
  116503. * @return the animationGroup
  116504. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  116505. */
  116506. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  116507. /**
  116508. * Goes to a specific frame in this animation group
  116509. * @param frame the frame number to go to
  116510. * @return the animationGroup
  116511. */
  116512. goToFrame(frame: number): AnimationGroup;
  116513. /**
  116514. * Dispose all associated resources
  116515. */
  116516. dispose(): void;
  116517. private _checkAnimationGroupEnded;
  116518. /**
  116519. * Clone the current animation group and returns a copy
  116520. * @param newName defines the name of the new group
  116521. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  116522. * @returns the new aniamtion group
  116523. */
  116524. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  116525. /**
  116526. * Serializes the animationGroup to an object
  116527. * @returns Serialized object
  116528. */
  116529. serialize(): any;
  116530. /**
  116531. * Returns a new AnimationGroup object parsed from the source provided.
  116532. * @param parsedAnimationGroup defines the source
  116533. * @param scene defines the scene that will receive the animationGroup
  116534. * @returns a new AnimationGroup
  116535. */
  116536. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  116537. /**
  116538. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  116539. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  116540. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  116541. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  116542. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  116543. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  116544. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  116545. */
  116546. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  116547. /**
  116548. * Returns the string "AnimationGroup"
  116549. * @returns "AnimationGroup"
  116550. */
  116551. getClassName(): string;
  116552. /**
  116553. * Creates a detailled string about the object
  116554. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  116555. * @returns a string representing the object
  116556. */
  116557. toString(fullDetails?: boolean): string;
  116558. }
  116559. }
  116560. declare module BABYLON {
  116561. /**
  116562. * Define an interface for all classes that will hold resources
  116563. */
  116564. export interface IDisposable {
  116565. /**
  116566. * Releases all held resources
  116567. */
  116568. dispose(): void;
  116569. }
  116570. /** Interface defining initialization parameters for Scene class */
  116571. export interface SceneOptions {
  116572. /**
  116573. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  116574. * It will improve performance when the number of geometries becomes important.
  116575. */
  116576. useGeometryUniqueIdsMap?: boolean;
  116577. /**
  116578. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  116579. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116580. */
  116581. useMaterialMeshMap?: boolean;
  116582. /**
  116583. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  116584. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116585. */
  116586. useClonedMeshMap?: boolean;
  116587. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  116588. virtual?: boolean;
  116589. }
  116590. /**
  116591. * Represents a scene to be rendered by the engine.
  116592. * @see https://doc.babylonjs.com/features/scene
  116593. */
  116594. export class Scene extends AbstractScene implements IAnimatable {
  116595. /** The fog is deactivated */
  116596. static readonly FOGMODE_NONE: number;
  116597. /** The fog density is following an exponential function */
  116598. static readonly FOGMODE_EXP: number;
  116599. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  116600. static readonly FOGMODE_EXP2: number;
  116601. /** The fog density is following a linear function. */
  116602. static readonly FOGMODE_LINEAR: number;
  116603. /**
  116604. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  116605. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116606. */
  116607. static MinDeltaTime: number;
  116608. /**
  116609. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  116610. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116611. */
  116612. static MaxDeltaTime: number;
  116613. /**
  116614. * Factory used to create the default material.
  116615. * @param name The name of the material to create
  116616. * @param scene The scene to create the material for
  116617. * @returns The default material
  116618. */
  116619. static DefaultMaterialFactory(scene: Scene): Material;
  116620. /**
  116621. * Factory used to create the a collision coordinator.
  116622. * @returns The collision coordinator
  116623. */
  116624. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  116625. /** @hidden */
  116626. _inputManager: InputManager;
  116627. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  116628. cameraToUseForPointers: Nullable<Camera>;
  116629. /** @hidden */
  116630. readonly _isScene: boolean;
  116631. /** @hidden */
  116632. _blockEntityCollection: boolean;
  116633. /**
  116634. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  116635. */
  116636. autoClear: boolean;
  116637. /**
  116638. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  116639. */
  116640. autoClearDepthAndStencil: boolean;
  116641. /**
  116642. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  116643. */
  116644. clearColor: Color4;
  116645. /**
  116646. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  116647. */
  116648. ambientColor: Color3;
  116649. /**
  116650. * This is use to store the default BRDF lookup for PBR materials in your scene.
  116651. * It should only be one of the following (if not the default embedded one):
  116652. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116653. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  116654. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116655. * The material properties need to be setup according to the type of texture in use.
  116656. */
  116657. environmentBRDFTexture: BaseTexture;
  116658. /** @hidden */
  116659. protected _environmentTexture: Nullable<BaseTexture>;
  116660. /**
  116661. * Texture used in all pbr material as the reflection texture.
  116662. * As in the majority of the scene they are the same (exception for multi room and so on),
  116663. * this is easier to reference from here than from all the materials.
  116664. */
  116665. get environmentTexture(): Nullable<BaseTexture>;
  116666. /**
  116667. * Texture used in all pbr material as the reflection texture.
  116668. * As in the majority of the scene they are the same (exception for multi room and so on),
  116669. * this is easier to set here than in all the materials.
  116670. */
  116671. set environmentTexture(value: Nullable<BaseTexture>);
  116672. /** @hidden */
  116673. protected _environmentIntensity: number;
  116674. /**
  116675. * Intensity of the environment in all pbr material.
  116676. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116677. * As in the majority of the scene they are the same (exception for multi room and so on),
  116678. * this is easier to reference from here than from all the materials.
  116679. */
  116680. get environmentIntensity(): number;
  116681. /**
  116682. * Intensity of the environment in all pbr material.
  116683. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116684. * As in the majority of the scene they are the same (exception for multi room and so on),
  116685. * this is easier to set here than in all the materials.
  116686. */
  116687. set environmentIntensity(value: number);
  116688. /** @hidden */
  116689. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116690. /**
  116691. * Default image processing configuration used either in the rendering
  116692. * Forward main pass or through the imageProcessingPostProcess if present.
  116693. * As in the majority of the scene they are the same (exception for multi camera),
  116694. * this is easier to reference from here than from all the materials and post process.
  116695. *
  116696. * No setter as we it is a shared configuration, you can set the values instead.
  116697. */
  116698. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116699. private _forceWireframe;
  116700. /**
  116701. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  116702. */
  116703. set forceWireframe(value: boolean);
  116704. get forceWireframe(): boolean;
  116705. private _skipFrustumClipping;
  116706. /**
  116707. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  116708. */
  116709. set skipFrustumClipping(value: boolean);
  116710. get skipFrustumClipping(): boolean;
  116711. private _forcePointsCloud;
  116712. /**
  116713. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  116714. */
  116715. set forcePointsCloud(value: boolean);
  116716. get forcePointsCloud(): boolean;
  116717. /**
  116718. * Gets or sets the active clipplane 1
  116719. */
  116720. clipPlane: Nullable<Plane>;
  116721. /**
  116722. * Gets or sets the active clipplane 2
  116723. */
  116724. clipPlane2: Nullable<Plane>;
  116725. /**
  116726. * Gets or sets the active clipplane 3
  116727. */
  116728. clipPlane3: Nullable<Plane>;
  116729. /**
  116730. * Gets or sets the active clipplane 4
  116731. */
  116732. clipPlane4: Nullable<Plane>;
  116733. /**
  116734. * Gets or sets the active clipplane 5
  116735. */
  116736. clipPlane5: Nullable<Plane>;
  116737. /**
  116738. * Gets or sets the active clipplane 6
  116739. */
  116740. clipPlane6: Nullable<Plane>;
  116741. /**
  116742. * Gets or sets a boolean indicating if animations are enabled
  116743. */
  116744. animationsEnabled: boolean;
  116745. private _animationPropertiesOverride;
  116746. /**
  116747. * Gets or sets the animation properties override
  116748. */
  116749. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116750. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116751. /**
  116752. * Gets or sets a boolean indicating if a constant deltatime has to be used
  116753. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  116754. */
  116755. useConstantAnimationDeltaTime: boolean;
  116756. /**
  116757. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  116758. * Please note that it requires to run a ray cast through the scene on every frame
  116759. */
  116760. constantlyUpdateMeshUnderPointer: boolean;
  116761. /**
  116762. * Defines the HTML cursor to use when hovering over interactive elements
  116763. */
  116764. hoverCursor: string;
  116765. /**
  116766. * Defines the HTML default cursor to use (empty by default)
  116767. */
  116768. defaultCursor: string;
  116769. /**
  116770. * Defines whether cursors are handled by the scene.
  116771. */
  116772. doNotHandleCursors: boolean;
  116773. /**
  116774. * This is used to call preventDefault() on pointer down
  116775. * in order to block unwanted artifacts like system double clicks
  116776. */
  116777. preventDefaultOnPointerDown: boolean;
  116778. /**
  116779. * This is used to call preventDefault() on pointer up
  116780. * in order to block unwanted artifacts like system double clicks
  116781. */
  116782. preventDefaultOnPointerUp: boolean;
  116783. /**
  116784. * Gets or sets user defined metadata
  116785. */
  116786. metadata: any;
  116787. /**
  116788. * For internal use only. Please do not use.
  116789. */
  116790. reservedDataStore: any;
  116791. /**
  116792. * Gets the name of the plugin used to load this scene (null by default)
  116793. */
  116794. loadingPluginName: string;
  116795. /**
  116796. * Use this array to add regular expressions used to disable offline support for specific urls
  116797. */
  116798. disableOfflineSupportExceptionRules: RegExp[];
  116799. /**
  116800. * An event triggered when the scene is disposed.
  116801. */
  116802. onDisposeObservable: Observable<Scene>;
  116803. private _onDisposeObserver;
  116804. /** Sets a function to be executed when this scene is disposed. */
  116805. set onDispose(callback: () => void);
  116806. /**
  116807. * An event triggered before rendering the scene (right after animations and physics)
  116808. */
  116809. onBeforeRenderObservable: Observable<Scene>;
  116810. private _onBeforeRenderObserver;
  116811. /** Sets a function to be executed before rendering this scene */
  116812. set beforeRender(callback: Nullable<() => void>);
  116813. /**
  116814. * An event triggered after rendering the scene
  116815. */
  116816. onAfterRenderObservable: Observable<Scene>;
  116817. /**
  116818. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  116819. */
  116820. onAfterRenderCameraObservable: Observable<Camera>;
  116821. private _onAfterRenderObserver;
  116822. /** Sets a function to be executed after rendering this scene */
  116823. set afterRender(callback: Nullable<() => void>);
  116824. /**
  116825. * An event triggered before animating the scene
  116826. */
  116827. onBeforeAnimationsObservable: Observable<Scene>;
  116828. /**
  116829. * An event triggered after animations processing
  116830. */
  116831. onAfterAnimationsObservable: Observable<Scene>;
  116832. /**
  116833. * An event triggered before draw calls are ready to be sent
  116834. */
  116835. onBeforeDrawPhaseObservable: Observable<Scene>;
  116836. /**
  116837. * An event triggered after draw calls have been sent
  116838. */
  116839. onAfterDrawPhaseObservable: Observable<Scene>;
  116840. /**
  116841. * An event triggered when the scene is ready
  116842. */
  116843. onReadyObservable: Observable<Scene>;
  116844. /**
  116845. * An event triggered before rendering a camera
  116846. */
  116847. onBeforeCameraRenderObservable: Observable<Camera>;
  116848. private _onBeforeCameraRenderObserver;
  116849. /** Sets a function to be executed before rendering a camera*/
  116850. set beforeCameraRender(callback: () => void);
  116851. /**
  116852. * An event triggered after rendering a camera
  116853. */
  116854. onAfterCameraRenderObservable: Observable<Camera>;
  116855. private _onAfterCameraRenderObserver;
  116856. /** Sets a function to be executed after rendering a camera*/
  116857. set afterCameraRender(callback: () => void);
  116858. /**
  116859. * An event triggered when active meshes evaluation is about to start
  116860. */
  116861. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  116862. /**
  116863. * An event triggered when active meshes evaluation is done
  116864. */
  116865. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  116866. /**
  116867. * An event triggered when particles rendering is about to start
  116868. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116869. */
  116870. onBeforeParticlesRenderingObservable: Observable<Scene>;
  116871. /**
  116872. * An event triggered when particles rendering is done
  116873. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116874. */
  116875. onAfterParticlesRenderingObservable: Observable<Scene>;
  116876. /**
  116877. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  116878. */
  116879. onDataLoadedObservable: Observable<Scene>;
  116880. /**
  116881. * An event triggered when a camera is created
  116882. */
  116883. onNewCameraAddedObservable: Observable<Camera>;
  116884. /**
  116885. * An event triggered when a camera is removed
  116886. */
  116887. onCameraRemovedObservable: Observable<Camera>;
  116888. /**
  116889. * An event triggered when a light is created
  116890. */
  116891. onNewLightAddedObservable: Observable<Light>;
  116892. /**
  116893. * An event triggered when a light is removed
  116894. */
  116895. onLightRemovedObservable: Observable<Light>;
  116896. /**
  116897. * An event triggered when a geometry is created
  116898. */
  116899. onNewGeometryAddedObservable: Observable<Geometry>;
  116900. /**
  116901. * An event triggered when a geometry is removed
  116902. */
  116903. onGeometryRemovedObservable: Observable<Geometry>;
  116904. /**
  116905. * An event triggered when a transform node is created
  116906. */
  116907. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  116908. /**
  116909. * An event triggered when a transform node is removed
  116910. */
  116911. onTransformNodeRemovedObservable: Observable<TransformNode>;
  116912. /**
  116913. * An event triggered when a mesh is created
  116914. */
  116915. onNewMeshAddedObservable: Observable<AbstractMesh>;
  116916. /**
  116917. * An event triggered when a mesh is removed
  116918. */
  116919. onMeshRemovedObservable: Observable<AbstractMesh>;
  116920. /**
  116921. * An event triggered when a skeleton is created
  116922. */
  116923. onNewSkeletonAddedObservable: Observable<Skeleton>;
  116924. /**
  116925. * An event triggered when a skeleton is removed
  116926. */
  116927. onSkeletonRemovedObservable: Observable<Skeleton>;
  116928. /**
  116929. * An event triggered when a material is created
  116930. */
  116931. onNewMaterialAddedObservable: Observable<Material>;
  116932. /**
  116933. * An event triggered when a material is removed
  116934. */
  116935. onMaterialRemovedObservable: Observable<Material>;
  116936. /**
  116937. * An event triggered when a texture is created
  116938. */
  116939. onNewTextureAddedObservable: Observable<BaseTexture>;
  116940. /**
  116941. * An event triggered when a texture is removed
  116942. */
  116943. onTextureRemovedObservable: Observable<BaseTexture>;
  116944. /**
  116945. * An event triggered when render targets are about to be rendered
  116946. * Can happen multiple times per frame.
  116947. */
  116948. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  116949. /**
  116950. * An event triggered when render targets were rendered.
  116951. * Can happen multiple times per frame.
  116952. */
  116953. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  116954. /**
  116955. * An event triggered before calculating deterministic simulation step
  116956. */
  116957. onBeforeStepObservable: Observable<Scene>;
  116958. /**
  116959. * An event triggered after calculating deterministic simulation step
  116960. */
  116961. onAfterStepObservable: Observable<Scene>;
  116962. /**
  116963. * An event triggered when the activeCamera property is updated
  116964. */
  116965. onActiveCameraChanged: Observable<Scene>;
  116966. /**
  116967. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  116968. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116969. * 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)
  116970. */
  116971. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116972. /**
  116973. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  116974. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116975. * 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)
  116976. */
  116977. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116978. /**
  116979. * This Observable will when a mesh has been imported into the scene.
  116980. */
  116981. onMeshImportedObservable: Observable<AbstractMesh>;
  116982. /**
  116983. * This Observable will when an animation file has been imported into the scene.
  116984. */
  116985. onAnimationFileImportedObservable: Observable<Scene>;
  116986. /**
  116987. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  116988. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  116989. */
  116990. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  116991. /** @hidden */
  116992. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  116993. /**
  116994. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  116995. */
  116996. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  116997. /**
  116998. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  116999. */
  117000. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  117001. /**
  117002. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  117003. */
  117004. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  117005. /** Callback called when a pointer move is detected */
  117006. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  117007. /** Callback called when a pointer down is detected */
  117008. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  117009. /** Callback called when a pointer up is detected */
  117010. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  117011. /** Callback called when a pointer pick is detected */
  117012. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  117013. /**
  117014. * 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).
  117015. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  117016. */
  117017. onPrePointerObservable: Observable<PointerInfoPre>;
  117018. /**
  117019. * Observable event triggered each time an input event is received from the rendering canvas
  117020. */
  117021. onPointerObservable: Observable<PointerInfo>;
  117022. /**
  117023. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  117024. */
  117025. get unTranslatedPointer(): Vector2;
  117026. /**
  117027. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  117028. */
  117029. static get DragMovementThreshold(): number;
  117030. static set DragMovementThreshold(value: number);
  117031. /**
  117032. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  117033. */
  117034. static get LongPressDelay(): number;
  117035. static set LongPressDelay(value: number);
  117036. /**
  117037. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  117038. */
  117039. static get DoubleClickDelay(): number;
  117040. static set DoubleClickDelay(value: number);
  117041. /** If you need to check double click without raising a single click at first click, enable this flag */
  117042. static get ExclusiveDoubleClickMode(): boolean;
  117043. static set ExclusiveDoubleClickMode(value: boolean);
  117044. /** @hidden */
  117045. _mirroredCameraPosition: Nullable<Vector3>;
  117046. /**
  117047. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  117048. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  117049. */
  117050. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  117051. /**
  117052. * Observable event triggered each time an keyboard event is received from the hosting window
  117053. */
  117054. onKeyboardObservable: Observable<KeyboardInfo>;
  117055. private _useRightHandedSystem;
  117056. /**
  117057. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  117058. */
  117059. set useRightHandedSystem(value: boolean);
  117060. get useRightHandedSystem(): boolean;
  117061. private _timeAccumulator;
  117062. private _currentStepId;
  117063. private _currentInternalStep;
  117064. /**
  117065. * Sets the step Id used by deterministic lock step
  117066. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117067. * @param newStepId defines the step Id
  117068. */
  117069. setStepId(newStepId: number): void;
  117070. /**
  117071. * Gets the step Id used by deterministic lock step
  117072. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117073. * @returns the step Id
  117074. */
  117075. getStepId(): number;
  117076. /**
  117077. * Gets the internal step used by deterministic lock step
  117078. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117079. * @returns the internal step
  117080. */
  117081. getInternalStep(): number;
  117082. private _fogEnabled;
  117083. /**
  117084. * Gets or sets a boolean indicating if fog is enabled on this scene
  117085. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117086. * (Default is true)
  117087. */
  117088. set fogEnabled(value: boolean);
  117089. get fogEnabled(): boolean;
  117090. private _fogMode;
  117091. /**
  117092. * Gets or sets the fog mode to use
  117093. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117094. * | mode | value |
  117095. * | --- | --- |
  117096. * | FOGMODE_NONE | 0 |
  117097. * | FOGMODE_EXP | 1 |
  117098. * | FOGMODE_EXP2 | 2 |
  117099. * | FOGMODE_LINEAR | 3 |
  117100. */
  117101. set fogMode(value: number);
  117102. get fogMode(): number;
  117103. /**
  117104. * Gets or sets the fog color to use
  117105. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117106. * (Default is Color3(0.2, 0.2, 0.3))
  117107. */
  117108. fogColor: Color3;
  117109. /**
  117110. * Gets or sets the fog density to use
  117111. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117112. * (Default is 0.1)
  117113. */
  117114. fogDensity: number;
  117115. /**
  117116. * Gets or sets the fog start distance to use
  117117. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117118. * (Default is 0)
  117119. */
  117120. fogStart: number;
  117121. /**
  117122. * Gets or sets the fog end distance to use
  117123. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117124. * (Default is 1000)
  117125. */
  117126. fogEnd: number;
  117127. /**
  117128. * Flag indicating that the frame buffer binding is handled by another component
  117129. */
  117130. prePass: boolean;
  117131. private _shadowsEnabled;
  117132. /**
  117133. * Gets or sets a boolean indicating if shadows are enabled on this scene
  117134. */
  117135. set shadowsEnabled(value: boolean);
  117136. get shadowsEnabled(): boolean;
  117137. private _lightsEnabled;
  117138. /**
  117139. * Gets or sets a boolean indicating if lights are enabled on this scene
  117140. */
  117141. set lightsEnabled(value: boolean);
  117142. get lightsEnabled(): boolean;
  117143. /** All of the active cameras added to this scene. */
  117144. activeCameras: Camera[];
  117145. /** @hidden */
  117146. _activeCamera: Nullable<Camera>;
  117147. /** Gets or sets the current active camera */
  117148. get activeCamera(): Nullable<Camera>;
  117149. set activeCamera(value: Nullable<Camera>);
  117150. private _defaultMaterial;
  117151. /** The default material used on meshes when no material is affected */
  117152. get defaultMaterial(): Material;
  117153. /** The default material used on meshes when no material is affected */
  117154. set defaultMaterial(value: Material);
  117155. private _texturesEnabled;
  117156. /**
  117157. * Gets or sets a boolean indicating if textures are enabled on this scene
  117158. */
  117159. set texturesEnabled(value: boolean);
  117160. get texturesEnabled(): boolean;
  117161. /**
  117162. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  117163. */
  117164. physicsEnabled: boolean;
  117165. /**
  117166. * Gets or sets a boolean indicating if particles are enabled on this scene
  117167. */
  117168. particlesEnabled: boolean;
  117169. /**
  117170. * Gets or sets a boolean indicating if sprites are enabled on this scene
  117171. */
  117172. spritesEnabled: boolean;
  117173. private _skeletonsEnabled;
  117174. /**
  117175. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  117176. */
  117177. set skeletonsEnabled(value: boolean);
  117178. get skeletonsEnabled(): boolean;
  117179. /**
  117180. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  117181. */
  117182. lensFlaresEnabled: boolean;
  117183. /**
  117184. * Gets or sets a boolean indicating if collisions are enabled on this scene
  117185. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117186. */
  117187. collisionsEnabled: boolean;
  117188. private _collisionCoordinator;
  117189. /** @hidden */
  117190. get collisionCoordinator(): ICollisionCoordinator;
  117191. /**
  117192. * Defines the gravity applied to this scene (used only for collisions)
  117193. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117194. */
  117195. gravity: Vector3;
  117196. /**
  117197. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  117198. */
  117199. postProcessesEnabled: boolean;
  117200. /**
  117201. * The list of postprocesses added to the scene
  117202. */
  117203. postProcesses: PostProcess[];
  117204. /**
  117205. * Gets the current postprocess manager
  117206. */
  117207. postProcessManager: PostProcessManager;
  117208. /**
  117209. * Gets or sets a boolean indicating if render targets are enabled on this scene
  117210. */
  117211. renderTargetsEnabled: boolean;
  117212. /**
  117213. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  117214. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  117215. */
  117216. dumpNextRenderTargets: boolean;
  117217. /**
  117218. * The list of user defined render targets added to the scene
  117219. */
  117220. customRenderTargets: RenderTargetTexture[];
  117221. /**
  117222. * Defines if texture loading must be delayed
  117223. * If true, textures will only be loaded when they need to be rendered
  117224. */
  117225. useDelayedTextureLoading: boolean;
  117226. /**
  117227. * Gets the list of meshes imported to the scene through SceneLoader
  117228. */
  117229. importedMeshesFiles: String[];
  117230. /**
  117231. * Gets or sets a boolean indicating if probes are enabled on this scene
  117232. */
  117233. probesEnabled: boolean;
  117234. /**
  117235. * Gets or sets the current offline provider to use to store scene data
  117236. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  117237. */
  117238. offlineProvider: IOfflineProvider;
  117239. /**
  117240. * Gets or sets the action manager associated with the scene
  117241. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117242. */
  117243. actionManager: AbstractActionManager;
  117244. private _meshesForIntersections;
  117245. /**
  117246. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  117247. */
  117248. proceduralTexturesEnabled: boolean;
  117249. private _engine;
  117250. private _totalVertices;
  117251. /** @hidden */
  117252. _activeIndices: PerfCounter;
  117253. /** @hidden */
  117254. _activeParticles: PerfCounter;
  117255. /** @hidden */
  117256. _activeBones: PerfCounter;
  117257. private _animationRatio;
  117258. /** @hidden */
  117259. _animationTimeLast: number;
  117260. /** @hidden */
  117261. _animationTime: number;
  117262. /**
  117263. * Gets or sets a general scale for animation speed
  117264. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  117265. */
  117266. animationTimeScale: number;
  117267. /** @hidden */
  117268. _cachedMaterial: Nullable<Material>;
  117269. /** @hidden */
  117270. _cachedEffect: Nullable<Effect>;
  117271. /** @hidden */
  117272. _cachedVisibility: Nullable<number>;
  117273. private _renderId;
  117274. private _frameId;
  117275. private _executeWhenReadyTimeoutId;
  117276. private _intermediateRendering;
  117277. private _viewUpdateFlag;
  117278. private _projectionUpdateFlag;
  117279. /** @hidden */
  117280. _toBeDisposed: Nullable<IDisposable>[];
  117281. private _activeRequests;
  117282. /** @hidden */
  117283. _pendingData: any[];
  117284. private _isDisposed;
  117285. /**
  117286. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  117287. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  117288. */
  117289. dispatchAllSubMeshesOfActiveMeshes: boolean;
  117290. private _activeMeshes;
  117291. private _processedMaterials;
  117292. private _renderTargets;
  117293. /** @hidden */
  117294. _activeParticleSystems: SmartArray<IParticleSystem>;
  117295. private _activeSkeletons;
  117296. private _softwareSkinnedMeshes;
  117297. private _renderingManager;
  117298. /** @hidden */
  117299. _activeAnimatables: Animatable[];
  117300. private _transformMatrix;
  117301. private _sceneUbo;
  117302. /** @hidden */
  117303. _viewMatrix: Matrix;
  117304. private _projectionMatrix;
  117305. /** @hidden */
  117306. _forcedViewPosition: Nullable<Vector3>;
  117307. /** @hidden */
  117308. _frustumPlanes: Plane[];
  117309. /**
  117310. * Gets the list of frustum planes (built from the active camera)
  117311. */
  117312. get frustumPlanes(): Plane[];
  117313. /**
  117314. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  117315. * This is useful if there are more lights that the maximum simulteanous authorized
  117316. */
  117317. requireLightSorting: boolean;
  117318. /** @hidden */
  117319. readonly useMaterialMeshMap: boolean;
  117320. /** @hidden */
  117321. readonly useClonedMeshMap: boolean;
  117322. private _externalData;
  117323. private _uid;
  117324. /**
  117325. * @hidden
  117326. * Backing store of defined scene components.
  117327. */
  117328. _components: ISceneComponent[];
  117329. /**
  117330. * @hidden
  117331. * Backing store of defined scene components.
  117332. */
  117333. _serializableComponents: ISceneSerializableComponent[];
  117334. /**
  117335. * List of components to register on the next registration step.
  117336. */
  117337. private _transientComponents;
  117338. /**
  117339. * Registers the transient components if needed.
  117340. */
  117341. private _registerTransientComponents;
  117342. /**
  117343. * @hidden
  117344. * Add a component to the scene.
  117345. * Note that the ccomponent could be registered on th next frame if this is called after
  117346. * the register component stage.
  117347. * @param component Defines the component to add to the scene
  117348. */
  117349. _addComponent(component: ISceneComponent): void;
  117350. /**
  117351. * @hidden
  117352. * Gets a component from the scene.
  117353. * @param name defines the name of the component to retrieve
  117354. * @returns the component or null if not present
  117355. */
  117356. _getComponent(name: string): Nullable<ISceneComponent>;
  117357. /**
  117358. * @hidden
  117359. * Defines the actions happening before camera updates.
  117360. */
  117361. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  117362. /**
  117363. * @hidden
  117364. * Defines the actions happening before clear the canvas.
  117365. */
  117366. _beforeClearStage: Stage<SimpleStageAction>;
  117367. /**
  117368. * @hidden
  117369. * Defines the actions when collecting render targets for the frame.
  117370. */
  117371. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  117372. /**
  117373. * @hidden
  117374. * Defines the actions happening for one camera in the frame.
  117375. */
  117376. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  117377. /**
  117378. * @hidden
  117379. * Defines the actions happening during the per mesh ready checks.
  117380. */
  117381. _isReadyForMeshStage: Stage<MeshStageAction>;
  117382. /**
  117383. * @hidden
  117384. * Defines the actions happening before evaluate active mesh checks.
  117385. */
  117386. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  117387. /**
  117388. * @hidden
  117389. * Defines the actions happening during the evaluate sub mesh checks.
  117390. */
  117391. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  117392. /**
  117393. * @hidden
  117394. * Defines the actions happening during the active mesh stage.
  117395. */
  117396. _activeMeshStage: Stage<ActiveMeshStageAction>;
  117397. /**
  117398. * @hidden
  117399. * Defines the actions happening during the per camera render target step.
  117400. */
  117401. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  117402. /**
  117403. * @hidden
  117404. * Defines the actions happening just before the active camera is drawing.
  117405. */
  117406. _beforeCameraDrawStage: Stage<CameraStageAction>;
  117407. /**
  117408. * @hidden
  117409. * Defines the actions happening just before a render target is drawing.
  117410. */
  117411. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117412. /**
  117413. * @hidden
  117414. * Defines the actions happening just before a rendering group is drawing.
  117415. */
  117416. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117417. /**
  117418. * @hidden
  117419. * Defines the actions happening just before a mesh is drawing.
  117420. */
  117421. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117422. /**
  117423. * @hidden
  117424. * Defines the actions happening just after a mesh has been drawn.
  117425. */
  117426. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117427. /**
  117428. * @hidden
  117429. * Defines the actions happening just after a rendering group has been drawn.
  117430. */
  117431. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117432. /**
  117433. * @hidden
  117434. * Defines the actions happening just after the active camera has been drawn.
  117435. */
  117436. _afterCameraDrawStage: Stage<CameraStageAction>;
  117437. /**
  117438. * @hidden
  117439. * Defines the actions happening just after a render target has been drawn.
  117440. */
  117441. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117442. /**
  117443. * @hidden
  117444. * Defines the actions happening just after rendering all cameras and computing intersections.
  117445. */
  117446. _afterRenderStage: Stage<SimpleStageAction>;
  117447. /**
  117448. * @hidden
  117449. * Defines the actions happening when a pointer move event happens.
  117450. */
  117451. _pointerMoveStage: Stage<PointerMoveStageAction>;
  117452. /**
  117453. * @hidden
  117454. * Defines the actions happening when a pointer down event happens.
  117455. */
  117456. _pointerDownStage: Stage<PointerUpDownStageAction>;
  117457. /**
  117458. * @hidden
  117459. * Defines the actions happening when a pointer up event happens.
  117460. */
  117461. _pointerUpStage: Stage<PointerUpDownStageAction>;
  117462. /**
  117463. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  117464. */
  117465. private geometriesByUniqueId;
  117466. /**
  117467. * Creates a new Scene
  117468. * @param engine defines the engine to use to render this scene
  117469. * @param options defines the scene options
  117470. */
  117471. constructor(engine: Engine, options?: SceneOptions);
  117472. /**
  117473. * Gets a string idenfifying the name of the class
  117474. * @returns "Scene" string
  117475. */
  117476. getClassName(): string;
  117477. private _defaultMeshCandidates;
  117478. /**
  117479. * @hidden
  117480. */
  117481. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  117482. private _defaultSubMeshCandidates;
  117483. /**
  117484. * @hidden
  117485. */
  117486. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  117487. /**
  117488. * Sets the default candidate providers for the scene.
  117489. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  117490. * and getCollidingSubMeshCandidates to their default function
  117491. */
  117492. setDefaultCandidateProviders(): void;
  117493. /**
  117494. * Gets the mesh that is currently under the pointer
  117495. */
  117496. get meshUnderPointer(): Nullable<AbstractMesh>;
  117497. /**
  117498. * Gets or sets the current on-screen X position of the pointer
  117499. */
  117500. get pointerX(): number;
  117501. set pointerX(value: number);
  117502. /**
  117503. * Gets or sets the current on-screen Y position of the pointer
  117504. */
  117505. get pointerY(): number;
  117506. set pointerY(value: number);
  117507. /**
  117508. * Gets the cached material (ie. the latest rendered one)
  117509. * @returns the cached material
  117510. */
  117511. getCachedMaterial(): Nullable<Material>;
  117512. /**
  117513. * Gets the cached effect (ie. the latest rendered one)
  117514. * @returns the cached effect
  117515. */
  117516. getCachedEffect(): Nullable<Effect>;
  117517. /**
  117518. * Gets the cached visibility state (ie. the latest rendered one)
  117519. * @returns the cached visibility state
  117520. */
  117521. getCachedVisibility(): Nullable<number>;
  117522. /**
  117523. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  117524. * @param material defines the current material
  117525. * @param effect defines the current effect
  117526. * @param visibility defines the current visibility state
  117527. * @returns true if one parameter is not cached
  117528. */
  117529. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  117530. /**
  117531. * Gets the engine associated with the scene
  117532. * @returns an Engine
  117533. */
  117534. getEngine(): Engine;
  117535. /**
  117536. * Gets the total number of vertices rendered per frame
  117537. * @returns the total number of vertices rendered per frame
  117538. */
  117539. getTotalVertices(): number;
  117540. /**
  117541. * Gets the performance counter for total vertices
  117542. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117543. */
  117544. get totalVerticesPerfCounter(): PerfCounter;
  117545. /**
  117546. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  117547. * @returns the total number of active indices rendered per frame
  117548. */
  117549. getActiveIndices(): number;
  117550. /**
  117551. * Gets the performance counter for active indices
  117552. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117553. */
  117554. get totalActiveIndicesPerfCounter(): PerfCounter;
  117555. /**
  117556. * Gets the total number of active particles rendered per frame
  117557. * @returns the total number of active particles rendered per frame
  117558. */
  117559. getActiveParticles(): number;
  117560. /**
  117561. * Gets the performance counter for active particles
  117562. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117563. */
  117564. get activeParticlesPerfCounter(): PerfCounter;
  117565. /**
  117566. * Gets the total number of active bones rendered per frame
  117567. * @returns the total number of active bones rendered per frame
  117568. */
  117569. getActiveBones(): number;
  117570. /**
  117571. * Gets the performance counter for active bones
  117572. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117573. */
  117574. get activeBonesPerfCounter(): PerfCounter;
  117575. /**
  117576. * Gets the array of active meshes
  117577. * @returns an array of AbstractMesh
  117578. */
  117579. getActiveMeshes(): SmartArray<AbstractMesh>;
  117580. /**
  117581. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  117582. * @returns a number
  117583. */
  117584. getAnimationRatio(): number;
  117585. /**
  117586. * Gets an unique Id for the current render phase
  117587. * @returns a number
  117588. */
  117589. getRenderId(): number;
  117590. /**
  117591. * Gets an unique Id for the current frame
  117592. * @returns a number
  117593. */
  117594. getFrameId(): number;
  117595. /** Call this function if you want to manually increment the render Id*/
  117596. incrementRenderId(): void;
  117597. private _createUbo;
  117598. /**
  117599. * Use this method to simulate a pointer move on a mesh
  117600. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117601. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117602. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117603. * @returns the current scene
  117604. */
  117605. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117606. /**
  117607. * Use this method to simulate a pointer down on a mesh
  117608. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117609. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117610. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117611. * @returns the current scene
  117612. */
  117613. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117614. /**
  117615. * Use this method to simulate a pointer up on a mesh
  117616. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117617. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117618. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117619. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117620. * @returns the current scene
  117621. */
  117622. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  117623. /**
  117624. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117625. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117626. * @returns true if the pointer was captured
  117627. */
  117628. isPointerCaptured(pointerId?: number): boolean;
  117629. /**
  117630. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117631. * @param attachUp defines if you want to attach events to pointerup
  117632. * @param attachDown defines if you want to attach events to pointerdown
  117633. * @param attachMove defines if you want to attach events to pointermove
  117634. */
  117635. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  117636. /** Detaches all event handlers*/
  117637. detachControl(): void;
  117638. /**
  117639. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  117640. * Delay loaded resources are not taking in account
  117641. * @return true if all required resources are ready
  117642. */
  117643. isReady(): boolean;
  117644. /** Resets all cached information relative to material (including effect and visibility) */
  117645. resetCachedMaterial(): void;
  117646. /**
  117647. * Registers a function to be called before every frame render
  117648. * @param func defines the function to register
  117649. */
  117650. registerBeforeRender(func: () => void): void;
  117651. /**
  117652. * Unregisters a function called before every frame render
  117653. * @param func defines the function to unregister
  117654. */
  117655. unregisterBeforeRender(func: () => void): void;
  117656. /**
  117657. * Registers a function to be called after every frame render
  117658. * @param func defines the function to register
  117659. */
  117660. registerAfterRender(func: () => void): void;
  117661. /**
  117662. * Unregisters a function called after every frame render
  117663. * @param func defines the function to unregister
  117664. */
  117665. unregisterAfterRender(func: () => void): void;
  117666. private _executeOnceBeforeRender;
  117667. /**
  117668. * The provided function will run before render once and will be disposed afterwards.
  117669. * A timeout delay can be provided so that the function will be executed in N ms.
  117670. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  117671. * @param func The function to be executed.
  117672. * @param timeout optional delay in ms
  117673. */
  117674. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  117675. /** @hidden */
  117676. _addPendingData(data: any): void;
  117677. /** @hidden */
  117678. _removePendingData(data: any): void;
  117679. /**
  117680. * Returns the number of items waiting to be loaded
  117681. * @returns the number of items waiting to be loaded
  117682. */
  117683. getWaitingItemsCount(): number;
  117684. /**
  117685. * Returns a boolean indicating if the scene is still loading data
  117686. */
  117687. get isLoading(): boolean;
  117688. /**
  117689. * Registers a function to be executed when the scene is ready
  117690. * @param {Function} func - the function to be executed
  117691. */
  117692. executeWhenReady(func: () => void): void;
  117693. /**
  117694. * Returns a promise that resolves when the scene is ready
  117695. * @returns A promise that resolves when the scene is ready
  117696. */
  117697. whenReadyAsync(): Promise<void>;
  117698. /** @hidden */
  117699. _checkIsReady(): void;
  117700. /**
  117701. * Gets all animatable attached to the scene
  117702. */
  117703. get animatables(): Animatable[];
  117704. /**
  117705. * Resets the last animation time frame.
  117706. * Useful to override when animations start running when loading a scene for the first time.
  117707. */
  117708. resetLastAnimationTimeFrame(): void;
  117709. /**
  117710. * Gets the current view matrix
  117711. * @returns a Matrix
  117712. */
  117713. getViewMatrix(): Matrix;
  117714. /**
  117715. * Gets the current projection matrix
  117716. * @returns a Matrix
  117717. */
  117718. getProjectionMatrix(): Matrix;
  117719. /**
  117720. * Gets the current transform matrix
  117721. * @returns a Matrix made of View * Projection
  117722. */
  117723. getTransformMatrix(): Matrix;
  117724. /**
  117725. * Sets the current transform matrix
  117726. * @param viewL defines the View matrix to use
  117727. * @param projectionL defines the Projection matrix to use
  117728. * @param viewR defines the right View matrix to use (if provided)
  117729. * @param projectionR defines the right Projection matrix to use (if provided)
  117730. */
  117731. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  117732. /**
  117733. * Gets the uniform buffer used to store scene data
  117734. * @returns a UniformBuffer
  117735. */
  117736. getSceneUniformBuffer(): UniformBuffer;
  117737. /**
  117738. * Gets an unique (relatively to the current scene) Id
  117739. * @returns an unique number for the scene
  117740. */
  117741. getUniqueId(): number;
  117742. /**
  117743. * Add a mesh to the list of scene's meshes
  117744. * @param newMesh defines the mesh to add
  117745. * @param recursive if all child meshes should also be added to the scene
  117746. */
  117747. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  117748. /**
  117749. * Remove a mesh for the list of scene's meshes
  117750. * @param toRemove defines the mesh to remove
  117751. * @param recursive if all child meshes should also be removed from the scene
  117752. * @returns the index where the mesh was in the mesh list
  117753. */
  117754. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  117755. /**
  117756. * Add a transform node to the list of scene's transform nodes
  117757. * @param newTransformNode defines the transform node to add
  117758. */
  117759. addTransformNode(newTransformNode: TransformNode): void;
  117760. /**
  117761. * Remove a transform node for the list of scene's transform nodes
  117762. * @param toRemove defines the transform node to remove
  117763. * @returns the index where the transform node was in the transform node list
  117764. */
  117765. removeTransformNode(toRemove: TransformNode): number;
  117766. /**
  117767. * Remove a skeleton for the list of scene's skeletons
  117768. * @param toRemove defines the skeleton to remove
  117769. * @returns the index where the skeleton was in the skeleton list
  117770. */
  117771. removeSkeleton(toRemove: Skeleton): number;
  117772. /**
  117773. * Remove a morph target for the list of scene's morph targets
  117774. * @param toRemove defines the morph target to remove
  117775. * @returns the index where the morph target was in the morph target list
  117776. */
  117777. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  117778. /**
  117779. * Remove a light for the list of scene's lights
  117780. * @param toRemove defines the light to remove
  117781. * @returns the index where the light was in the light list
  117782. */
  117783. removeLight(toRemove: Light): number;
  117784. /**
  117785. * Remove a camera for the list of scene's cameras
  117786. * @param toRemove defines the camera to remove
  117787. * @returns the index where the camera was in the camera list
  117788. */
  117789. removeCamera(toRemove: Camera): number;
  117790. /**
  117791. * Remove a particle system for the list of scene's particle systems
  117792. * @param toRemove defines the particle system to remove
  117793. * @returns the index where the particle system was in the particle system list
  117794. */
  117795. removeParticleSystem(toRemove: IParticleSystem): number;
  117796. /**
  117797. * Remove a animation for the list of scene's animations
  117798. * @param toRemove defines the animation to remove
  117799. * @returns the index where the animation was in the animation list
  117800. */
  117801. removeAnimation(toRemove: Animation): number;
  117802. /**
  117803. * Will stop the animation of the given target
  117804. * @param target - the target
  117805. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  117806. * @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)
  117807. */
  117808. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  117809. /**
  117810. * Removes the given animation group from this scene.
  117811. * @param toRemove The animation group to remove
  117812. * @returns The index of the removed animation group
  117813. */
  117814. removeAnimationGroup(toRemove: AnimationGroup): number;
  117815. /**
  117816. * Removes the given multi-material from this scene.
  117817. * @param toRemove The multi-material to remove
  117818. * @returns The index of the removed multi-material
  117819. */
  117820. removeMultiMaterial(toRemove: MultiMaterial): number;
  117821. /**
  117822. * Removes the given material from this scene.
  117823. * @param toRemove The material to remove
  117824. * @returns The index of the removed material
  117825. */
  117826. removeMaterial(toRemove: Material): number;
  117827. /**
  117828. * Removes the given action manager from this scene.
  117829. * @param toRemove The action manager to remove
  117830. * @returns The index of the removed action manager
  117831. */
  117832. removeActionManager(toRemove: AbstractActionManager): number;
  117833. /**
  117834. * Removes the given texture from this scene.
  117835. * @param toRemove The texture to remove
  117836. * @returns The index of the removed texture
  117837. */
  117838. removeTexture(toRemove: BaseTexture): number;
  117839. /**
  117840. * Adds the given light to this scene
  117841. * @param newLight The light to add
  117842. */
  117843. addLight(newLight: Light): void;
  117844. /**
  117845. * Sorts the list list based on light priorities
  117846. */
  117847. sortLightsByPriority(): void;
  117848. /**
  117849. * Adds the given camera to this scene
  117850. * @param newCamera The camera to add
  117851. */
  117852. addCamera(newCamera: Camera): void;
  117853. /**
  117854. * Adds the given skeleton to this scene
  117855. * @param newSkeleton The skeleton to add
  117856. */
  117857. addSkeleton(newSkeleton: Skeleton): void;
  117858. /**
  117859. * Adds the given particle system to this scene
  117860. * @param newParticleSystem The particle system to add
  117861. */
  117862. addParticleSystem(newParticleSystem: IParticleSystem): void;
  117863. /**
  117864. * Adds the given animation to this scene
  117865. * @param newAnimation The animation to add
  117866. */
  117867. addAnimation(newAnimation: Animation): void;
  117868. /**
  117869. * Adds the given animation group to this scene.
  117870. * @param newAnimationGroup The animation group to add
  117871. */
  117872. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  117873. /**
  117874. * Adds the given multi-material to this scene
  117875. * @param newMultiMaterial The multi-material to add
  117876. */
  117877. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  117878. /**
  117879. * Adds the given material to this scene
  117880. * @param newMaterial The material to add
  117881. */
  117882. addMaterial(newMaterial: Material): void;
  117883. /**
  117884. * Adds the given morph target to this scene
  117885. * @param newMorphTargetManager The morph target to add
  117886. */
  117887. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  117888. /**
  117889. * Adds the given geometry to this scene
  117890. * @param newGeometry The geometry to add
  117891. */
  117892. addGeometry(newGeometry: Geometry): void;
  117893. /**
  117894. * Adds the given action manager to this scene
  117895. * @param newActionManager The action manager to add
  117896. */
  117897. addActionManager(newActionManager: AbstractActionManager): void;
  117898. /**
  117899. * Adds the given texture to this scene.
  117900. * @param newTexture The texture to add
  117901. */
  117902. addTexture(newTexture: BaseTexture): void;
  117903. /**
  117904. * Switch active camera
  117905. * @param newCamera defines the new active camera
  117906. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  117907. */
  117908. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  117909. /**
  117910. * sets the active camera of the scene using its ID
  117911. * @param id defines the camera's ID
  117912. * @return the new active camera or null if none found.
  117913. */
  117914. setActiveCameraByID(id: string): Nullable<Camera>;
  117915. /**
  117916. * sets the active camera of the scene using its name
  117917. * @param name defines the camera's name
  117918. * @returns the new active camera or null if none found.
  117919. */
  117920. setActiveCameraByName(name: string): Nullable<Camera>;
  117921. /**
  117922. * get an animation group using its name
  117923. * @param name defines the material's name
  117924. * @return the animation group or null if none found.
  117925. */
  117926. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  117927. /**
  117928. * Get a material using its unique id
  117929. * @param uniqueId defines the material's unique id
  117930. * @return the material or null if none found.
  117931. */
  117932. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  117933. /**
  117934. * get a material using its id
  117935. * @param id defines the material's ID
  117936. * @return the material or null if none found.
  117937. */
  117938. getMaterialByID(id: string): Nullable<Material>;
  117939. /**
  117940. * Gets a the last added material using a given id
  117941. * @param id defines the material's ID
  117942. * @return the last material with the given id or null if none found.
  117943. */
  117944. getLastMaterialByID(id: string): Nullable<Material>;
  117945. /**
  117946. * Gets a material using its name
  117947. * @param name defines the material's name
  117948. * @return the material or null if none found.
  117949. */
  117950. getMaterialByName(name: string): Nullable<Material>;
  117951. /**
  117952. * Get a texture using its unique id
  117953. * @param uniqueId defines the texture's unique id
  117954. * @return the texture or null if none found.
  117955. */
  117956. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  117957. /**
  117958. * Gets a camera using its id
  117959. * @param id defines the id to look for
  117960. * @returns the camera or null if not found
  117961. */
  117962. getCameraByID(id: string): Nullable<Camera>;
  117963. /**
  117964. * Gets a camera using its unique id
  117965. * @param uniqueId defines the unique id to look for
  117966. * @returns the camera or null if not found
  117967. */
  117968. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  117969. /**
  117970. * Gets a camera using its name
  117971. * @param name defines the camera's name
  117972. * @return the camera or null if none found.
  117973. */
  117974. getCameraByName(name: string): Nullable<Camera>;
  117975. /**
  117976. * Gets a bone using its id
  117977. * @param id defines the bone's id
  117978. * @return the bone or null if not found
  117979. */
  117980. getBoneByID(id: string): Nullable<Bone>;
  117981. /**
  117982. * Gets a bone using its id
  117983. * @param name defines the bone's name
  117984. * @return the bone or null if not found
  117985. */
  117986. getBoneByName(name: string): Nullable<Bone>;
  117987. /**
  117988. * Gets a light node using its name
  117989. * @param name defines the the light's name
  117990. * @return the light or null if none found.
  117991. */
  117992. getLightByName(name: string): Nullable<Light>;
  117993. /**
  117994. * Gets a light node using its id
  117995. * @param id defines the light's id
  117996. * @return the light or null if none found.
  117997. */
  117998. getLightByID(id: string): Nullable<Light>;
  117999. /**
  118000. * Gets a light node using its scene-generated unique ID
  118001. * @param uniqueId defines the light's unique id
  118002. * @return the light or null if none found.
  118003. */
  118004. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  118005. /**
  118006. * Gets a particle system by id
  118007. * @param id defines the particle system id
  118008. * @return the corresponding system or null if none found
  118009. */
  118010. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  118011. /**
  118012. * Gets a geometry using its ID
  118013. * @param id defines the geometry's id
  118014. * @return the geometry or null if none found.
  118015. */
  118016. getGeometryByID(id: string): Nullable<Geometry>;
  118017. private _getGeometryByUniqueID;
  118018. /**
  118019. * Add a new geometry to this scene
  118020. * @param geometry defines the geometry to be added to the scene.
  118021. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  118022. * @return a boolean defining if the geometry was added or not
  118023. */
  118024. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  118025. /**
  118026. * Removes an existing geometry
  118027. * @param geometry defines the geometry to be removed from the scene
  118028. * @return a boolean defining if the geometry was removed or not
  118029. */
  118030. removeGeometry(geometry: Geometry): boolean;
  118031. /**
  118032. * Gets the list of geometries attached to the scene
  118033. * @returns an array of Geometry
  118034. */
  118035. getGeometries(): Geometry[];
  118036. /**
  118037. * Gets the first added mesh found of a given ID
  118038. * @param id defines the id to search for
  118039. * @return the mesh found or null if not found at all
  118040. */
  118041. getMeshByID(id: string): Nullable<AbstractMesh>;
  118042. /**
  118043. * Gets a list of meshes using their id
  118044. * @param id defines the id to search for
  118045. * @returns a list of meshes
  118046. */
  118047. getMeshesByID(id: string): Array<AbstractMesh>;
  118048. /**
  118049. * Gets the first added transform node found of a given ID
  118050. * @param id defines the id to search for
  118051. * @return the found transform node or null if not found at all.
  118052. */
  118053. getTransformNodeByID(id: string): Nullable<TransformNode>;
  118054. /**
  118055. * Gets a transform node with its auto-generated unique id
  118056. * @param uniqueId efines the unique id to search for
  118057. * @return the found transform node or null if not found at all.
  118058. */
  118059. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  118060. /**
  118061. * Gets a list of transform nodes using their id
  118062. * @param id defines the id to search for
  118063. * @returns a list of transform nodes
  118064. */
  118065. getTransformNodesByID(id: string): Array<TransformNode>;
  118066. /**
  118067. * Gets a mesh with its auto-generated unique id
  118068. * @param uniqueId defines the unique id to search for
  118069. * @return the found mesh or null if not found at all.
  118070. */
  118071. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  118072. /**
  118073. * Gets a the last added mesh using a given id
  118074. * @param id defines the id to search for
  118075. * @return the found mesh or null if not found at all.
  118076. */
  118077. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  118078. /**
  118079. * Gets a the last added node (Mesh, Camera, Light) using a given id
  118080. * @param id defines the id to search for
  118081. * @return the found node or null if not found at all
  118082. */
  118083. getLastEntryByID(id: string): Nullable<Node>;
  118084. /**
  118085. * Gets a node (Mesh, Camera, Light) using a given id
  118086. * @param id defines the id to search for
  118087. * @return the found node or null if not found at all
  118088. */
  118089. getNodeByID(id: string): Nullable<Node>;
  118090. /**
  118091. * Gets a node (Mesh, Camera, Light) using a given name
  118092. * @param name defines the name to search for
  118093. * @return the found node or null if not found at all.
  118094. */
  118095. getNodeByName(name: string): Nullable<Node>;
  118096. /**
  118097. * Gets a mesh using a given name
  118098. * @param name defines the name to search for
  118099. * @return the found mesh or null if not found at all.
  118100. */
  118101. getMeshByName(name: string): Nullable<AbstractMesh>;
  118102. /**
  118103. * Gets a transform node using a given name
  118104. * @param name defines the name to search for
  118105. * @return the found transform node or null if not found at all.
  118106. */
  118107. getTransformNodeByName(name: string): Nullable<TransformNode>;
  118108. /**
  118109. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  118110. * @param id defines the id to search for
  118111. * @return the found skeleton or null if not found at all.
  118112. */
  118113. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  118114. /**
  118115. * Gets a skeleton using a given auto generated unique id
  118116. * @param uniqueId defines the unique id to search for
  118117. * @return the found skeleton or null if not found at all.
  118118. */
  118119. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  118120. /**
  118121. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  118122. * @param id defines the id to search for
  118123. * @return the found skeleton or null if not found at all.
  118124. */
  118125. getSkeletonById(id: string): Nullable<Skeleton>;
  118126. /**
  118127. * Gets a skeleton using a given name
  118128. * @param name defines the name to search for
  118129. * @return the found skeleton or null if not found at all.
  118130. */
  118131. getSkeletonByName(name: string): Nullable<Skeleton>;
  118132. /**
  118133. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  118134. * @param id defines the id to search for
  118135. * @return the found morph target manager or null if not found at all.
  118136. */
  118137. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  118138. /**
  118139. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  118140. * @param id defines the id to search for
  118141. * @return the found morph target or null if not found at all.
  118142. */
  118143. getMorphTargetById(id: string): Nullable<MorphTarget>;
  118144. /**
  118145. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  118146. * @param name defines the name to search for
  118147. * @return the found morph target or null if not found at all.
  118148. */
  118149. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  118150. /**
  118151. * Gets a boolean indicating if the given mesh is active
  118152. * @param mesh defines the mesh to look for
  118153. * @returns true if the mesh is in the active list
  118154. */
  118155. isActiveMesh(mesh: AbstractMesh): boolean;
  118156. /**
  118157. * Return a unique id as a string which can serve as an identifier for the scene
  118158. */
  118159. get uid(): string;
  118160. /**
  118161. * Add an externaly attached data from its key.
  118162. * This method call will fail and return false, if such key already exists.
  118163. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  118164. * @param key the unique key that identifies the data
  118165. * @param data the data object to associate to the key for this Engine instance
  118166. * @return true if no such key were already present and the data was added successfully, false otherwise
  118167. */
  118168. addExternalData<T>(key: string, data: T): boolean;
  118169. /**
  118170. * Get an externaly attached data from its key
  118171. * @param key the unique key that identifies the data
  118172. * @return the associated data, if present (can be null), or undefined if not present
  118173. */
  118174. getExternalData<T>(key: string): Nullable<T>;
  118175. /**
  118176. * Get an externaly attached data from its key, create it using a factory if it's not already present
  118177. * @param key the unique key that identifies the data
  118178. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  118179. * @return the associated data, can be null if the factory returned null.
  118180. */
  118181. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  118182. /**
  118183. * Remove an externaly attached data from the Engine instance
  118184. * @param key the unique key that identifies the data
  118185. * @return true if the data was successfully removed, false if it doesn't exist
  118186. */
  118187. removeExternalData(key: string): boolean;
  118188. private _evaluateSubMesh;
  118189. /**
  118190. * Clear the processed materials smart array preventing retention point in material dispose.
  118191. */
  118192. freeProcessedMaterials(): void;
  118193. private _preventFreeActiveMeshesAndRenderingGroups;
  118194. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  118195. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  118196. * when disposing several meshes in a row or a hierarchy of meshes.
  118197. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  118198. */
  118199. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  118200. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  118201. /**
  118202. * Clear the active meshes smart array preventing retention point in mesh dispose.
  118203. */
  118204. freeActiveMeshes(): void;
  118205. /**
  118206. * Clear the info related to rendering groups preventing retention points during dispose.
  118207. */
  118208. freeRenderingGroups(): void;
  118209. /** @hidden */
  118210. _isInIntermediateRendering(): boolean;
  118211. /**
  118212. * Lambda returning the list of potentially active meshes.
  118213. */
  118214. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  118215. /**
  118216. * Lambda returning the list of potentially active sub meshes.
  118217. */
  118218. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  118219. /**
  118220. * Lambda returning the list of potentially intersecting sub meshes.
  118221. */
  118222. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  118223. /**
  118224. * Lambda returning the list of potentially colliding sub meshes.
  118225. */
  118226. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  118227. private _activeMeshesFrozen;
  118228. private _skipEvaluateActiveMeshesCompletely;
  118229. /**
  118230. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  118231. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  118232. * @returns the current scene
  118233. */
  118234. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  118235. /**
  118236. * Use this function to restart evaluating active meshes on every frame
  118237. * @returns the current scene
  118238. */
  118239. unfreezeActiveMeshes(): Scene;
  118240. private _evaluateActiveMeshes;
  118241. private _activeMesh;
  118242. /**
  118243. * Update the transform matrix to update from the current active camera
  118244. * @param force defines a boolean used to force the update even if cache is up to date
  118245. */
  118246. updateTransformMatrix(force?: boolean): void;
  118247. private _bindFrameBuffer;
  118248. /** @hidden */
  118249. _allowPostProcessClearColor: boolean;
  118250. /** @hidden */
  118251. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  118252. private _processSubCameras;
  118253. private _checkIntersections;
  118254. /** @hidden */
  118255. _advancePhysicsEngineStep(step: number): void;
  118256. /**
  118257. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  118258. */
  118259. getDeterministicFrameTime: () => number;
  118260. /** @hidden */
  118261. _animate(): void;
  118262. /** Execute all animations (for a frame) */
  118263. animate(): void;
  118264. /**
  118265. * Render the scene
  118266. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  118267. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  118268. */
  118269. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  118270. /**
  118271. * Freeze all materials
  118272. * A frozen material will not be updatable but should be faster to render
  118273. */
  118274. freezeMaterials(): void;
  118275. /**
  118276. * Unfreeze all materials
  118277. * A frozen material will not be updatable but should be faster to render
  118278. */
  118279. unfreezeMaterials(): void;
  118280. /**
  118281. * Releases all held ressources
  118282. */
  118283. dispose(): void;
  118284. /**
  118285. * Gets if the scene is already disposed
  118286. */
  118287. get isDisposed(): boolean;
  118288. /**
  118289. * Call this function to reduce memory footprint of the scene.
  118290. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  118291. */
  118292. clearCachedVertexData(): void;
  118293. /**
  118294. * This function will remove the local cached buffer data from texture.
  118295. * It will save memory but will prevent the texture from being rebuilt
  118296. */
  118297. cleanCachedTextureBuffer(): void;
  118298. /**
  118299. * Get the world extend vectors with an optional filter
  118300. *
  118301. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  118302. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  118303. */
  118304. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  118305. min: Vector3;
  118306. max: Vector3;
  118307. };
  118308. /**
  118309. * Creates a ray that can be used to pick in the scene
  118310. * @param x defines the x coordinate of the origin (on-screen)
  118311. * @param y defines the y coordinate of the origin (on-screen)
  118312. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  118313. * @param camera defines the camera to use for the picking
  118314. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  118315. * @returns a Ray
  118316. */
  118317. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  118318. /**
  118319. * Creates a ray that can be used to pick in the scene
  118320. * @param x defines the x coordinate of the origin (on-screen)
  118321. * @param y defines the y coordinate of the origin (on-screen)
  118322. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  118323. * @param result defines the ray where to store the picking ray
  118324. * @param camera defines the camera to use for the picking
  118325. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  118326. * @returns the current scene
  118327. */
  118328. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  118329. /**
  118330. * Creates a ray that can be used to pick in the scene
  118331. * @param x defines the x coordinate of the origin (on-screen)
  118332. * @param y defines the y coordinate of the origin (on-screen)
  118333. * @param camera defines the camera to use for the picking
  118334. * @returns a Ray
  118335. */
  118336. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  118337. /**
  118338. * Creates a ray that can be used to pick in the scene
  118339. * @param x defines the x coordinate of the origin (on-screen)
  118340. * @param y defines the y coordinate of the origin (on-screen)
  118341. * @param result defines the ray where to store the picking ray
  118342. * @param camera defines the camera to use for the picking
  118343. * @returns the current scene
  118344. */
  118345. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  118346. /** Launch a ray to try to pick a mesh in the scene
  118347. * @param x position on screen
  118348. * @param y position on screen
  118349. * @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
  118350. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118351. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118352. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118353. * @returns a PickingInfo
  118354. */
  118355. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  118356. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  118357. * @param x position on screen
  118358. * @param y position on screen
  118359. * @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
  118360. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118361. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118362. * @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)
  118363. */
  118364. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  118365. /** Use the given ray to pick a mesh in the scene
  118366. * @param ray The ray to use to pick meshes
  118367. * @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
  118368. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118369. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118370. * @returns a PickingInfo
  118371. */
  118372. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  118373. /**
  118374. * Launch a ray to try to pick a mesh in the scene
  118375. * @param x X position on screen
  118376. * @param y Y position on screen
  118377. * @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
  118378. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118379. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118380. * @returns an array of PickingInfo
  118381. */
  118382. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  118383. /**
  118384. * Launch a ray to try to pick a mesh in the scene
  118385. * @param ray Ray to use
  118386. * @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
  118387. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118388. * @returns an array of PickingInfo
  118389. */
  118390. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  118391. /**
  118392. * Force the value of meshUnderPointer
  118393. * @param mesh defines the mesh to use
  118394. */
  118395. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  118396. /**
  118397. * Gets the mesh under the pointer
  118398. * @returns a Mesh or null if no mesh is under the pointer
  118399. */
  118400. getPointerOverMesh(): Nullable<AbstractMesh>;
  118401. /** @hidden */
  118402. _rebuildGeometries(): void;
  118403. /** @hidden */
  118404. _rebuildTextures(): void;
  118405. private _getByTags;
  118406. /**
  118407. * Get a list of meshes by tags
  118408. * @param tagsQuery defines the tags query to use
  118409. * @param forEach defines a predicate used to filter results
  118410. * @returns an array of Mesh
  118411. */
  118412. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  118413. /**
  118414. * Get a list of cameras by tags
  118415. * @param tagsQuery defines the tags query to use
  118416. * @param forEach defines a predicate used to filter results
  118417. * @returns an array of Camera
  118418. */
  118419. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  118420. /**
  118421. * Get a list of lights by tags
  118422. * @param tagsQuery defines the tags query to use
  118423. * @param forEach defines a predicate used to filter results
  118424. * @returns an array of Light
  118425. */
  118426. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  118427. /**
  118428. * Get a list of materials by tags
  118429. * @param tagsQuery defines the tags query to use
  118430. * @param forEach defines a predicate used to filter results
  118431. * @returns an array of Material
  118432. */
  118433. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  118434. /**
  118435. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  118436. * This allowed control for front to back rendering or reversly depending of the special needs.
  118437. *
  118438. * @param renderingGroupId The rendering group id corresponding to its index
  118439. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  118440. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  118441. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  118442. */
  118443. 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;
  118444. /**
  118445. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  118446. *
  118447. * @param renderingGroupId The rendering group id corresponding to its index
  118448. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118449. * @param depth Automatically clears depth between groups if true and autoClear is true.
  118450. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  118451. */
  118452. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  118453. /**
  118454. * Gets the current auto clear configuration for one rendering group of the rendering
  118455. * manager.
  118456. * @param index the rendering group index to get the information for
  118457. * @returns The auto clear setup for the requested rendering group
  118458. */
  118459. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  118460. private _blockMaterialDirtyMechanism;
  118461. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  118462. get blockMaterialDirtyMechanism(): boolean;
  118463. set blockMaterialDirtyMechanism(value: boolean);
  118464. /**
  118465. * Will flag all materials as dirty to trigger new shader compilation
  118466. * @param flag defines the flag used to specify which material part must be marked as dirty
  118467. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  118468. */
  118469. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  118470. /** @hidden */
  118471. _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;
  118472. /** @hidden */
  118473. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118474. /** @hidden */
  118475. _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;
  118476. /** @hidden */
  118477. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  118478. /** @hidden */
  118479. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118480. /** @hidden */
  118481. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118482. }
  118483. }
  118484. declare module BABYLON {
  118485. /**
  118486. * Set of assets to keep when moving a scene into an asset container.
  118487. */
  118488. export class KeepAssets extends AbstractScene {
  118489. }
  118490. /**
  118491. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  118492. */
  118493. export class InstantiatedEntries {
  118494. /**
  118495. * List of new root nodes (eg. nodes with no parent)
  118496. */
  118497. rootNodes: TransformNode[];
  118498. /**
  118499. * List of new skeletons
  118500. */
  118501. skeletons: Skeleton[];
  118502. /**
  118503. * List of new animation groups
  118504. */
  118505. animationGroups: AnimationGroup[];
  118506. }
  118507. /**
  118508. * Container with a set of assets that can be added or removed from a scene.
  118509. */
  118510. export class AssetContainer extends AbstractScene {
  118511. private _wasAddedToScene;
  118512. /**
  118513. * The scene the AssetContainer belongs to.
  118514. */
  118515. scene: Scene;
  118516. /**
  118517. * Instantiates an AssetContainer.
  118518. * @param scene The scene the AssetContainer belongs to.
  118519. */
  118520. constructor(scene: Scene);
  118521. /**
  118522. * Instantiate or clone all meshes and add the new ones to the scene.
  118523. * Skeletons and animation groups will all be cloned
  118524. * @param nameFunction defines an optional function used to get new names for clones
  118525. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  118526. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  118527. */
  118528. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  118529. /**
  118530. * Adds all the assets from the container to the scene.
  118531. */
  118532. addAllToScene(): void;
  118533. /**
  118534. * Removes all the assets in the container from the scene
  118535. */
  118536. removeAllFromScene(): void;
  118537. /**
  118538. * Disposes all the assets in the container
  118539. */
  118540. dispose(): void;
  118541. private _moveAssets;
  118542. /**
  118543. * Removes all the assets contained in the scene and adds them to the container.
  118544. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  118545. */
  118546. moveAllFromScene(keepAssets?: KeepAssets): void;
  118547. /**
  118548. * 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.
  118549. * @returns the root mesh
  118550. */
  118551. createRootMesh(): Mesh;
  118552. /**
  118553. * Merge animations (direct and animation groups) from this asset container into a scene
  118554. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118555. * @param animatables set of animatables to retarget to a node from the scene
  118556. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  118557. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  118558. */
  118559. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  118560. }
  118561. }
  118562. declare module BABYLON {
  118563. /**
  118564. * Defines how the parser contract is defined.
  118565. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  118566. */
  118567. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  118568. /**
  118569. * Defines how the individual parser contract is defined.
  118570. * These parser can parse an individual asset
  118571. */
  118572. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  118573. /**
  118574. * Base class of the scene acting as a container for the different elements composing a scene.
  118575. * This class is dynamically extended by the different components of the scene increasing
  118576. * flexibility and reducing coupling
  118577. */
  118578. export abstract class AbstractScene {
  118579. /**
  118580. * Stores the list of available parsers in the application.
  118581. */
  118582. private static _BabylonFileParsers;
  118583. /**
  118584. * Stores the list of available individual parsers in the application.
  118585. */
  118586. private static _IndividualBabylonFileParsers;
  118587. /**
  118588. * Adds a parser in the list of available ones
  118589. * @param name Defines the name of the parser
  118590. * @param parser Defines the parser to add
  118591. */
  118592. static AddParser(name: string, parser: BabylonFileParser): void;
  118593. /**
  118594. * Gets a general parser from the list of avaialble ones
  118595. * @param name Defines the name of the parser
  118596. * @returns the requested parser or null
  118597. */
  118598. static GetParser(name: string): Nullable<BabylonFileParser>;
  118599. /**
  118600. * Adds n individual parser in the list of available ones
  118601. * @param name Defines the name of the parser
  118602. * @param parser Defines the parser to add
  118603. */
  118604. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  118605. /**
  118606. * Gets an individual parser from the list of avaialble ones
  118607. * @param name Defines the name of the parser
  118608. * @returns the requested parser or null
  118609. */
  118610. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  118611. /**
  118612. * Parser json data and populate both a scene and its associated container object
  118613. * @param jsonData Defines the data to parse
  118614. * @param scene Defines the scene to parse the data for
  118615. * @param container Defines the container attached to the parsing sequence
  118616. * @param rootUrl Defines the root url of the data
  118617. */
  118618. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  118619. /**
  118620. * Gets the list of root nodes (ie. nodes with no parent)
  118621. */
  118622. rootNodes: Node[];
  118623. /** All of the cameras added to this scene
  118624. * @see https://doc.babylonjs.com/babylon101/cameras
  118625. */
  118626. cameras: Camera[];
  118627. /**
  118628. * All of the lights added to this scene
  118629. * @see https://doc.babylonjs.com/babylon101/lights
  118630. */
  118631. lights: Light[];
  118632. /**
  118633. * All of the (abstract) meshes added to this scene
  118634. */
  118635. meshes: AbstractMesh[];
  118636. /**
  118637. * The list of skeletons added to the scene
  118638. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  118639. */
  118640. skeletons: Skeleton[];
  118641. /**
  118642. * All of the particle systems added to this scene
  118643. * @see https://doc.babylonjs.com/babylon101/particles
  118644. */
  118645. particleSystems: IParticleSystem[];
  118646. /**
  118647. * Gets a list of Animations associated with the scene
  118648. */
  118649. animations: Animation[];
  118650. /**
  118651. * All of the animation groups added to this scene
  118652. * @see https://doc.babylonjs.com/how_to/group
  118653. */
  118654. animationGroups: AnimationGroup[];
  118655. /**
  118656. * All of the multi-materials added to this scene
  118657. * @see https://doc.babylonjs.com/how_to/multi_materials
  118658. */
  118659. multiMaterials: MultiMaterial[];
  118660. /**
  118661. * All of the materials added to this scene
  118662. * In the context of a Scene, it is not supposed to be modified manually.
  118663. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  118664. * Note also that the order of the Material within the array is not significant and might change.
  118665. * @see https://doc.babylonjs.com/babylon101/materials
  118666. */
  118667. materials: Material[];
  118668. /**
  118669. * The list of morph target managers added to the scene
  118670. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  118671. */
  118672. morphTargetManagers: MorphTargetManager[];
  118673. /**
  118674. * The list of geometries used in the scene.
  118675. */
  118676. geometries: Geometry[];
  118677. /**
  118678. * All of the tranform nodes added to this scene
  118679. * In the context of a Scene, it is not supposed to be modified manually.
  118680. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  118681. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  118682. * @see https://doc.babylonjs.com/how_to/transformnode
  118683. */
  118684. transformNodes: TransformNode[];
  118685. /**
  118686. * ActionManagers available on the scene.
  118687. */
  118688. actionManagers: AbstractActionManager[];
  118689. /**
  118690. * Textures to keep.
  118691. */
  118692. textures: BaseTexture[];
  118693. /**
  118694. * Environment texture for the scene
  118695. */
  118696. environmentTexture: Nullable<BaseTexture>;
  118697. /**
  118698. * @returns all meshes, lights, cameras, transformNodes and bones
  118699. */
  118700. getNodes(): Array<Node>;
  118701. }
  118702. }
  118703. declare module BABYLON {
  118704. /**
  118705. * Interface used to define options for Sound class
  118706. */
  118707. export interface ISoundOptions {
  118708. /**
  118709. * Does the sound autoplay once loaded.
  118710. */
  118711. autoplay?: boolean;
  118712. /**
  118713. * Does the sound loop after it finishes playing once.
  118714. */
  118715. loop?: boolean;
  118716. /**
  118717. * Sound's volume
  118718. */
  118719. volume?: number;
  118720. /**
  118721. * Is it a spatial sound?
  118722. */
  118723. spatialSound?: boolean;
  118724. /**
  118725. * Maximum distance to hear that sound
  118726. */
  118727. maxDistance?: number;
  118728. /**
  118729. * Uses user defined attenuation function
  118730. */
  118731. useCustomAttenuation?: boolean;
  118732. /**
  118733. * Define the roll off factor of spatial sounds.
  118734. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118735. */
  118736. rolloffFactor?: number;
  118737. /**
  118738. * Define the reference distance the sound should be heard perfectly.
  118739. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118740. */
  118741. refDistance?: number;
  118742. /**
  118743. * Define the distance attenuation model the sound will follow.
  118744. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118745. */
  118746. distanceModel?: string;
  118747. /**
  118748. * Defines the playback speed (1 by default)
  118749. */
  118750. playbackRate?: number;
  118751. /**
  118752. * Defines if the sound is from a streaming source
  118753. */
  118754. streaming?: boolean;
  118755. /**
  118756. * Defines an optional length (in seconds) inside the sound file
  118757. */
  118758. length?: number;
  118759. /**
  118760. * Defines an optional offset (in seconds) inside the sound file
  118761. */
  118762. offset?: number;
  118763. /**
  118764. * If true, URLs will not be required to state the audio file codec to use.
  118765. */
  118766. skipCodecCheck?: boolean;
  118767. }
  118768. /**
  118769. * Defines a sound that can be played in the application.
  118770. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  118771. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118772. */
  118773. export class Sound {
  118774. /**
  118775. * The name of the sound in the scene.
  118776. */
  118777. name: string;
  118778. /**
  118779. * Does the sound autoplay once loaded.
  118780. */
  118781. autoplay: boolean;
  118782. /**
  118783. * Does the sound loop after it finishes playing once.
  118784. */
  118785. loop: boolean;
  118786. /**
  118787. * Does the sound use a custom attenuation curve to simulate the falloff
  118788. * happening when the source gets further away from the camera.
  118789. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118790. */
  118791. useCustomAttenuation: boolean;
  118792. /**
  118793. * The sound track id this sound belongs to.
  118794. */
  118795. soundTrackId: number;
  118796. /**
  118797. * Is this sound currently played.
  118798. */
  118799. isPlaying: boolean;
  118800. /**
  118801. * Is this sound currently paused.
  118802. */
  118803. isPaused: boolean;
  118804. /**
  118805. * Does this sound enables spatial sound.
  118806. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118807. */
  118808. spatialSound: boolean;
  118809. /**
  118810. * Define the reference distance the sound should be heard perfectly.
  118811. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118812. */
  118813. refDistance: number;
  118814. /**
  118815. * Define the roll off factor of spatial sounds.
  118816. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118817. */
  118818. rolloffFactor: number;
  118819. /**
  118820. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  118821. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118822. */
  118823. maxDistance: number;
  118824. /**
  118825. * Define the distance attenuation model the sound will follow.
  118826. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118827. */
  118828. distanceModel: string;
  118829. /**
  118830. * @hidden
  118831. * Back Compat
  118832. **/
  118833. onended: () => any;
  118834. /**
  118835. * Gets or sets an object used to store user defined information for the sound.
  118836. */
  118837. metadata: any;
  118838. /**
  118839. * Observable event when the current playing sound finishes.
  118840. */
  118841. onEndedObservable: Observable<Sound>;
  118842. private _panningModel;
  118843. private _playbackRate;
  118844. private _streaming;
  118845. private _startTime;
  118846. private _startOffset;
  118847. private _position;
  118848. /** @hidden */
  118849. _positionInEmitterSpace: boolean;
  118850. private _localDirection;
  118851. private _volume;
  118852. private _isReadyToPlay;
  118853. private _isDirectional;
  118854. private _readyToPlayCallback;
  118855. private _audioBuffer;
  118856. private _soundSource;
  118857. private _streamingSource;
  118858. private _soundPanner;
  118859. private _soundGain;
  118860. private _inputAudioNode;
  118861. private _outputAudioNode;
  118862. private _coneInnerAngle;
  118863. private _coneOuterAngle;
  118864. private _coneOuterGain;
  118865. private _scene;
  118866. private _connectedTransformNode;
  118867. private _customAttenuationFunction;
  118868. private _registerFunc;
  118869. private _isOutputConnected;
  118870. private _htmlAudioElement;
  118871. private _urlType;
  118872. private _length?;
  118873. private _offset?;
  118874. /** @hidden */
  118875. static _SceneComponentInitialization: (scene: Scene) => void;
  118876. /**
  118877. * Create a sound and attach it to a scene
  118878. * @param name Name of your sound
  118879. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  118880. * @param scene defines the scene the sound belongs to
  118881. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  118882. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  118883. */
  118884. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  118885. /**
  118886. * Release the sound and its associated resources
  118887. */
  118888. dispose(): void;
  118889. /**
  118890. * Gets if the sounds is ready to be played or not.
  118891. * @returns true if ready, otherwise false
  118892. */
  118893. isReady(): boolean;
  118894. private _soundLoaded;
  118895. /**
  118896. * Sets the data of the sound from an audiobuffer
  118897. * @param audioBuffer The audioBuffer containing the data
  118898. */
  118899. setAudioBuffer(audioBuffer: AudioBuffer): void;
  118900. /**
  118901. * Updates the current sounds options such as maxdistance, loop...
  118902. * @param options A JSON object containing values named as the object properties
  118903. */
  118904. updateOptions(options: ISoundOptions): void;
  118905. private _createSpatialParameters;
  118906. private _updateSpatialParameters;
  118907. /**
  118908. * Switch the panning model to HRTF:
  118909. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118910. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118911. */
  118912. switchPanningModelToHRTF(): void;
  118913. /**
  118914. * Switch the panning model to Equal Power:
  118915. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118916. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118917. */
  118918. switchPanningModelToEqualPower(): void;
  118919. private _switchPanningModel;
  118920. /**
  118921. * Connect this sound to a sound track audio node like gain...
  118922. * @param soundTrackAudioNode the sound track audio node to connect to
  118923. */
  118924. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  118925. /**
  118926. * Transform this sound into a directional source
  118927. * @param coneInnerAngle Size of the inner cone in degree
  118928. * @param coneOuterAngle Size of the outer cone in degree
  118929. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  118930. */
  118931. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  118932. /**
  118933. * Gets or sets the inner angle for the directional cone.
  118934. */
  118935. get directionalConeInnerAngle(): number;
  118936. /**
  118937. * Gets or sets the inner angle for the directional cone.
  118938. */
  118939. set directionalConeInnerAngle(value: number);
  118940. /**
  118941. * Gets or sets the outer angle for the directional cone.
  118942. */
  118943. get directionalConeOuterAngle(): number;
  118944. /**
  118945. * Gets or sets the outer angle for the directional cone.
  118946. */
  118947. set directionalConeOuterAngle(value: number);
  118948. /**
  118949. * Sets the position of the emitter if spatial sound is enabled
  118950. * @param newPosition Defines the new posisiton
  118951. */
  118952. setPosition(newPosition: Vector3): void;
  118953. /**
  118954. * Sets the local direction of the emitter if spatial sound is enabled
  118955. * @param newLocalDirection Defines the new local direction
  118956. */
  118957. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  118958. private _updateDirection;
  118959. /** @hidden */
  118960. updateDistanceFromListener(): void;
  118961. /**
  118962. * Sets a new custom attenuation function for the sound.
  118963. * @param callback Defines the function used for the attenuation
  118964. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118965. */
  118966. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  118967. /**
  118968. * Play the sound
  118969. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  118970. * @param offset (optional) Start the sound at a specific time in seconds
  118971. * @param length (optional) Sound duration (in seconds)
  118972. */
  118973. play(time?: number, offset?: number, length?: number): void;
  118974. private _onended;
  118975. /**
  118976. * Stop the sound
  118977. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  118978. */
  118979. stop(time?: number): void;
  118980. /**
  118981. * Put the sound in pause
  118982. */
  118983. pause(): void;
  118984. /**
  118985. * Sets a dedicated volume for this sounds
  118986. * @param newVolume Define the new volume of the sound
  118987. * @param time Define time for gradual change to new volume
  118988. */
  118989. setVolume(newVolume: number, time?: number): void;
  118990. /**
  118991. * Set the sound play back rate
  118992. * @param newPlaybackRate Define the playback rate the sound should be played at
  118993. */
  118994. setPlaybackRate(newPlaybackRate: number): void;
  118995. /**
  118996. * Gets the volume of the sound.
  118997. * @returns the volume of the sound
  118998. */
  118999. getVolume(): number;
  119000. /**
  119001. * Attach the sound to a dedicated mesh
  119002. * @param transformNode The transform node to connect the sound with
  119003. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  119004. */
  119005. attachToMesh(transformNode: TransformNode): void;
  119006. /**
  119007. * Detach the sound from the previously attached mesh
  119008. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  119009. */
  119010. detachFromMesh(): void;
  119011. private _onRegisterAfterWorldMatrixUpdate;
  119012. /**
  119013. * Clone the current sound in the scene.
  119014. * @returns the new sound clone
  119015. */
  119016. clone(): Nullable<Sound>;
  119017. /**
  119018. * Gets the current underlying audio buffer containing the data
  119019. * @returns the audio buffer
  119020. */
  119021. getAudioBuffer(): Nullable<AudioBuffer>;
  119022. /**
  119023. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  119024. * @returns the source node
  119025. */
  119026. getSoundSource(): Nullable<AudioBufferSourceNode>;
  119027. /**
  119028. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  119029. * @returns the gain node
  119030. */
  119031. getSoundGain(): Nullable<GainNode>;
  119032. /**
  119033. * Serializes the Sound in a JSON representation
  119034. * @returns the JSON representation of the sound
  119035. */
  119036. serialize(): any;
  119037. /**
  119038. * Parse a JSON representation of a sound to innstantiate in a given scene
  119039. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  119040. * @param scene Define the scene the new parsed sound should be created in
  119041. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  119042. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  119043. * @returns the newly parsed sound
  119044. */
  119045. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  119046. }
  119047. }
  119048. declare module BABYLON {
  119049. /**
  119050. * This defines an action helpful to play a defined sound on a triggered action.
  119051. */
  119052. export class PlaySoundAction extends Action {
  119053. private _sound;
  119054. /**
  119055. * Instantiate the action
  119056. * @param triggerOptions defines the trigger options
  119057. * @param sound defines the sound to play
  119058. * @param condition defines the trigger related conditions
  119059. */
  119060. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  119061. /** @hidden */
  119062. _prepare(): void;
  119063. /**
  119064. * Execute the action and play the sound.
  119065. */
  119066. execute(): void;
  119067. /**
  119068. * Serializes the actions and its related information.
  119069. * @param parent defines the object to serialize in
  119070. * @returns the serialized object
  119071. */
  119072. serialize(parent: any): any;
  119073. }
  119074. /**
  119075. * This defines an action helpful to stop a defined sound on a triggered action.
  119076. */
  119077. export class StopSoundAction extends Action {
  119078. private _sound;
  119079. /**
  119080. * Instantiate the action
  119081. * @param triggerOptions defines the trigger options
  119082. * @param sound defines the sound to stop
  119083. * @param condition defines the trigger related conditions
  119084. */
  119085. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  119086. /** @hidden */
  119087. _prepare(): void;
  119088. /**
  119089. * Execute the action and stop the sound.
  119090. */
  119091. execute(): void;
  119092. /**
  119093. * Serializes the actions and its related information.
  119094. * @param parent defines the object to serialize in
  119095. * @returns the serialized object
  119096. */
  119097. serialize(parent: any): any;
  119098. }
  119099. }
  119100. declare module BABYLON {
  119101. /**
  119102. * This defines an action responsible to change the value of a property
  119103. * by interpolating between its current value and the newly set one once triggered.
  119104. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  119105. */
  119106. export class InterpolateValueAction extends Action {
  119107. /**
  119108. * Defines the path of the property where the value should be interpolated
  119109. */
  119110. propertyPath: string;
  119111. /**
  119112. * Defines the target value at the end of the interpolation.
  119113. */
  119114. value: any;
  119115. /**
  119116. * Defines the time it will take for the property to interpolate to the value.
  119117. */
  119118. duration: number;
  119119. /**
  119120. * Defines if the other scene animations should be stopped when the action has been triggered
  119121. */
  119122. stopOtherAnimations?: boolean;
  119123. /**
  119124. * Defines a callback raised once the interpolation animation has been done.
  119125. */
  119126. onInterpolationDone?: () => void;
  119127. /**
  119128. * Observable triggered once the interpolation animation has been done.
  119129. */
  119130. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  119131. private _target;
  119132. private _effectiveTarget;
  119133. private _property;
  119134. /**
  119135. * Instantiate the action
  119136. * @param triggerOptions defines the trigger options
  119137. * @param target defines the object containing the value to interpolate
  119138. * @param propertyPath defines the path to the property in the target object
  119139. * @param value defines the target value at the end of the interpolation
  119140. * @param duration deines the time it will take for the property to interpolate to the value.
  119141. * @param condition defines the trigger related conditions
  119142. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  119143. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  119144. */
  119145. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  119146. /** @hidden */
  119147. _prepare(): void;
  119148. /**
  119149. * Execute the action starts the value interpolation.
  119150. */
  119151. execute(): void;
  119152. /**
  119153. * Serializes the actions and its related information.
  119154. * @param parent defines the object to serialize in
  119155. * @returns the serialized object
  119156. */
  119157. serialize(parent: any): any;
  119158. }
  119159. }
  119160. declare module BABYLON {
  119161. /**
  119162. * Options allowed during the creation of a sound track.
  119163. */
  119164. export interface ISoundTrackOptions {
  119165. /**
  119166. * The volume the sound track should take during creation
  119167. */
  119168. volume?: number;
  119169. /**
  119170. * Define if the sound track is the main sound track of the scene
  119171. */
  119172. mainTrack?: boolean;
  119173. }
  119174. /**
  119175. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  119176. * It will be also used in a future release to apply effects on a specific track.
  119177. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  119178. */
  119179. export class SoundTrack {
  119180. /**
  119181. * The unique identifier of the sound track in the scene.
  119182. */
  119183. id: number;
  119184. /**
  119185. * The list of sounds included in the sound track.
  119186. */
  119187. soundCollection: Array<Sound>;
  119188. private _outputAudioNode;
  119189. private _scene;
  119190. private _connectedAnalyser;
  119191. private _options;
  119192. private _isInitialized;
  119193. /**
  119194. * Creates a new sound track.
  119195. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  119196. * @param scene Define the scene the sound track belongs to
  119197. * @param options
  119198. */
  119199. constructor(scene: Scene, options?: ISoundTrackOptions);
  119200. private _initializeSoundTrackAudioGraph;
  119201. /**
  119202. * Release the sound track and its associated resources
  119203. */
  119204. dispose(): void;
  119205. /**
  119206. * Adds a sound to this sound track
  119207. * @param sound define the cound to add
  119208. * @ignoreNaming
  119209. */
  119210. AddSound(sound: Sound): void;
  119211. /**
  119212. * Removes a sound to this sound track
  119213. * @param sound define the cound to remove
  119214. * @ignoreNaming
  119215. */
  119216. RemoveSound(sound: Sound): void;
  119217. /**
  119218. * Set a global volume for the full sound track.
  119219. * @param newVolume Define the new volume of the sound track
  119220. */
  119221. setVolume(newVolume: number): void;
  119222. /**
  119223. * Switch the panning model to HRTF:
  119224. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  119225. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119226. */
  119227. switchPanningModelToHRTF(): void;
  119228. /**
  119229. * Switch the panning model to Equal Power:
  119230. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  119231. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119232. */
  119233. switchPanningModelToEqualPower(): void;
  119234. /**
  119235. * Connect the sound track to an audio analyser allowing some amazing
  119236. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  119237. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  119238. * @param analyser The analyser to connect to the engine
  119239. */
  119240. connectToAnalyser(analyser: Analyser): void;
  119241. }
  119242. }
  119243. declare module BABYLON {
  119244. interface AbstractScene {
  119245. /**
  119246. * The list of sounds used in the scene.
  119247. */
  119248. sounds: Nullable<Array<Sound>>;
  119249. }
  119250. interface Scene {
  119251. /**
  119252. * @hidden
  119253. * Backing field
  119254. */
  119255. _mainSoundTrack: SoundTrack;
  119256. /**
  119257. * The main sound track played by the scene.
  119258. * It cotains your primary collection of sounds.
  119259. */
  119260. mainSoundTrack: SoundTrack;
  119261. /**
  119262. * The list of sound tracks added to the scene
  119263. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119264. */
  119265. soundTracks: Nullable<Array<SoundTrack>>;
  119266. /**
  119267. * Gets a sound using a given name
  119268. * @param name defines the name to search for
  119269. * @return the found sound or null if not found at all.
  119270. */
  119271. getSoundByName(name: string): Nullable<Sound>;
  119272. /**
  119273. * Gets or sets if audio support is enabled
  119274. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119275. */
  119276. audioEnabled: boolean;
  119277. /**
  119278. * Gets or sets if audio will be output to headphones
  119279. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119280. */
  119281. headphone: boolean;
  119282. /**
  119283. * Gets or sets custom audio listener position provider
  119284. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119285. */
  119286. audioListenerPositionProvider: Nullable<() => Vector3>;
  119287. /**
  119288. * Gets or sets a refresh rate when using 3D audio positioning
  119289. */
  119290. audioPositioningRefreshRate: number;
  119291. }
  119292. /**
  119293. * Defines the sound scene component responsible to manage any sounds
  119294. * in a given scene.
  119295. */
  119296. export class AudioSceneComponent implements ISceneSerializableComponent {
  119297. /**
  119298. * The component name helpfull to identify the component in the list of scene components.
  119299. */
  119300. readonly name: string;
  119301. /**
  119302. * The scene the component belongs to.
  119303. */
  119304. scene: Scene;
  119305. private _audioEnabled;
  119306. /**
  119307. * Gets whether audio is enabled or not.
  119308. * Please use related enable/disable method to switch state.
  119309. */
  119310. get audioEnabled(): boolean;
  119311. private _headphone;
  119312. /**
  119313. * Gets whether audio is outputing to headphone or not.
  119314. * Please use the according Switch methods to change output.
  119315. */
  119316. get headphone(): boolean;
  119317. /**
  119318. * Gets or sets a refresh rate when using 3D audio positioning
  119319. */
  119320. audioPositioningRefreshRate: number;
  119321. private _audioListenerPositionProvider;
  119322. /**
  119323. * Gets the current audio listener position provider
  119324. */
  119325. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  119326. /**
  119327. * Sets a custom listener position for all sounds in the scene
  119328. * By default, this is the position of the first active camera
  119329. */
  119330. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  119331. /**
  119332. * Creates a new instance of the component for the given scene
  119333. * @param scene Defines the scene to register the component in
  119334. */
  119335. constructor(scene: Scene);
  119336. /**
  119337. * Registers the component in a given scene
  119338. */
  119339. register(): void;
  119340. /**
  119341. * Rebuilds the elements related to this component in case of
  119342. * context lost for instance.
  119343. */
  119344. rebuild(): void;
  119345. /**
  119346. * Serializes the component data to the specified json object
  119347. * @param serializationObject The object to serialize to
  119348. */
  119349. serialize(serializationObject: any): void;
  119350. /**
  119351. * Adds all the elements from the container to the scene
  119352. * @param container the container holding the elements
  119353. */
  119354. addFromContainer(container: AbstractScene): void;
  119355. /**
  119356. * Removes all the elements in the container from the scene
  119357. * @param container contains the elements to remove
  119358. * @param dispose if the removed element should be disposed (default: false)
  119359. */
  119360. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119361. /**
  119362. * Disposes the component and the associated ressources.
  119363. */
  119364. dispose(): void;
  119365. /**
  119366. * Disables audio in the associated scene.
  119367. */
  119368. disableAudio(): void;
  119369. /**
  119370. * Enables audio in the associated scene.
  119371. */
  119372. enableAudio(): void;
  119373. /**
  119374. * Switch audio to headphone output.
  119375. */
  119376. switchAudioModeForHeadphones(): void;
  119377. /**
  119378. * Switch audio to normal speakers.
  119379. */
  119380. switchAudioModeForNormalSpeakers(): void;
  119381. private _cachedCameraDirection;
  119382. private _cachedCameraPosition;
  119383. private _lastCheck;
  119384. private _afterRender;
  119385. }
  119386. }
  119387. declare module BABYLON {
  119388. /**
  119389. * Wraps one or more Sound objects and selects one with random weight for playback.
  119390. */
  119391. export class WeightedSound {
  119392. /** When true a Sound will be selected and played when the current playing Sound completes. */
  119393. loop: boolean;
  119394. private _coneInnerAngle;
  119395. private _coneOuterAngle;
  119396. private _volume;
  119397. /** A Sound is currently playing. */
  119398. isPlaying: boolean;
  119399. /** A Sound is currently paused. */
  119400. isPaused: boolean;
  119401. private _sounds;
  119402. private _weights;
  119403. private _currentIndex?;
  119404. /**
  119405. * Creates a new WeightedSound from the list of sounds given.
  119406. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  119407. * @param sounds Array of Sounds that will be selected from.
  119408. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  119409. */
  119410. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  119411. /**
  119412. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  119413. */
  119414. get directionalConeInnerAngle(): number;
  119415. /**
  119416. * The size of cone in degress for a directional sound in which there will be no attenuation.
  119417. */
  119418. set directionalConeInnerAngle(value: number);
  119419. /**
  119420. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119421. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119422. */
  119423. get directionalConeOuterAngle(): number;
  119424. /**
  119425. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119426. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119427. */
  119428. set directionalConeOuterAngle(value: number);
  119429. /**
  119430. * Playback volume.
  119431. */
  119432. get volume(): number;
  119433. /**
  119434. * Playback volume.
  119435. */
  119436. set volume(value: number);
  119437. private _onended;
  119438. /**
  119439. * Suspend playback
  119440. */
  119441. pause(): void;
  119442. /**
  119443. * Stop playback
  119444. */
  119445. stop(): void;
  119446. /**
  119447. * Start playback.
  119448. * @param startOffset Position the clip head at a specific time in seconds.
  119449. */
  119450. play(startOffset?: number): void;
  119451. }
  119452. }
  119453. declare module BABYLON {
  119454. /**
  119455. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  119456. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119457. */
  119458. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  119459. /**
  119460. * Gets the name of the behavior.
  119461. */
  119462. get name(): string;
  119463. /**
  119464. * The easing function used by animations
  119465. */
  119466. static EasingFunction: BackEase;
  119467. /**
  119468. * The easing mode used by animations
  119469. */
  119470. static EasingMode: number;
  119471. /**
  119472. * The duration of the animation, in milliseconds
  119473. */
  119474. transitionDuration: number;
  119475. /**
  119476. * Length of the distance animated by the transition when lower radius is reached
  119477. */
  119478. lowerRadiusTransitionRange: number;
  119479. /**
  119480. * Length of the distance animated by the transition when upper radius is reached
  119481. */
  119482. upperRadiusTransitionRange: number;
  119483. private _autoTransitionRange;
  119484. /**
  119485. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119486. */
  119487. get autoTransitionRange(): boolean;
  119488. /**
  119489. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119490. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  119491. */
  119492. set autoTransitionRange(value: boolean);
  119493. private _attachedCamera;
  119494. private _onAfterCheckInputsObserver;
  119495. private _onMeshTargetChangedObserver;
  119496. /**
  119497. * Initializes the behavior.
  119498. */
  119499. init(): void;
  119500. /**
  119501. * Attaches the behavior to its arc rotate camera.
  119502. * @param camera Defines the camera to attach the behavior to
  119503. */
  119504. attach(camera: ArcRotateCamera): void;
  119505. /**
  119506. * Detaches the behavior from its current arc rotate camera.
  119507. */
  119508. detach(): void;
  119509. private _radiusIsAnimating;
  119510. private _radiusBounceTransition;
  119511. private _animatables;
  119512. private _cachedWheelPrecision;
  119513. /**
  119514. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  119515. * @param radiusLimit The limit to check against.
  119516. * @return Bool to indicate if at limit.
  119517. */
  119518. private _isRadiusAtLimit;
  119519. /**
  119520. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  119521. * @param radiusDelta The delta by which to animate to. Can be negative.
  119522. */
  119523. private _applyBoundRadiusAnimation;
  119524. /**
  119525. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  119526. */
  119527. protected _clearAnimationLocks(): void;
  119528. /**
  119529. * Stops and removes all animations that have been applied to the camera
  119530. */
  119531. stopAllAnimations(): void;
  119532. }
  119533. }
  119534. declare module BABYLON {
  119535. /**
  119536. * 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.
  119537. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119538. */
  119539. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  119540. /**
  119541. * Gets the name of the behavior.
  119542. */
  119543. get name(): string;
  119544. private _mode;
  119545. private _radiusScale;
  119546. private _positionScale;
  119547. private _defaultElevation;
  119548. private _elevationReturnTime;
  119549. private _elevationReturnWaitTime;
  119550. private _zoomStopsAnimation;
  119551. private _framingTime;
  119552. /**
  119553. * The easing function used by animations
  119554. */
  119555. static EasingFunction: ExponentialEase;
  119556. /**
  119557. * The easing mode used by animations
  119558. */
  119559. static EasingMode: number;
  119560. /**
  119561. * Sets the current mode used by the behavior
  119562. */
  119563. set mode(mode: number);
  119564. /**
  119565. * Gets current mode used by the behavior.
  119566. */
  119567. get mode(): number;
  119568. /**
  119569. * Sets the scale applied to the radius (1 by default)
  119570. */
  119571. set radiusScale(radius: number);
  119572. /**
  119573. * Gets the scale applied to the radius
  119574. */
  119575. get radiusScale(): number;
  119576. /**
  119577. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119578. */
  119579. set positionScale(scale: number);
  119580. /**
  119581. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119582. */
  119583. get positionScale(): number;
  119584. /**
  119585. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119586. * behaviour is triggered, in radians.
  119587. */
  119588. set defaultElevation(elevation: number);
  119589. /**
  119590. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119591. * behaviour is triggered, in radians.
  119592. */
  119593. get defaultElevation(): number;
  119594. /**
  119595. * Sets the time (in milliseconds) taken to return to the default beta position.
  119596. * Negative value indicates camera should not return to default.
  119597. */
  119598. set elevationReturnTime(speed: number);
  119599. /**
  119600. * Gets the time (in milliseconds) taken to return to the default beta position.
  119601. * Negative value indicates camera should not return to default.
  119602. */
  119603. get elevationReturnTime(): number;
  119604. /**
  119605. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119606. */
  119607. set elevationReturnWaitTime(time: number);
  119608. /**
  119609. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119610. */
  119611. get elevationReturnWaitTime(): number;
  119612. /**
  119613. * Sets the flag that indicates if user zooming should stop animation.
  119614. */
  119615. set zoomStopsAnimation(flag: boolean);
  119616. /**
  119617. * Gets the flag that indicates if user zooming should stop animation.
  119618. */
  119619. get zoomStopsAnimation(): boolean;
  119620. /**
  119621. * Sets the transition time when framing the mesh, in milliseconds
  119622. */
  119623. set framingTime(time: number);
  119624. /**
  119625. * Gets the transition time when framing the mesh, in milliseconds
  119626. */
  119627. get framingTime(): number;
  119628. /**
  119629. * Define if the behavior should automatically change the configured
  119630. * camera limits and sensibilities.
  119631. */
  119632. autoCorrectCameraLimitsAndSensibility: boolean;
  119633. private _onPrePointerObservableObserver;
  119634. private _onAfterCheckInputsObserver;
  119635. private _onMeshTargetChangedObserver;
  119636. private _attachedCamera;
  119637. private _isPointerDown;
  119638. private _lastInteractionTime;
  119639. /**
  119640. * Initializes the behavior.
  119641. */
  119642. init(): void;
  119643. /**
  119644. * Attaches the behavior to its arc rotate camera.
  119645. * @param camera Defines the camera to attach the behavior to
  119646. */
  119647. attach(camera: ArcRotateCamera): void;
  119648. /**
  119649. * Detaches the behavior from its current arc rotate camera.
  119650. */
  119651. detach(): void;
  119652. private _animatables;
  119653. private _betaIsAnimating;
  119654. private _betaTransition;
  119655. private _radiusTransition;
  119656. private _vectorTransition;
  119657. /**
  119658. * Targets the given mesh and updates zoom level accordingly.
  119659. * @param mesh The mesh to target.
  119660. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119661. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119662. */
  119663. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119664. /**
  119665. * Targets the given mesh with its children and updates zoom level accordingly.
  119666. * @param mesh The mesh to target.
  119667. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119668. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119669. */
  119670. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119671. /**
  119672. * Targets the given meshes with their children and updates zoom level accordingly.
  119673. * @param meshes The mesh to target.
  119674. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119675. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119676. */
  119677. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119678. /**
  119679. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  119680. * @param minimumWorld Determines the smaller position of the bounding box extend
  119681. * @param maximumWorld Determines the bigger position of the bounding box extend
  119682. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119683. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119684. */
  119685. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119686. /**
  119687. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  119688. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  119689. * frustum width.
  119690. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  119691. * to fully enclose the mesh in the viewing frustum.
  119692. */
  119693. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  119694. /**
  119695. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  119696. * is automatically returned to its default position (expected to be above ground plane).
  119697. */
  119698. private _maintainCameraAboveGround;
  119699. /**
  119700. * Returns the frustum slope based on the canvas ratio and camera FOV
  119701. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  119702. */
  119703. private _getFrustumSlope;
  119704. /**
  119705. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  119706. */
  119707. private _clearAnimationLocks;
  119708. /**
  119709. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119710. */
  119711. private _applyUserInteraction;
  119712. /**
  119713. * Stops and removes all animations that have been applied to the camera
  119714. */
  119715. stopAllAnimations(): void;
  119716. /**
  119717. * Gets a value indicating if the user is moving the camera
  119718. */
  119719. get isUserIsMoving(): boolean;
  119720. /**
  119721. * The camera can move all the way towards the mesh.
  119722. */
  119723. static IgnoreBoundsSizeMode: number;
  119724. /**
  119725. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  119726. */
  119727. static FitFrustumSidesMode: number;
  119728. }
  119729. }
  119730. declare module BABYLON {
  119731. /**
  119732. * Base class for Camera Pointer Inputs.
  119733. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  119734. * for example usage.
  119735. */
  119736. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  119737. /**
  119738. * Defines the camera the input is attached to.
  119739. */
  119740. abstract camera: Camera;
  119741. /**
  119742. * Whether keyboard modifier keys are pressed at time of last mouse event.
  119743. */
  119744. protected _altKey: boolean;
  119745. protected _ctrlKey: boolean;
  119746. protected _metaKey: boolean;
  119747. protected _shiftKey: boolean;
  119748. /**
  119749. * Which mouse buttons were pressed at time of last mouse event.
  119750. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  119751. */
  119752. protected _buttonsPressed: number;
  119753. /**
  119754. * Defines the buttons associated with the input to handle camera move.
  119755. */
  119756. buttons: number[];
  119757. /**
  119758. * Attach the input controls to a specific dom element to get the input from.
  119759. * @param element Defines the element the controls should be listened from
  119760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119761. */
  119762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119763. /**
  119764. * Detach the current controls from the specified dom element.
  119765. * @param element Defines the element to stop listening the inputs from
  119766. */
  119767. detachControl(element: Nullable<HTMLElement>): void;
  119768. /**
  119769. * Gets the class name of the current input.
  119770. * @returns the class name
  119771. */
  119772. getClassName(): string;
  119773. /**
  119774. * Get the friendly name associated with the input class.
  119775. * @returns the input friendly name
  119776. */
  119777. getSimpleName(): string;
  119778. /**
  119779. * Called on pointer POINTERDOUBLETAP event.
  119780. * Override this method to provide functionality on POINTERDOUBLETAP event.
  119781. */
  119782. protected onDoubleTap(type: string): void;
  119783. /**
  119784. * Called on pointer POINTERMOVE event if only a single touch is active.
  119785. * Override this method to provide functionality.
  119786. */
  119787. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119788. /**
  119789. * Called on pointer POINTERMOVE event if multiple touches are active.
  119790. * Override this method to provide functionality.
  119791. */
  119792. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119793. /**
  119794. * Called on JS contextmenu event.
  119795. * Override this method to provide functionality.
  119796. */
  119797. protected onContextMenu(evt: PointerEvent): void;
  119798. /**
  119799. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119800. * press.
  119801. * Override this method to provide functionality.
  119802. */
  119803. protected onButtonDown(evt: PointerEvent): void;
  119804. /**
  119805. * Called each time a new POINTERUP event occurs. Ie, for each button
  119806. * release.
  119807. * Override this method to provide functionality.
  119808. */
  119809. protected onButtonUp(evt: PointerEvent): void;
  119810. /**
  119811. * Called when window becomes inactive.
  119812. * Override this method to provide functionality.
  119813. */
  119814. protected onLostFocus(): void;
  119815. private _pointerInput;
  119816. private _observer;
  119817. private _onLostFocus;
  119818. private pointA;
  119819. private pointB;
  119820. }
  119821. }
  119822. declare module BABYLON {
  119823. /**
  119824. * Manage the pointers inputs to control an arc rotate camera.
  119825. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  119826. */
  119827. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  119828. /**
  119829. * Defines the camera the input is attached to.
  119830. */
  119831. camera: ArcRotateCamera;
  119832. /**
  119833. * Gets the class name of the current input.
  119834. * @returns the class name
  119835. */
  119836. getClassName(): string;
  119837. /**
  119838. * Defines the buttons associated with the input to handle camera move.
  119839. */
  119840. buttons: number[];
  119841. /**
  119842. * Defines the pointer angular sensibility along the X axis or how fast is
  119843. * the camera rotating.
  119844. */
  119845. angularSensibilityX: number;
  119846. /**
  119847. * Defines the pointer angular sensibility along the Y axis or how fast is
  119848. * the camera rotating.
  119849. */
  119850. angularSensibilityY: number;
  119851. /**
  119852. * Defines the pointer pinch precision or how fast is the camera zooming.
  119853. */
  119854. pinchPrecision: number;
  119855. /**
  119856. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  119857. * from 0.
  119858. * It defines the percentage of current camera.radius to use as delta when
  119859. * pinch zoom is used.
  119860. */
  119861. pinchDeltaPercentage: number;
  119862. /**
  119863. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119864. * that any object in the plane at the camera's target point will scale
  119865. * perfectly with finger motion.
  119866. * Overrides pinchDeltaPercentage and pinchPrecision.
  119867. */
  119868. useNaturalPinchZoom: boolean;
  119869. /**
  119870. * Defines the pointer panning sensibility or how fast is the camera moving.
  119871. */
  119872. panningSensibility: number;
  119873. /**
  119874. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  119875. */
  119876. multiTouchPanning: boolean;
  119877. /**
  119878. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  119879. * zoom (pinch) through multitouch.
  119880. */
  119881. multiTouchPanAndZoom: boolean;
  119882. /**
  119883. * Revers pinch action direction.
  119884. */
  119885. pinchInwards: boolean;
  119886. private _isPanClick;
  119887. private _twoFingerActivityCount;
  119888. private _isPinching;
  119889. /**
  119890. * Called on pointer POINTERMOVE event if only a single touch is active.
  119891. */
  119892. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119893. /**
  119894. * Called on pointer POINTERDOUBLETAP event.
  119895. */
  119896. protected onDoubleTap(type: string): void;
  119897. /**
  119898. * Called on pointer POINTERMOVE event if multiple touches are active.
  119899. */
  119900. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119901. /**
  119902. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119903. * press.
  119904. */
  119905. protected onButtonDown(evt: PointerEvent): void;
  119906. /**
  119907. * Called each time a new POINTERUP event occurs. Ie, for each button
  119908. * release.
  119909. */
  119910. protected onButtonUp(evt: PointerEvent): void;
  119911. /**
  119912. * Called when window becomes inactive.
  119913. */
  119914. protected onLostFocus(): void;
  119915. }
  119916. }
  119917. declare module BABYLON {
  119918. /**
  119919. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  119920. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  119921. */
  119922. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  119923. /**
  119924. * Defines the camera the input is attached to.
  119925. */
  119926. camera: ArcRotateCamera;
  119927. /**
  119928. * Defines the list of key codes associated with the up action (increase alpha)
  119929. */
  119930. keysUp: number[];
  119931. /**
  119932. * Defines the list of key codes associated with the down action (decrease alpha)
  119933. */
  119934. keysDown: number[];
  119935. /**
  119936. * Defines the list of key codes associated with the left action (increase beta)
  119937. */
  119938. keysLeft: number[];
  119939. /**
  119940. * Defines the list of key codes associated with the right action (decrease beta)
  119941. */
  119942. keysRight: number[];
  119943. /**
  119944. * Defines the list of key codes associated with the reset action.
  119945. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  119946. */
  119947. keysReset: number[];
  119948. /**
  119949. * Defines the panning sensibility of the inputs.
  119950. * (How fast is the camera panning)
  119951. */
  119952. panningSensibility: number;
  119953. /**
  119954. * Defines the zooming sensibility of the inputs.
  119955. * (How fast is the camera zooming)
  119956. */
  119957. zoomingSensibility: number;
  119958. /**
  119959. * Defines whether maintaining the alt key down switch the movement mode from
  119960. * orientation to zoom.
  119961. */
  119962. useAltToZoom: boolean;
  119963. /**
  119964. * Rotation speed of the camera
  119965. */
  119966. angularSpeed: number;
  119967. private _keys;
  119968. private _ctrlPressed;
  119969. private _altPressed;
  119970. private _onCanvasBlurObserver;
  119971. private _onKeyboardObserver;
  119972. private _engine;
  119973. private _scene;
  119974. /**
  119975. * Attach the input controls to a specific dom element to get the input from.
  119976. * @param element Defines the element the controls should be listened from
  119977. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119978. */
  119979. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119980. /**
  119981. * Detach the current controls from the specified dom element.
  119982. * @param element Defines the element to stop listening the inputs from
  119983. */
  119984. detachControl(element: Nullable<HTMLElement>): void;
  119985. /**
  119986. * Update the current camera state depending on the inputs that have been used this frame.
  119987. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119988. */
  119989. checkInputs(): void;
  119990. /**
  119991. * Gets the class name of the current intput.
  119992. * @returns the class name
  119993. */
  119994. getClassName(): string;
  119995. /**
  119996. * Get the friendly name associated with the input class.
  119997. * @returns the input friendly name
  119998. */
  119999. getSimpleName(): string;
  120000. }
  120001. }
  120002. declare module BABYLON {
  120003. /**
  120004. * Manage the mouse wheel inputs to control an arc rotate camera.
  120005. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120006. */
  120007. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  120008. /**
  120009. * Defines the camera the input is attached to.
  120010. */
  120011. camera: ArcRotateCamera;
  120012. /**
  120013. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  120014. */
  120015. wheelPrecision: number;
  120016. /**
  120017. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  120018. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  120019. */
  120020. wheelDeltaPercentage: number;
  120021. private _wheel;
  120022. private _observer;
  120023. private computeDeltaFromMouseWheelLegacyEvent;
  120024. /**
  120025. * Attach the input controls to a specific dom element to get the input from.
  120026. * @param element Defines the element the controls should be listened from
  120027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120028. */
  120029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120030. /**
  120031. * Detach the current controls from the specified dom element.
  120032. * @param element Defines the element to stop listening the inputs from
  120033. */
  120034. detachControl(element: Nullable<HTMLElement>): void;
  120035. /**
  120036. * Gets the class name of the current intput.
  120037. * @returns the class name
  120038. */
  120039. getClassName(): string;
  120040. /**
  120041. * Get the friendly name associated with the input class.
  120042. * @returns the input friendly name
  120043. */
  120044. getSimpleName(): string;
  120045. }
  120046. }
  120047. declare module BABYLON {
  120048. /**
  120049. * Default Inputs manager for the ArcRotateCamera.
  120050. * It groups all the default supported inputs for ease of use.
  120051. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120052. */
  120053. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  120054. /**
  120055. * Instantiates a new ArcRotateCameraInputsManager.
  120056. * @param camera Defines the camera the inputs belong to
  120057. */
  120058. constructor(camera: ArcRotateCamera);
  120059. /**
  120060. * Add mouse wheel input support to the input manager.
  120061. * @returns the current input manager
  120062. */
  120063. addMouseWheel(): ArcRotateCameraInputsManager;
  120064. /**
  120065. * Add pointers input support to the input manager.
  120066. * @returns the current input manager
  120067. */
  120068. addPointers(): ArcRotateCameraInputsManager;
  120069. /**
  120070. * Add keyboard input support to the input manager.
  120071. * @returns the current input manager
  120072. */
  120073. addKeyboard(): ArcRotateCameraInputsManager;
  120074. }
  120075. }
  120076. declare module BABYLON {
  120077. /**
  120078. * This represents an orbital type of camera.
  120079. *
  120080. * 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.
  120081. * 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.
  120082. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  120083. */
  120084. export class ArcRotateCamera extends TargetCamera {
  120085. /**
  120086. * Defines the rotation angle of the camera along the longitudinal axis.
  120087. */
  120088. alpha: number;
  120089. /**
  120090. * Defines the rotation angle of the camera along the latitudinal axis.
  120091. */
  120092. beta: number;
  120093. /**
  120094. * Defines the radius of the camera from it s target point.
  120095. */
  120096. radius: number;
  120097. protected _target: Vector3;
  120098. protected _targetHost: Nullable<AbstractMesh>;
  120099. /**
  120100. * Defines the target point of the camera.
  120101. * The camera looks towards it form the radius distance.
  120102. */
  120103. get target(): Vector3;
  120104. set target(value: Vector3);
  120105. /**
  120106. * Define the current local position of the camera in the scene
  120107. */
  120108. get position(): Vector3;
  120109. set position(newPosition: Vector3);
  120110. protected _upVector: Vector3;
  120111. protected _upToYMatrix: Matrix;
  120112. protected _YToUpMatrix: Matrix;
  120113. /**
  120114. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  120115. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  120116. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  120117. */
  120118. set upVector(vec: Vector3);
  120119. get upVector(): Vector3;
  120120. /**
  120121. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  120122. */
  120123. setMatUp(): void;
  120124. /**
  120125. * Current inertia value on the longitudinal axis.
  120126. * The bigger this number the longer it will take for the camera to stop.
  120127. */
  120128. inertialAlphaOffset: number;
  120129. /**
  120130. * Current inertia value on the latitudinal axis.
  120131. * The bigger this number the longer it will take for the camera to stop.
  120132. */
  120133. inertialBetaOffset: number;
  120134. /**
  120135. * Current inertia value on the radius axis.
  120136. * The bigger this number the longer it will take for the camera to stop.
  120137. */
  120138. inertialRadiusOffset: number;
  120139. /**
  120140. * Minimum allowed angle on the longitudinal axis.
  120141. * This can help limiting how the Camera is able to move in the scene.
  120142. */
  120143. lowerAlphaLimit: Nullable<number>;
  120144. /**
  120145. * Maximum allowed angle on the longitudinal axis.
  120146. * This can help limiting how the Camera is able to move in the scene.
  120147. */
  120148. upperAlphaLimit: Nullable<number>;
  120149. /**
  120150. * Minimum allowed angle on the latitudinal axis.
  120151. * This can help limiting how the Camera is able to move in the scene.
  120152. */
  120153. lowerBetaLimit: number;
  120154. /**
  120155. * Maximum allowed angle on the latitudinal axis.
  120156. * This can help limiting how the Camera is able to move in the scene.
  120157. */
  120158. upperBetaLimit: number;
  120159. /**
  120160. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  120161. * This can help limiting how the Camera is able to move in the scene.
  120162. */
  120163. lowerRadiusLimit: Nullable<number>;
  120164. /**
  120165. * Maximum allowed distance of the camera to the target (The camera can not get further).
  120166. * This can help limiting how the Camera is able to move in the scene.
  120167. */
  120168. upperRadiusLimit: Nullable<number>;
  120169. /**
  120170. * Defines the current inertia value used during panning of the camera along the X axis.
  120171. */
  120172. inertialPanningX: number;
  120173. /**
  120174. * Defines the current inertia value used during panning of the camera along the Y axis.
  120175. */
  120176. inertialPanningY: number;
  120177. /**
  120178. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  120179. * Basically if your fingers moves away from more than this distance you will be considered
  120180. * in pinch mode.
  120181. */
  120182. pinchToPanMaxDistance: number;
  120183. /**
  120184. * Defines the maximum distance the camera can pan.
  120185. * This could help keeping the cammera always in your scene.
  120186. */
  120187. panningDistanceLimit: Nullable<number>;
  120188. /**
  120189. * Defines the target of the camera before paning.
  120190. */
  120191. panningOriginTarget: Vector3;
  120192. /**
  120193. * Defines the value of the inertia used during panning.
  120194. * 0 would mean stop inertia and one would mean no decelleration at all.
  120195. */
  120196. panningInertia: number;
  120197. /**
  120198. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  120199. */
  120200. get angularSensibilityX(): number;
  120201. set angularSensibilityX(value: number);
  120202. /**
  120203. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  120204. */
  120205. get angularSensibilityY(): number;
  120206. set angularSensibilityY(value: number);
  120207. /**
  120208. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  120209. */
  120210. get pinchPrecision(): number;
  120211. set pinchPrecision(value: number);
  120212. /**
  120213. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  120214. * It will be used instead of pinchDeltaPrecision if different from 0.
  120215. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  120216. */
  120217. get pinchDeltaPercentage(): number;
  120218. set pinchDeltaPercentage(value: number);
  120219. /**
  120220. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  120221. * and pinch delta percentage.
  120222. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  120223. * that any object in the plane at the camera's target point will scale
  120224. * perfectly with finger motion.
  120225. */
  120226. get useNaturalPinchZoom(): boolean;
  120227. set useNaturalPinchZoom(value: boolean);
  120228. /**
  120229. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  120230. */
  120231. get panningSensibility(): number;
  120232. set panningSensibility(value: number);
  120233. /**
  120234. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  120235. */
  120236. get keysUp(): number[];
  120237. set keysUp(value: number[]);
  120238. /**
  120239. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  120240. */
  120241. get keysDown(): number[];
  120242. set keysDown(value: number[]);
  120243. /**
  120244. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  120245. */
  120246. get keysLeft(): number[];
  120247. set keysLeft(value: number[]);
  120248. /**
  120249. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  120250. */
  120251. get keysRight(): number[];
  120252. set keysRight(value: number[]);
  120253. /**
  120254. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  120255. */
  120256. get wheelPrecision(): number;
  120257. set wheelPrecision(value: number);
  120258. /**
  120259. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  120260. * It will be used instead of pinchDeltaPrecision if different from 0.
  120261. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  120262. */
  120263. get wheelDeltaPercentage(): number;
  120264. set wheelDeltaPercentage(value: number);
  120265. /**
  120266. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  120267. */
  120268. zoomOnFactor: number;
  120269. /**
  120270. * Defines a screen offset for the camera position.
  120271. */
  120272. targetScreenOffset: Vector2;
  120273. /**
  120274. * Allows the camera to be completely reversed.
  120275. * If false the camera can not arrive upside down.
  120276. */
  120277. allowUpsideDown: boolean;
  120278. /**
  120279. * Define if double tap/click is used to restore the previously saved state of the camera.
  120280. */
  120281. useInputToRestoreState: boolean;
  120282. /** @hidden */
  120283. _viewMatrix: Matrix;
  120284. /** @hidden */
  120285. _useCtrlForPanning: boolean;
  120286. /** @hidden */
  120287. _panningMouseButton: number;
  120288. /**
  120289. * Defines the input associated to the camera.
  120290. */
  120291. inputs: ArcRotateCameraInputsManager;
  120292. /** @hidden */
  120293. _reset: () => void;
  120294. /**
  120295. * Defines the allowed panning axis.
  120296. */
  120297. panningAxis: Vector3;
  120298. protected _localDirection: Vector3;
  120299. protected _transformedDirection: Vector3;
  120300. private _bouncingBehavior;
  120301. /**
  120302. * Gets the bouncing behavior of the camera if it has been enabled.
  120303. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120304. */
  120305. get bouncingBehavior(): Nullable<BouncingBehavior>;
  120306. /**
  120307. * Defines if the bouncing behavior of the camera is enabled on the camera.
  120308. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120309. */
  120310. get useBouncingBehavior(): boolean;
  120311. set useBouncingBehavior(value: boolean);
  120312. private _framingBehavior;
  120313. /**
  120314. * Gets the framing behavior of the camera if it has been enabled.
  120315. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120316. */
  120317. get framingBehavior(): Nullable<FramingBehavior>;
  120318. /**
  120319. * Defines if the framing behavior of the camera is enabled on the camera.
  120320. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120321. */
  120322. get useFramingBehavior(): boolean;
  120323. set useFramingBehavior(value: boolean);
  120324. private _autoRotationBehavior;
  120325. /**
  120326. * Gets the auto rotation behavior of the camera if it has been enabled.
  120327. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120328. */
  120329. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  120330. /**
  120331. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  120332. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120333. */
  120334. get useAutoRotationBehavior(): boolean;
  120335. set useAutoRotationBehavior(value: boolean);
  120336. /**
  120337. * Observable triggered when the mesh target has been changed on the camera.
  120338. */
  120339. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  120340. /**
  120341. * Event raised when the camera is colliding with a mesh.
  120342. */
  120343. onCollide: (collidedMesh: AbstractMesh) => void;
  120344. /**
  120345. * Defines whether the camera should check collision with the objects oh the scene.
  120346. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  120347. */
  120348. checkCollisions: boolean;
  120349. /**
  120350. * Defines the collision radius of the camera.
  120351. * This simulates a sphere around the camera.
  120352. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120353. */
  120354. collisionRadius: Vector3;
  120355. protected _collider: Collider;
  120356. protected _previousPosition: Vector3;
  120357. protected _collisionVelocity: Vector3;
  120358. protected _newPosition: Vector3;
  120359. protected _previousAlpha: number;
  120360. protected _previousBeta: number;
  120361. protected _previousRadius: number;
  120362. protected _collisionTriggered: boolean;
  120363. protected _targetBoundingCenter: Nullable<Vector3>;
  120364. private _computationVector;
  120365. /**
  120366. * Instantiates a new ArcRotateCamera in a given scene
  120367. * @param name Defines the name of the camera
  120368. * @param alpha Defines the camera rotation along the logitudinal axis
  120369. * @param beta Defines the camera rotation along the latitudinal axis
  120370. * @param radius Defines the camera distance from its target
  120371. * @param target Defines the camera target
  120372. * @param scene Defines the scene the camera belongs to
  120373. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  120374. */
  120375. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120376. /** @hidden */
  120377. _initCache(): void;
  120378. /** @hidden */
  120379. _updateCache(ignoreParentClass?: boolean): void;
  120380. protected _getTargetPosition(): Vector3;
  120381. private _storedAlpha;
  120382. private _storedBeta;
  120383. private _storedRadius;
  120384. private _storedTarget;
  120385. private _storedTargetScreenOffset;
  120386. /**
  120387. * Stores the current state of the camera (alpha, beta, radius and target)
  120388. * @returns the camera itself
  120389. */
  120390. storeState(): Camera;
  120391. /**
  120392. * @hidden
  120393. * Restored camera state. You must call storeState() first
  120394. */
  120395. _restoreStateValues(): boolean;
  120396. /** @hidden */
  120397. _isSynchronizedViewMatrix(): boolean;
  120398. /**
  120399. * Attached controls to the current camera.
  120400. * @param element Defines the element the controls should be listened from
  120401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120402. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  120403. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  120404. */
  120405. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  120406. /**
  120407. * Detach the current controls from the camera.
  120408. * The camera will stop reacting to inputs.
  120409. * @param element Defines the element to stop listening the inputs from
  120410. */
  120411. detachControl(element: HTMLElement): void;
  120412. /** @hidden */
  120413. _checkInputs(): void;
  120414. protected _checkLimits(): void;
  120415. /**
  120416. * Rebuilds angles (alpha, beta) and radius from the give position and target
  120417. */
  120418. rebuildAnglesAndRadius(): void;
  120419. /**
  120420. * Use a position to define the current camera related information like alpha, beta and radius
  120421. * @param position Defines the position to set the camera at
  120422. */
  120423. setPosition(position: Vector3): void;
  120424. /**
  120425. * Defines the target the camera should look at.
  120426. * This will automatically adapt alpha beta and radius to fit within the new target.
  120427. * @param target Defines the new target as a Vector or a mesh
  120428. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  120429. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  120430. */
  120431. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  120432. /** @hidden */
  120433. _getViewMatrix(): Matrix;
  120434. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  120435. /**
  120436. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  120437. * @param meshes Defines the mesh to zoom on
  120438. * @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)
  120439. */
  120440. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  120441. /**
  120442. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  120443. * The target will be changed but the radius
  120444. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  120445. * @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)
  120446. */
  120447. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  120448. min: Vector3;
  120449. max: Vector3;
  120450. distance: number;
  120451. }, doNotUpdateMaxZ?: boolean): void;
  120452. /**
  120453. * @override
  120454. * Override Camera.createRigCamera
  120455. */
  120456. createRigCamera(name: string, cameraIndex: number): Camera;
  120457. /**
  120458. * @hidden
  120459. * @override
  120460. * Override Camera._updateRigCameras
  120461. */
  120462. _updateRigCameras(): void;
  120463. /**
  120464. * Destroy the camera and release the current resources hold by it.
  120465. */
  120466. dispose(): void;
  120467. /**
  120468. * Gets the current object class name.
  120469. * @return the class name
  120470. */
  120471. getClassName(): string;
  120472. }
  120473. }
  120474. declare module BABYLON {
  120475. /**
  120476. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  120477. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120478. */
  120479. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  120480. /**
  120481. * Gets the name of the behavior.
  120482. */
  120483. get name(): string;
  120484. private _zoomStopsAnimation;
  120485. private _idleRotationSpeed;
  120486. private _idleRotationWaitTime;
  120487. private _idleRotationSpinupTime;
  120488. /**
  120489. * Sets the flag that indicates if user zooming should stop animation.
  120490. */
  120491. set zoomStopsAnimation(flag: boolean);
  120492. /**
  120493. * Gets the flag that indicates if user zooming should stop animation.
  120494. */
  120495. get zoomStopsAnimation(): boolean;
  120496. /**
  120497. * Sets the default speed at which the camera rotates around the model.
  120498. */
  120499. set idleRotationSpeed(speed: number);
  120500. /**
  120501. * Gets the default speed at which the camera rotates around the model.
  120502. */
  120503. get idleRotationSpeed(): number;
  120504. /**
  120505. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  120506. */
  120507. set idleRotationWaitTime(time: number);
  120508. /**
  120509. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  120510. */
  120511. get idleRotationWaitTime(): number;
  120512. /**
  120513. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120514. */
  120515. set idleRotationSpinupTime(time: number);
  120516. /**
  120517. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120518. */
  120519. get idleRotationSpinupTime(): number;
  120520. /**
  120521. * Gets a value indicating if the camera is currently rotating because of this behavior
  120522. */
  120523. get rotationInProgress(): boolean;
  120524. private _onPrePointerObservableObserver;
  120525. private _onAfterCheckInputsObserver;
  120526. private _attachedCamera;
  120527. private _isPointerDown;
  120528. private _lastFrameTime;
  120529. private _lastInteractionTime;
  120530. private _cameraRotationSpeed;
  120531. /**
  120532. * Initializes the behavior.
  120533. */
  120534. init(): void;
  120535. /**
  120536. * Attaches the behavior to its arc rotate camera.
  120537. * @param camera Defines the camera to attach the behavior to
  120538. */
  120539. attach(camera: ArcRotateCamera): void;
  120540. /**
  120541. * Detaches the behavior from its current arc rotate camera.
  120542. */
  120543. detach(): void;
  120544. /**
  120545. * Returns true if user is scrolling.
  120546. * @return true if user is scrolling.
  120547. */
  120548. private _userIsZooming;
  120549. private _lastFrameRadius;
  120550. private _shouldAnimationStopForInteraction;
  120551. /**
  120552. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  120553. */
  120554. private _applyUserInteraction;
  120555. private _userIsMoving;
  120556. }
  120557. }
  120558. declare module BABYLON {
  120559. /**
  120560. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  120561. */
  120562. export class AttachToBoxBehavior implements Behavior<Mesh> {
  120563. private ui;
  120564. /**
  120565. * The name of the behavior
  120566. */
  120567. name: string;
  120568. /**
  120569. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  120570. */
  120571. distanceAwayFromFace: number;
  120572. /**
  120573. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  120574. */
  120575. distanceAwayFromBottomOfFace: number;
  120576. private _faceVectors;
  120577. private _target;
  120578. private _scene;
  120579. private _onRenderObserver;
  120580. private _tmpMatrix;
  120581. private _tmpVector;
  120582. /**
  120583. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  120584. * @param ui The transform node that should be attched to the mesh
  120585. */
  120586. constructor(ui: TransformNode);
  120587. /**
  120588. * Initializes the behavior
  120589. */
  120590. init(): void;
  120591. private _closestFace;
  120592. private _zeroVector;
  120593. private _lookAtTmpMatrix;
  120594. private _lookAtToRef;
  120595. /**
  120596. * Attaches the AttachToBoxBehavior to the passed in mesh
  120597. * @param target The mesh that the specified node will be attached to
  120598. */
  120599. attach(target: Mesh): void;
  120600. /**
  120601. * Detaches the behavior from the mesh
  120602. */
  120603. detach(): void;
  120604. }
  120605. }
  120606. declare module BABYLON {
  120607. /**
  120608. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  120609. */
  120610. export class FadeInOutBehavior implements Behavior<Mesh> {
  120611. /**
  120612. * Time in milliseconds to delay before fading in (Default: 0)
  120613. */
  120614. delay: number;
  120615. /**
  120616. * Time in milliseconds for the mesh to fade in (Default: 300)
  120617. */
  120618. fadeInTime: number;
  120619. private _millisecondsPerFrame;
  120620. private _hovered;
  120621. private _hoverValue;
  120622. private _ownerNode;
  120623. /**
  120624. * Instatiates the FadeInOutBehavior
  120625. */
  120626. constructor();
  120627. /**
  120628. * The name of the behavior
  120629. */
  120630. get name(): string;
  120631. /**
  120632. * Initializes the behavior
  120633. */
  120634. init(): void;
  120635. /**
  120636. * Attaches the fade behavior on the passed in mesh
  120637. * @param ownerNode The mesh that will be faded in/out once attached
  120638. */
  120639. attach(ownerNode: Mesh): void;
  120640. /**
  120641. * Detaches the behavior from the mesh
  120642. */
  120643. detach(): void;
  120644. /**
  120645. * Triggers the mesh to begin fading in or out
  120646. * @param value if the object should fade in or out (true to fade in)
  120647. */
  120648. fadeIn(value: boolean): void;
  120649. private _update;
  120650. private _setAllVisibility;
  120651. }
  120652. }
  120653. declare module BABYLON {
  120654. /**
  120655. * Class containing a set of static utilities functions for managing Pivots
  120656. * @hidden
  120657. */
  120658. export class PivotTools {
  120659. private static _PivotCached;
  120660. private static _OldPivotPoint;
  120661. private static _PivotTranslation;
  120662. private static _PivotTmpVector;
  120663. /** @hidden */
  120664. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  120665. /** @hidden */
  120666. static _RestorePivotPoint(mesh: AbstractMesh): void;
  120667. }
  120668. }
  120669. declare module BABYLON {
  120670. /**
  120671. * Class containing static functions to help procedurally build meshes
  120672. */
  120673. export class PlaneBuilder {
  120674. /**
  120675. * Creates a plane mesh
  120676. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120677. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120678. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120682. * @param name defines the name of the mesh
  120683. * @param options defines the options used to create the mesh
  120684. * @param scene defines the hosting scene
  120685. * @returns the plane mesh
  120686. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120687. */
  120688. static CreatePlane(name: string, options: {
  120689. size?: number;
  120690. width?: number;
  120691. height?: number;
  120692. sideOrientation?: number;
  120693. frontUVs?: Vector4;
  120694. backUVs?: Vector4;
  120695. updatable?: boolean;
  120696. sourcePlane?: Plane;
  120697. }, scene?: Nullable<Scene>): Mesh;
  120698. }
  120699. }
  120700. declare module BABYLON {
  120701. /**
  120702. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  120703. */
  120704. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  120705. private static _AnyMouseID;
  120706. /**
  120707. * Abstract mesh the behavior is set on
  120708. */
  120709. attachedNode: AbstractMesh;
  120710. private _dragPlane;
  120711. private _scene;
  120712. private _pointerObserver;
  120713. private _beforeRenderObserver;
  120714. private static _planeScene;
  120715. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  120716. /**
  120717. * 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)
  120718. */
  120719. maxDragAngle: number;
  120720. /**
  120721. * @hidden
  120722. */
  120723. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  120724. /**
  120725. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120726. */
  120727. currentDraggingPointerID: number;
  120728. /**
  120729. * The last position where the pointer hit the drag plane in world space
  120730. */
  120731. lastDragPosition: Vector3;
  120732. /**
  120733. * If the behavior is currently in a dragging state
  120734. */
  120735. dragging: boolean;
  120736. /**
  120737. * 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)
  120738. */
  120739. dragDeltaRatio: number;
  120740. /**
  120741. * If the drag plane orientation should be updated during the dragging (Default: true)
  120742. */
  120743. updateDragPlane: boolean;
  120744. private _debugMode;
  120745. private _moving;
  120746. /**
  120747. * Fires each time the attached mesh is dragged with the pointer
  120748. * * delta between last drag position and current drag position in world space
  120749. * * dragDistance along the drag axis
  120750. * * dragPlaneNormal normal of the current drag plane used during the drag
  120751. * * dragPlanePoint in world space where the drag intersects the drag plane
  120752. */
  120753. onDragObservable: Observable<{
  120754. delta: Vector3;
  120755. dragPlanePoint: Vector3;
  120756. dragPlaneNormal: Vector3;
  120757. dragDistance: number;
  120758. pointerId: number;
  120759. }>;
  120760. /**
  120761. * Fires each time a drag begins (eg. mouse down on mesh)
  120762. */
  120763. onDragStartObservable: Observable<{
  120764. dragPlanePoint: Vector3;
  120765. pointerId: number;
  120766. }>;
  120767. /**
  120768. * Fires each time a drag ends (eg. mouse release after drag)
  120769. */
  120770. onDragEndObservable: Observable<{
  120771. dragPlanePoint: Vector3;
  120772. pointerId: number;
  120773. }>;
  120774. /**
  120775. * If the attached mesh should be moved when dragged
  120776. */
  120777. moveAttached: boolean;
  120778. /**
  120779. * If the drag behavior will react to drag events (Default: true)
  120780. */
  120781. enabled: boolean;
  120782. /**
  120783. * If pointer events should start and release the drag (Default: true)
  120784. */
  120785. startAndReleaseDragOnPointerEvents: boolean;
  120786. /**
  120787. * If camera controls should be detached during the drag
  120788. */
  120789. detachCameraControls: boolean;
  120790. /**
  120791. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  120792. */
  120793. useObjectOrientationForDragging: boolean;
  120794. private _options;
  120795. /**
  120796. * Gets the options used by the behavior
  120797. */
  120798. get options(): {
  120799. dragAxis?: Vector3;
  120800. dragPlaneNormal?: Vector3;
  120801. };
  120802. /**
  120803. * Sets the options used by the behavior
  120804. */
  120805. set options(options: {
  120806. dragAxis?: Vector3;
  120807. dragPlaneNormal?: Vector3;
  120808. });
  120809. /**
  120810. * Creates a pointer drag behavior that can be attached to a mesh
  120811. * @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)
  120812. */
  120813. constructor(options?: {
  120814. dragAxis?: Vector3;
  120815. dragPlaneNormal?: Vector3;
  120816. });
  120817. /**
  120818. * Predicate to determine if it is valid to move the object to a new position when it is moved
  120819. */
  120820. validateDrag: (targetPosition: Vector3) => boolean;
  120821. /**
  120822. * The name of the behavior
  120823. */
  120824. get name(): string;
  120825. /**
  120826. * Initializes the behavior
  120827. */
  120828. init(): void;
  120829. private _tmpVector;
  120830. private _alternatePickedPoint;
  120831. private _worldDragAxis;
  120832. private _targetPosition;
  120833. private _attachedElement;
  120834. /**
  120835. * Attaches the drag behavior the passed in mesh
  120836. * @param ownerNode The mesh that will be dragged around once attached
  120837. * @param predicate Predicate to use for pick filtering
  120838. */
  120839. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  120840. /**
  120841. * Force relase the drag action by code.
  120842. */
  120843. releaseDrag(): void;
  120844. private _startDragRay;
  120845. private _lastPointerRay;
  120846. /**
  120847. * Simulates the start of a pointer drag event on the behavior
  120848. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  120849. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  120850. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  120851. */
  120852. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  120853. private _startDrag;
  120854. private _dragDelta;
  120855. private _moveDrag;
  120856. private _pickWithRayOnDragPlane;
  120857. private _pointA;
  120858. private _pointB;
  120859. private _pointC;
  120860. private _lineA;
  120861. private _lineB;
  120862. private _localAxis;
  120863. private _lookAt;
  120864. private _updateDragPlanePosition;
  120865. /**
  120866. * Detaches the behavior from the mesh
  120867. */
  120868. detach(): void;
  120869. }
  120870. }
  120871. declare module BABYLON {
  120872. /**
  120873. * A behavior that when attached to a mesh will allow the mesh to be scaled
  120874. */
  120875. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  120876. private _dragBehaviorA;
  120877. private _dragBehaviorB;
  120878. private _startDistance;
  120879. private _initialScale;
  120880. private _targetScale;
  120881. private _ownerNode;
  120882. private _sceneRenderObserver;
  120883. /**
  120884. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  120885. */
  120886. constructor();
  120887. /**
  120888. * The name of the behavior
  120889. */
  120890. get name(): string;
  120891. /**
  120892. * Initializes the behavior
  120893. */
  120894. init(): void;
  120895. private _getCurrentDistance;
  120896. /**
  120897. * Attaches the scale behavior the passed in mesh
  120898. * @param ownerNode The mesh that will be scaled around once attached
  120899. */
  120900. attach(ownerNode: Mesh): void;
  120901. /**
  120902. * Detaches the behavior from the mesh
  120903. */
  120904. detach(): void;
  120905. }
  120906. }
  120907. declare module BABYLON {
  120908. /**
  120909. * 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
  120910. */
  120911. export class SixDofDragBehavior implements Behavior<Mesh> {
  120912. private static _virtualScene;
  120913. private _ownerNode;
  120914. private _sceneRenderObserver;
  120915. private _scene;
  120916. private _targetPosition;
  120917. private _virtualOriginMesh;
  120918. private _virtualDragMesh;
  120919. private _pointerObserver;
  120920. private _moving;
  120921. private _startingOrientation;
  120922. private _attachedElement;
  120923. /**
  120924. * 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)
  120925. */
  120926. private zDragFactor;
  120927. /**
  120928. * If the object should rotate to face the drag origin
  120929. */
  120930. rotateDraggedObject: boolean;
  120931. /**
  120932. * If the behavior is currently in a dragging state
  120933. */
  120934. dragging: boolean;
  120935. /**
  120936. * 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)
  120937. */
  120938. dragDeltaRatio: number;
  120939. /**
  120940. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120941. */
  120942. currentDraggingPointerID: number;
  120943. /**
  120944. * If camera controls should be detached during the drag
  120945. */
  120946. detachCameraControls: boolean;
  120947. /**
  120948. * Fires each time a drag starts
  120949. */
  120950. onDragStartObservable: Observable<{}>;
  120951. /**
  120952. * Fires each time a drag ends (eg. mouse release after drag)
  120953. */
  120954. onDragEndObservable: Observable<{}>;
  120955. /**
  120956. * 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
  120957. */
  120958. constructor();
  120959. /**
  120960. * The name of the behavior
  120961. */
  120962. get name(): string;
  120963. /**
  120964. * Initializes the behavior
  120965. */
  120966. init(): void;
  120967. /**
  120968. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  120969. */
  120970. private get _pointerCamera();
  120971. /**
  120972. * Attaches the scale behavior the passed in mesh
  120973. * @param ownerNode The mesh that will be scaled around once attached
  120974. */
  120975. attach(ownerNode: Mesh): void;
  120976. /**
  120977. * Detaches the behavior from the mesh
  120978. */
  120979. detach(): void;
  120980. }
  120981. }
  120982. declare module BABYLON {
  120983. /**
  120984. * Class used to apply inverse kinematics to bones
  120985. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  120986. */
  120987. export class BoneIKController {
  120988. private static _tmpVecs;
  120989. private static _tmpQuat;
  120990. private static _tmpMats;
  120991. /**
  120992. * Gets or sets the target mesh
  120993. */
  120994. targetMesh: AbstractMesh;
  120995. /** Gets or sets the mesh used as pole */
  120996. poleTargetMesh: AbstractMesh;
  120997. /**
  120998. * Gets or sets the bone used as pole
  120999. */
  121000. poleTargetBone: Nullable<Bone>;
  121001. /**
  121002. * Gets or sets the target position
  121003. */
  121004. targetPosition: Vector3;
  121005. /**
  121006. * Gets or sets the pole target position
  121007. */
  121008. poleTargetPosition: Vector3;
  121009. /**
  121010. * Gets or sets the pole target local offset
  121011. */
  121012. poleTargetLocalOffset: Vector3;
  121013. /**
  121014. * Gets or sets the pole angle
  121015. */
  121016. poleAngle: number;
  121017. /**
  121018. * Gets or sets the mesh associated with the controller
  121019. */
  121020. mesh: AbstractMesh;
  121021. /**
  121022. * 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)
  121023. */
  121024. slerpAmount: number;
  121025. private _bone1Quat;
  121026. private _bone1Mat;
  121027. private _bone2Ang;
  121028. private _bone1;
  121029. private _bone2;
  121030. private _bone1Length;
  121031. private _bone2Length;
  121032. private _maxAngle;
  121033. private _maxReach;
  121034. private _rightHandedSystem;
  121035. private _bendAxis;
  121036. private _slerping;
  121037. private _adjustRoll;
  121038. /**
  121039. * Gets or sets maximum allowed angle
  121040. */
  121041. get maxAngle(): number;
  121042. set maxAngle(value: number);
  121043. /**
  121044. * Creates a new BoneIKController
  121045. * @param mesh defines the mesh to control
  121046. * @param bone defines the bone to control
  121047. * @param options defines options to set up the controller
  121048. */
  121049. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  121050. targetMesh?: AbstractMesh;
  121051. poleTargetMesh?: AbstractMesh;
  121052. poleTargetBone?: Bone;
  121053. poleTargetLocalOffset?: Vector3;
  121054. poleAngle?: number;
  121055. bendAxis?: Vector3;
  121056. maxAngle?: number;
  121057. slerpAmount?: number;
  121058. });
  121059. private _setMaxAngle;
  121060. /**
  121061. * Force the controller to update the bones
  121062. */
  121063. update(): void;
  121064. }
  121065. }
  121066. declare module BABYLON {
  121067. /**
  121068. * Class used to make a bone look toward a point in space
  121069. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  121070. */
  121071. export class BoneLookController {
  121072. private static _tmpVecs;
  121073. private static _tmpQuat;
  121074. private static _tmpMats;
  121075. /**
  121076. * The target Vector3 that the bone will look at
  121077. */
  121078. target: Vector3;
  121079. /**
  121080. * The mesh that the bone is attached to
  121081. */
  121082. mesh: AbstractMesh;
  121083. /**
  121084. * The bone that will be looking to the target
  121085. */
  121086. bone: Bone;
  121087. /**
  121088. * The up axis of the coordinate system that is used when the bone is rotated
  121089. */
  121090. upAxis: Vector3;
  121091. /**
  121092. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  121093. */
  121094. upAxisSpace: Space;
  121095. /**
  121096. * Used to make an adjustment to the yaw of the bone
  121097. */
  121098. adjustYaw: number;
  121099. /**
  121100. * Used to make an adjustment to the pitch of the bone
  121101. */
  121102. adjustPitch: number;
  121103. /**
  121104. * Used to make an adjustment to the roll of the bone
  121105. */
  121106. adjustRoll: number;
  121107. /**
  121108. * 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)
  121109. */
  121110. slerpAmount: number;
  121111. private _minYaw;
  121112. private _maxYaw;
  121113. private _minPitch;
  121114. private _maxPitch;
  121115. private _minYawSin;
  121116. private _minYawCos;
  121117. private _maxYawSin;
  121118. private _maxYawCos;
  121119. private _midYawConstraint;
  121120. private _minPitchTan;
  121121. private _maxPitchTan;
  121122. private _boneQuat;
  121123. private _slerping;
  121124. private _transformYawPitch;
  121125. private _transformYawPitchInv;
  121126. private _firstFrameSkipped;
  121127. private _yawRange;
  121128. private _fowardAxis;
  121129. /**
  121130. * Gets or sets the minimum yaw angle that the bone can look to
  121131. */
  121132. get minYaw(): number;
  121133. set minYaw(value: number);
  121134. /**
  121135. * Gets or sets the maximum yaw angle that the bone can look to
  121136. */
  121137. get maxYaw(): number;
  121138. set maxYaw(value: number);
  121139. /**
  121140. * Gets or sets the minimum pitch angle that the bone can look to
  121141. */
  121142. get minPitch(): number;
  121143. set minPitch(value: number);
  121144. /**
  121145. * Gets or sets the maximum pitch angle that the bone can look to
  121146. */
  121147. get maxPitch(): number;
  121148. set maxPitch(value: number);
  121149. /**
  121150. * Create a BoneLookController
  121151. * @param mesh the mesh that the bone belongs to
  121152. * @param bone the bone that will be looking to the target
  121153. * @param target the target Vector3 to look at
  121154. * @param options optional settings:
  121155. * * maxYaw: the maximum angle the bone will yaw to
  121156. * * minYaw: the minimum angle the bone will yaw to
  121157. * * maxPitch: the maximum angle the bone will pitch to
  121158. * * minPitch: the minimum angle the bone will yaw to
  121159. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  121160. * * upAxis: the up axis of the coordinate system
  121161. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  121162. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  121163. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  121164. * * adjustYaw: used to make an adjustment to the yaw of the bone
  121165. * * adjustPitch: used to make an adjustment to the pitch of the bone
  121166. * * adjustRoll: used to make an adjustment to the roll of the bone
  121167. **/
  121168. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  121169. maxYaw?: number;
  121170. minYaw?: number;
  121171. maxPitch?: number;
  121172. minPitch?: number;
  121173. slerpAmount?: number;
  121174. upAxis?: Vector3;
  121175. upAxisSpace?: Space;
  121176. yawAxis?: Vector3;
  121177. pitchAxis?: Vector3;
  121178. adjustYaw?: number;
  121179. adjustPitch?: number;
  121180. adjustRoll?: number;
  121181. });
  121182. /**
  121183. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  121184. */
  121185. update(): void;
  121186. private _getAngleDiff;
  121187. private _getAngleBetween;
  121188. private _isAngleBetween;
  121189. }
  121190. }
  121191. declare module BABYLON {
  121192. /**
  121193. * Manage the gamepad inputs to control an arc rotate camera.
  121194. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121195. */
  121196. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  121197. /**
  121198. * Defines the camera the input is attached to.
  121199. */
  121200. camera: ArcRotateCamera;
  121201. /**
  121202. * Defines the gamepad the input is gathering event from.
  121203. */
  121204. gamepad: Nullable<Gamepad>;
  121205. /**
  121206. * Defines the gamepad rotation sensiblity.
  121207. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121208. */
  121209. gamepadRotationSensibility: number;
  121210. /**
  121211. * Defines the gamepad move sensiblity.
  121212. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121213. */
  121214. gamepadMoveSensibility: number;
  121215. private _yAxisScale;
  121216. /**
  121217. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  121218. */
  121219. get invertYAxis(): boolean;
  121220. set invertYAxis(value: boolean);
  121221. private _onGamepadConnectedObserver;
  121222. private _onGamepadDisconnectedObserver;
  121223. /**
  121224. * Attach the input controls to a specific dom element to get the input from.
  121225. * @param element Defines the element the controls should be listened from
  121226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121227. */
  121228. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121229. /**
  121230. * Detach the current controls from the specified dom element.
  121231. * @param element Defines the element to stop listening the inputs from
  121232. */
  121233. detachControl(element: Nullable<HTMLElement>): void;
  121234. /**
  121235. * Update the current camera state depending on the inputs that have been used this frame.
  121236. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121237. */
  121238. checkInputs(): void;
  121239. /**
  121240. * Gets the class name of the current intput.
  121241. * @returns the class name
  121242. */
  121243. getClassName(): string;
  121244. /**
  121245. * Get the friendly name associated with the input class.
  121246. * @returns the input friendly name
  121247. */
  121248. getSimpleName(): string;
  121249. }
  121250. }
  121251. declare module BABYLON {
  121252. interface ArcRotateCameraInputsManager {
  121253. /**
  121254. * Add orientation input support to the input manager.
  121255. * @returns the current input manager
  121256. */
  121257. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  121258. }
  121259. /**
  121260. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  121261. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121262. */
  121263. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  121264. /**
  121265. * Defines the camera the input is attached to.
  121266. */
  121267. camera: ArcRotateCamera;
  121268. /**
  121269. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  121270. */
  121271. alphaCorrection: number;
  121272. /**
  121273. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  121274. */
  121275. gammaCorrection: number;
  121276. private _alpha;
  121277. private _gamma;
  121278. private _dirty;
  121279. private _deviceOrientationHandler;
  121280. /**
  121281. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  121282. */
  121283. constructor();
  121284. /**
  121285. * Attach the input controls to a specific dom element to get the input from.
  121286. * @param element Defines the element the controls should be listened from
  121287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121288. */
  121289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121290. /** @hidden */
  121291. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  121292. /**
  121293. * Update the current camera state depending on the inputs that have been used this frame.
  121294. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121295. */
  121296. checkInputs(): void;
  121297. /**
  121298. * Detach the current controls from the specified dom element.
  121299. * @param element Defines the element to stop listening the inputs from
  121300. */
  121301. detachControl(element: Nullable<HTMLElement>): void;
  121302. /**
  121303. * Gets the class name of the current intput.
  121304. * @returns the class name
  121305. */
  121306. getClassName(): string;
  121307. /**
  121308. * Get the friendly name associated with the input class.
  121309. * @returns the input friendly name
  121310. */
  121311. getSimpleName(): string;
  121312. }
  121313. }
  121314. declare module BABYLON {
  121315. /**
  121316. * Listen to mouse events to control the camera.
  121317. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121318. */
  121319. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  121320. /**
  121321. * Defines the camera the input is attached to.
  121322. */
  121323. camera: FlyCamera;
  121324. /**
  121325. * Defines if touch is enabled. (Default is true.)
  121326. */
  121327. touchEnabled: boolean;
  121328. /**
  121329. * Defines the buttons associated with the input to handle camera rotation.
  121330. */
  121331. buttons: number[];
  121332. /**
  121333. * Assign buttons for Yaw control.
  121334. */
  121335. buttonsYaw: number[];
  121336. /**
  121337. * Assign buttons for Pitch control.
  121338. */
  121339. buttonsPitch: number[];
  121340. /**
  121341. * Assign buttons for Roll control.
  121342. */
  121343. buttonsRoll: number[];
  121344. /**
  121345. * Detect if any button is being pressed while mouse is moved.
  121346. * -1 = Mouse locked.
  121347. * 0 = Left button.
  121348. * 1 = Middle Button.
  121349. * 2 = Right Button.
  121350. */
  121351. activeButton: number;
  121352. /**
  121353. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  121354. * Higher values reduce its sensitivity.
  121355. */
  121356. angularSensibility: number;
  121357. private _mousemoveCallback;
  121358. private _observer;
  121359. private _rollObserver;
  121360. private previousPosition;
  121361. private noPreventDefault;
  121362. private element;
  121363. /**
  121364. * Listen to mouse events to control the camera.
  121365. * @param touchEnabled Define if touch is enabled. (Default is true.)
  121366. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121367. */
  121368. constructor(touchEnabled?: boolean);
  121369. /**
  121370. * Attach the mouse control to the HTML DOM element.
  121371. * @param element Defines the element that listens to the input events.
  121372. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  121373. */
  121374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121375. /**
  121376. * Detach the current controls from the specified dom element.
  121377. * @param element Defines the element to stop listening the inputs from
  121378. */
  121379. detachControl(element: Nullable<HTMLElement>): void;
  121380. /**
  121381. * Gets the class name of the current input.
  121382. * @returns the class name.
  121383. */
  121384. getClassName(): string;
  121385. /**
  121386. * Get the friendly name associated with the input class.
  121387. * @returns the input's friendly name.
  121388. */
  121389. getSimpleName(): string;
  121390. private _pointerInput;
  121391. private _onMouseMove;
  121392. /**
  121393. * Rotate camera by mouse offset.
  121394. */
  121395. private rotateCamera;
  121396. }
  121397. }
  121398. declare module BABYLON {
  121399. /**
  121400. * Default Inputs manager for the FlyCamera.
  121401. * It groups all the default supported inputs for ease of use.
  121402. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121403. */
  121404. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  121405. /**
  121406. * Instantiates a new FlyCameraInputsManager.
  121407. * @param camera Defines the camera the inputs belong to.
  121408. */
  121409. constructor(camera: FlyCamera);
  121410. /**
  121411. * Add keyboard input support to the input manager.
  121412. * @returns the new FlyCameraKeyboardMoveInput().
  121413. */
  121414. addKeyboard(): FlyCameraInputsManager;
  121415. /**
  121416. * Add mouse input support to the input manager.
  121417. * @param touchEnabled Enable touch screen support.
  121418. * @returns the new FlyCameraMouseInput().
  121419. */
  121420. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  121421. }
  121422. }
  121423. declare module BABYLON {
  121424. /**
  121425. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121426. * such as in a 3D Space Shooter or a Flight Simulator.
  121427. */
  121428. export class FlyCamera extends TargetCamera {
  121429. /**
  121430. * Define the collision ellipsoid of the camera.
  121431. * This is helpful for simulating a camera body, like a player's body.
  121432. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121433. */
  121434. ellipsoid: Vector3;
  121435. /**
  121436. * Define an offset for the position of the ellipsoid around the camera.
  121437. * This can be helpful if the camera is attached away from the player's body center,
  121438. * such as at its head.
  121439. */
  121440. ellipsoidOffset: Vector3;
  121441. /**
  121442. * Enable or disable collisions of the camera with the rest of the scene objects.
  121443. */
  121444. checkCollisions: boolean;
  121445. /**
  121446. * Enable or disable gravity on the camera.
  121447. */
  121448. applyGravity: boolean;
  121449. /**
  121450. * Define the current direction the camera is moving to.
  121451. */
  121452. cameraDirection: Vector3;
  121453. /**
  121454. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  121455. * This overrides and empties cameraRotation.
  121456. */
  121457. rotationQuaternion: Quaternion;
  121458. /**
  121459. * Track Roll to maintain the wanted Rolling when looking around.
  121460. */
  121461. _trackRoll: number;
  121462. /**
  121463. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  121464. */
  121465. rollCorrect: number;
  121466. /**
  121467. * Mimic a banked turn, Rolling the camera when Yawing.
  121468. * It's recommended to use rollCorrect = 10 for faster banking correction.
  121469. */
  121470. bankedTurn: boolean;
  121471. /**
  121472. * Limit in radians for how much Roll banking will add. (Default: 90°)
  121473. */
  121474. bankedTurnLimit: number;
  121475. /**
  121476. * Value of 0 disables the banked Roll.
  121477. * Value of 1 is equal to the Yaw angle in radians.
  121478. */
  121479. bankedTurnMultiplier: number;
  121480. /**
  121481. * The inputs manager loads all the input sources, such as keyboard and mouse.
  121482. */
  121483. inputs: FlyCameraInputsManager;
  121484. /**
  121485. * Gets the input sensibility for mouse input.
  121486. * Higher values reduce sensitivity.
  121487. */
  121488. get angularSensibility(): number;
  121489. /**
  121490. * Sets the input sensibility for a mouse input.
  121491. * Higher values reduce sensitivity.
  121492. */
  121493. set angularSensibility(value: number);
  121494. /**
  121495. * Get the keys for camera movement forward.
  121496. */
  121497. get keysForward(): number[];
  121498. /**
  121499. * Set the keys for camera movement forward.
  121500. */
  121501. set keysForward(value: number[]);
  121502. /**
  121503. * Get the keys for camera movement backward.
  121504. */
  121505. get keysBackward(): number[];
  121506. set keysBackward(value: number[]);
  121507. /**
  121508. * Get the keys for camera movement up.
  121509. */
  121510. get keysUp(): number[];
  121511. /**
  121512. * Set the keys for camera movement up.
  121513. */
  121514. set keysUp(value: number[]);
  121515. /**
  121516. * Get the keys for camera movement down.
  121517. */
  121518. get keysDown(): number[];
  121519. /**
  121520. * Set the keys for camera movement down.
  121521. */
  121522. set keysDown(value: number[]);
  121523. /**
  121524. * Get the keys for camera movement left.
  121525. */
  121526. get keysLeft(): number[];
  121527. /**
  121528. * Set the keys for camera movement left.
  121529. */
  121530. set keysLeft(value: number[]);
  121531. /**
  121532. * Set the keys for camera movement right.
  121533. */
  121534. get keysRight(): number[];
  121535. /**
  121536. * Set the keys for camera movement right.
  121537. */
  121538. set keysRight(value: number[]);
  121539. /**
  121540. * Event raised when the camera collides with a mesh in the scene.
  121541. */
  121542. onCollide: (collidedMesh: AbstractMesh) => void;
  121543. private _collider;
  121544. private _needMoveForGravity;
  121545. private _oldPosition;
  121546. private _diffPosition;
  121547. private _newPosition;
  121548. /** @hidden */
  121549. _localDirection: Vector3;
  121550. /** @hidden */
  121551. _transformedDirection: Vector3;
  121552. /**
  121553. * Instantiates a FlyCamera.
  121554. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121555. * such as in a 3D Space Shooter or a Flight Simulator.
  121556. * @param name Define the name of the camera in the scene.
  121557. * @param position Define the starting position of the camera in the scene.
  121558. * @param scene Define the scene the camera belongs to.
  121559. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  121560. */
  121561. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121562. /**
  121563. * Attach a control to the HTML DOM element.
  121564. * @param element Defines the element that listens to the input events.
  121565. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  121566. */
  121567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121568. /**
  121569. * Detach a control from the HTML DOM element.
  121570. * The camera will stop reacting to that input.
  121571. * @param element Defines the element that listens to the input events.
  121572. */
  121573. detachControl(element: HTMLElement): void;
  121574. private _collisionMask;
  121575. /**
  121576. * Get the mask that the camera ignores in collision events.
  121577. */
  121578. get collisionMask(): number;
  121579. /**
  121580. * Set the mask that the camera ignores in collision events.
  121581. */
  121582. set collisionMask(mask: number);
  121583. /** @hidden */
  121584. _collideWithWorld(displacement: Vector3): void;
  121585. /** @hidden */
  121586. private _onCollisionPositionChange;
  121587. /** @hidden */
  121588. _checkInputs(): void;
  121589. /** @hidden */
  121590. _decideIfNeedsToMove(): boolean;
  121591. /** @hidden */
  121592. _updatePosition(): void;
  121593. /**
  121594. * Restore the Roll to its target value at the rate specified.
  121595. * @param rate - Higher means slower restoring.
  121596. * @hidden
  121597. */
  121598. restoreRoll(rate: number): void;
  121599. /**
  121600. * Destroy the camera and release the current resources held by it.
  121601. */
  121602. dispose(): void;
  121603. /**
  121604. * Get the current object class name.
  121605. * @returns the class name.
  121606. */
  121607. getClassName(): string;
  121608. }
  121609. }
  121610. declare module BABYLON {
  121611. /**
  121612. * Listen to keyboard events to control the camera.
  121613. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121614. */
  121615. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  121616. /**
  121617. * Defines the camera the input is attached to.
  121618. */
  121619. camera: FlyCamera;
  121620. /**
  121621. * The list of keyboard keys used to control the forward move of the camera.
  121622. */
  121623. keysForward: number[];
  121624. /**
  121625. * The list of keyboard keys used to control the backward move of the camera.
  121626. */
  121627. keysBackward: number[];
  121628. /**
  121629. * The list of keyboard keys used to control the forward move of the camera.
  121630. */
  121631. keysUp: number[];
  121632. /**
  121633. * The list of keyboard keys used to control the backward move of the camera.
  121634. */
  121635. keysDown: number[];
  121636. /**
  121637. * The list of keyboard keys used to control the right strafe move of the camera.
  121638. */
  121639. keysRight: number[];
  121640. /**
  121641. * The list of keyboard keys used to control the left strafe move of the camera.
  121642. */
  121643. keysLeft: number[];
  121644. private _keys;
  121645. private _onCanvasBlurObserver;
  121646. private _onKeyboardObserver;
  121647. private _engine;
  121648. private _scene;
  121649. /**
  121650. * Attach the input controls to a specific dom element to get the input from.
  121651. * @param element Defines the element the controls should be listened from
  121652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121653. */
  121654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121655. /**
  121656. * Detach the current controls from the specified dom element.
  121657. * @param element Defines the element to stop listening the inputs from
  121658. */
  121659. detachControl(element: Nullable<HTMLElement>): void;
  121660. /**
  121661. * Gets the class name of the current intput.
  121662. * @returns the class name
  121663. */
  121664. getClassName(): string;
  121665. /** @hidden */
  121666. _onLostFocus(e: FocusEvent): void;
  121667. /**
  121668. * Get the friendly name associated with the input class.
  121669. * @returns the input friendly name
  121670. */
  121671. getSimpleName(): string;
  121672. /**
  121673. * Update the current camera state depending on the inputs that have been used this frame.
  121674. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121675. */
  121676. checkInputs(): void;
  121677. }
  121678. }
  121679. declare module BABYLON {
  121680. /**
  121681. * Manage the mouse wheel inputs to control a follow camera.
  121682. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121683. */
  121684. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  121685. /**
  121686. * Defines the camera the input is attached to.
  121687. */
  121688. camera: FollowCamera;
  121689. /**
  121690. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  121691. */
  121692. axisControlRadius: boolean;
  121693. /**
  121694. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  121695. */
  121696. axisControlHeight: boolean;
  121697. /**
  121698. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  121699. */
  121700. axisControlRotation: boolean;
  121701. /**
  121702. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  121703. * relation to mouseWheel events.
  121704. */
  121705. wheelPrecision: number;
  121706. /**
  121707. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121708. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121709. */
  121710. wheelDeltaPercentage: number;
  121711. private _wheel;
  121712. private _observer;
  121713. /**
  121714. * Attach the input controls to a specific dom element to get the input from.
  121715. * @param element Defines the element the controls should be listened from
  121716. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121717. */
  121718. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121719. /**
  121720. * Detach the current controls from the specified dom element.
  121721. * @param element Defines the element to stop listening the inputs from
  121722. */
  121723. detachControl(element: Nullable<HTMLElement>): void;
  121724. /**
  121725. * Gets the class name of the current intput.
  121726. * @returns the class name
  121727. */
  121728. getClassName(): string;
  121729. /**
  121730. * Get the friendly name associated with the input class.
  121731. * @returns the input friendly name
  121732. */
  121733. getSimpleName(): string;
  121734. }
  121735. }
  121736. declare module BABYLON {
  121737. /**
  121738. * Manage the pointers inputs to control an follow camera.
  121739. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121740. */
  121741. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  121742. /**
  121743. * Defines the camera the input is attached to.
  121744. */
  121745. camera: FollowCamera;
  121746. /**
  121747. * Gets the class name of the current input.
  121748. * @returns the class name
  121749. */
  121750. getClassName(): string;
  121751. /**
  121752. * Defines the pointer angular sensibility along the X axis or how fast is
  121753. * the camera rotating.
  121754. * A negative number will reverse the axis direction.
  121755. */
  121756. angularSensibilityX: number;
  121757. /**
  121758. * Defines the pointer angular sensibility along the Y axis or how fast is
  121759. * the camera rotating.
  121760. * A negative number will reverse the axis direction.
  121761. */
  121762. angularSensibilityY: number;
  121763. /**
  121764. * Defines the pointer pinch precision or how fast is the camera zooming.
  121765. * A negative number will reverse the axis direction.
  121766. */
  121767. pinchPrecision: number;
  121768. /**
  121769. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121770. * from 0.
  121771. * It defines the percentage of current camera.radius to use as delta when
  121772. * pinch zoom is used.
  121773. */
  121774. pinchDeltaPercentage: number;
  121775. /**
  121776. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  121777. */
  121778. axisXControlRadius: boolean;
  121779. /**
  121780. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  121781. */
  121782. axisXControlHeight: boolean;
  121783. /**
  121784. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  121785. */
  121786. axisXControlRotation: boolean;
  121787. /**
  121788. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  121789. */
  121790. axisYControlRadius: boolean;
  121791. /**
  121792. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  121793. */
  121794. axisYControlHeight: boolean;
  121795. /**
  121796. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  121797. */
  121798. axisYControlRotation: boolean;
  121799. /**
  121800. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  121801. */
  121802. axisPinchControlRadius: boolean;
  121803. /**
  121804. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  121805. */
  121806. axisPinchControlHeight: boolean;
  121807. /**
  121808. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  121809. */
  121810. axisPinchControlRotation: boolean;
  121811. /**
  121812. * Log error messages if basic misconfiguration has occurred.
  121813. */
  121814. warningEnable: boolean;
  121815. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121816. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121817. private _warningCounter;
  121818. private _warning;
  121819. }
  121820. }
  121821. declare module BABYLON {
  121822. /**
  121823. * Default Inputs manager for the FollowCamera.
  121824. * It groups all the default supported inputs for ease of use.
  121825. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121826. */
  121827. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  121828. /**
  121829. * Instantiates a new FollowCameraInputsManager.
  121830. * @param camera Defines the camera the inputs belong to
  121831. */
  121832. constructor(camera: FollowCamera);
  121833. /**
  121834. * Add keyboard input support to the input manager.
  121835. * @returns the current input manager
  121836. */
  121837. addKeyboard(): FollowCameraInputsManager;
  121838. /**
  121839. * Add mouse wheel input support to the input manager.
  121840. * @returns the current input manager
  121841. */
  121842. addMouseWheel(): FollowCameraInputsManager;
  121843. /**
  121844. * Add pointers input support to the input manager.
  121845. * @returns the current input manager
  121846. */
  121847. addPointers(): FollowCameraInputsManager;
  121848. /**
  121849. * Add orientation input support to the input manager.
  121850. * @returns the current input manager
  121851. */
  121852. addVRDeviceOrientation(): FollowCameraInputsManager;
  121853. }
  121854. }
  121855. declare module BABYLON {
  121856. /**
  121857. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  121858. * an arc rotate version arcFollowCamera are available.
  121859. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121860. */
  121861. export class FollowCamera extends TargetCamera {
  121862. /**
  121863. * Distance the follow camera should follow an object at
  121864. */
  121865. radius: number;
  121866. /**
  121867. * Minimum allowed distance of the camera to the axis of rotation
  121868. * (The camera can not get closer).
  121869. * This can help limiting how the Camera is able to move in the scene.
  121870. */
  121871. lowerRadiusLimit: Nullable<number>;
  121872. /**
  121873. * Maximum allowed distance of the camera to the axis of rotation
  121874. * (The camera can not get further).
  121875. * This can help limiting how the Camera is able to move in the scene.
  121876. */
  121877. upperRadiusLimit: Nullable<number>;
  121878. /**
  121879. * Define a rotation offset between the camera and the object it follows
  121880. */
  121881. rotationOffset: number;
  121882. /**
  121883. * Minimum allowed angle to camera position relative to target object.
  121884. * This can help limiting how the Camera is able to move in the scene.
  121885. */
  121886. lowerRotationOffsetLimit: Nullable<number>;
  121887. /**
  121888. * Maximum allowed angle to camera position relative to target object.
  121889. * This can help limiting how the Camera is able to move in the scene.
  121890. */
  121891. upperRotationOffsetLimit: Nullable<number>;
  121892. /**
  121893. * Define a height offset between the camera and the object it follows.
  121894. * It can help following an object from the top (like a car chaing a plane)
  121895. */
  121896. heightOffset: number;
  121897. /**
  121898. * Minimum allowed height of camera position relative to target object.
  121899. * This can help limiting how the Camera is able to move in the scene.
  121900. */
  121901. lowerHeightOffsetLimit: Nullable<number>;
  121902. /**
  121903. * Maximum allowed height of camera position relative to target object.
  121904. * This can help limiting how the Camera is able to move in the scene.
  121905. */
  121906. upperHeightOffsetLimit: Nullable<number>;
  121907. /**
  121908. * Define how fast the camera can accelerate to follow it s target.
  121909. */
  121910. cameraAcceleration: number;
  121911. /**
  121912. * Define the speed limit of the camera following an object.
  121913. */
  121914. maxCameraSpeed: number;
  121915. /**
  121916. * Define the target of the camera.
  121917. */
  121918. lockedTarget: Nullable<AbstractMesh>;
  121919. /**
  121920. * Defines the input associated with the camera.
  121921. */
  121922. inputs: FollowCameraInputsManager;
  121923. /**
  121924. * Instantiates the follow camera.
  121925. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121926. * @param name Define the name of the camera in the scene
  121927. * @param position Define the position of the camera
  121928. * @param scene Define the scene the camera belong to
  121929. * @param lockedTarget Define the target of the camera
  121930. */
  121931. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  121932. private _follow;
  121933. /**
  121934. * Attached controls to the current camera.
  121935. * @param element Defines the element the controls should be listened from
  121936. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121937. */
  121938. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121939. /**
  121940. * Detach the current controls from the camera.
  121941. * The camera will stop reacting to inputs.
  121942. * @param element Defines the element to stop listening the inputs from
  121943. */
  121944. detachControl(element: HTMLElement): void;
  121945. /** @hidden */
  121946. _checkInputs(): void;
  121947. private _checkLimits;
  121948. /**
  121949. * Gets the camera class name.
  121950. * @returns the class name
  121951. */
  121952. getClassName(): string;
  121953. }
  121954. /**
  121955. * Arc Rotate version of the follow camera.
  121956. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  121957. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121958. */
  121959. export class ArcFollowCamera extends TargetCamera {
  121960. /** The longitudinal angle of the camera */
  121961. alpha: number;
  121962. /** The latitudinal angle of the camera */
  121963. beta: number;
  121964. /** The radius of the camera from its target */
  121965. radius: number;
  121966. /** Define the camera target (the mesh it should follow) */
  121967. target: Nullable<AbstractMesh>;
  121968. private _cartesianCoordinates;
  121969. /**
  121970. * Instantiates a new ArcFollowCamera
  121971. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121972. * @param name Define the name of the camera
  121973. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  121974. * @param beta Define the rotation angle of the camera around the elevation axis
  121975. * @param radius Define the radius of the camera from its target point
  121976. * @param target Define the target of the camera
  121977. * @param scene Define the scene the camera belongs to
  121978. */
  121979. constructor(name: string,
  121980. /** The longitudinal angle of the camera */
  121981. alpha: number,
  121982. /** The latitudinal angle of the camera */
  121983. beta: number,
  121984. /** The radius of the camera from its target */
  121985. radius: number,
  121986. /** Define the camera target (the mesh it should follow) */
  121987. target: Nullable<AbstractMesh>, scene: Scene);
  121988. private _follow;
  121989. /** @hidden */
  121990. _checkInputs(): void;
  121991. /**
  121992. * Returns the class name of the object.
  121993. * It is mostly used internally for serialization purposes.
  121994. */
  121995. getClassName(): string;
  121996. }
  121997. }
  121998. declare module BABYLON {
  121999. /**
  122000. * Manage the keyboard inputs to control the movement of a follow camera.
  122001. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122002. */
  122003. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  122004. /**
  122005. * Defines the camera the input is attached to.
  122006. */
  122007. camera: FollowCamera;
  122008. /**
  122009. * Defines the list of key codes associated with the up action (increase heightOffset)
  122010. */
  122011. keysHeightOffsetIncr: number[];
  122012. /**
  122013. * Defines the list of key codes associated with the down action (decrease heightOffset)
  122014. */
  122015. keysHeightOffsetDecr: number[];
  122016. /**
  122017. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  122018. */
  122019. keysHeightOffsetModifierAlt: boolean;
  122020. /**
  122021. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  122022. */
  122023. keysHeightOffsetModifierCtrl: boolean;
  122024. /**
  122025. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  122026. */
  122027. keysHeightOffsetModifierShift: boolean;
  122028. /**
  122029. * Defines the list of key codes associated with the left action (increase rotationOffset)
  122030. */
  122031. keysRotationOffsetIncr: number[];
  122032. /**
  122033. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  122034. */
  122035. keysRotationOffsetDecr: number[];
  122036. /**
  122037. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  122038. */
  122039. keysRotationOffsetModifierAlt: boolean;
  122040. /**
  122041. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  122042. */
  122043. keysRotationOffsetModifierCtrl: boolean;
  122044. /**
  122045. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  122046. */
  122047. keysRotationOffsetModifierShift: boolean;
  122048. /**
  122049. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  122050. */
  122051. keysRadiusIncr: number[];
  122052. /**
  122053. * Defines the list of key codes associated with the zoom-out action (increase radius)
  122054. */
  122055. keysRadiusDecr: number[];
  122056. /**
  122057. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  122058. */
  122059. keysRadiusModifierAlt: boolean;
  122060. /**
  122061. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  122062. */
  122063. keysRadiusModifierCtrl: boolean;
  122064. /**
  122065. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  122066. */
  122067. keysRadiusModifierShift: boolean;
  122068. /**
  122069. * Defines the rate of change of heightOffset.
  122070. */
  122071. heightSensibility: number;
  122072. /**
  122073. * Defines the rate of change of rotationOffset.
  122074. */
  122075. rotationSensibility: number;
  122076. /**
  122077. * Defines the rate of change of radius.
  122078. */
  122079. radiusSensibility: number;
  122080. private _keys;
  122081. private _ctrlPressed;
  122082. private _altPressed;
  122083. private _shiftPressed;
  122084. private _onCanvasBlurObserver;
  122085. private _onKeyboardObserver;
  122086. private _engine;
  122087. private _scene;
  122088. /**
  122089. * Attach the input controls to a specific dom element to get the input from.
  122090. * @param element Defines the element the controls should be listened from
  122091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122092. */
  122093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122094. /**
  122095. * Detach the current controls from the specified dom element.
  122096. * @param element Defines the element to stop listening the inputs from
  122097. */
  122098. detachControl(element: Nullable<HTMLElement>): void;
  122099. /**
  122100. * Update the current camera state depending on the inputs that have been used this frame.
  122101. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122102. */
  122103. checkInputs(): void;
  122104. /**
  122105. * Gets the class name of the current input.
  122106. * @returns the class name
  122107. */
  122108. getClassName(): string;
  122109. /**
  122110. * Get the friendly name associated with the input class.
  122111. * @returns the input friendly name
  122112. */
  122113. getSimpleName(): string;
  122114. /**
  122115. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122116. * allow modification of the heightOffset value.
  122117. */
  122118. private _modifierHeightOffset;
  122119. /**
  122120. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122121. * allow modification of the rotationOffset value.
  122122. */
  122123. private _modifierRotationOffset;
  122124. /**
  122125. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122126. * allow modification of the radius value.
  122127. */
  122128. private _modifierRadius;
  122129. }
  122130. }
  122131. declare module BABYLON {
  122132. interface FreeCameraInputsManager {
  122133. /**
  122134. * @hidden
  122135. */
  122136. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  122137. /**
  122138. * Add orientation input support to the input manager.
  122139. * @returns the current input manager
  122140. */
  122141. addDeviceOrientation(): FreeCameraInputsManager;
  122142. }
  122143. /**
  122144. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  122145. * Screen rotation is taken into account.
  122146. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122147. */
  122148. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  122149. private _camera;
  122150. private _screenOrientationAngle;
  122151. private _constantTranform;
  122152. private _screenQuaternion;
  122153. private _alpha;
  122154. private _beta;
  122155. private _gamma;
  122156. /**
  122157. * Can be used to detect if a device orientation sensor is available on a device
  122158. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  122159. * @returns a promise that will resolve on orientation change
  122160. */
  122161. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  122162. /**
  122163. * @hidden
  122164. */
  122165. _onDeviceOrientationChangedObservable: Observable<void>;
  122166. /**
  122167. * Instantiates a new input
  122168. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122169. */
  122170. constructor();
  122171. /**
  122172. * Define the camera controlled by the input.
  122173. */
  122174. get camera(): FreeCamera;
  122175. set camera(camera: FreeCamera);
  122176. /**
  122177. * Attach the input controls to a specific dom element to get the input from.
  122178. * @param element Defines the element the controls should be listened from
  122179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122180. */
  122181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122182. private _orientationChanged;
  122183. private _deviceOrientation;
  122184. /**
  122185. * Detach the current controls from the specified dom element.
  122186. * @param element Defines the element to stop listening the inputs from
  122187. */
  122188. detachControl(element: Nullable<HTMLElement>): void;
  122189. /**
  122190. * Update the current camera state depending on the inputs that have been used this frame.
  122191. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122192. */
  122193. checkInputs(): void;
  122194. /**
  122195. * Gets the class name of the current intput.
  122196. * @returns the class name
  122197. */
  122198. getClassName(): string;
  122199. /**
  122200. * Get the friendly name associated with the input class.
  122201. * @returns the input friendly name
  122202. */
  122203. getSimpleName(): string;
  122204. }
  122205. }
  122206. declare module BABYLON {
  122207. /**
  122208. * Manage the gamepad inputs to control a free camera.
  122209. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122210. */
  122211. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  122212. /**
  122213. * Define the camera the input is attached to.
  122214. */
  122215. camera: FreeCamera;
  122216. /**
  122217. * Define the Gamepad controlling the input
  122218. */
  122219. gamepad: Nullable<Gamepad>;
  122220. /**
  122221. * Defines the gamepad rotation sensiblity.
  122222. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122223. */
  122224. gamepadAngularSensibility: number;
  122225. /**
  122226. * Defines the gamepad move sensiblity.
  122227. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122228. */
  122229. gamepadMoveSensibility: number;
  122230. private _yAxisScale;
  122231. /**
  122232. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122233. */
  122234. get invertYAxis(): boolean;
  122235. set invertYAxis(value: boolean);
  122236. private _onGamepadConnectedObserver;
  122237. private _onGamepadDisconnectedObserver;
  122238. private _cameraTransform;
  122239. private _deltaTransform;
  122240. private _vector3;
  122241. private _vector2;
  122242. /**
  122243. * Attach the input controls to a specific dom element to get the input from.
  122244. * @param element Defines the element the controls should be listened from
  122245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122246. */
  122247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122248. /**
  122249. * Detach the current controls from the specified dom element.
  122250. * @param element Defines the element to stop listening the inputs from
  122251. */
  122252. detachControl(element: Nullable<HTMLElement>): void;
  122253. /**
  122254. * Update the current camera state depending on the inputs that have been used this frame.
  122255. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122256. */
  122257. checkInputs(): void;
  122258. /**
  122259. * Gets the class name of the current intput.
  122260. * @returns the class name
  122261. */
  122262. getClassName(): string;
  122263. /**
  122264. * Get the friendly name associated with the input class.
  122265. * @returns the input friendly name
  122266. */
  122267. getSimpleName(): string;
  122268. }
  122269. }
  122270. declare module BABYLON {
  122271. /**
  122272. * Defines the potential axis of a Joystick
  122273. */
  122274. export enum JoystickAxis {
  122275. /** X axis */
  122276. X = 0,
  122277. /** Y axis */
  122278. Y = 1,
  122279. /** Z axis */
  122280. Z = 2
  122281. }
  122282. /**
  122283. * Represents the different customization options available
  122284. * for VirtualJoystick
  122285. */
  122286. interface VirtualJoystickCustomizations {
  122287. /**
  122288. * Size of the joystick's puck
  122289. */
  122290. puckSize: number;
  122291. /**
  122292. * Size of the joystick's container
  122293. */
  122294. containerSize: number;
  122295. /**
  122296. * Color of the joystick && puck
  122297. */
  122298. color: string;
  122299. /**
  122300. * Image URL for the joystick's puck
  122301. */
  122302. puckImage?: string;
  122303. /**
  122304. * Image URL for the joystick's container
  122305. */
  122306. containerImage?: string;
  122307. /**
  122308. * Defines the unmoving position of the joystick container
  122309. */
  122310. position?: {
  122311. x: number;
  122312. y: number;
  122313. };
  122314. /**
  122315. * Defines whether or not the joystick container is always visible
  122316. */
  122317. alwaysVisible: boolean;
  122318. /**
  122319. * Defines whether or not to limit the movement of the puck to the joystick's container
  122320. */
  122321. limitToContainer: boolean;
  122322. }
  122323. /**
  122324. * Class used to define virtual joystick (used in touch mode)
  122325. */
  122326. export class VirtualJoystick {
  122327. /**
  122328. * Gets or sets a boolean indicating that left and right values must be inverted
  122329. */
  122330. reverseLeftRight: boolean;
  122331. /**
  122332. * Gets or sets a boolean indicating that up and down values must be inverted
  122333. */
  122334. reverseUpDown: boolean;
  122335. /**
  122336. * Gets the offset value for the position (ie. the change of the position value)
  122337. */
  122338. deltaPosition: Vector3;
  122339. /**
  122340. * Gets a boolean indicating if the virtual joystick was pressed
  122341. */
  122342. pressed: boolean;
  122343. /**
  122344. * Canvas the virtual joystick will render onto, default z-index of this is 5
  122345. */
  122346. static Canvas: Nullable<HTMLCanvasElement>;
  122347. /**
  122348. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  122349. */
  122350. limitToContainer: boolean;
  122351. private static _globalJoystickIndex;
  122352. private static _alwaysVisibleSticks;
  122353. private static vjCanvasContext;
  122354. private static vjCanvasWidth;
  122355. private static vjCanvasHeight;
  122356. private static halfWidth;
  122357. private static _GetDefaultOptions;
  122358. private _action;
  122359. private _axisTargetedByLeftAndRight;
  122360. private _axisTargetedByUpAndDown;
  122361. private _joystickSensibility;
  122362. private _inversedSensibility;
  122363. private _joystickPointerID;
  122364. private _joystickColor;
  122365. private _joystickPointerPos;
  122366. private _joystickPreviousPointerPos;
  122367. private _joystickPointerStartPos;
  122368. private _deltaJoystickVector;
  122369. private _leftJoystick;
  122370. private _touches;
  122371. private _joystickPosition;
  122372. private _alwaysVisible;
  122373. private _puckImage;
  122374. private _containerImage;
  122375. private _joystickPuckSize;
  122376. private _joystickContainerSize;
  122377. private _clearPuckSize;
  122378. private _clearContainerSize;
  122379. private _clearPuckSizeOffset;
  122380. private _clearContainerSizeOffset;
  122381. private _onPointerDownHandlerRef;
  122382. private _onPointerMoveHandlerRef;
  122383. private _onPointerUpHandlerRef;
  122384. private _onResize;
  122385. /**
  122386. * Creates a new virtual joystick
  122387. * @param leftJoystick defines that the joystick is for left hand (false by default)
  122388. * @param customizations Defines the options we want to customize the VirtualJoystick
  122389. */
  122390. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  122391. /**
  122392. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  122393. * @param newJoystickSensibility defines the new sensibility
  122394. */
  122395. setJoystickSensibility(newJoystickSensibility: number): void;
  122396. private _onPointerDown;
  122397. private _onPointerMove;
  122398. private _onPointerUp;
  122399. /**
  122400. * Change the color of the virtual joystick
  122401. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  122402. */
  122403. setJoystickColor(newColor: string): void;
  122404. /**
  122405. * Size of the joystick's container
  122406. */
  122407. set containerSize(newSize: number);
  122408. get containerSize(): number;
  122409. /**
  122410. * Size of the joystick's puck
  122411. */
  122412. set puckSize(newSize: number);
  122413. get puckSize(): number;
  122414. /**
  122415. * Clears the set position of the joystick
  122416. */
  122417. clearPosition(): void;
  122418. /**
  122419. * Defines whether or not the joystick container is always visible
  122420. */
  122421. set alwaysVisible(value: boolean);
  122422. get alwaysVisible(): boolean;
  122423. /**
  122424. * Sets the constant position of the Joystick container
  122425. * @param x X axis coordinate
  122426. * @param y Y axis coordinate
  122427. */
  122428. setPosition(x: number, y: number): void;
  122429. /**
  122430. * Defines a callback to call when the joystick is touched
  122431. * @param action defines the callback
  122432. */
  122433. setActionOnTouch(action: () => any): void;
  122434. /**
  122435. * Defines which axis you'd like to control for left & right
  122436. * @param axis defines the axis to use
  122437. */
  122438. setAxisForLeftRight(axis: JoystickAxis): void;
  122439. /**
  122440. * Defines which axis you'd like to control for up & down
  122441. * @param axis defines the axis to use
  122442. */
  122443. setAxisForUpDown(axis: JoystickAxis): void;
  122444. /**
  122445. * Clears the canvas from the previous puck / container draw
  122446. */
  122447. private _clearPreviousDraw;
  122448. /**
  122449. * Loads `urlPath` to be used for the container's image
  122450. * @param urlPath defines the urlPath of an image to use
  122451. */
  122452. setContainerImage(urlPath: string): void;
  122453. /**
  122454. * Loads `urlPath` to be used for the puck's image
  122455. * @param urlPath defines the urlPath of an image to use
  122456. */
  122457. setPuckImage(urlPath: string): void;
  122458. /**
  122459. * Draws the Virtual Joystick's container
  122460. */
  122461. private _drawContainer;
  122462. /**
  122463. * Draws the Virtual Joystick's puck
  122464. */
  122465. private _drawPuck;
  122466. private _drawVirtualJoystick;
  122467. /**
  122468. * Release internal HTML canvas
  122469. */
  122470. releaseCanvas(): void;
  122471. }
  122472. }
  122473. declare module BABYLON {
  122474. interface FreeCameraInputsManager {
  122475. /**
  122476. * Add virtual joystick input support to the input manager.
  122477. * @returns the current input manager
  122478. */
  122479. addVirtualJoystick(): FreeCameraInputsManager;
  122480. }
  122481. /**
  122482. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  122483. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122484. */
  122485. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  122486. /**
  122487. * Defines the camera the input is attached to.
  122488. */
  122489. camera: FreeCamera;
  122490. private _leftjoystick;
  122491. private _rightjoystick;
  122492. /**
  122493. * Gets the left stick of the virtual joystick.
  122494. * @returns The virtual Joystick
  122495. */
  122496. getLeftJoystick(): VirtualJoystick;
  122497. /**
  122498. * Gets the right stick of the virtual joystick.
  122499. * @returns The virtual Joystick
  122500. */
  122501. getRightJoystick(): VirtualJoystick;
  122502. /**
  122503. * Update the current camera state depending on the inputs that have been used this frame.
  122504. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122505. */
  122506. checkInputs(): void;
  122507. /**
  122508. * Attach the input controls to a specific dom element to get the input from.
  122509. * @param element Defines the element the controls should be listened from
  122510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122511. */
  122512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122513. /**
  122514. * Detach the current controls from the specified dom element.
  122515. * @param element Defines the element to stop listening the inputs from
  122516. */
  122517. detachControl(element: Nullable<HTMLElement>): void;
  122518. /**
  122519. * Gets the class name of the current intput.
  122520. * @returns the class name
  122521. */
  122522. getClassName(): string;
  122523. /**
  122524. * Get the friendly name associated with the input class.
  122525. * @returns the input friendly name
  122526. */
  122527. getSimpleName(): string;
  122528. }
  122529. }
  122530. declare module BABYLON {
  122531. /**
  122532. * This represents a FPS type of camera controlled by touch.
  122533. * This is like a universal camera minus the Gamepad controls.
  122534. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  122535. */
  122536. export class TouchCamera extends FreeCamera {
  122537. /**
  122538. * Defines the touch sensibility for rotation.
  122539. * The higher the faster.
  122540. */
  122541. get touchAngularSensibility(): number;
  122542. set touchAngularSensibility(value: number);
  122543. /**
  122544. * Defines the touch sensibility for move.
  122545. * The higher the faster.
  122546. */
  122547. get touchMoveSensibility(): number;
  122548. set touchMoveSensibility(value: number);
  122549. /**
  122550. * Instantiates a new touch camera.
  122551. * This represents a FPS type of camera controlled by touch.
  122552. * This is like a universal camera minus the Gamepad controls.
  122553. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  122554. * @param name Define the name of the camera in the scene
  122555. * @param position Define the start position of the camera in the scene
  122556. * @param scene Define the scene the camera belongs to
  122557. */
  122558. constructor(name: string, position: Vector3, scene: Scene);
  122559. /**
  122560. * Gets the current object class name.
  122561. * @return the class name
  122562. */
  122563. getClassName(): string;
  122564. /** @hidden */
  122565. _setupInputs(): void;
  122566. }
  122567. }
  122568. declare module BABYLON {
  122569. /**
  122570. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  122571. * being tilted forward or back and left or right.
  122572. */
  122573. export class DeviceOrientationCamera extends FreeCamera {
  122574. private _initialQuaternion;
  122575. private _quaternionCache;
  122576. private _tmpDragQuaternion;
  122577. private _disablePointerInputWhenUsingDeviceOrientation;
  122578. /**
  122579. * Creates a new device orientation camera
  122580. * @param name The name of the camera
  122581. * @param position The start position camera
  122582. * @param scene The scene the camera belongs to
  122583. */
  122584. constructor(name: string, position: Vector3, scene: Scene);
  122585. /**
  122586. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  122587. */
  122588. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  122589. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  122590. private _dragFactor;
  122591. /**
  122592. * Enabled turning on the y axis when the orientation sensor is active
  122593. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  122594. */
  122595. enableHorizontalDragging(dragFactor?: number): void;
  122596. /**
  122597. * Gets the current instance class name ("DeviceOrientationCamera").
  122598. * This helps avoiding instanceof at run time.
  122599. * @returns the class name
  122600. */
  122601. getClassName(): string;
  122602. /**
  122603. * @hidden
  122604. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  122605. */
  122606. _checkInputs(): void;
  122607. /**
  122608. * Reset the camera to its default orientation on the specified axis only.
  122609. * @param axis The axis to reset
  122610. */
  122611. resetToCurrentRotation(axis?: Axis): void;
  122612. }
  122613. }
  122614. declare module BABYLON {
  122615. /**
  122616. * Defines supported buttons for XBox360 compatible gamepads
  122617. */
  122618. export enum Xbox360Button {
  122619. /** A */
  122620. A = 0,
  122621. /** B */
  122622. B = 1,
  122623. /** X */
  122624. X = 2,
  122625. /** Y */
  122626. Y = 3,
  122627. /** Left button */
  122628. LB = 4,
  122629. /** Right button */
  122630. RB = 5,
  122631. /** Back */
  122632. Back = 8,
  122633. /** Start */
  122634. Start = 9,
  122635. /** Left stick */
  122636. LeftStick = 10,
  122637. /** Right stick */
  122638. RightStick = 11
  122639. }
  122640. /** Defines values for XBox360 DPad */
  122641. export enum Xbox360Dpad {
  122642. /** Up */
  122643. Up = 12,
  122644. /** Down */
  122645. Down = 13,
  122646. /** Left */
  122647. Left = 14,
  122648. /** Right */
  122649. Right = 15
  122650. }
  122651. /**
  122652. * Defines a XBox360 gamepad
  122653. */
  122654. export class Xbox360Pad extends Gamepad {
  122655. private _leftTrigger;
  122656. private _rightTrigger;
  122657. private _onlefttriggerchanged;
  122658. private _onrighttriggerchanged;
  122659. private _onbuttondown;
  122660. private _onbuttonup;
  122661. private _ondpaddown;
  122662. private _ondpadup;
  122663. /** Observable raised when a button is pressed */
  122664. onButtonDownObservable: Observable<Xbox360Button>;
  122665. /** Observable raised when a button is released */
  122666. onButtonUpObservable: Observable<Xbox360Button>;
  122667. /** Observable raised when a pad is pressed */
  122668. onPadDownObservable: Observable<Xbox360Dpad>;
  122669. /** Observable raised when a pad is released */
  122670. onPadUpObservable: Observable<Xbox360Dpad>;
  122671. private _buttonA;
  122672. private _buttonB;
  122673. private _buttonX;
  122674. private _buttonY;
  122675. private _buttonBack;
  122676. private _buttonStart;
  122677. private _buttonLB;
  122678. private _buttonRB;
  122679. private _buttonLeftStick;
  122680. private _buttonRightStick;
  122681. private _dPadUp;
  122682. private _dPadDown;
  122683. private _dPadLeft;
  122684. private _dPadRight;
  122685. private _isXboxOnePad;
  122686. /**
  122687. * Creates a new XBox360 gamepad object
  122688. * @param id defines the id of this gamepad
  122689. * @param index defines its index
  122690. * @param gamepad defines the internal HTML gamepad object
  122691. * @param xboxOne defines if it is a XBox One gamepad
  122692. */
  122693. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  122694. /**
  122695. * Defines the callback to call when left trigger is pressed
  122696. * @param callback defines the callback to use
  122697. */
  122698. onlefttriggerchanged(callback: (value: number) => void): void;
  122699. /**
  122700. * Defines the callback to call when right trigger is pressed
  122701. * @param callback defines the callback to use
  122702. */
  122703. onrighttriggerchanged(callback: (value: number) => void): void;
  122704. /**
  122705. * Gets the left trigger value
  122706. */
  122707. get leftTrigger(): number;
  122708. /**
  122709. * Sets the left trigger value
  122710. */
  122711. set leftTrigger(newValue: number);
  122712. /**
  122713. * Gets the right trigger value
  122714. */
  122715. get rightTrigger(): number;
  122716. /**
  122717. * Sets the right trigger value
  122718. */
  122719. set rightTrigger(newValue: number);
  122720. /**
  122721. * Defines the callback to call when a button is pressed
  122722. * @param callback defines the callback to use
  122723. */
  122724. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  122725. /**
  122726. * Defines the callback to call when a button is released
  122727. * @param callback defines the callback to use
  122728. */
  122729. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  122730. /**
  122731. * Defines the callback to call when a pad is pressed
  122732. * @param callback defines the callback to use
  122733. */
  122734. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  122735. /**
  122736. * Defines the callback to call when a pad is released
  122737. * @param callback defines the callback to use
  122738. */
  122739. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  122740. private _setButtonValue;
  122741. private _setDPadValue;
  122742. /**
  122743. * Gets the value of the `A` button
  122744. */
  122745. get buttonA(): number;
  122746. /**
  122747. * Sets the value of the `A` button
  122748. */
  122749. set buttonA(value: number);
  122750. /**
  122751. * Gets the value of the `B` button
  122752. */
  122753. get buttonB(): number;
  122754. /**
  122755. * Sets the value of the `B` button
  122756. */
  122757. set buttonB(value: number);
  122758. /**
  122759. * Gets the value of the `X` button
  122760. */
  122761. get buttonX(): number;
  122762. /**
  122763. * Sets the value of the `X` button
  122764. */
  122765. set buttonX(value: number);
  122766. /**
  122767. * Gets the value of the `Y` button
  122768. */
  122769. get buttonY(): number;
  122770. /**
  122771. * Sets the value of the `Y` button
  122772. */
  122773. set buttonY(value: number);
  122774. /**
  122775. * Gets the value of the `Start` button
  122776. */
  122777. get buttonStart(): number;
  122778. /**
  122779. * Sets the value of the `Start` button
  122780. */
  122781. set buttonStart(value: number);
  122782. /**
  122783. * Gets the value of the `Back` button
  122784. */
  122785. get buttonBack(): number;
  122786. /**
  122787. * Sets the value of the `Back` button
  122788. */
  122789. set buttonBack(value: number);
  122790. /**
  122791. * Gets the value of the `Left` button
  122792. */
  122793. get buttonLB(): number;
  122794. /**
  122795. * Sets the value of the `Left` button
  122796. */
  122797. set buttonLB(value: number);
  122798. /**
  122799. * Gets the value of the `Right` button
  122800. */
  122801. get buttonRB(): number;
  122802. /**
  122803. * Sets the value of the `Right` button
  122804. */
  122805. set buttonRB(value: number);
  122806. /**
  122807. * Gets the value of the Left joystick
  122808. */
  122809. get buttonLeftStick(): number;
  122810. /**
  122811. * Sets the value of the Left joystick
  122812. */
  122813. set buttonLeftStick(value: number);
  122814. /**
  122815. * Gets the value of the Right joystick
  122816. */
  122817. get buttonRightStick(): number;
  122818. /**
  122819. * Sets the value of the Right joystick
  122820. */
  122821. set buttonRightStick(value: number);
  122822. /**
  122823. * Gets the value of D-pad up
  122824. */
  122825. get dPadUp(): number;
  122826. /**
  122827. * Sets the value of D-pad up
  122828. */
  122829. set dPadUp(value: number);
  122830. /**
  122831. * Gets the value of D-pad down
  122832. */
  122833. get dPadDown(): number;
  122834. /**
  122835. * Sets the value of D-pad down
  122836. */
  122837. set dPadDown(value: number);
  122838. /**
  122839. * Gets the value of D-pad left
  122840. */
  122841. get dPadLeft(): number;
  122842. /**
  122843. * Sets the value of D-pad left
  122844. */
  122845. set dPadLeft(value: number);
  122846. /**
  122847. * Gets the value of D-pad right
  122848. */
  122849. get dPadRight(): number;
  122850. /**
  122851. * Sets the value of D-pad right
  122852. */
  122853. set dPadRight(value: number);
  122854. /**
  122855. * Force the gamepad to synchronize with device values
  122856. */
  122857. update(): void;
  122858. /**
  122859. * Disposes the gamepad
  122860. */
  122861. dispose(): void;
  122862. }
  122863. }
  122864. declare module BABYLON {
  122865. /**
  122866. * Defines supported buttons for DualShock compatible gamepads
  122867. */
  122868. export enum DualShockButton {
  122869. /** Cross */
  122870. Cross = 0,
  122871. /** Circle */
  122872. Circle = 1,
  122873. /** Square */
  122874. Square = 2,
  122875. /** Triangle */
  122876. Triangle = 3,
  122877. /** L1 */
  122878. L1 = 4,
  122879. /** R1 */
  122880. R1 = 5,
  122881. /** Share */
  122882. Share = 8,
  122883. /** Options */
  122884. Options = 9,
  122885. /** Left stick */
  122886. LeftStick = 10,
  122887. /** Right stick */
  122888. RightStick = 11
  122889. }
  122890. /** Defines values for DualShock DPad */
  122891. export enum DualShockDpad {
  122892. /** Up */
  122893. Up = 12,
  122894. /** Down */
  122895. Down = 13,
  122896. /** Left */
  122897. Left = 14,
  122898. /** Right */
  122899. Right = 15
  122900. }
  122901. /**
  122902. * Defines a DualShock gamepad
  122903. */
  122904. export class DualShockPad extends Gamepad {
  122905. private _leftTrigger;
  122906. private _rightTrigger;
  122907. private _onlefttriggerchanged;
  122908. private _onrighttriggerchanged;
  122909. private _onbuttondown;
  122910. private _onbuttonup;
  122911. private _ondpaddown;
  122912. private _ondpadup;
  122913. /** Observable raised when a button is pressed */
  122914. onButtonDownObservable: Observable<DualShockButton>;
  122915. /** Observable raised when a button is released */
  122916. onButtonUpObservable: Observable<DualShockButton>;
  122917. /** Observable raised when a pad is pressed */
  122918. onPadDownObservable: Observable<DualShockDpad>;
  122919. /** Observable raised when a pad is released */
  122920. onPadUpObservable: Observable<DualShockDpad>;
  122921. private _buttonCross;
  122922. private _buttonCircle;
  122923. private _buttonSquare;
  122924. private _buttonTriangle;
  122925. private _buttonShare;
  122926. private _buttonOptions;
  122927. private _buttonL1;
  122928. private _buttonR1;
  122929. private _buttonLeftStick;
  122930. private _buttonRightStick;
  122931. private _dPadUp;
  122932. private _dPadDown;
  122933. private _dPadLeft;
  122934. private _dPadRight;
  122935. /**
  122936. * Creates a new DualShock gamepad object
  122937. * @param id defines the id of this gamepad
  122938. * @param index defines its index
  122939. * @param gamepad defines the internal HTML gamepad object
  122940. */
  122941. constructor(id: string, index: number, gamepad: any);
  122942. /**
  122943. * Defines the callback to call when left trigger is pressed
  122944. * @param callback defines the callback to use
  122945. */
  122946. onlefttriggerchanged(callback: (value: number) => void): void;
  122947. /**
  122948. * Defines the callback to call when right trigger is pressed
  122949. * @param callback defines the callback to use
  122950. */
  122951. onrighttriggerchanged(callback: (value: number) => void): void;
  122952. /**
  122953. * Gets the left trigger value
  122954. */
  122955. get leftTrigger(): number;
  122956. /**
  122957. * Sets the left trigger value
  122958. */
  122959. set leftTrigger(newValue: number);
  122960. /**
  122961. * Gets the right trigger value
  122962. */
  122963. get rightTrigger(): number;
  122964. /**
  122965. * Sets the right trigger value
  122966. */
  122967. set rightTrigger(newValue: number);
  122968. /**
  122969. * Defines the callback to call when a button is pressed
  122970. * @param callback defines the callback to use
  122971. */
  122972. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  122973. /**
  122974. * Defines the callback to call when a button is released
  122975. * @param callback defines the callback to use
  122976. */
  122977. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  122978. /**
  122979. * Defines the callback to call when a pad is pressed
  122980. * @param callback defines the callback to use
  122981. */
  122982. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  122983. /**
  122984. * Defines the callback to call when a pad is released
  122985. * @param callback defines the callback to use
  122986. */
  122987. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  122988. private _setButtonValue;
  122989. private _setDPadValue;
  122990. /**
  122991. * Gets the value of the `Cross` button
  122992. */
  122993. get buttonCross(): number;
  122994. /**
  122995. * Sets the value of the `Cross` button
  122996. */
  122997. set buttonCross(value: number);
  122998. /**
  122999. * Gets the value of the `Circle` button
  123000. */
  123001. get buttonCircle(): number;
  123002. /**
  123003. * Sets the value of the `Circle` button
  123004. */
  123005. set buttonCircle(value: number);
  123006. /**
  123007. * Gets the value of the `Square` button
  123008. */
  123009. get buttonSquare(): number;
  123010. /**
  123011. * Sets the value of the `Square` button
  123012. */
  123013. set buttonSquare(value: number);
  123014. /**
  123015. * Gets the value of the `Triangle` button
  123016. */
  123017. get buttonTriangle(): number;
  123018. /**
  123019. * Sets the value of the `Triangle` button
  123020. */
  123021. set buttonTriangle(value: number);
  123022. /**
  123023. * Gets the value of the `Options` button
  123024. */
  123025. get buttonOptions(): number;
  123026. /**
  123027. * Sets the value of the `Options` button
  123028. */
  123029. set buttonOptions(value: number);
  123030. /**
  123031. * Gets the value of the `Share` button
  123032. */
  123033. get buttonShare(): number;
  123034. /**
  123035. * Sets the value of the `Share` button
  123036. */
  123037. set buttonShare(value: number);
  123038. /**
  123039. * Gets the value of the `L1` button
  123040. */
  123041. get buttonL1(): number;
  123042. /**
  123043. * Sets the value of the `L1` button
  123044. */
  123045. set buttonL1(value: number);
  123046. /**
  123047. * Gets the value of the `R1` button
  123048. */
  123049. get buttonR1(): number;
  123050. /**
  123051. * Sets the value of the `R1` button
  123052. */
  123053. set buttonR1(value: number);
  123054. /**
  123055. * Gets the value of the Left joystick
  123056. */
  123057. get buttonLeftStick(): number;
  123058. /**
  123059. * Sets the value of the Left joystick
  123060. */
  123061. set buttonLeftStick(value: number);
  123062. /**
  123063. * Gets the value of the Right joystick
  123064. */
  123065. get buttonRightStick(): number;
  123066. /**
  123067. * Sets the value of the Right joystick
  123068. */
  123069. set buttonRightStick(value: number);
  123070. /**
  123071. * Gets the value of D-pad up
  123072. */
  123073. get dPadUp(): number;
  123074. /**
  123075. * Sets the value of D-pad up
  123076. */
  123077. set dPadUp(value: number);
  123078. /**
  123079. * Gets the value of D-pad down
  123080. */
  123081. get dPadDown(): number;
  123082. /**
  123083. * Sets the value of D-pad down
  123084. */
  123085. set dPadDown(value: number);
  123086. /**
  123087. * Gets the value of D-pad left
  123088. */
  123089. get dPadLeft(): number;
  123090. /**
  123091. * Sets the value of D-pad left
  123092. */
  123093. set dPadLeft(value: number);
  123094. /**
  123095. * Gets the value of D-pad right
  123096. */
  123097. get dPadRight(): number;
  123098. /**
  123099. * Sets the value of D-pad right
  123100. */
  123101. set dPadRight(value: number);
  123102. /**
  123103. * Force the gamepad to synchronize with device values
  123104. */
  123105. update(): void;
  123106. /**
  123107. * Disposes the gamepad
  123108. */
  123109. dispose(): void;
  123110. }
  123111. }
  123112. declare module BABYLON {
  123113. /**
  123114. * Manager for handling gamepads
  123115. */
  123116. export class GamepadManager {
  123117. private _scene?;
  123118. private _babylonGamepads;
  123119. private _oneGamepadConnected;
  123120. /** @hidden */
  123121. _isMonitoring: boolean;
  123122. private _gamepadEventSupported;
  123123. private _gamepadSupport?;
  123124. /**
  123125. * observable to be triggered when the gamepad controller has been connected
  123126. */
  123127. onGamepadConnectedObservable: Observable<Gamepad>;
  123128. /**
  123129. * observable to be triggered when the gamepad controller has been disconnected
  123130. */
  123131. onGamepadDisconnectedObservable: Observable<Gamepad>;
  123132. private _onGamepadConnectedEvent;
  123133. private _onGamepadDisconnectedEvent;
  123134. /**
  123135. * Initializes the gamepad manager
  123136. * @param _scene BabylonJS scene
  123137. */
  123138. constructor(_scene?: Scene | undefined);
  123139. /**
  123140. * The gamepads in the game pad manager
  123141. */
  123142. get gamepads(): Gamepad[];
  123143. /**
  123144. * Get the gamepad controllers based on type
  123145. * @param type The type of gamepad controller
  123146. * @returns Nullable gamepad
  123147. */
  123148. getGamepadByType(type?: number): Nullable<Gamepad>;
  123149. /**
  123150. * Disposes the gamepad manager
  123151. */
  123152. dispose(): void;
  123153. private _addNewGamepad;
  123154. private _startMonitoringGamepads;
  123155. private _stopMonitoringGamepads;
  123156. /** @hidden */
  123157. _checkGamepadsStatus(): void;
  123158. private _updateGamepadObjects;
  123159. }
  123160. }
  123161. declare module BABYLON {
  123162. interface Scene {
  123163. /** @hidden */
  123164. _gamepadManager: Nullable<GamepadManager>;
  123165. /**
  123166. * Gets the gamepad manager associated with the scene
  123167. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  123168. */
  123169. gamepadManager: GamepadManager;
  123170. }
  123171. /**
  123172. * Interface representing a free camera inputs manager
  123173. */
  123174. interface FreeCameraInputsManager {
  123175. /**
  123176. * Adds gamepad input support to the FreeCameraInputsManager.
  123177. * @returns the FreeCameraInputsManager
  123178. */
  123179. addGamepad(): FreeCameraInputsManager;
  123180. }
  123181. /**
  123182. * Interface representing an arc rotate camera inputs manager
  123183. */
  123184. interface ArcRotateCameraInputsManager {
  123185. /**
  123186. * Adds gamepad input support to the ArcRotateCamera InputManager.
  123187. * @returns the camera inputs manager
  123188. */
  123189. addGamepad(): ArcRotateCameraInputsManager;
  123190. }
  123191. /**
  123192. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  123193. */
  123194. export class GamepadSystemSceneComponent implements ISceneComponent {
  123195. /**
  123196. * The component name helpfull to identify the component in the list of scene components.
  123197. */
  123198. readonly name: string;
  123199. /**
  123200. * The scene the component belongs to.
  123201. */
  123202. scene: Scene;
  123203. /**
  123204. * Creates a new instance of the component for the given scene
  123205. * @param scene Defines the scene to register the component in
  123206. */
  123207. constructor(scene: Scene);
  123208. /**
  123209. * Registers the component in a given scene
  123210. */
  123211. register(): void;
  123212. /**
  123213. * Rebuilds the elements related to this component in case of
  123214. * context lost for instance.
  123215. */
  123216. rebuild(): void;
  123217. /**
  123218. * Disposes the component and the associated ressources
  123219. */
  123220. dispose(): void;
  123221. private _beforeCameraUpdate;
  123222. }
  123223. }
  123224. declare module BABYLON {
  123225. /**
  123226. * 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,
  123227. * which still works and will still be found in many Playgrounds.
  123228. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123229. */
  123230. export class UniversalCamera extends TouchCamera {
  123231. /**
  123232. * Defines the gamepad rotation sensiblity.
  123233. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123234. */
  123235. get gamepadAngularSensibility(): number;
  123236. set gamepadAngularSensibility(value: number);
  123237. /**
  123238. * Defines the gamepad move sensiblity.
  123239. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123240. */
  123241. get gamepadMoveSensibility(): number;
  123242. set gamepadMoveSensibility(value: number);
  123243. /**
  123244. * 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,
  123245. * which still works and will still be found in many Playgrounds.
  123246. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123247. * @param name Define the name of the camera in the scene
  123248. * @param position Define the start position of the camera in the scene
  123249. * @param scene Define the scene the camera belongs to
  123250. */
  123251. constructor(name: string, position: Vector3, scene: Scene);
  123252. /**
  123253. * Gets the current object class name.
  123254. * @return the class name
  123255. */
  123256. getClassName(): string;
  123257. }
  123258. }
  123259. declare module BABYLON {
  123260. /**
  123261. * This represents a FPS type of camera. This is only here for back compat purpose.
  123262. * Please use the UniversalCamera instead as both are identical.
  123263. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123264. */
  123265. export class GamepadCamera extends UniversalCamera {
  123266. /**
  123267. * Instantiates a new Gamepad Camera
  123268. * This represents a FPS type of camera. This is only here for back compat purpose.
  123269. * Please use the UniversalCamera instead as both are identical.
  123270. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123271. * @param name Define the name of the camera in the scene
  123272. * @param position Define the start position of the camera in the scene
  123273. * @param scene Define the scene the camera belongs to
  123274. */
  123275. constructor(name: string, position: Vector3, scene: Scene);
  123276. /**
  123277. * Gets the current object class name.
  123278. * @return the class name
  123279. */
  123280. getClassName(): string;
  123281. }
  123282. }
  123283. declare module BABYLON {
  123284. /** @hidden */
  123285. export var passPixelShader: {
  123286. name: string;
  123287. shader: string;
  123288. };
  123289. }
  123290. declare module BABYLON {
  123291. /** @hidden */
  123292. export var passCubePixelShader: {
  123293. name: string;
  123294. shader: string;
  123295. };
  123296. }
  123297. declare module BABYLON {
  123298. /**
  123299. * PassPostProcess which produces an output the same as it's input
  123300. */
  123301. export class PassPostProcess extends PostProcess {
  123302. /**
  123303. * Creates the PassPostProcess
  123304. * @param name The name of the effect.
  123305. * @param options The required width/height ratio to downsize to before computing the render pass.
  123306. * @param camera The camera to apply the render pass to.
  123307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123308. * @param engine The engine which the post process will be applied. (default: current engine)
  123309. * @param reusable If the post process can be reused on the same frame. (default: false)
  123310. * @param textureType The type of texture to be used when performing the post processing.
  123311. * @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)
  123312. */
  123313. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123314. }
  123315. /**
  123316. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  123317. */
  123318. export class PassCubePostProcess extends PostProcess {
  123319. private _face;
  123320. /**
  123321. * Gets or sets the cube face to display.
  123322. * * 0 is +X
  123323. * * 1 is -X
  123324. * * 2 is +Y
  123325. * * 3 is -Y
  123326. * * 4 is +Z
  123327. * * 5 is -Z
  123328. */
  123329. get face(): number;
  123330. set face(value: number);
  123331. /**
  123332. * Creates the PassCubePostProcess
  123333. * @param name The name of the effect.
  123334. * @param options The required width/height ratio to downsize to before computing the render pass.
  123335. * @param camera The camera to apply the render pass to.
  123336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123337. * @param engine The engine which the post process will be applied. (default: current engine)
  123338. * @param reusable If the post process can be reused on the same frame. (default: false)
  123339. * @param textureType The type of texture to be used when performing the post processing.
  123340. * @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)
  123341. */
  123342. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123343. }
  123344. }
  123345. declare module BABYLON {
  123346. /** @hidden */
  123347. export var anaglyphPixelShader: {
  123348. name: string;
  123349. shader: string;
  123350. };
  123351. }
  123352. declare module BABYLON {
  123353. /**
  123354. * Postprocess used to generate anaglyphic rendering
  123355. */
  123356. export class AnaglyphPostProcess extends PostProcess {
  123357. private _passedProcess;
  123358. /**
  123359. * Creates a new AnaglyphPostProcess
  123360. * @param name defines postprocess name
  123361. * @param options defines creation options or target ratio scale
  123362. * @param rigCameras defines cameras using this postprocess
  123363. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  123364. * @param engine defines hosting engine
  123365. * @param reusable defines if the postprocess will be reused multiple times per frame
  123366. */
  123367. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  123368. }
  123369. }
  123370. declare module BABYLON {
  123371. /**
  123372. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  123373. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123374. */
  123375. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  123376. /**
  123377. * Creates a new AnaglyphArcRotateCamera
  123378. * @param name defines camera name
  123379. * @param alpha defines alpha angle (in radians)
  123380. * @param beta defines beta angle (in radians)
  123381. * @param radius defines radius
  123382. * @param target defines camera target
  123383. * @param interaxialDistance defines distance between each color axis
  123384. * @param scene defines the hosting scene
  123385. */
  123386. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  123387. /**
  123388. * Gets camera class name
  123389. * @returns AnaglyphArcRotateCamera
  123390. */
  123391. getClassName(): string;
  123392. }
  123393. }
  123394. declare module BABYLON {
  123395. /**
  123396. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  123397. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123398. */
  123399. export class AnaglyphFreeCamera extends FreeCamera {
  123400. /**
  123401. * Creates a new AnaglyphFreeCamera
  123402. * @param name defines camera name
  123403. * @param position defines initial position
  123404. * @param interaxialDistance defines distance between each color axis
  123405. * @param scene defines the hosting scene
  123406. */
  123407. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123408. /**
  123409. * Gets camera class name
  123410. * @returns AnaglyphFreeCamera
  123411. */
  123412. getClassName(): string;
  123413. }
  123414. }
  123415. declare module BABYLON {
  123416. /**
  123417. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  123418. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123419. */
  123420. export class AnaglyphGamepadCamera extends GamepadCamera {
  123421. /**
  123422. * Creates a new AnaglyphGamepadCamera
  123423. * @param name defines camera name
  123424. * @param position defines initial position
  123425. * @param interaxialDistance defines distance between each color axis
  123426. * @param scene defines the hosting scene
  123427. */
  123428. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123429. /**
  123430. * Gets camera class name
  123431. * @returns AnaglyphGamepadCamera
  123432. */
  123433. getClassName(): string;
  123434. }
  123435. }
  123436. declare module BABYLON {
  123437. /**
  123438. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  123439. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123440. */
  123441. export class AnaglyphUniversalCamera extends UniversalCamera {
  123442. /**
  123443. * Creates a new AnaglyphUniversalCamera
  123444. * @param name defines camera name
  123445. * @param position defines initial position
  123446. * @param interaxialDistance defines distance between each color axis
  123447. * @param scene defines the hosting scene
  123448. */
  123449. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123450. /**
  123451. * Gets camera class name
  123452. * @returns AnaglyphUniversalCamera
  123453. */
  123454. getClassName(): string;
  123455. }
  123456. }
  123457. declare module BABYLON {
  123458. /**
  123459. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  123460. * @see https://doc.babylonjs.com/features/cameras
  123461. */
  123462. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  123463. /**
  123464. * Creates a new StereoscopicArcRotateCamera
  123465. * @param name defines camera name
  123466. * @param alpha defines alpha angle (in radians)
  123467. * @param beta defines beta angle (in radians)
  123468. * @param radius defines radius
  123469. * @param target defines camera target
  123470. * @param interaxialDistance defines distance between each color axis
  123471. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123472. * @param scene defines the hosting scene
  123473. */
  123474. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123475. /**
  123476. * Gets camera class name
  123477. * @returns StereoscopicArcRotateCamera
  123478. */
  123479. getClassName(): string;
  123480. }
  123481. }
  123482. declare module BABYLON {
  123483. /**
  123484. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  123485. * @see https://doc.babylonjs.com/features/cameras
  123486. */
  123487. export class StereoscopicFreeCamera extends FreeCamera {
  123488. /**
  123489. * Creates a new StereoscopicFreeCamera
  123490. * @param name defines camera name
  123491. * @param position defines initial position
  123492. * @param interaxialDistance defines distance between each color axis
  123493. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123494. * @param scene defines the hosting scene
  123495. */
  123496. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123497. /**
  123498. * Gets camera class name
  123499. * @returns StereoscopicFreeCamera
  123500. */
  123501. getClassName(): string;
  123502. }
  123503. }
  123504. declare module BABYLON {
  123505. /**
  123506. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  123507. * @see https://doc.babylonjs.com/features/cameras
  123508. */
  123509. export class StereoscopicGamepadCamera extends GamepadCamera {
  123510. /**
  123511. * Creates a new StereoscopicGamepadCamera
  123512. * @param name defines camera name
  123513. * @param position defines initial position
  123514. * @param interaxialDistance defines distance between each color axis
  123515. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123516. * @param scene defines the hosting scene
  123517. */
  123518. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123519. /**
  123520. * Gets camera class name
  123521. * @returns StereoscopicGamepadCamera
  123522. */
  123523. getClassName(): string;
  123524. }
  123525. }
  123526. declare module BABYLON {
  123527. /**
  123528. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  123529. * @see https://doc.babylonjs.com/features/cameras
  123530. */
  123531. export class StereoscopicUniversalCamera extends UniversalCamera {
  123532. /**
  123533. * Creates a new StereoscopicUniversalCamera
  123534. * @param name defines camera name
  123535. * @param position defines initial position
  123536. * @param interaxialDistance defines distance between each color axis
  123537. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123538. * @param scene defines the hosting scene
  123539. */
  123540. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123541. /**
  123542. * Gets camera class name
  123543. * @returns StereoscopicUniversalCamera
  123544. */
  123545. getClassName(): string;
  123546. }
  123547. }
  123548. declare module BABYLON {
  123549. /**
  123550. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  123551. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123552. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123553. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123554. */
  123555. export class VirtualJoysticksCamera extends FreeCamera {
  123556. /**
  123557. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  123558. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123559. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123560. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123561. * @param name Define the name of the camera in the scene
  123562. * @param position Define the start position of the camera in the scene
  123563. * @param scene Define the scene the camera belongs to
  123564. */
  123565. constructor(name: string, position: Vector3, scene: Scene);
  123566. /**
  123567. * Gets the current object class name.
  123568. * @return the class name
  123569. */
  123570. getClassName(): string;
  123571. }
  123572. }
  123573. declare module BABYLON {
  123574. /**
  123575. * This represents all the required metrics to create a VR camera.
  123576. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  123577. */
  123578. export class VRCameraMetrics {
  123579. /**
  123580. * Define the horizontal resolution off the screen.
  123581. */
  123582. hResolution: number;
  123583. /**
  123584. * Define the vertical resolution off the screen.
  123585. */
  123586. vResolution: number;
  123587. /**
  123588. * Define the horizontal screen size.
  123589. */
  123590. hScreenSize: number;
  123591. /**
  123592. * Define the vertical screen size.
  123593. */
  123594. vScreenSize: number;
  123595. /**
  123596. * Define the vertical screen center position.
  123597. */
  123598. vScreenCenter: number;
  123599. /**
  123600. * Define the distance of the eyes to the screen.
  123601. */
  123602. eyeToScreenDistance: number;
  123603. /**
  123604. * Define the distance between both lenses
  123605. */
  123606. lensSeparationDistance: number;
  123607. /**
  123608. * Define the distance between both viewer's eyes.
  123609. */
  123610. interpupillaryDistance: number;
  123611. /**
  123612. * Define the distortion factor of the VR postprocess.
  123613. * Please, touch with care.
  123614. */
  123615. distortionK: number[];
  123616. /**
  123617. * Define the chromatic aberration correction factors for the VR post process.
  123618. */
  123619. chromaAbCorrection: number[];
  123620. /**
  123621. * Define the scale factor of the post process.
  123622. * The smaller the better but the slower.
  123623. */
  123624. postProcessScaleFactor: number;
  123625. /**
  123626. * Define an offset for the lens center.
  123627. */
  123628. lensCenterOffset: number;
  123629. /**
  123630. * Define if the current vr camera should compensate the distortion of the lense or not.
  123631. */
  123632. compensateDistortion: boolean;
  123633. /**
  123634. * Defines if multiview should be enabled when rendering (Default: false)
  123635. */
  123636. multiviewEnabled: boolean;
  123637. /**
  123638. * Gets the rendering aspect ratio based on the provided resolutions.
  123639. */
  123640. get aspectRatio(): number;
  123641. /**
  123642. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  123643. */
  123644. get aspectRatioFov(): number;
  123645. /**
  123646. * @hidden
  123647. */
  123648. get leftHMatrix(): Matrix;
  123649. /**
  123650. * @hidden
  123651. */
  123652. get rightHMatrix(): Matrix;
  123653. /**
  123654. * @hidden
  123655. */
  123656. get leftPreViewMatrix(): Matrix;
  123657. /**
  123658. * @hidden
  123659. */
  123660. get rightPreViewMatrix(): Matrix;
  123661. /**
  123662. * Get the default VRMetrics based on the most generic setup.
  123663. * @returns the default vr metrics
  123664. */
  123665. static GetDefault(): VRCameraMetrics;
  123666. }
  123667. }
  123668. declare module BABYLON {
  123669. /** @hidden */
  123670. export var vrDistortionCorrectionPixelShader: {
  123671. name: string;
  123672. shader: string;
  123673. };
  123674. }
  123675. declare module BABYLON {
  123676. /**
  123677. * VRDistortionCorrectionPostProcess used for mobile VR
  123678. */
  123679. export class VRDistortionCorrectionPostProcess extends PostProcess {
  123680. private _isRightEye;
  123681. private _distortionFactors;
  123682. private _postProcessScaleFactor;
  123683. private _lensCenterOffset;
  123684. private _scaleIn;
  123685. private _scaleFactor;
  123686. private _lensCenter;
  123687. /**
  123688. * Initializes the VRDistortionCorrectionPostProcess
  123689. * @param name The name of the effect.
  123690. * @param camera The camera to apply the render pass to.
  123691. * @param isRightEye If this is for the right eye distortion
  123692. * @param vrMetrics All the required metrics for the VR camera
  123693. */
  123694. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  123695. }
  123696. }
  123697. declare module BABYLON {
  123698. /**
  123699. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  123700. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123701. */
  123702. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  123703. /**
  123704. * Creates a new VRDeviceOrientationArcRotateCamera
  123705. * @param name defines camera name
  123706. * @param alpha defines the camera rotation along the logitudinal axis
  123707. * @param beta defines the camera rotation along the latitudinal axis
  123708. * @param radius defines the camera distance from its target
  123709. * @param target defines the camera target
  123710. * @param scene defines the scene the camera belongs to
  123711. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123712. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123713. */
  123714. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123715. /**
  123716. * Gets camera class name
  123717. * @returns VRDeviceOrientationArcRotateCamera
  123718. */
  123719. getClassName(): string;
  123720. }
  123721. }
  123722. declare module BABYLON {
  123723. /**
  123724. * Camera used to simulate VR rendering (based on FreeCamera)
  123725. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123726. */
  123727. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  123728. /**
  123729. * Creates a new VRDeviceOrientationFreeCamera
  123730. * @param name defines camera name
  123731. * @param position defines the start position of the camera
  123732. * @param scene defines the scene the camera belongs to
  123733. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123734. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123735. */
  123736. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123737. /**
  123738. * Gets camera class name
  123739. * @returns VRDeviceOrientationFreeCamera
  123740. */
  123741. getClassName(): string;
  123742. }
  123743. }
  123744. declare module BABYLON {
  123745. /**
  123746. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  123747. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123748. */
  123749. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  123750. /**
  123751. * Creates a new VRDeviceOrientationGamepadCamera
  123752. * @param name defines camera name
  123753. * @param position defines the start position of the camera
  123754. * @param scene defines the scene the camera belongs to
  123755. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123756. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123757. */
  123758. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123759. /**
  123760. * Gets camera class name
  123761. * @returns VRDeviceOrientationGamepadCamera
  123762. */
  123763. getClassName(): string;
  123764. }
  123765. }
  123766. declare module BABYLON {
  123767. /**
  123768. * A class extending Texture allowing drawing on a texture
  123769. * @see https://doc.babylonjs.com/how_to/dynamictexture
  123770. */
  123771. export class DynamicTexture extends Texture {
  123772. private _generateMipMaps;
  123773. private _canvas;
  123774. private _context;
  123775. /**
  123776. * Creates a DynamicTexture
  123777. * @param name defines the name of the texture
  123778. * @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
  123779. * @param scene defines the scene where you want the texture
  123780. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  123781. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123782. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  123783. */
  123784. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  123785. /**
  123786. * Get the current class name of the texture useful for serialization or dynamic coding.
  123787. * @returns "DynamicTexture"
  123788. */
  123789. getClassName(): string;
  123790. /**
  123791. * Gets the current state of canRescale
  123792. */
  123793. get canRescale(): boolean;
  123794. private _recreate;
  123795. /**
  123796. * Scales the texture
  123797. * @param ratio the scale factor to apply to both width and height
  123798. */
  123799. scale(ratio: number): void;
  123800. /**
  123801. * Resizes the texture
  123802. * @param width the new width
  123803. * @param height the new height
  123804. */
  123805. scaleTo(width: number, height: number): void;
  123806. /**
  123807. * Gets the context of the canvas used by the texture
  123808. * @returns the canvas context of the dynamic texture
  123809. */
  123810. getContext(): CanvasRenderingContext2D;
  123811. /**
  123812. * Clears the texture
  123813. */
  123814. clear(): void;
  123815. /**
  123816. * Updates the texture
  123817. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  123818. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  123819. */
  123820. update(invertY?: boolean, premulAlpha?: boolean): void;
  123821. /**
  123822. * Draws text onto the texture
  123823. * @param text defines the text to be drawn
  123824. * @param x defines the placement of the text from the left
  123825. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  123826. * @param font defines the font to be used with font-style, font-size, font-name
  123827. * @param color defines the color used for the text
  123828. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  123829. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  123830. * @param update defines whether texture is immediately update (default is true)
  123831. */
  123832. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  123833. /**
  123834. * Clones the texture
  123835. * @returns the clone of the texture.
  123836. */
  123837. clone(): DynamicTexture;
  123838. /**
  123839. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  123840. * @returns a serialized dynamic texture object
  123841. */
  123842. serialize(): any;
  123843. private _IsCanvasElement;
  123844. /** @hidden */
  123845. _rebuild(): void;
  123846. }
  123847. }
  123848. declare module BABYLON {
  123849. /** @hidden */
  123850. export var imageProcessingPixelShader: {
  123851. name: string;
  123852. shader: string;
  123853. };
  123854. }
  123855. declare module BABYLON {
  123856. /**
  123857. * ImageProcessingPostProcess
  123858. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  123859. */
  123860. export class ImageProcessingPostProcess extends PostProcess {
  123861. /**
  123862. * Default configuration related to image processing available in the PBR Material.
  123863. */
  123864. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123865. /**
  123866. * Gets the image processing configuration used either in this material.
  123867. */
  123868. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123869. /**
  123870. * Sets the Default image processing configuration used either in the this material.
  123871. *
  123872. * If sets to null, the scene one is in use.
  123873. */
  123874. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  123875. /**
  123876. * Keep track of the image processing observer to allow dispose and replace.
  123877. */
  123878. private _imageProcessingObserver;
  123879. /**
  123880. * Attaches a new image processing configuration to the PBR Material.
  123881. * @param configuration
  123882. */
  123883. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  123884. /**
  123885. * If the post process is supported.
  123886. */
  123887. get isSupported(): boolean;
  123888. /**
  123889. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123890. */
  123891. get colorCurves(): Nullable<ColorCurves>;
  123892. /**
  123893. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123894. */
  123895. set colorCurves(value: Nullable<ColorCurves>);
  123896. /**
  123897. * Gets wether the color curves effect is enabled.
  123898. */
  123899. get colorCurvesEnabled(): boolean;
  123900. /**
  123901. * Sets wether the color curves effect is enabled.
  123902. */
  123903. set colorCurvesEnabled(value: boolean);
  123904. /**
  123905. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123906. */
  123907. get colorGradingTexture(): Nullable<BaseTexture>;
  123908. /**
  123909. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123910. */
  123911. set colorGradingTexture(value: Nullable<BaseTexture>);
  123912. /**
  123913. * Gets wether the color grading effect is enabled.
  123914. */
  123915. get colorGradingEnabled(): boolean;
  123916. /**
  123917. * Gets wether the color grading effect is enabled.
  123918. */
  123919. set colorGradingEnabled(value: boolean);
  123920. /**
  123921. * Gets exposure used in the effect.
  123922. */
  123923. get exposure(): number;
  123924. /**
  123925. * Sets exposure used in the effect.
  123926. */
  123927. set exposure(value: number);
  123928. /**
  123929. * Gets wether tonemapping is enabled or not.
  123930. */
  123931. get toneMappingEnabled(): boolean;
  123932. /**
  123933. * Sets wether tonemapping is enabled or not
  123934. */
  123935. set toneMappingEnabled(value: boolean);
  123936. /**
  123937. * Gets the type of tone mapping effect.
  123938. */
  123939. get toneMappingType(): number;
  123940. /**
  123941. * Sets the type of tone mapping effect.
  123942. */
  123943. set toneMappingType(value: number);
  123944. /**
  123945. * Gets contrast used in the effect.
  123946. */
  123947. get contrast(): number;
  123948. /**
  123949. * Sets contrast used in the effect.
  123950. */
  123951. set contrast(value: number);
  123952. /**
  123953. * Gets Vignette stretch size.
  123954. */
  123955. get vignetteStretch(): number;
  123956. /**
  123957. * Sets Vignette stretch size.
  123958. */
  123959. set vignetteStretch(value: number);
  123960. /**
  123961. * Gets Vignette centre X Offset.
  123962. */
  123963. get vignetteCentreX(): number;
  123964. /**
  123965. * Sets Vignette centre X Offset.
  123966. */
  123967. set vignetteCentreX(value: number);
  123968. /**
  123969. * Gets Vignette centre Y Offset.
  123970. */
  123971. get vignetteCentreY(): number;
  123972. /**
  123973. * Sets Vignette centre Y Offset.
  123974. */
  123975. set vignetteCentreY(value: number);
  123976. /**
  123977. * Gets Vignette weight or intensity of the vignette effect.
  123978. */
  123979. get vignetteWeight(): number;
  123980. /**
  123981. * Sets Vignette weight or intensity of the vignette effect.
  123982. */
  123983. set vignetteWeight(value: number);
  123984. /**
  123985. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123986. * if vignetteEnabled is set to true.
  123987. */
  123988. get vignetteColor(): Color4;
  123989. /**
  123990. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123991. * if vignetteEnabled is set to true.
  123992. */
  123993. set vignetteColor(value: Color4);
  123994. /**
  123995. * Gets Camera field of view used by the Vignette effect.
  123996. */
  123997. get vignetteCameraFov(): number;
  123998. /**
  123999. * Sets Camera field of view used by the Vignette effect.
  124000. */
  124001. set vignetteCameraFov(value: number);
  124002. /**
  124003. * Gets the vignette blend mode allowing different kind of effect.
  124004. */
  124005. get vignetteBlendMode(): number;
  124006. /**
  124007. * Sets the vignette blend mode allowing different kind of effect.
  124008. */
  124009. set vignetteBlendMode(value: number);
  124010. /**
  124011. * Gets wether the vignette effect is enabled.
  124012. */
  124013. get vignetteEnabled(): boolean;
  124014. /**
  124015. * Sets wether the vignette effect is enabled.
  124016. */
  124017. set vignetteEnabled(value: boolean);
  124018. private _fromLinearSpace;
  124019. /**
  124020. * Gets wether the input of the processing is in Gamma or Linear Space.
  124021. */
  124022. get fromLinearSpace(): boolean;
  124023. /**
  124024. * Sets wether the input of the processing is in Gamma or Linear Space.
  124025. */
  124026. set fromLinearSpace(value: boolean);
  124027. /**
  124028. * Defines cache preventing GC.
  124029. */
  124030. private _defines;
  124031. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  124032. /**
  124033. * "ImageProcessingPostProcess"
  124034. * @returns "ImageProcessingPostProcess"
  124035. */
  124036. getClassName(): string;
  124037. protected _updateParameters(): void;
  124038. dispose(camera?: Camera): void;
  124039. }
  124040. }
  124041. declare module BABYLON {
  124042. /**
  124043. * Class containing static functions to help procedurally build meshes
  124044. */
  124045. export class GroundBuilder {
  124046. /**
  124047. * Creates a ground mesh
  124048. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124049. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124051. * @param name defines the name of the mesh
  124052. * @param options defines the options used to create the mesh
  124053. * @param scene defines the hosting scene
  124054. * @returns the ground mesh
  124055. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124056. */
  124057. static CreateGround(name: string, options: {
  124058. width?: number;
  124059. height?: number;
  124060. subdivisions?: number;
  124061. subdivisionsX?: number;
  124062. subdivisionsY?: number;
  124063. updatable?: boolean;
  124064. }, scene: any): Mesh;
  124065. /**
  124066. * Creates a tiled ground mesh
  124067. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124068. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124069. * * 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
  124070. * * 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
  124071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124072. * @param name defines the name of the mesh
  124073. * @param options defines the options used to create the mesh
  124074. * @param scene defines the hosting scene
  124075. * @returns the tiled ground mesh
  124076. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124077. */
  124078. static CreateTiledGround(name: string, options: {
  124079. xmin: number;
  124080. zmin: number;
  124081. xmax: number;
  124082. zmax: number;
  124083. subdivisions?: {
  124084. w: number;
  124085. h: number;
  124086. };
  124087. precision?: {
  124088. w: number;
  124089. h: number;
  124090. };
  124091. updatable?: boolean;
  124092. }, scene?: Nullable<Scene>): Mesh;
  124093. /**
  124094. * Creates a ground mesh from a height map
  124095. * * The parameter `url` sets the URL of the height map image resource.
  124096. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124097. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124098. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124099. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124100. * * 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.
  124101. * * 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).
  124102. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124104. * @param name defines the name of the mesh
  124105. * @param url defines the url to the height map
  124106. * @param options defines the options used to create the mesh
  124107. * @param scene defines the hosting scene
  124108. * @returns the ground mesh
  124109. * @see https://doc.babylonjs.com/babylon101/height_map
  124110. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124111. */
  124112. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124113. width?: number;
  124114. height?: number;
  124115. subdivisions?: number;
  124116. minHeight?: number;
  124117. maxHeight?: number;
  124118. colorFilter?: Color3;
  124119. alphaFilter?: number;
  124120. updatable?: boolean;
  124121. onReady?: (mesh: GroundMesh) => void;
  124122. }, scene?: Nullable<Scene>): GroundMesh;
  124123. }
  124124. }
  124125. declare module BABYLON {
  124126. /**
  124127. * Class containing static functions to help procedurally build meshes
  124128. */
  124129. export class TorusBuilder {
  124130. /**
  124131. * Creates a torus mesh
  124132. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124133. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124134. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124136. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124138. * @param name defines the name of the mesh
  124139. * @param options defines the options used to create the mesh
  124140. * @param scene defines the hosting scene
  124141. * @returns the torus mesh
  124142. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  124143. */
  124144. static CreateTorus(name: string, options: {
  124145. diameter?: number;
  124146. thickness?: number;
  124147. tessellation?: number;
  124148. updatable?: boolean;
  124149. sideOrientation?: number;
  124150. frontUVs?: Vector4;
  124151. backUVs?: Vector4;
  124152. }, scene: any): Mesh;
  124153. }
  124154. }
  124155. declare module BABYLON {
  124156. /**
  124157. * Class containing static functions to help procedurally build meshes
  124158. */
  124159. export class CylinderBuilder {
  124160. /**
  124161. * Creates a cylinder or a cone mesh
  124162. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  124163. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  124164. * * 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.
  124165. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  124166. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  124167. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  124168. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  124169. * * 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).
  124170. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  124171. * * 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).
  124172. * * 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
  124173. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124174. * * 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
  124175. * * 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.
  124176. * * If `enclose` is false, a ring surface is one element.
  124177. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124178. * * 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
  124179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124182. * @param name defines the name of the mesh
  124183. * @param options defines the options used to create the mesh
  124184. * @param scene defines the hosting scene
  124185. * @returns the cylinder mesh
  124186. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124187. */
  124188. static CreateCylinder(name: string, options: {
  124189. height?: number;
  124190. diameterTop?: number;
  124191. diameterBottom?: number;
  124192. diameter?: number;
  124193. tessellation?: number;
  124194. subdivisions?: number;
  124195. arc?: number;
  124196. faceColors?: Color4[];
  124197. faceUV?: Vector4[];
  124198. updatable?: boolean;
  124199. hasRings?: boolean;
  124200. enclose?: boolean;
  124201. cap?: number;
  124202. sideOrientation?: number;
  124203. frontUVs?: Vector4;
  124204. backUVs?: Vector4;
  124205. }, scene: any): Mesh;
  124206. }
  124207. }
  124208. declare module BABYLON {
  124209. /**
  124210. * States of the webXR experience
  124211. */
  124212. export enum WebXRState {
  124213. /**
  124214. * Transitioning to being in XR mode
  124215. */
  124216. ENTERING_XR = 0,
  124217. /**
  124218. * Transitioning to non XR mode
  124219. */
  124220. EXITING_XR = 1,
  124221. /**
  124222. * In XR mode and presenting
  124223. */
  124224. IN_XR = 2,
  124225. /**
  124226. * Not entered XR mode
  124227. */
  124228. NOT_IN_XR = 3
  124229. }
  124230. /**
  124231. * Abstraction of the XR render target
  124232. */
  124233. export interface WebXRRenderTarget extends IDisposable {
  124234. /**
  124235. * xrpresent context of the canvas which can be used to display/mirror xr content
  124236. */
  124237. canvasContext: WebGLRenderingContext;
  124238. /**
  124239. * xr layer for the canvas
  124240. */
  124241. xrLayer: Nullable<XRWebGLLayer>;
  124242. /**
  124243. * Initializes the xr layer for the session
  124244. * @param xrSession xr session
  124245. * @returns a promise that will resolve once the XR Layer has been created
  124246. */
  124247. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  124248. }
  124249. }
  124250. declare module BABYLON {
  124251. /**
  124252. * COnfiguration object for WebXR output canvas
  124253. */
  124254. export class WebXRManagedOutputCanvasOptions {
  124255. /**
  124256. * An optional canvas in case you wish to create it yourself and provide it here.
  124257. * If not provided, a new canvas will be created
  124258. */
  124259. canvasElement?: HTMLCanvasElement;
  124260. /**
  124261. * Options for this XR Layer output
  124262. */
  124263. canvasOptions?: XRWebGLLayerOptions;
  124264. /**
  124265. * CSS styling for a newly created canvas (if not provided)
  124266. */
  124267. newCanvasCssStyle?: string;
  124268. /**
  124269. * Get the default values of the configuration object
  124270. * @returns default values of this configuration object
  124271. */
  124272. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  124273. }
  124274. /**
  124275. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  124276. */
  124277. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  124278. private _options;
  124279. private _canvas;
  124280. private _engine;
  124281. private _originalCanvasSize;
  124282. /**
  124283. * Rendering context of the canvas which can be used to display/mirror xr content
  124284. */
  124285. canvasContext: WebGLRenderingContext;
  124286. /**
  124287. * xr layer for the canvas
  124288. */
  124289. xrLayer: Nullable<XRWebGLLayer>;
  124290. /**
  124291. * Obseervers registered here will be triggered when the xr layer was initialized
  124292. */
  124293. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  124294. /**
  124295. * Initializes the canvas to be added/removed upon entering/exiting xr
  124296. * @param _xrSessionManager The XR Session manager
  124297. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  124298. */
  124299. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  124300. /**
  124301. * Disposes of the object
  124302. */
  124303. dispose(): void;
  124304. /**
  124305. * Initializes the xr layer for the session
  124306. * @param xrSession xr session
  124307. * @returns a promise that will resolve once the XR Layer has been created
  124308. */
  124309. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  124310. private _addCanvas;
  124311. private _removeCanvas;
  124312. private _setCanvasSize;
  124313. private _setManagedOutputCanvas;
  124314. }
  124315. }
  124316. declare module BABYLON {
  124317. /**
  124318. * Manages an XRSession to work with Babylon's engine
  124319. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  124320. */
  124321. export class WebXRSessionManager implements IDisposable {
  124322. /** The scene which the session should be created for */
  124323. scene: Scene;
  124324. private _referenceSpace;
  124325. private _rttProvider;
  124326. private _sessionEnded;
  124327. private _xrNavigator;
  124328. private baseLayer;
  124329. /**
  124330. * The base reference space from which the session started. good if you want to reset your
  124331. * reference space
  124332. */
  124333. baseReferenceSpace: XRReferenceSpace;
  124334. /**
  124335. * Current XR frame
  124336. */
  124337. currentFrame: Nullable<XRFrame>;
  124338. /** WebXR timestamp updated every frame */
  124339. currentTimestamp: number;
  124340. /**
  124341. * Used just in case of a failure to initialize an immersive session.
  124342. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  124343. */
  124344. defaultHeightCompensation: number;
  124345. /**
  124346. * Fires every time a new xrFrame arrives which can be used to update the camera
  124347. */
  124348. onXRFrameObservable: Observable<XRFrame>;
  124349. /**
  124350. * Fires when the reference space changed
  124351. */
  124352. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  124353. /**
  124354. * Fires when the xr session is ended either by the device or manually done
  124355. */
  124356. onXRSessionEnded: Observable<any>;
  124357. /**
  124358. * Fires when the xr session is ended either by the device or manually done
  124359. */
  124360. onXRSessionInit: Observable<XRSession>;
  124361. /**
  124362. * Underlying xr session
  124363. */
  124364. session: XRSession;
  124365. /**
  124366. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  124367. * or get the offset the player is currently at.
  124368. */
  124369. viewerReferenceSpace: XRReferenceSpace;
  124370. /**
  124371. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  124372. * @param scene The scene which the session should be created for
  124373. */
  124374. constructor(
  124375. /** The scene which the session should be created for */
  124376. scene: Scene);
  124377. /**
  124378. * The current reference space used in this session. This reference space can constantly change!
  124379. * It is mainly used to offset the camera's position.
  124380. */
  124381. get referenceSpace(): XRReferenceSpace;
  124382. /**
  124383. * Set a new reference space and triggers the observable
  124384. */
  124385. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  124386. /**
  124387. * Disposes of the session manager
  124388. */
  124389. dispose(): void;
  124390. /**
  124391. * Stops the xrSession and restores the render loop
  124392. * @returns Promise which resolves after it exits XR
  124393. */
  124394. exitXRAsync(): Promise<void>;
  124395. /**
  124396. * Gets the correct render target texture to be rendered this frame for this eye
  124397. * @param eye the eye for which to get the render target
  124398. * @returns the render target for the specified eye
  124399. */
  124400. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  124401. /**
  124402. * Creates a WebXRRenderTarget object for the XR session
  124403. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  124404. * @param options optional options to provide when creating a new render target
  124405. * @returns a WebXR render target to which the session can render
  124406. */
  124407. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  124408. /**
  124409. * Initializes the manager
  124410. * After initialization enterXR can be called to start an XR session
  124411. * @returns Promise which resolves after it is initialized
  124412. */
  124413. initializeAsync(): Promise<void>;
  124414. /**
  124415. * Initializes an xr session
  124416. * @param xrSessionMode mode to initialize
  124417. * @param xrSessionInit defines optional and required values to pass to the session builder
  124418. * @returns a promise which will resolve once the session has been initialized
  124419. */
  124420. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  124421. /**
  124422. * Checks if a session would be supported for the creation options specified
  124423. * @param sessionMode session mode to check if supported eg. immersive-vr
  124424. * @returns A Promise that resolves to true if supported and false if not
  124425. */
  124426. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124427. /**
  124428. * Resets the reference space to the one started the session
  124429. */
  124430. resetReferenceSpace(): void;
  124431. /**
  124432. * Starts rendering to the xr layer
  124433. */
  124434. runXRRenderLoop(): void;
  124435. /**
  124436. * Sets the reference space on the xr session
  124437. * @param referenceSpaceType space to set
  124438. * @returns a promise that will resolve once the reference space has been set
  124439. */
  124440. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  124441. /**
  124442. * Updates the render state of the session
  124443. * @param state state to set
  124444. * @returns a promise that resolves once the render state has been updated
  124445. */
  124446. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  124447. /**
  124448. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  124449. * @param sessionMode defines the session to test
  124450. * @returns a promise with boolean as final value
  124451. */
  124452. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124453. private _createRenderTargetTexture;
  124454. }
  124455. }
  124456. declare module BABYLON {
  124457. /**
  124458. * WebXR Camera which holds the views for the xrSession
  124459. * @see https://doc.babylonjs.com/how_to/webxr_camera
  124460. */
  124461. export class WebXRCamera extends FreeCamera {
  124462. private _xrSessionManager;
  124463. private _firstFrame;
  124464. private _referenceQuaternion;
  124465. private _referencedPosition;
  124466. private _xrInvPositionCache;
  124467. private _xrInvQuaternionCache;
  124468. /**
  124469. * Should position compensation execute on first frame.
  124470. * This is used when copying the position from a native (non XR) camera
  124471. */
  124472. compensateOnFirstFrame: boolean;
  124473. /**
  124474. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  124475. * @param name the name of the camera
  124476. * @param scene the scene to add the camera to
  124477. * @param _xrSessionManager a constructed xr session manager
  124478. */
  124479. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  124480. /**
  124481. * Return the user's height, unrelated to the current ground.
  124482. * This will be the y position of this camera, when ground level is 0.
  124483. */
  124484. get realWorldHeight(): number;
  124485. /** @hidden */
  124486. _updateForDualEyeDebugging(): void;
  124487. /**
  124488. * Sets this camera's transformation based on a non-vr camera
  124489. * @param otherCamera the non-vr camera to copy the transformation from
  124490. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  124491. */
  124492. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  124493. /**
  124494. * Gets the current instance class name ("WebXRCamera").
  124495. * @returns the class name
  124496. */
  124497. getClassName(): string;
  124498. private _rotate180;
  124499. private _updateFromXRSession;
  124500. private _updateNumberOfRigCameras;
  124501. private _updateReferenceSpace;
  124502. private _updateReferenceSpaceOffset;
  124503. }
  124504. }
  124505. declare module BABYLON {
  124506. /**
  124507. * Defining the interface required for a (webxr) feature
  124508. */
  124509. export interface IWebXRFeature extends IDisposable {
  124510. /**
  124511. * Is this feature attached
  124512. */
  124513. attached: boolean;
  124514. /**
  124515. * Should auto-attach be disabled?
  124516. */
  124517. disableAutoAttach: boolean;
  124518. /**
  124519. * Attach the feature to the session
  124520. * Will usually be called by the features manager
  124521. *
  124522. * @param force should attachment be forced (even when already attached)
  124523. * @returns true if successful.
  124524. */
  124525. attach(force?: boolean): boolean;
  124526. /**
  124527. * Detach the feature from the session
  124528. * Will usually be called by the features manager
  124529. *
  124530. * @returns true if successful.
  124531. */
  124532. detach(): boolean;
  124533. }
  124534. /**
  124535. * A list of the currently available features without referencing them
  124536. */
  124537. export class WebXRFeatureName {
  124538. /**
  124539. * The name of the anchor system feature
  124540. */
  124541. static ANCHOR_SYSTEM: string;
  124542. /**
  124543. * The name of the background remover feature
  124544. */
  124545. static BACKGROUND_REMOVER: string;
  124546. /**
  124547. * The name of the hit test feature
  124548. */
  124549. static HIT_TEST: string;
  124550. /**
  124551. * physics impostors for xr controllers feature
  124552. */
  124553. static PHYSICS_CONTROLLERS: string;
  124554. /**
  124555. * The name of the plane detection feature
  124556. */
  124557. static PLANE_DETECTION: string;
  124558. /**
  124559. * The name of the pointer selection feature
  124560. */
  124561. static POINTER_SELECTION: string;
  124562. /**
  124563. * The name of the teleportation feature
  124564. */
  124565. static TELEPORTATION: string;
  124566. }
  124567. /**
  124568. * Defining the constructor of a feature. Used to register the modules.
  124569. */
  124570. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  124571. /**
  124572. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  124573. * It is mainly used in AR sessions.
  124574. *
  124575. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  124576. */
  124577. export class WebXRFeaturesManager implements IDisposable {
  124578. private _xrSessionManager;
  124579. private static readonly _AvailableFeatures;
  124580. private _features;
  124581. /**
  124582. * constructs a new features manages.
  124583. *
  124584. * @param _xrSessionManager an instance of WebXRSessionManager
  124585. */
  124586. constructor(_xrSessionManager: WebXRSessionManager);
  124587. /**
  124588. * Used to register a module. After calling this function a developer can use this feature in the scene.
  124589. * Mainly used internally.
  124590. *
  124591. * @param featureName the name of the feature to register
  124592. * @param constructorFunction the function used to construct the module
  124593. * @param version the (babylon) version of the module
  124594. * @param stable is that a stable version of this module
  124595. */
  124596. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  124597. /**
  124598. * Returns a constructor of a specific feature.
  124599. *
  124600. * @param featureName the name of the feature to construct
  124601. * @param version the version of the feature to load
  124602. * @param xrSessionManager the xrSessionManager. Used to construct the module
  124603. * @param options optional options provided to the module.
  124604. * @returns a function that, when called, will return a new instance of this feature
  124605. */
  124606. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  124607. /**
  124608. * Can be used to return the list of features currently registered
  124609. *
  124610. * @returns an Array of available features
  124611. */
  124612. static GetAvailableFeatures(): string[];
  124613. /**
  124614. * Gets the versions available for a specific feature
  124615. * @param featureName the name of the feature
  124616. * @returns an array with the available versions
  124617. */
  124618. static GetAvailableVersions(featureName: string): string[];
  124619. /**
  124620. * Return the latest unstable version of this feature
  124621. * @param featureName the name of the feature to search
  124622. * @returns the version number. if not found will return -1
  124623. */
  124624. static GetLatestVersionOfFeature(featureName: string): number;
  124625. /**
  124626. * Return the latest stable version of this feature
  124627. * @param featureName the name of the feature to search
  124628. * @returns the version number. if not found will return -1
  124629. */
  124630. static GetStableVersionOfFeature(featureName: string): number;
  124631. /**
  124632. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  124633. * Can be used during a session to start a feature
  124634. * @param featureName the name of feature to attach
  124635. */
  124636. attachFeature(featureName: string): void;
  124637. /**
  124638. * Can be used inside a session or when the session ends to detach a specific feature
  124639. * @param featureName the name of the feature to detach
  124640. */
  124641. detachFeature(featureName: string): void;
  124642. /**
  124643. * Used to disable an already-enabled feature
  124644. * The feature will be disposed and will be recreated once enabled.
  124645. * @param featureName the feature to disable
  124646. * @returns true if disable was successful
  124647. */
  124648. disableFeature(featureName: string | {
  124649. Name: string;
  124650. }): boolean;
  124651. /**
  124652. * dispose this features manager
  124653. */
  124654. dispose(): void;
  124655. /**
  124656. * 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.
  124657. * 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.
  124658. *
  124659. * @param featureName the name of the feature to load or the class of the feature
  124660. * @param version optional version to load. if not provided the latest version will be enabled
  124661. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  124662. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  124663. * @returns a new constructed feature or throws an error if feature not found.
  124664. */
  124665. enableFeature(featureName: string | {
  124666. Name: string;
  124667. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  124668. /**
  124669. * get the implementation of an enabled feature.
  124670. * @param featureName the name of the feature to load
  124671. * @returns the feature class, if found
  124672. */
  124673. getEnabledFeature(featureName: string): IWebXRFeature;
  124674. /**
  124675. * Get the list of enabled features
  124676. * @returns an array of enabled features
  124677. */
  124678. getEnabledFeatures(): string[];
  124679. }
  124680. }
  124681. declare module BABYLON {
  124682. /**
  124683. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  124684. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  124685. */
  124686. export class WebXRExperienceHelper implements IDisposable {
  124687. private scene;
  124688. private _nonVRCamera;
  124689. private _originalSceneAutoClear;
  124690. private _supported;
  124691. /**
  124692. * Camera used to render xr content
  124693. */
  124694. camera: WebXRCamera;
  124695. /** A features manager for this xr session */
  124696. featuresManager: WebXRFeaturesManager;
  124697. /**
  124698. * Observers registered here will be triggered after the camera's initial transformation is set
  124699. * This can be used to set a different ground level or an extra rotation.
  124700. *
  124701. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  124702. * to the position set after this observable is done executing.
  124703. */
  124704. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  124705. /**
  124706. * Fires when the state of the experience helper has changed
  124707. */
  124708. onStateChangedObservable: Observable<WebXRState>;
  124709. /** Session manager used to keep track of xr session */
  124710. sessionManager: WebXRSessionManager;
  124711. /**
  124712. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  124713. */
  124714. state: WebXRState;
  124715. /**
  124716. * Creates a WebXRExperienceHelper
  124717. * @param scene The scene the helper should be created in
  124718. */
  124719. private constructor();
  124720. /**
  124721. * Creates the experience helper
  124722. * @param scene the scene to attach the experience helper to
  124723. * @returns a promise for the experience helper
  124724. */
  124725. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  124726. /**
  124727. * Disposes of the experience helper
  124728. */
  124729. dispose(): void;
  124730. /**
  124731. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  124732. * @param sessionMode options for the XR session
  124733. * @param referenceSpaceType frame of reference of the XR session
  124734. * @param renderTarget the output canvas that will be used to enter XR mode
  124735. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  124736. * @returns promise that resolves after xr mode has entered
  124737. */
  124738. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  124739. /**
  124740. * Exits XR mode and returns the scene to its original state
  124741. * @returns promise that resolves after xr mode has exited
  124742. */
  124743. exitXRAsync(): Promise<void>;
  124744. private _nonXRToXRCamera;
  124745. private _setState;
  124746. }
  124747. }
  124748. declare module BABYLON {
  124749. /**
  124750. * X-Y values for axes in WebXR
  124751. */
  124752. export interface IWebXRMotionControllerAxesValue {
  124753. /**
  124754. * The value of the x axis
  124755. */
  124756. x: number;
  124757. /**
  124758. * The value of the y-axis
  124759. */
  124760. y: number;
  124761. }
  124762. /**
  124763. * changed / previous values for the values of this component
  124764. */
  124765. export interface IWebXRMotionControllerComponentChangesValues<T> {
  124766. /**
  124767. * current (this frame) value
  124768. */
  124769. current: T;
  124770. /**
  124771. * previous (last change) value
  124772. */
  124773. previous: T;
  124774. }
  124775. /**
  124776. * Represents changes in the component between current frame and last values recorded
  124777. */
  124778. export interface IWebXRMotionControllerComponentChanges {
  124779. /**
  124780. * will be populated with previous and current values if axes changed
  124781. */
  124782. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  124783. /**
  124784. * will be populated with previous and current values if pressed changed
  124785. */
  124786. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124787. /**
  124788. * will be populated with previous and current values if touched changed
  124789. */
  124790. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124791. /**
  124792. * will be populated with previous and current values if value changed
  124793. */
  124794. value?: IWebXRMotionControllerComponentChangesValues<number>;
  124795. }
  124796. /**
  124797. * This class represents a single component (for example button or thumbstick) of a motion controller
  124798. */
  124799. export class WebXRControllerComponent implements IDisposable {
  124800. /**
  124801. * the id of this component
  124802. */
  124803. id: string;
  124804. /**
  124805. * the type of the component
  124806. */
  124807. type: MotionControllerComponentType;
  124808. private _buttonIndex;
  124809. private _axesIndices;
  124810. private _axes;
  124811. private _changes;
  124812. private _currentValue;
  124813. private _hasChanges;
  124814. private _pressed;
  124815. private _touched;
  124816. /**
  124817. * button component type
  124818. */
  124819. static BUTTON_TYPE: MotionControllerComponentType;
  124820. /**
  124821. * squeeze component type
  124822. */
  124823. static SQUEEZE_TYPE: MotionControllerComponentType;
  124824. /**
  124825. * Thumbstick component type
  124826. */
  124827. static THUMBSTICK_TYPE: MotionControllerComponentType;
  124828. /**
  124829. * Touchpad component type
  124830. */
  124831. static TOUCHPAD_TYPE: MotionControllerComponentType;
  124832. /**
  124833. * trigger component type
  124834. */
  124835. static TRIGGER_TYPE: MotionControllerComponentType;
  124836. /**
  124837. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  124838. * the axes data changes
  124839. */
  124840. onAxisValueChangedObservable: Observable<{
  124841. x: number;
  124842. y: number;
  124843. }>;
  124844. /**
  124845. * Observers registered here will be triggered when the state of a button changes
  124846. * State change is either pressed / touched / value
  124847. */
  124848. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  124849. /**
  124850. * Creates a new component for a motion controller.
  124851. * It is created by the motion controller itself
  124852. *
  124853. * @param id the id of this component
  124854. * @param type the type of the component
  124855. * @param _buttonIndex index in the buttons array of the gamepad
  124856. * @param _axesIndices indices of the values in the axes array of the gamepad
  124857. */
  124858. constructor(
  124859. /**
  124860. * the id of this component
  124861. */
  124862. id: string,
  124863. /**
  124864. * the type of the component
  124865. */
  124866. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  124867. /**
  124868. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  124869. */
  124870. get axes(): IWebXRMotionControllerAxesValue;
  124871. /**
  124872. * Get the changes. Elements will be populated only if they changed with their previous and current value
  124873. */
  124874. get changes(): IWebXRMotionControllerComponentChanges;
  124875. /**
  124876. * Return whether or not the component changed the last frame
  124877. */
  124878. get hasChanges(): boolean;
  124879. /**
  124880. * is the button currently pressed
  124881. */
  124882. get pressed(): boolean;
  124883. /**
  124884. * is the button currently touched
  124885. */
  124886. get touched(): boolean;
  124887. /**
  124888. * Get the current value of this component
  124889. */
  124890. get value(): number;
  124891. /**
  124892. * Dispose this component
  124893. */
  124894. dispose(): void;
  124895. /**
  124896. * Are there axes correlating to this component
  124897. * @return true is axes data is available
  124898. */
  124899. isAxes(): boolean;
  124900. /**
  124901. * Is this component a button (hence - pressable)
  124902. * @returns true if can be pressed
  124903. */
  124904. isButton(): boolean;
  124905. /**
  124906. * update this component using the gamepad object it is in. Called on every frame
  124907. * @param nativeController the native gamepad controller object
  124908. */
  124909. update(nativeController: IMinimalMotionControllerObject): void;
  124910. }
  124911. }
  124912. declare module BABYLON {
  124913. /**
  124914. * Interface used to represent data loading progression
  124915. */
  124916. export interface ISceneLoaderProgressEvent {
  124917. /**
  124918. * Defines if data length to load can be evaluated
  124919. */
  124920. readonly lengthComputable: boolean;
  124921. /**
  124922. * Defines the loaded data length
  124923. */
  124924. readonly loaded: number;
  124925. /**
  124926. * Defines the data length to load
  124927. */
  124928. readonly total: number;
  124929. }
  124930. /**
  124931. * Interface used by SceneLoader plugins to define supported file extensions
  124932. */
  124933. export interface ISceneLoaderPluginExtensions {
  124934. /**
  124935. * Defines the list of supported extensions
  124936. */
  124937. [extension: string]: {
  124938. isBinary: boolean;
  124939. };
  124940. }
  124941. /**
  124942. * Interface used by SceneLoader plugin factory
  124943. */
  124944. export interface ISceneLoaderPluginFactory {
  124945. /**
  124946. * Defines the name of the factory
  124947. */
  124948. name: string;
  124949. /**
  124950. * Function called to create a new plugin
  124951. * @return the new plugin
  124952. */
  124953. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  124954. /**
  124955. * The callback that returns true if the data can be directly loaded.
  124956. * @param data string containing the file data
  124957. * @returns if the data can be loaded directly
  124958. */
  124959. canDirectLoad?(data: string): boolean;
  124960. }
  124961. /**
  124962. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  124963. */
  124964. export interface ISceneLoaderPluginBase {
  124965. /**
  124966. * The friendly name of this plugin.
  124967. */
  124968. name: string;
  124969. /**
  124970. * The file extensions supported by this plugin.
  124971. */
  124972. extensions: string | ISceneLoaderPluginExtensions;
  124973. /**
  124974. * The callback called when loading from a url.
  124975. * @param scene scene loading this url
  124976. * @param url url to load
  124977. * @param onSuccess callback called when the file successfully loads
  124978. * @param onProgress callback called while file is loading (if the server supports this mode)
  124979. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  124980. * @param onError callback called when the file fails to load
  124981. * @returns a file request object
  124982. */
  124983. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124984. /**
  124985. * The callback called when loading from a file object.
  124986. * @param scene scene loading this file
  124987. * @param file defines the file to load
  124988. * @param onSuccess defines the callback to call when data is loaded
  124989. * @param onProgress defines the callback to call during loading process
  124990. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  124991. * @param onError defines the callback to call when an error occurs
  124992. * @returns a file request object
  124993. */
  124994. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124995. /**
  124996. * The callback that returns true if the data can be directly loaded.
  124997. * @param data string containing the file data
  124998. * @returns if the data can be loaded directly
  124999. */
  125000. canDirectLoad?(data: string): boolean;
  125001. /**
  125002. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  125003. * @param scene scene loading this data
  125004. * @param data string containing the data
  125005. * @returns data to pass to the plugin
  125006. */
  125007. directLoad?(scene: Scene, data: string): any;
  125008. /**
  125009. * The callback that allows custom handling of the root url based on the response url.
  125010. * @param rootUrl the original root url
  125011. * @param responseURL the response url if available
  125012. * @returns the new root url
  125013. */
  125014. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  125015. }
  125016. /**
  125017. * Interface used to define a SceneLoader plugin
  125018. */
  125019. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  125020. /**
  125021. * Import meshes into a scene.
  125022. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125023. * @param scene The scene to import into
  125024. * @param data The data to import
  125025. * @param rootUrl The root url for scene and resources
  125026. * @param meshes The meshes array to import into
  125027. * @param particleSystems The particle systems array to import into
  125028. * @param skeletons The skeletons array to import into
  125029. * @param onError The callback when import fails
  125030. * @returns True if successful or false otherwise
  125031. */
  125032. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  125033. /**
  125034. * Load into a scene.
  125035. * @param scene The scene to load into
  125036. * @param data The data to import
  125037. * @param rootUrl The root url for scene and resources
  125038. * @param onError The callback when import fails
  125039. * @returns True if successful or false otherwise
  125040. */
  125041. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  125042. /**
  125043. * Load into an asset container.
  125044. * @param scene The scene to load into
  125045. * @param data The data to import
  125046. * @param rootUrl The root url for scene and resources
  125047. * @param onError The callback when import fails
  125048. * @returns The loaded asset container
  125049. */
  125050. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  125051. }
  125052. /**
  125053. * Interface used to define an async SceneLoader plugin
  125054. */
  125055. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  125056. /**
  125057. * Import meshes into a scene.
  125058. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125059. * @param scene The scene to import into
  125060. * @param data The data to import
  125061. * @param rootUrl The root url for scene and resources
  125062. * @param onProgress The callback when the load progresses
  125063. * @param fileName Defines the name of the file to load
  125064. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  125065. */
  125066. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  125067. meshes: AbstractMesh[];
  125068. particleSystems: IParticleSystem[];
  125069. skeletons: Skeleton[];
  125070. animationGroups: AnimationGroup[];
  125071. }>;
  125072. /**
  125073. * Load into a scene.
  125074. * @param scene The scene to load into
  125075. * @param data The data to import
  125076. * @param rootUrl The root url for scene and resources
  125077. * @param onProgress The callback when the load progresses
  125078. * @param fileName Defines the name of the file to load
  125079. * @returns Nothing
  125080. */
  125081. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  125082. /**
  125083. * Load into an asset container.
  125084. * @param scene The scene to load into
  125085. * @param data The data to import
  125086. * @param rootUrl The root url for scene and resources
  125087. * @param onProgress The callback when the load progresses
  125088. * @param fileName Defines the name of the file to load
  125089. * @returns The loaded asset container
  125090. */
  125091. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  125092. }
  125093. /**
  125094. * Mode that determines how to handle old animation groups before loading new ones.
  125095. */
  125096. export enum SceneLoaderAnimationGroupLoadingMode {
  125097. /**
  125098. * Reset all old animations to initial state then dispose them.
  125099. */
  125100. Clean = 0,
  125101. /**
  125102. * Stop all old animations.
  125103. */
  125104. Stop = 1,
  125105. /**
  125106. * Restart old animations from first frame.
  125107. */
  125108. Sync = 2,
  125109. /**
  125110. * Old animations remains untouched.
  125111. */
  125112. NoSync = 3
  125113. }
  125114. /**
  125115. * Class used to load scene from various file formats using registered plugins
  125116. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  125117. */
  125118. export class SceneLoader {
  125119. /**
  125120. * No logging while loading
  125121. */
  125122. static readonly NO_LOGGING: number;
  125123. /**
  125124. * Minimal logging while loading
  125125. */
  125126. static readonly MINIMAL_LOGGING: number;
  125127. /**
  125128. * Summary logging while loading
  125129. */
  125130. static readonly SUMMARY_LOGGING: number;
  125131. /**
  125132. * Detailled logging while loading
  125133. */
  125134. static readonly DETAILED_LOGGING: number;
  125135. /**
  125136. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  125137. */
  125138. static get ForceFullSceneLoadingForIncremental(): boolean;
  125139. static set ForceFullSceneLoadingForIncremental(value: boolean);
  125140. /**
  125141. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  125142. */
  125143. static get ShowLoadingScreen(): boolean;
  125144. static set ShowLoadingScreen(value: boolean);
  125145. /**
  125146. * Defines the current logging level (while loading the scene)
  125147. * @ignorenaming
  125148. */
  125149. static get loggingLevel(): number;
  125150. static set loggingLevel(value: number);
  125151. /**
  125152. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  125153. */
  125154. static get CleanBoneMatrixWeights(): boolean;
  125155. static set CleanBoneMatrixWeights(value: boolean);
  125156. /**
  125157. * Event raised when a plugin is used to load a scene
  125158. */
  125159. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  125160. private static _registeredPlugins;
  125161. private static _getDefaultPlugin;
  125162. private static _getPluginForExtension;
  125163. private static _getPluginForDirectLoad;
  125164. private static _getPluginForFilename;
  125165. private static _getDirectLoad;
  125166. private static _loadData;
  125167. private static _getFileInfo;
  125168. /**
  125169. * Gets a plugin that can load the given extension
  125170. * @param extension defines the extension to load
  125171. * @returns a plugin or null if none works
  125172. */
  125173. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  125174. /**
  125175. * Gets a boolean indicating that the given extension can be loaded
  125176. * @param extension defines the extension to load
  125177. * @returns true if the extension is supported
  125178. */
  125179. static IsPluginForExtensionAvailable(extension: string): boolean;
  125180. /**
  125181. * Adds a new plugin to the list of registered plugins
  125182. * @param plugin defines the plugin to add
  125183. */
  125184. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  125185. /**
  125186. * Import meshes into a scene
  125187. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125188. * @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)
  125189. * @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)
  125190. * @param scene the instance of BABYLON.Scene to append to
  125191. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  125192. * @param onProgress a callback with a progress event for each file being loaded
  125193. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125194. * @param pluginExtension the extension used to determine the plugin
  125195. * @returns The loaded plugin
  125196. */
  125197. 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>;
  125198. /**
  125199. * Import meshes into a scene
  125200. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125201. * @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)
  125202. * @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)
  125203. * @param scene the instance of BABYLON.Scene to append to
  125204. * @param onProgress a callback with a progress event for each file being loaded
  125205. * @param pluginExtension the extension used to determine the plugin
  125206. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  125207. */
  125208. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  125209. meshes: AbstractMesh[];
  125210. particleSystems: IParticleSystem[];
  125211. skeletons: Skeleton[];
  125212. animationGroups: AnimationGroup[];
  125213. }>;
  125214. /**
  125215. * Load a scene
  125216. * @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)
  125217. * @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)
  125218. * @param engine is the instance of BABYLON.Engine to use to create the scene
  125219. * @param onSuccess a callback with the scene when import succeeds
  125220. * @param onProgress a callback with a progress event for each file being loaded
  125221. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125222. * @param pluginExtension the extension used to determine the plugin
  125223. * @returns The loaded plugin
  125224. */
  125225. 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>;
  125226. /**
  125227. * Load a scene
  125228. * @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)
  125229. * @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)
  125230. * @param engine is the instance of BABYLON.Engine to use to create the scene
  125231. * @param onProgress a callback with a progress event for each file being loaded
  125232. * @param pluginExtension the extension used to determine the plugin
  125233. * @returns The loaded scene
  125234. */
  125235. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125236. /**
  125237. * Append a scene
  125238. * @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)
  125239. * @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)
  125240. * @param scene is the instance of BABYLON.Scene to append to
  125241. * @param onSuccess a callback with the scene when import succeeds
  125242. * @param onProgress a callback with a progress event for each file being loaded
  125243. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125244. * @param pluginExtension the extension used to determine the plugin
  125245. * @returns The loaded plugin
  125246. */
  125247. 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>;
  125248. /**
  125249. * Append a scene
  125250. * @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)
  125251. * @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)
  125252. * @param scene is the instance of BABYLON.Scene to append to
  125253. * @param onProgress a callback with a progress event for each file being loaded
  125254. * @param pluginExtension the extension used to determine the plugin
  125255. * @returns The given scene
  125256. */
  125257. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125258. /**
  125259. * Load a scene into an asset container
  125260. * @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)
  125261. * @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)
  125262. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125263. * @param onSuccess a callback with the scene when import succeeds
  125264. * @param onProgress a callback with a progress event for each file being loaded
  125265. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125266. * @param pluginExtension the extension used to determine the plugin
  125267. * @returns The loaded plugin
  125268. */
  125269. 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>;
  125270. /**
  125271. * Load a scene into an asset container
  125272. * @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)
  125273. * @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)
  125274. * @param scene is the instance of Scene to append to
  125275. * @param onProgress a callback with a progress event for each file being loaded
  125276. * @param pluginExtension the extension used to determine the plugin
  125277. * @returns The loaded asset container
  125278. */
  125279. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  125280. /**
  125281. * Import animations from a file into a scene
  125282. * @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)
  125283. * @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)
  125284. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125285. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  125286. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  125287. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  125288. * @param onSuccess a callback with the scene when import succeeds
  125289. * @param onProgress a callback with a progress event for each file being loaded
  125290. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125291. * @param pluginExtension the extension used to determine the plugin
  125292. */
  125293. 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;
  125294. /**
  125295. * Import animations from a file into a scene
  125296. * @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)
  125297. * @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)
  125298. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125299. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  125300. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  125301. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  125302. * @param onSuccess a callback with the scene when import succeeds
  125303. * @param onProgress a callback with a progress event for each file being loaded
  125304. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125305. * @param pluginExtension the extension used to determine the plugin
  125306. * @returns the updated scene with imported animations
  125307. */
  125308. 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>;
  125309. }
  125310. }
  125311. declare module BABYLON {
  125312. /**
  125313. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  125314. */
  125315. export type MotionControllerHandedness = "none" | "left" | "right";
  125316. /**
  125317. * The type of components available in motion controllers.
  125318. * This is not the name of the component.
  125319. */
  125320. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  125321. /**
  125322. * The state of a controller component
  125323. */
  125324. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  125325. /**
  125326. * The schema of motion controller layout.
  125327. * No object will be initialized using this interface
  125328. * This is used just to define the profile.
  125329. */
  125330. export interface IMotionControllerLayout {
  125331. /**
  125332. * Path to load the assets. Usually relative to the base path
  125333. */
  125334. assetPath: string;
  125335. /**
  125336. * Available components (unsorted)
  125337. */
  125338. components: {
  125339. /**
  125340. * A map of component Ids
  125341. */
  125342. [componentId: string]: {
  125343. /**
  125344. * The type of input the component outputs
  125345. */
  125346. type: MotionControllerComponentType;
  125347. /**
  125348. * The indices of this component in the gamepad object
  125349. */
  125350. gamepadIndices: {
  125351. /**
  125352. * Index of button
  125353. */
  125354. button?: number;
  125355. /**
  125356. * If available, index of x-axis
  125357. */
  125358. xAxis?: number;
  125359. /**
  125360. * If available, index of y-axis
  125361. */
  125362. yAxis?: number;
  125363. };
  125364. /**
  125365. * The mesh's root node name
  125366. */
  125367. rootNodeName: string;
  125368. /**
  125369. * Animation definitions for this model
  125370. */
  125371. visualResponses: {
  125372. [stateKey: string]: {
  125373. /**
  125374. * What property will be animated
  125375. */
  125376. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  125377. /**
  125378. * What states influence this visual response
  125379. */
  125380. states: MotionControllerComponentStateType[];
  125381. /**
  125382. * Type of animation - movement or visibility
  125383. */
  125384. valueNodeProperty: "transform" | "visibility";
  125385. /**
  125386. * Base node name to move. Its position will be calculated according to the min and max nodes
  125387. */
  125388. valueNodeName?: string;
  125389. /**
  125390. * Minimum movement node
  125391. */
  125392. minNodeName?: string;
  125393. /**
  125394. * Max movement node
  125395. */
  125396. maxNodeName?: string;
  125397. };
  125398. };
  125399. /**
  125400. * If touch enabled, what is the name of node to display user feedback
  125401. */
  125402. touchPointNodeName?: string;
  125403. };
  125404. };
  125405. /**
  125406. * Is it xr standard mapping or not
  125407. */
  125408. gamepadMapping: "" | "xr-standard";
  125409. /**
  125410. * Base root node of this entire model
  125411. */
  125412. rootNodeName: string;
  125413. /**
  125414. * Defines the main button component id
  125415. */
  125416. selectComponentId: string;
  125417. }
  125418. /**
  125419. * A definition for the layout map in the input profile
  125420. */
  125421. export interface IMotionControllerLayoutMap {
  125422. /**
  125423. * Layouts with handedness type as a key
  125424. */
  125425. [handedness: string]: IMotionControllerLayout;
  125426. }
  125427. /**
  125428. * The XR Input profile schema
  125429. * Profiles can be found here:
  125430. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  125431. */
  125432. export interface IMotionControllerProfile {
  125433. /**
  125434. * fallback profiles for this profileId
  125435. */
  125436. fallbackProfileIds: string[];
  125437. /**
  125438. * The layout map, with handedness as key
  125439. */
  125440. layouts: IMotionControllerLayoutMap;
  125441. /**
  125442. * The id of this profile
  125443. * correlates to the profile(s) in the xrInput.profiles array
  125444. */
  125445. profileId: string;
  125446. }
  125447. /**
  125448. * A helper-interface for the 3 meshes needed for controller button animation
  125449. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  125450. */
  125451. export interface IMotionControllerButtonMeshMap {
  125452. /**
  125453. * the mesh that defines the pressed value mesh position.
  125454. * This is used to find the max-position of this button
  125455. */
  125456. pressedMesh: AbstractMesh;
  125457. /**
  125458. * the mesh that defines the unpressed value mesh position.
  125459. * This is used to find the min (or initial) position of this button
  125460. */
  125461. unpressedMesh: AbstractMesh;
  125462. /**
  125463. * The mesh that will be changed when value changes
  125464. */
  125465. valueMesh: AbstractMesh;
  125466. }
  125467. /**
  125468. * A helper-interface for the 3 meshes needed for controller axis animation.
  125469. * This will be expanded when touchpad animations are fully supported
  125470. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  125471. */
  125472. export interface IMotionControllerMeshMap {
  125473. /**
  125474. * the mesh that defines the maximum value mesh position.
  125475. */
  125476. maxMesh?: AbstractMesh;
  125477. /**
  125478. * the mesh that defines the minimum value mesh position.
  125479. */
  125480. minMesh?: AbstractMesh;
  125481. /**
  125482. * The mesh that will be changed when axis value changes
  125483. */
  125484. valueMesh: AbstractMesh;
  125485. }
  125486. /**
  125487. * The elements needed for change-detection of the gamepad objects in motion controllers
  125488. */
  125489. export interface IMinimalMotionControllerObject {
  125490. /**
  125491. * Available axes of this controller
  125492. */
  125493. axes: number[];
  125494. /**
  125495. * An array of available buttons
  125496. */
  125497. buttons: Array<{
  125498. /**
  125499. * Value of the button/trigger
  125500. */
  125501. value: number;
  125502. /**
  125503. * If the button/trigger is currently touched
  125504. */
  125505. touched: boolean;
  125506. /**
  125507. * If the button/trigger is currently pressed
  125508. */
  125509. pressed: boolean;
  125510. }>;
  125511. /**
  125512. * EXPERIMENTAL haptic support.
  125513. */
  125514. hapticActuators?: Array<{
  125515. pulse: (value: number, duration: number) => Promise<boolean>;
  125516. }>;
  125517. }
  125518. /**
  125519. * An Abstract Motion controller
  125520. * This class receives an xrInput and a profile layout and uses those to initialize the components
  125521. * Each component has an observable to check for changes in value and state
  125522. */
  125523. export abstract class WebXRAbstractMotionController implements IDisposable {
  125524. protected scene: Scene;
  125525. protected layout: IMotionControllerLayout;
  125526. /**
  125527. * The gamepad object correlating to this controller
  125528. */
  125529. gamepadObject: IMinimalMotionControllerObject;
  125530. /**
  125531. * handedness (left/right/none) of this controller
  125532. */
  125533. handedness: MotionControllerHandedness;
  125534. private _initComponent;
  125535. private _modelReady;
  125536. /**
  125537. * A map of components (WebXRControllerComponent) in this motion controller
  125538. * Components have a ComponentType and can also have both button and axis definitions
  125539. */
  125540. readonly components: {
  125541. [id: string]: WebXRControllerComponent;
  125542. };
  125543. /**
  125544. * Disable the model's animation. Can be set at any time.
  125545. */
  125546. disableAnimation: boolean;
  125547. /**
  125548. * Observers registered here will be triggered when the model of this controller is done loading
  125549. */
  125550. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  125551. /**
  125552. * The profile id of this motion controller
  125553. */
  125554. abstract profileId: string;
  125555. /**
  125556. * The root mesh of the model. It is null if the model was not yet initialized
  125557. */
  125558. rootMesh: Nullable<AbstractMesh>;
  125559. /**
  125560. * constructs a new abstract motion controller
  125561. * @param scene the scene to which the model of the controller will be added
  125562. * @param layout The profile layout to load
  125563. * @param gamepadObject The gamepad object correlating to this controller
  125564. * @param handedness handedness (left/right/none) of this controller
  125565. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  125566. */
  125567. constructor(scene: Scene, layout: IMotionControllerLayout,
  125568. /**
  125569. * The gamepad object correlating to this controller
  125570. */
  125571. gamepadObject: IMinimalMotionControllerObject,
  125572. /**
  125573. * handedness (left/right/none) of this controller
  125574. */
  125575. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  125576. /**
  125577. * Dispose this controller, the model mesh and all its components
  125578. */
  125579. dispose(): void;
  125580. /**
  125581. * Returns all components of specific type
  125582. * @param type the type to search for
  125583. * @return an array of components with this type
  125584. */
  125585. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  125586. /**
  125587. * get a component based an its component id as defined in layout.components
  125588. * @param id the id of the component
  125589. * @returns the component correlates to the id or undefined if not found
  125590. */
  125591. getComponent(id: string): WebXRControllerComponent;
  125592. /**
  125593. * Get the list of components available in this motion controller
  125594. * @returns an array of strings correlating to available components
  125595. */
  125596. getComponentIds(): string[];
  125597. /**
  125598. * Get the first component of specific type
  125599. * @param type type of component to find
  125600. * @return a controller component or null if not found
  125601. */
  125602. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  125603. /**
  125604. * Get the main (Select) component of this controller as defined in the layout
  125605. * @returns the main component of this controller
  125606. */
  125607. getMainComponent(): WebXRControllerComponent;
  125608. /**
  125609. * Loads the model correlating to this controller
  125610. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  125611. * @returns A promise fulfilled with the result of the model loading
  125612. */
  125613. loadModel(): Promise<boolean>;
  125614. /**
  125615. * Update this model using the current XRFrame
  125616. * @param xrFrame the current xr frame to use and update the model
  125617. */
  125618. updateFromXRFrame(xrFrame: XRFrame): void;
  125619. /**
  125620. * Backwards compatibility due to a deeply-integrated typo
  125621. */
  125622. get handness(): XREye;
  125623. /**
  125624. * Pulse (vibrate) this controller
  125625. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  125626. * Consecutive calls to this function will cancel the last pulse call
  125627. *
  125628. * @param value the strength of the pulse in 0.0...1.0 range
  125629. * @param duration Duration of the pulse in milliseconds
  125630. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  125631. * @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
  125632. */
  125633. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  125634. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125635. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125636. /**
  125637. * Moves the axis on the controller mesh based on its current state
  125638. * @param axis the index of the axis
  125639. * @param axisValue the value of the axis which determines the meshes new position
  125640. * @hidden
  125641. */
  125642. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  125643. /**
  125644. * Update the model itself with the current frame data
  125645. * @param xrFrame the frame to use for updating the model mesh
  125646. */
  125647. protected updateModel(xrFrame: XRFrame): void;
  125648. /**
  125649. * Get the filename and path for this controller's model
  125650. * @returns a map of filename and path
  125651. */
  125652. protected abstract _getFilenameAndPath(): {
  125653. filename: string;
  125654. path: string;
  125655. };
  125656. /**
  125657. * This function is called before the mesh is loaded. It checks for loading constraints.
  125658. * For example, this function can check if the GLB loader is available
  125659. * If this function returns false, the generic controller will be loaded instead
  125660. * @returns Is the client ready to load the mesh
  125661. */
  125662. protected abstract _getModelLoadingConstraints(): boolean;
  125663. /**
  125664. * This function will be called after the model was successfully loaded and can be used
  125665. * for mesh transformations before it is available for the user
  125666. * @param meshes the loaded meshes
  125667. */
  125668. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  125669. /**
  125670. * Set the root mesh for this controller. Important for the WebXR controller class
  125671. * @param meshes the loaded meshes
  125672. */
  125673. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  125674. /**
  125675. * A function executed each frame that updates the mesh (if needed)
  125676. * @param xrFrame the current xrFrame
  125677. */
  125678. protected abstract _updateModel(xrFrame: XRFrame): void;
  125679. private _getGenericFilenameAndPath;
  125680. private _getGenericParentMesh;
  125681. }
  125682. }
  125683. declare module BABYLON {
  125684. /**
  125685. * A generic trigger-only motion controller for WebXR
  125686. */
  125687. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  125688. /**
  125689. * Static version of the profile id of this controller
  125690. */
  125691. static ProfileId: string;
  125692. profileId: string;
  125693. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  125694. protected _getFilenameAndPath(): {
  125695. filename: string;
  125696. path: string;
  125697. };
  125698. protected _getModelLoadingConstraints(): boolean;
  125699. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  125700. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125701. protected _updateModel(): void;
  125702. }
  125703. }
  125704. declare module BABYLON {
  125705. /**
  125706. * Class containing static functions to help procedurally build meshes
  125707. */
  125708. export class SphereBuilder {
  125709. /**
  125710. * Creates a sphere mesh
  125711. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125712. * * 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`)
  125713. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125714. * * 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
  125715. * * 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)
  125716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125719. * @param name defines the name of the mesh
  125720. * @param options defines the options used to create the mesh
  125721. * @param scene defines the hosting scene
  125722. * @returns the sphere mesh
  125723. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125724. */
  125725. static CreateSphere(name: string, options: {
  125726. segments?: number;
  125727. diameter?: number;
  125728. diameterX?: number;
  125729. diameterY?: number;
  125730. diameterZ?: number;
  125731. arc?: number;
  125732. slice?: number;
  125733. sideOrientation?: number;
  125734. frontUVs?: Vector4;
  125735. backUVs?: Vector4;
  125736. updatable?: boolean;
  125737. }, scene?: Nullable<Scene>): Mesh;
  125738. }
  125739. }
  125740. declare module BABYLON {
  125741. /**
  125742. * A profiled motion controller has its profile loaded from an online repository.
  125743. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  125744. */
  125745. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  125746. private _repositoryUrl;
  125747. private _buttonMeshMapping;
  125748. private _touchDots;
  125749. /**
  125750. * The profile ID of this controller. Will be populated when the controller initializes.
  125751. */
  125752. profileId: string;
  125753. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  125754. dispose(): void;
  125755. protected _getFilenameAndPath(): {
  125756. filename: string;
  125757. path: string;
  125758. };
  125759. protected _getModelLoadingConstraints(): boolean;
  125760. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  125761. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125762. protected _updateModel(_xrFrame: XRFrame): void;
  125763. }
  125764. }
  125765. declare module BABYLON {
  125766. /**
  125767. * A construction function type to create a new controller based on an xrInput object
  125768. */
  125769. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  125770. /**
  125771. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  125772. *
  125773. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  125774. * it should be replaced with auto-loaded controllers.
  125775. *
  125776. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  125777. */
  125778. export class WebXRMotionControllerManager {
  125779. private static _AvailableControllers;
  125780. private static _Fallbacks;
  125781. private static _ProfileLoadingPromises;
  125782. private static _ProfilesList;
  125783. /**
  125784. * The base URL of the online controller repository. Can be changed at any time.
  125785. */
  125786. static BaseRepositoryUrl: string;
  125787. /**
  125788. * Which repository gets priority - local or online
  125789. */
  125790. static PrioritizeOnlineRepository: boolean;
  125791. /**
  125792. * Use the online repository, or use only locally-defined controllers
  125793. */
  125794. static UseOnlineRepository: boolean;
  125795. /**
  125796. * Clear the cache used for profile loading and reload when requested again
  125797. */
  125798. static ClearProfilesCache(): void;
  125799. /**
  125800. * Register the default fallbacks.
  125801. * This function is called automatically when this file is imported.
  125802. */
  125803. static DefaultFallbacks(): void;
  125804. /**
  125805. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  125806. * @param profileId the profile to which a fallback needs to be found
  125807. * @return an array with corresponding fallback profiles
  125808. */
  125809. static FindFallbackWithProfileId(profileId: string): string[];
  125810. /**
  125811. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  125812. * The order of search:
  125813. *
  125814. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  125815. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  125816. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  125817. * 4) return the generic trigger controller if none were found
  125818. *
  125819. * @param xrInput the xrInput to which a new controller is initialized
  125820. * @param scene the scene to which the model will be added
  125821. * @param forceProfile force a certain profile for this controller
  125822. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  125823. */
  125824. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  125825. /**
  125826. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  125827. *
  125828. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  125829. *
  125830. * @param type the profile type to register
  125831. * @param constructFunction the function to be called when loading this profile
  125832. */
  125833. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  125834. /**
  125835. * Register a fallback to a specific profile.
  125836. * @param profileId the profileId that will receive the fallbacks
  125837. * @param fallbacks A list of fallback profiles
  125838. */
  125839. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  125840. /**
  125841. * Will update the list of profiles available in the repository
  125842. * @return a promise that resolves to a map of profiles available online
  125843. */
  125844. static UpdateProfilesList(): Promise<{
  125845. [profile: string]: string;
  125846. }>;
  125847. private static _LoadProfileFromRepository;
  125848. private static _LoadProfilesFromAvailableControllers;
  125849. }
  125850. }
  125851. declare module BABYLON {
  125852. /**
  125853. * Configuration options for the WebXR controller creation
  125854. */
  125855. export interface IWebXRControllerOptions {
  125856. /**
  125857. * Should the controller mesh be animated when a user interacts with it
  125858. * The pressed buttons / thumbstick and touchpad animations will be disabled
  125859. */
  125860. disableMotionControllerAnimation?: boolean;
  125861. /**
  125862. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  125863. */
  125864. doNotLoadControllerMesh?: boolean;
  125865. /**
  125866. * Force a specific controller type for this controller.
  125867. * This can be used when creating your own profile or when testing different controllers
  125868. */
  125869. forceControllerProfile?: string;
  125870. /**
  125871. * Defines a rendering group ID for meshes that will be loaded.
  125872. * This is for the default controllers only.
  125873. */
  125874. renderingGroupId?: number;
  125875. }
  125876. /**
  125877. * Represents an XR controller
  125878. */
  125879. export class WebXRInputSource {
  125880. private _scene;
  125881. /** The underlying input source for the controller */
  125882. inputSource: XRInputSource;
  125883. private _options;
  125884. private _tmpVector;
  125885. private _uniqueId;
  125886. /**
  125887. * 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
  125888. */
  125889. grip?: AbstractMesh;
  125890. /**
  125891. * If available, this is the gamepad object related to this controller.
  125892. * Using this object it is possible to get click events and trackpad changes of the
  125893. * webxr controller that is currently being used.
  125894. */
  125895. motionController?: WebXRAbstractMotionController;
  125896. /**
  125897. * Event that fires when the controller is removed/disposed.
  125898. * The object provided as event data is this controller, after associated assets were disposed.
  125899. * uniqueId is still available.
  125900. */
  125901. onDisposeObservable: Observable<WebXRInputSource>;
  125902. /**
  125903. * Will be triggered when the mesh associated with the motion controller is done loading.
  125904. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  125905. * A shortened version of controller -> motion controller -> on mesh loaded.
  125906. */
  125907. onMeshLoadedObservable: Observable<AbstractMesh>;
  125908. /**
  125909. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  125910. */
  125911. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  125912. /**
  125913. * Pointer which can be used to select objects or attach a visible laser to
  125914. */
  125915. pointer: AbstractMesh;
  125916. /**
  125917. * Creates the input source object
  125918. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  125919. * @param _scene the scene which the controller should be associated to
  125920. * @param inputSource the underlying input source for the controller
  125921. * @param _options options for this controller creation
  125922. */
  125923. constructor(_scene: Scene,
  125924. /** The underlying input source for the controller */
  125925. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  125926. /**
  125927. * Get this controllers unique id
  125928. */
  125929. get uniqueId(): string;
  125930. /**
  125931. * Disposes of the object
  125932. */
  125933. dispose(): void;
  125934. /**
  125935. * Gets a world space ray coming from the pointer or grip
  125936. * @param result the resulting ray
  125937. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  125938. */
  125939. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  125940. /**
  125941. * Updates the controller pose based on the given XRFrame
  125942. * @param xrFrame xr frame to update the pose with
  125943. * @param referenceSpace reference space to use
  125944. */
  125945. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  125946. }
  125947. }
  125948. declare module BABYLON {
  125949. /**
  125950. * The schema for initialization options of the XR Input class
  125951. */
  125952. export interface IWebXRInputOptions {
  125953. /**
  125954. * If set to true no model will be automatically loaded
  125955. */
  125956. doNotLoadControllerMeshes?: boolean;
  125957. /**
  125958. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  125959. * If not found, the xr input profile data will be used.
  125960. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  125961. */
  125962. forceInputProfile?: string;
  125963. /**
  125964. * Do not send a request to the controller repository to load the profile.
  125965. *
  125966. * Instead, use the controllers available in babylon itself.
  125967. */
  125968. disableOnlineControllerRepository?: boolean;
  125969. /**
  125970. * A custom URL for the controllers repository
  125971. */
  125972. customControllersRepositoryURL?: string;
  125973. /**
  125974. * Should the controller model's components not move according to the user input
  125975. */
  125976. disableControllerAnimation?: boolean;
  125977. /**
  125978. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  125979. */
  125980. controllerOptions?: IWebXRControllerOptions;
  125981. }
  125982. /**
  125983. * XR input used to track XR inputs such as controllers/rays
  125984. */
  125985. export class WebXRInput implements IDisposable {
  125986. /**
  125987. * the xr session manager for this session
  125988. */
  125989. xrSessionManager: WebXRSessionManager;
  125990. /**
  125991. * the WebXR camera for this session. Mainly used for teleportation
  125992. */
  125993. xrCamera: WebXRCamera;
  125994. private readonly options;
  125995. /**
  125996. * XR controllers being tracked
  125997. */
  125998. controllers: Array<WebXRInputSource>;
  125999. private _frameObserver;
  126000. private _sessionEndedObserver;
  126001. private _sessionInitObserver;
  126002. /**
  126003. * Event when a controller has been connected/added
  126004. */
  126005. onControllerAddedObservable: Observable<WebXRInputSource>;
  126006. /**
  126007. * Event when a controller has been removed/disconnected
  126008. */
  126009. onControllerRemovedObservable: Observable<WebXRInputSource>;
  126010. /**
  126011. * Initializes the WebXRInput
  126012. * @param xrSessionManager the xr session manager for this session
  126013. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  126014. * @param options = initialization options for this xr input
  126015. */
  126016. constructor(
  126017. /**
  126018. * the xr session manager for this session
  126019. */
  126020. xrSessionManager: WebXRSessionManager,
  126021. /**
  126022. * the WebXR camera for this session. Mainly used for teleportation
  126023. */
  126024. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  126025. private _onInputSourcesChange;
  126026. private _addAndRemoveControllers;
  126027. /**
  126028. * Disposes of the object
  126029. */
  126030. dispose(): void;
  126031. }
  126032. }
  126033. declare module BABYLON {
  126034. /**
  126035. * This is the base class for all WebXR features.
  126036. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  126037. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  126038. */
  126039. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  126040. protected _xrSessionManager: WebXRSessionManager;
  126041. private _attached;
  126042. private _removeOnDetach;
  126043. /**
  126044. * Should auto-attach be disabled?
  126045. */
  126046. disableAutoAttach: boolean;
  126047. /**
  126048. * Construct a new (abstract) WebXR feature
  126049. * @param _xrSessionManager the xr session manager for this feature
  126050. */
  126051. constructor(_xrSessionManager: WebXRSessionManager);
  126052. /**
  126053. * Is this feature attached
  126054. */
  126055. get attached(): boolean;
  126056. /**
  126057. * attach this feature
  126058. *
  126059. * @param force should attachment be forced (even when already attached)
  126060. * @returns true if successful, false is failed or already attached
  126061. */
  126062. attach(force?: boolean): boolean;
  126063. /**
  126064. * detach this feature.
  126065. *
  126066. * @returns true if successful, false if failed or already detached
  126067. */
  126068. detach(): boolean;
  126069. /**
  126070. * Dispose this feature and all of the resources attached
  126071. */
  126072. dispose(): void;
  126073. /**
  126074. * This is used to register callbacks that will automatically be removed when detach is called.
  126075. * @param observable the observable to which the observer will be attached
  126076. * @param callback the callback to register
  126077. */
  126078. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  126079. /**
  126080. * Code in this function will be executed on each xrFrame received from the browser.
  126081. * This function will not execute after the feature is detached.
  126082. * @param _xrFrame the current frame
  126083. */
  126084. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  126085. }
  126086. }
  126087. declare module BABYLON {
  126088. /**
  126089. * Renders a layer on top of an existing scene
  126090. */
  126091. export class UtilityLayerRenderer implements IDisposable {
  126092. /** the original scene that will be rendered on top of */
  126093. originalScene: Scene;
  126094. private _pointerCaptures;
  126095. private _lastPointerEvents;
  126096. private static _DefaultUtilityLayer;
  126097. private static _DefaultKeepDepthUtilityLayer;
  126098. private _sharedGizmoLight;
  126099. private _renderCamera;
  126100. /**
  126101. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  126102. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  126103. * @returns the camera that is used when rendering the utility layer
  126104. */
  126105. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  126106. /**
  126107. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  126108. * @param cam the camera that should be used when rendering the utility layer
  126109. */
  126110. setRenderCamera(cam: Nullable<Camera>): void;
  126111. /**
  126112. * @hidden
  126113. * Light which used by gizmos to get light shading
  126114. */
  126115. _getSharedGizmoLight(): HemisphericLight;
  126116. /**
  126117. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  126118. */
  126119. pickUtilitySceneFirst: boolean;
  126120. /**
  126121. * 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)
  126122. */
  126123. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  126124. /**
  126125. * 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)
  126126. */
  126127. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  126128. /**
  126129. * The scene that is rendered on top of the original scene
  126130. */
  126131. utilityLayerScene: Scene;
  126132. /**
  126133. * If the utility layer should automatically be rendered on top of existing scene
  126134. */
  126135. shouldRender: boolean;
  126136. /**
  126137. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  126138. */
  126139. onlyCheckPointerDownEvents: boolean;
  126140. /**
  126141. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  126142. */
  126143. processAllEvents: boolean;
  126144. /**
  126145. * Observable raised when the pointer move from the utility layer scene to the main scene
  126146. */
  126147. onPointerOutObservable: Observable<number>;
  126148. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  126149. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  126150. private _afterRenderObserver;
  126151. private _sceneDisposeObserver;
  126152. private _originalPointerObserver;
  126153. /**
  126154. * Instantiates a UtilityLayerRenderer
  126155. * @param originalScene the original scene that will be rendered on top of
  126156. * @param handleEvents boolean indicating if the utility layer should handle events
  126157. */
  126158. constructor(
  126159. /** the original scene that will be rendered on top of */
  126160. originalScene: Scene, handleEvents?: boolean);
  126161. private _notifyObservers;
  126162. /**
  126163. * Renders the utility layers scene on top of the original scene
  126164. */
  126165. render(): void;
  126166. /**
  126167. * Disposes of the renderer
  126168. */
  126169. dispose(): void;
  126170. private _updateCamera;
  126171. }
  126172. }
  126173. declare module BABYLON {
  126174. /**
  126175. * Options interface for the pointer selection module
  126176. */
  126177. export interface IWebXRControllerPointerSelectionOptions {
  126178. /**
  126179. * if provided, this scene will be used to render meshes.
  126180. */
  126181. customUtilityLayerScene?: Scene;
  126182. /**
  126183. * 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)
  126184. * If not disabled, the last picked point will be used to execute a pointer up event
  126185. * If disabled, pointer up event will be triggered right after the pointer down event.
  126186. * Used in screen and gaze target ray mode only
  126187. */
  126188. disablePointerUpOnTouchOut: boolean;
  126189. /**
  126190. * For gaze mode (time to select instead of press)
  126191. */
  126192. forceGazeMode: boolean;
  126193. /**
  126194. * 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
  126195. * to start a new countdown to the pointer down event.
  126196. * Defaults to 1.
  126197. */
  126198. gazeModePointerMovedFactor?: number;
  126199. /**
  126200. * Different button type to use instead of the main component
  126201. */
  126202. overrideButtonId?: string;
  126203. /**
  126204. * use this rendering group id for the meshes (optional)
  126205. */
  126206. renderingGroupId?: number;
  126207. /**
  126208. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  126209. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  126210. * 3000 means 3 seconds between pointing at something and selecting it
  126211. */
  126212. timeToSelect?: number;
  126213. /**
  126214. * Should meshes created here be added to a utility layer or the main scene
  126215. */
  126216. useUtilityLayer?: boolean;
  126217. /**
  126218. * the xr input to use with this pointer selection
  126219. */
  126220. xrInput: WebXRInput;
  126221. }
  126222. /**
  126223. * A module that will enable pointer selection for motion controllers of XR Input Sources
  126224. */
  126225. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  126226. private readonly _options;
  126227. private static _idCounter;
  126228. private _attachController;
  126229. private _controllers;
  126230. private _scene;
  126231. private _tmpVectorForPickCompare;
  126232. /**
  126233. * The module's name
  126234. */
  126235. static readonly Name: string;
  126236. /**
  126237. * The (Babylon) version of this module.
  126238. * This is an integer representing the implementation version.
  126239. * This number does not correspond to the WebXR specs version
  126240. */
  126241. static readonly Version: number;
  126242. /**
  126243. * Disable lighting on the laser pointer (so it will always be visible)
  126244. */
  126245. disablePointerLighting: boolean;
  126246. /**
  126247. * Disable lighting on the selection mesh (so it will always be visible)
  126248. */
  126249. disableSelectionMeshLighting: boolean;
  126250. /**
  126251. * Should the laser pointer be displayed
  126252. */
  126253. displayLaserPointer: boolean;
  126254. /**
  126255. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  126256. */
  126257. displaySelectionMesh: boolean;
  126258. /**
  126259. * This color will be set to the laser pointer when selection is triggered
  126260. */
  126261. laserPointerPickedColor: Color3;
  126262. /**
  126263. * Default color of the laser pointer
  126264. */
  126265. laserPointerDefaultColor: Color3;
  126266. /**
  126267. * default color of the selection ring
  126268. */
  126269. selectionMeshDefaultColor: Color3;
  126270. /**
  126271. * This color will be applied to the selection ring when selection is triggered
  126272. */
  126273. selectionMeshPickedColor: Color3;
  126274. /**
  126275. * Optional filter to be used for ray selection. This predicate shares behavior with
  126276. * scene.pointerMovePredicate which takes priority if it is also assigned.
  126277. */
  126278. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  126279. /**
  126280. * constructs a new background remover module
  126281. * @param _xrSessionManager the session manager for this module
  126282. * @param _options read-only options to be used in this module
  126283. */
  126284. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  126285. /**
  126286. * attach this feature
  126287. * Will usually be called by the features manager
  126288. *
  126289. * @returns true if successful.
  126290. */
  126291. attach(): boolean;
  126292. /**
  126293. * detach this feature.
  126294. * Will usually be called by the features manager
  126295. *
  126296. * @returns true if successful.
  126297. */
  126298. detach(): boolean;
  126299. /**
  126300. * Will get the mesh under a specific pointer.
  126301. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  126302. * @param controllerId the controllerId to check
  126303. * @returns The mesh under pointer or null if no mesh is under the pointer
  126304. */
  126305. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  126306. /**
  126307. * Get the xr controller that correlates to the pointer id in the pointer event
  126308. *
  126309. * @param id the pointer id to search for
  126310. * @returns the controller that correlates to this id or null if not found
  126311. */
  126312. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  126313. protected _onXRFrame(_xrFrame: XRFrame): void;
  126314. private _attachGazeMode;
  126315. private _attachScreenRayMode;
  126316. private _attachTrackedPointerRayMode;
  126317. private _convertNormalToDirectionOfRay;
  126318. private _detachController;
  126319. private _generateNewMeshPair;
  126320. private _pickingMoved;
  126321. private _updatePointerDistance;
  126322. /** @hidden */
  126323. get lasterPointerDefaultColor(): Color3;
  126324. }
  126325. }
  126326. declare module BABYLON {
  126327. /**
  126328. * Button which can be used to enter a different mode of XR
  126329. */
  126330. export class WebXREnterExitUIButton {
  126331. /** button element */
  126332. element: HTMLElement;
  126333. /** XR initialization options for the button */
  126334. sessionMode: XRSessionMode;
  126335. /** Reference space type */
  126336. referenceSpaceType: XRReferenceSpaceType;
  126337. /**
  126338. * Creates a WebXREnterExitUIButton
  126339. * @param element button element
  126340. * @param sessionMode XR initialization session mode
  126341. * @param referenceSpaceType the type of reference space to be used
  126342. */
  126343. constructor(
  126344. /** button element */
  126345. element: HTMLElement,
  126346. /** XR initialization options for the button */
  126347. sessionMode: XRSessionMode,
  126348. /** Reference space type */
  126349. referenceSpaceType: XRReferenceSpaceType);
  126350. /**
  126351. * Extendable function which can be used to update the button's visuals when the state changes
  126352. * @param activeButton the current active button in the UI
  126353. */
  126354. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  126355. }
  126356. /**
  126357. * Options to create the webXR UI
  126358. */
  126359. export class WebXREnterExitUIOptions {
  126360. /**
  126361. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  126362. */
  126363. customButtons?: Array<WebXREnterExitUIButton>;
  126364. /**
  126365. * A reference space type to use when creating the default button.
  126366. * Default is local-floor
  126367. */
  126368. referenceSpaceType?: XRReferenceSpaceType;
  126369. /**
  126370. * Context to enter xr with
  126371. */
  126372. renderTarget?: Nullable<WebXRRenderTarget>;
  126373. /**
  126374. * A session mode to use when creating the default button.
  126375. * Default is immersive-vr
  126376. */
  126377. sessionMode?: XRSessionMode;
  126378. /**
  126379. * A list of optional features to init the session with
  126380. */
  126381. optionalFeatures?: string[];
  126382. }
  126383. /**
  126384. * UI to allow the user to enter/exit XR mode
  126385. */
  126386. export class WebXREnterExitUI implements IDisposable {
  126387. private scene;
  126388. /** version of the options passed to this UI */
  126389. options: WebXREnterExitUIOptions;
  126390. private _activeButton;
  126391. private _buttons;
  126392. private _overlay;
  126393. /**
  126394. * Fired every time the active button is changed.
  126395. *
  126396. * When xr is entered via a button that launches xr that button will be the callback parameter
  126397. *
  126398. * When exiting xr the callback parameter will be null)
  126399. */
  126400. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  126401. /**
  126402. *
  126403. * @param scene babylon scene object to use
  126404. * @param options (read-only) version of the options passed to this UI
  126405. */
  126406. private constructor();
  126407. /**
  126408. * Creates UI to allow the user to enter/exit XR mode
  126409. * @param scene the scene to add the ui to
  126410. * @param helper the xr experience helper to enter/exit xr with
  126411. * @param options options to configure the UI
  126412. * @returns the created ui
  126413. */
  126414. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  126415. /**
  126416. * Disposes of the XR UI component
  126417. */
  126418. dispose(): void;
  126419. private _updateButtons;
  126420. }
  126421. }
  126422. declare module BABYLON {
  126423. /**
  126424. * Class containing static functions to help procedurally build meshes
  126425. */
  126426. export class LinesBuilder {
  126427. /**
  126428. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  126429. * * 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
  126430. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  126431. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  126432. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  126433. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  126434. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126435. * * 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
  126436. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  126437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126438. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  126439. * @param name defines the name of the new line system
  126440. * @param options defines the options used to create the line system
  126441. * @param scene defines the hosting scene
  126442. * @returns a new line system mesh
  126443. */
  126444. static CreateLineSystem(name: string, options: {
  126445. lines: Vector3[][];
  126446. updatable?: boolean;
  126447. instance?: Nullable<LinesMesh>;
  126448. colors?: Nullable<Color4[][]>;
  126449. useVertexAlpha?: boolean;
  126450. }, scene: Nullable<Scene>): LinesMesh;
  126451. /**
  126452. * Creates a line mesh
  126453. * 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
  126454. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126455. * * The parameter `points` is an array successive Vector3
  126456. * * 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
  126457. * * The optional parameter `colors` is an array of successive Color4, one per line point
  126458. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  126459. * * When updating an instance, remember that only point positions can change, not the number of points
  126460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  126462. * @param name defines the name of the new line system
  126463. * @param options defines the options used to create the line system
  126464. * @param scene defines the hosting scene
  126465. * @returns a new line mesh
  126466. */
  126467. static CreateLines(name: string, options: {
  126468. points: Vector3[];
  126469. updatable?: boolean;
  126470. instance?: Nullable<LinesMesh>;
  126471. colors?: Color4[];
  126472. useVertexAlpha?: boolean;
  126473. }, scene?: Nullable<Scene>): LinesMesh;
  126474. /**
  126475. * Creates a dashed line mesh
  126476. * * 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
  126477. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126478. * * The parameter `points` is an array successive Vector3
  126479. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  126480. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  126481. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  126482. * * 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
  126483. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126484. * * When updating an instance, remember that only point positions can change, not the number of points
  126485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126486. * @param name defines the name of the mesh
  126487. * @param options defines the options used to create the mesh
  126488. * @param scene defines the hosting scene
  126489. * @returns the dashed line mesh
  126490. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  126491. */
  126492. static CreateDashedLines(name: string, options: {
  126493. points: Vector3[];
  126494. dashSize?: number;
  126495. gapSize?: number;
  126496. dashNb?: number;
  126497. updatable?: boolean;
  126498. instance?: LinesMesh;
  126499. useVertexAlpha?: boolean;
  126500. }, scene?: Nullable<Scene>): LinesMesh;
  126501. }
  126502. }
  126503. declare module BABYLON {
  126504. /**
  126505. * Construction options for a timer
  126506. */
  126507. export interface ITimerOptions<T> {
  126508. /**
  126509. * Time-to-end
  126510. */
  126511. timeout: number;
  126512. /**
  126513. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  126514. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  126515. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  126516. */
  126517. contextObservable: Observable<T>;
  126518. /**
  126519. * Optional parameters when adding an observer to the observable
  126520. */
  126521. observableParameters?: {
  126522. mask?: number;
  126523. insertFirst?: boolean;
  126524. scope?: any;
  126525. };
  126526. /**
  126527. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  126528. */
  126529. breakCondition?: (data?: ITimerData<T>) => boolean;
  126530. /**
  126531. * Will be triggered when the time condition has met
  126532. */
  126533. onEnded?: (data: ITimerData<any>) => void;
  126534. /**
  126535. * Will be triggered when the break condition has met (prematurely ended)
  126536. */
  126537. onAborted?: (data: ITimerData<any>) => void;
  126538. /**
  126539. * Optional function to execute on each tick (or count)
  126540. */
  126541. onTick?: (data: ITimerData<any>) => void;
  126542. }
  126543. /**
  126544. * An interface defining the data sent by the timer
  126545. */
  126546. export interface ITimerData<T> {
  126547. /**
  126548. * When did it start
  126549. */
  126550. startTime: number;
  126551. /**
  126552. * Time now
  126553. */
  126554. currentTime: number;
  126555. /**
  126556. * Time passed since started
  126557. */
  126558. deltaTime: number;
  126559. /**
  126560. * How much is completed, in [0.0...1.0].
  126561. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  126562. */
  126563. completeRate: number;
  126564. /**
  126565. * What the registered observable sent in the last count
  126566. */
  126567. payload: T;
  126568. }
  126569. /**
  126570. * The current state of the timer
  126571. */
  126572. export enum TimerState {
  126573. /**
  126574. * Timer initialized, not yet started
  126575. */
  126576. INIT = 0,
  126577. /**
  126578. * Timer started and counting
  126579. */
  126580. STARTED = 1,
  126581. /**
  126582. * Timer ended (whether aborted or time reached)
  126583. */
  126584. ENDED = 2
  126585. }
  126586. /**
  126587. * A simple version of the timer. Will take options and start the timer immediately after calling it
  126588. *
  126589. * @param options options with which to initialize this timer
  126590. */
  126591. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  126592. /**
  126593. * An advanced implementation of a timer class
  126594. */
  126595. export class AdvancedTimer<T = any> implements IDisposable {
  126596. /**
  126597. * Will notify each time the timer calculates the remaining time
  126598. */
  126599. onEachCountObservable: Observable<ITimerData<T>>;
  126600. /**
  126601. * Will trigger when the timer was aborted due to the break condition
  126602. */
  126603. onTimerAbortedObservable: Observable<ITimerData<T>>;
  126604. /**
  126605. * Will trigger when the timer ended successfully
  126606. */
  126607. onTimerEndedObservable: Observable<ITimerData<T>>;
  126608. /**
  126609. * Will trigger when the timer state has changed
  126610. */
  126611. onStateChangedObservable: Observable<TimerState>;
  126612. private _observer;
  126613. private _contextObservable;
  126614. private _observableParameters;
  126615. private _startTime;
  126616. private _timer;
  126617. private _state;
  126618. private _breakCondition;
  126619. private _timeToEnd;
  126620. private _breakOnNextTick;
  126621. /**
  126622. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  126623. * @param options construction options for this advanced timer
  126624. */
  126625. constructor(options: ITimerOptions<T>);
  126626. /**
  126627. * set a breaking condition for this timer. Default is to never break during count
  126628. * @param predicate the new break condition. Returns true to break, false otherwise
  126629. */
  126630. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  126631. /**
  126632. * Reset ALL associated observables in this advanced timer
  126633. */
  126634. clearObservables(): void;
  126635. /**
  126636. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  126637. *
  126638. * @param timeToEnd how much time to measure until timer ended
  126639. */
  126640. start(timeToEnd?: number): void;
  126641. /**
  126642. * Will force a stop on the next tick.
  126643. */
  126644. stop(): void;
  126645. /**
  126646. * Dispose this timer, clearing all resources
  126647. */
  126648. dispose(): void;
  126649. private _setState;
  126650. private _tick;
  126651. private _stop;
  126652. }
  126653. }
  126654. declare module BABYLON {
  126655. /**
  126656. * The options container for the teleportation module
  126657. */
  126658. export interface IWebXRTeleportationOptions {
  126659. /**
  126660. * if provided, this scene will be used to render meshes.
  126661. */
  126662. customUtilityLayerScene?: Scene;
  126663. /**
  126664. * Values to configure the default target mesh
  126665. */
  126666. defaultTargetMeshOptions?: {
  126667. /**
  126668. * Fill color of the teleportation area
  126669. */
  126670. teleportationFillColor?: string;
  126671. /**
  126672. * Border color for the teleportation area
  126673. */
  126674. teleportationBorderColor?: string;
  126675. /**
  126676. * Disable the mesh's animation sequence
  126677. */
  126678. disableAnimation?: boolean;
  126679. /**
  126680. * Disable lighting on the material or the ring and arrow
  126681. */
  126682. disableLighting?: boolean;
  126683. /**
  126684. * Override the default material of the torus and arrow
  126685. */
  126686. torusArrowMaterial?: Material;
  126687. };
  126688. /**
  126689. * A list of meshes to use as floor meshes.
  126690. * Meshes can be added and removed after initializing the feature using the
  126691. * addFloorMesh and removeFloorMesh functions
  126692. * If empty, rotation will still work
  126693. */
  126694. floorMeshes?: AbstractMesh[];
  126695. /**
  126696. * use this rendering group id for the meshes (optional)
  126697. */
  126698. renderingGroupId?: number;
  126699. /**
  126700. * Should teleportation move only to snap points
  126701. */
  126702. snapPointsOnly?: boolean;
  126703. /**
  126704. * An array of points to which the teleportation will snap to.
  126705. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  126706. */
  126707. snapPositions?: Vector3[];
  126708. /**
  126709. * How close should the teleportation ray be in order to snap to position.
  126710. * Default to 0.8 units (meters)
  126711. */
  126712. snapToPositionRadius?: number;
  126713. /**
  126714. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  126715. * If you want to support rotation, make sure your mesh has a direction indicator.
  126716. *
  126717. * When left untouched, the default mesh will be initialized.
  126718. */
  126719. teleportationTargetMesh?: AbstractMesh;
  126720. /**
  126721. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  126722. */
  126723. timeToTeleport?: number;
  126724. /**
  126725. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  126726. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  126727. */
  126728. useMainComponentOnly?: boolean;
  126729. /**
  126730. * Should meshes created here be added to a utility layer or the main scene
  126731. */
  126732. useUtilityLayer?: boolean;
  126733. /**
  126734. * Babylon XR Input class for controller
  126735. */
  126736. xrInput: WebXRInput;
  126737. }
  126738. /**
  126739. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  126740. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  126741. * the input of the attached controllers.
  126742. */
  126743. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  126744. private _options;
  126745. private _controllers;
  126746. private _currentTeleportationControllerId;
  126747. private _floorMeshes;
  126748. private _quadraticBezierCurve;
  126749. private _selectionFeature;
  126750. private _snapToPositions;
  126751. private _snappedToPoint;
  126752. private _teleportationRingMaterial?;
  126753. private _tmpRay;
  126754. private _tmpVector;
  126755. /**
  126756. * The module's name
  126757. */
  126758. static readonly Name: string;
  126759. /**
  126760. * The (Babylon) version of this module.
  126761. * This is an integer representing the implementation version.
  126762. * This number does not correspond to the webxr specs version
  126763. */
  126764. static readonly Version: number;
  126765. /**
  126766. * Is movement backwards enabled
  126767. */
  126768. backwardsMovementEnabled: boolean;
  126769. /**
  126770. * Distance to travel when moving backwards
  126771. */
  126772. backwardsTeleportationDistance: number;
  126773. /**
  126774. * The distance from the user to the inspection point in the direction of the controller
  126775. * A higher number will allow the user to move further
  126776. * defaults to 5 (meters, in xr units)
  126777. */
  126778. parabolicCheckRadius: number;
  126779. /**
  126780. * Should the module support parabolic ray on top of direct ray
  126781. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  126782. * Very helpful when moving between floors / different heights
  126783. */
  126784. parabolicRayEnabled: boolean;
  126785. /**
  126786. * How much rotation should be applied when rotating right and left
  126787. */
  126788. rotationAngle: number;
  126789. /**
  126790. * Is rotation enabled when moving forward?
  126791. * Disabling this feature will prevent the user from deciding the direction when teleporting
  126792. */
  126793. rotationEnabled: boolean;
  126794. /**
  126795. * constructs a new anchor system
  126796. * @param _xrSessionManager an instance of WebXRSessionManager
  126797. * @param _options configuration object for this feature
  126798. */
  126799. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  126800. /**
  126801. * Get the snapPointsOnly flag
  126802. */
  126803. get snapPointsOnly(): boolean;
  126804. /**
  126805. * Sets the snapPointsOnly flag
  126806. * @param snapToPoints should teleportation be exclusively to snap points
  126807. */
  126808. set snapPointsOnly(snapToPoints: boolean);
  126809. /**
  126810. * Add a new mesh to the floor meshes array
  126811. * @param mesh the mesh to use as floor mesh
  126812. */
  126813. addFloorMesh(mesh: AbstractMesh): void;
  126814. /**
  126815. * Add a new snap-to point to fix teleportation to this position
  126816. * @param newSnapPoint The new Snap-To point
  126817. */
  126818. addSnapPoint(newSnapPoint: Vector3): void;
  126819. attach(): boolean;
  126820. detach(): boolean;
  126821. dispose(): void;
  126822. /**
  126823. * Remove a mesh from the floor meshes array
  126824. * @param mesh the mesh to remove
  126825. */
  126826. removeFloorMesh(mesh: AbstractMesh): void;
  126827. /**
  126828. * Remove a mesh from the floor meshes array using its name
  126829. * @param name the mesh name to remove
  126830. */
  126831. removeFloorMeshByName(name: string): void;
  126832. /**
  126833. * 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
  126834. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  126835. * @returns was the point found and removed or not
  126836. */
  126837. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  126838. /**
  126839. * This function sets a selection feature that will be disabled when
  126840. * the forward ray is shown and will be reattached when hidden.
  126841. * This is used to remove the selection rays when moving.
  126842. * @param selectionFeature the feature to disable when forward movement is enabled
  126843. */
  126844. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  126845. protected _onXRFrame(_xrFrame: XRFrame): void;
  126846. private _attachController;
  126847. private _createDefaultTargetMesh;
  126848. private _detachController;
  126849. private _findClosestSnapPointWithRadius;
  126850. private _setTargetMeshPosition;
  126851. private _setTargetMeshVisibility;
  126852. private _showParabolicPath;
  126853. private _teleportForward;
  126854. }
  126855. }
  126856. declare module BABYLON {
  126857. /**
  126858. * Options for the default xr helper
  126859. */
  126860. export class WebXRDefaultExperienceOptions {
  126861. /**
  126862. * Enable or disable default UI to enter XR
  126863. */
  126864. disableDefaultUI?: boolean;
  126865. /**
  126866. * Should teleportation not initialize. defaults to false.
  126867. */
  126868. disableTeleportation?: boolean;
  126869. /**
  126870. * Floor meshes that will be used for teleport
  126871. */
  126872. floorMeshes?: Array<AbstractMesh>;
  126873. /**
  126874. * If set to true, the first frame will not be used to reset position
  126875. * The first frame is mainly used when copying transformation from the old camera
  126876. * Mainly used in AR
  126877. */
  126878. ignoreNativeCameraTransformation?: boolean;
  126879. /**
  126880. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  126881. */
  126882. inputOptions?: IWebXRInputOptions;
  126883. /**
  126884. * optional configuration for the output canvas
  126885. */
  126886. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  126887. /**
  126888. * optional UI options. This can be used among other to change session mode and reference space type
  126889. */
  126890. uiOptions?: WebXREnterExitUIOptions;
  126891. /**
  126892. * When loading teleportation and pointer select, use stable versions instead of latest.
  126893. */
  126894. useStablePlugins?: boolean;
  126895. /**
  126896. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  126897. */
  126898. renderingGroupId?: number;
  126899. /**
  126900. * A list of optional features to init the session with
  126901. * If set to true, all features we support will be added
  126902. */
  126903. optionalFeatures?: boolean | string[];
  126904. }
  126905. /**
  126906. * Default experience which provides a similar setup to the previous webVRExperience
  126907. */
  126908. export class WebXRDefaultExperience {
  126909. /**
  126910. * Base experience
  126911. */
  126912. baseExperience: WebXRExperienceHelper;
  126913. /**
  126914. * Enables ui for entering/exiting xr
  126915. */
  126916. enterExitUI: WebXREnterExitUI;
  126917. /**
  126918. * Input experience extension
  126919. */
  126920. input: WebXRInput;
  126921. /**
  126922. * Enables laser pointer and selection
  126923. */
  126924. pointerSelection: WebXRControllerPointerSelection;
  126925. /**
  126926. * Default target xr should render to
  126927. */
  126928. renderTarget: WebXRRenderTarget;
  126929. /**
  126930. * Enables teleportation
  126931. */
  126932. teleportation: WebXRMotionControllerTeleportation;
  126933. private constructor();
  126934. /**
  126935. * Creates the default xr experience
  126936. * @param scene scene
  126937. * @param options options for basic configuration
  126938. * @returns resulting WebXRDefaultExperience
  126939. */
  126940. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  126941. /**
  126942. * DIsposes of the experience helper
  126943. */
  126944. dispose(): void;
  126945. }
  126946. }
  126947. declare module BABYLON {
  126948. /**
  126949. * Options to modify the vr teleportation behavior.
  126950. */
  126951. export interface VRTeleportationOptions {
  126952. /**
  126953. * The name of the mesh which should be used as the teleportation floor. (default: null)
  126954. */
  126955. floorMeshName?: string;
  126956. /**
  126957. * A list of meshes to be used as the teleportation floor. (default: empty)
  126958. */
  126959. floorMeshes?: Mesh[];
  126960. /**
  126961. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  126962. */
  126963. teleportationMode?: number;
  126964. /**
  126965. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  126966. */
  126967. teleportationTime?: number;
  126968. /**
  126969. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  126970. */
  126971. teleportationSpeed?: number;
  126972. /**
  126973. * The easing function used in the animation or null for Linear. (default CircleEase)
  126974. */
  126975. easingFunction?: EasingFunction;
  126976. }
  126977. /**
  126978. * Options to modify the vr experience helper's behavior.
  126979. */
  126980. export interface VRExperienceHelperOptions extends WebVROptions {
  126981. /**
  126982. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  126983. */
  126984. createDeviceOrientationCamera?: boolean;
  126985. /**
  126986. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  126987. */
  126988. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  126989. /**
  126990. * Uses the main button on the controller to toggle the laser casted. (default: true)
  126991. */
  126992. laserToggle?: boolean;
  126993. /**
  126994. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  126995. */
  126996. floorMeshes?: Mesh[];
  126997. /**
  126998. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  126999. */
  127000. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  127001. /**
  127002. * Defines if WebXR should be used instead of WebVR (if available)
  127003. */
  127004. useXR?: boolean;
  127005. }
  127006. /**
  127007. * Event containing information after VR has been entered
  127008. */
  127009. export class OnAfterEnteringVRObservableEvent {
  127010. /**
  127011. * If entering vr was successful
  127012. */
  127013. success: boolean;
  127014. }
  127015. /**
  127016. * Helps to quickly add VR support to an existing scene.
  127017. * See https://doc.babylonjs.com/how_to/webvr_helper
  127018. */
  127019. export class VRExperienceHelper {
  127020. /** Options to modify the vr experience helper's behavior. */
  127021. webVROptions: VRExperienceHelperOptions;
  127022. private _scene;
  127023. private _position;
  127024. private _btnVR;
  127025. private _btnVRDisplayed;
  127026. private _webVRsupported;
  127027. private _webVRready;
  127028. private _webVRrequesting;
  127029. private _webVRpresenting;
  127030. private _hasEnteredVR;
  127031. private _fullscreenVRpresenting;
  127032. private _inputElement;
  127033. private _webVRCamera;
  127034. private _vrDeviceOrientationCamera;
  127035. private _deviceOrientationCamera;
  127036. private _existingCamera;
  127037. private _onKeyDown;
  127038. private _onVrDisplayPresentChange;
  127039. private _onVRDisplayChanged;
  127040. private _onVRRequestPresentStart;
  127041. private _onVRRequestPresentComplete;
  127042. /**
  127043. * 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)
  127044. */
  127045. enableGazeEvenWhenNoPointerLock: boolean;
  127046. /**
  127047. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  127048. */
  127049. exitVROnDoubleTap: boolean;
  127050. /**
  127051. * Observable raised right before entering VR.
  127052. */
  127053. onEnteringVRObservable: Observable<VRExperienceHelper>;
  127054. /**
  127055. * Observable raised when entering VR has completed.
  127056. */
  127057. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  127058. /**
  127059. * Observable raised when exiting VR.
  127060. */
  127061. onExitingVRObservable: Observable<VRExperienceHelper>;
  127062. /**
  127063. * Observable raised when controller mesh is loaded.
  127064. */
  127065. onControllerMeshLoadedObservable: Observable<WebVRController>;
  127066. /** Return this.onEnteringVRObservable
  127067. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  127068. */
  127069. get onEnteringVR(): Observable<VRExperienceHelper>;
  127070. /** Return this.onExitingVRObservable
  127071. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  127072. */
  127073. get onExitingVR(): Observable<VRExperienceHelper>;
  127074. /** Return this.onControllerMeshLoadedObservable
  127075. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  127076. */
  127077. get onControllerMeshLoaded(): Observable<WebVRController>;
  127078. private _rayLength;
  127079. private _useCustomVRButton;
  127080. private _teleportationRequested;
  127081. private _teleportActive;
  127082. private _floorMeshName;
  127083. private _floorMeshesCollection;
  127084. private _teleportationMode;
  127085. private _teleportationTime;
  127086. private _teleportationSpeed;
  127087. private _teleportationEasing;
  127088. private _rotationAllowed;
  127089. private _teleportBackwardsVector;
  127090. private _teleportationTarget;
  127091. private _isDefaultTeleportationTarget;
  127092. private _postProcessMove;
  127093. private _teleportationFillColor;
  127094. private _teleportationBorderColor;
  127095. private _rotationAngle;
  127096. private _haloCenter;
  127097. private _cameraGazer;
  127098. private _padSensibilityUp;
  127099. private _padSensibilityDown;
  127100. private _leftController;
  127101. private _rightController;
  127102. private _gazeColor;
  127103. private _laserColor;
  127104. private _pickedLaserColor;
  127105. private _pickedGazeColor;
  127106. /**
  127107. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  127108. */
  127109. onNewMeshSelected: Observable<AbstractMesh>;
  127110. /**
  127111. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  127112. * This observable will provide the mesh and the controller used to select the mesh
  127113. */
  127114. onMeshSelectedWithController: Observable<{
  127115. mesh: AbstractMesh;
  127116. controller: WebVRController;
  127117. }>;
  127118. /**
  127119. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  127120. */
  127121. onNewMeshPicked: Observable<PickingInfo>;
  127122. private _circleEase;
  127123. /**
  127124. * Observable raised before camera teleportation
  127125. */
  127126. onBeforeCameraTeleport: Observable<Vector3>;
  127127. /**
  127128. * Observable raised after camera teleportation
  127129. */
  127130. onAfterCameraTeleport: Observable<Vector3>;
  127131. /**
  127132. * Observable raised when current selected mesh gets unselected
  127133. */
  127134. onSelectedMeshUnselected: Observable<AbstractMesh>;
  127135. private _raySelectionPredicate;
  127136. /**
  127137. * To be optionaly changed by user to define custom ray selection
  127138. */
  127139. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127140. /**
  127141. * To be optionaly changed by user to define custom selection logic (after ray selection)
  127142. */
  127143. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127144. /**
  127145. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  127146. */
  127147. teleportationEnabled: boolean;
  127148. private _defaultHeight;
  127149. private _teleportationInitialized;
  127150. private _interactionsEnabled;
  127151. private _interactionsRequested;
  127152. private _displayGaze;
  127153. private _displayLaserPointer;
  127154. /**
  127155. * The mesh used to display where the user is going to teleport.
  127156. */
  127157. get teleportationTarget(): Mesh;
  127158. /**
  127159. * Sets the mesh to be used to display where the user is going to teleport.
  127160. */
  127161. set teleportationTarget(value: Mesh);
  127162. /**
  127163. * 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
  127164. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  127165. * See https://doc.babylonjs.com/resources/baking_transformations
  127166. */
  127167. get gazeTrackerMesh(): Mesh;
  127168. set gazeTrackerMesh(value: Mesh);
  127169. /**
  127170. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  127171. */
  127172. updateGazeTrackerScale: boolean;
  127173. /**
  127174. * If the gaze trackers color should be updated when selecting meshes
  127175. */
  127176. updateGazeTrackerColor: boolean;
  127177. /**
  127178. * If the controller laser color should be updated when selecting meshes
  127179. */
  127180. updateControllerLaserColor: boolean;
  127181. /**
  127182. * The gaze tracking mesh corresponding to the left controller
  127183. */
  127184. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  127185. /**
  127186. * The gaze tracking mesh corresponding to the right controller
  127187. */
  127188. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  127189. /**
  127190. * If the ray of the gaze should be displayed.
  127191. */
  127192. get displayGaze(): boolean;
  127193. /**
  127194. * Sets if the ray of the gaze should be displayed.
  127195. */
  127196. set displayGaze(value: boolean);
  127197. /**
  127198. * If the ray of the LaserPointer should be displayed.
  127199. */
  127200. get displayLaserPointer(): boolean;
  127201. /**
  127202. * Sets if the ray of the LaserPointer should be displayed.
  127203. */
  127204. set displayLaserPointer(value: boolean);
  127205. /**
  127206. * The deviceOrientationCamera used as the camera when not in VR.
  127207. */
  127208. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  127209. /**
  127210. * Based on the current WebVR support, returns the current VR camera used.
  127211. */
  127212. get currentVRCamera(): Nullable<Camera>;
  127213. /**
  127214. * The webVRCamera which is used when in VR.
  127215. */
  127216. get webVRCamera(): WebVRFreeCamera;
  127217. /**
  127218. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  127219. */
  127220. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  127221. /**
  127222. * The html button that is used to trigger entering into VR.
  127223. */
  127224. get vrButton(): Nullable<HTMLButtonElement>;
  127225. private get _teleportationRequestInitiated();
  127226. /**
  127227. * Defines whether or not Pointer lock should be requested when switching to
  127228. * full screen.
  127229. */
  127230. requestPointerLockOnFullScreen: boolean;
  127231. /**
  127232. * If asking to force XR, this will be populated with the default xr experience
  127233. */
  127234. xr: WebXRDefaultExperience;
  127235. /**
  127236. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  127237. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  127238. */
  127239. xrTestDone: boolean;
  127240. /**
  127241. * Instantiates a VRExperienceHelper.
  127242. * Helps to quickly add VR support to an existing scene.
  127243. * @param scene The scene the VRExperienceHelper belongs to.
  127244. * @param webVROptions Options to modify the vr experience helper's behavior.
  127245. */
  127246. constructor(scene: Scene,
  127247. /** Options to modify the vr experience helper's behavior. */
  127248. webVROptions?: VRExperienceHelperOptions);
  127249. private completeVRInit;
  127250. private _onDefaultMeshLoaded;
  127251. private _onResize;
  127252. private _onFullscreenChange;
  127253. /**
  127254. * Gets a value indicating if we are currently in VR mode.
  127255. */
  127256. get isInVRMode(): boolean;
  127257. private onVrDisplayPresentChange;
  127258. private onVRDisplayChanged;
  127259. private moveButtonToBottomRight;
  127260. private displayVRButton;
  127261. private updateButtonVisibility;
  127262. private _cachedAngularSensibility;
  127263. /**
  127264. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  127265. * Otherwise, will use the fullscreen API.
  127266. */
  127267. enterVR(): void;
  127268. /**
  127269. * Attempt to exit VR, or fullscreen.
  127270. */
  127271. exitVR(): void;
  127272. /**
  127273. * The position of the vr experience helper.
  127274. */
  127275. get position(): Vector3;
  127276. /**
  127277. * Sets the position of the vr experience helper.
  127278. */
  127279. set position(value: Vector3);
  127280. /**
  127281. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  127282. */
  127283. enableInteractions(): void;
  127284. private get _noControllerIsActive();
  127285. private beforeRender;
  127286. private _isTeleportationFloor;
  127287. /**
  127288. * Adds a floor mesh to be used for teleportation.
  127289. * @param floorMesh the mesh to be used for teleportation.
  127290. */
  127291. addFloorMesh(floorMesh: Mesh): void;
  127292. /**
  127293. * Removes a floor mesh from being used for teleportation.
  127294. * @param floorMesh the mesh to be removed.
  127295. */
  127296. removeFloorMesh(floorMesh: Mesh): void;
  127297. /**
  127298. * Enables interactions and teleportation using the VR controllers and gaze.
  127299. * @param vrTeleportationOptions options to modify teleportation behavior.
  127300. */
  127301. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  127302. private _onNewGamepadConnected;
  127303. private _tryEnableInteractionOnController;
  127304. private _onNewGamepadDisconnected;
  127305. private _enableInteractionOnController;
  127306. private _checkTeleportWithRay;
  127307. private _checkRotate;
  127308. private _checkTeleportBackwards;
  127309. private _enableTeleportationOnController;
  127310. private _createTeleportationCircles;
  127311. private _displayTeleportationTarget;
  127312. private _hideTeleportationTarget;
  127313. private _rotateCamera;
  127314. private _moveTeleportationSelectorTo;
  127315. private _workingVector;
  127316. private _workingQuaternion;
  127317. private _workingMatrix;
  127318. /**
  127319. * Time Constant Teleportation Mode
  127320. */
  127321. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  127322. /**
  127323. * Speed Constant Teleportation Mode
  127324. */
  127325. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  127326. /**
  127327. * Teleports the users feet to the desired location
  127328. * @param location The location where the user's feet should be placed
  127329. */
  127330. teleportCamera(location: Vector3): void;
  127331. private _convertNormalToDirectionOfRay;
  127332. private _castRayAndSelectObject;
  127333. private _notifySelectedMeshUnselected;
  127334. /**
  127335. * Permanently set new colors for the laser pointer
  127336. * @param color the new laser color
  127337. * @param pickedColor the new laser color when picked mesh detected
  127338. */
  127339. setLaserColor(color: Color3, pickedColor?: Color3): void;
  127340. /**
  127341. * Set lighting enabled / disabled on the laser pointer of both controllers
  127342. * @param enabled should the lighting be enabled on the laser pointer
  127343. */
  127344. setLaserLightingState(enabled?: boolean): void;
  127345. /**
  127346. * Permanently set new colors for the gaze pointer
  127347. * @param color the new gaze color
  127348. * @param pickedColor the new gaze color when picked mesh detected
  127349. */
  127350. setGazeColor(color: Color3, pickedColor?: Color3): void;
  127351. /**
  127352. * Sets the color of the laser ray from the vr controllers.
  127353. * @param color new color for the ray.
  127354. */
  127355. changeLaserColor(color: Color3): void;
  127356. /**
  127357. * Sets the color of the ray from the vr headsets gaze.
  127358. * @param color new color for the ray.
  127359. */
  127360. changeGazeColor(color: Color3): void;
  127361. /**
  127362. * Exits VR and disposes of the vr experience helper
  127363. */
  127364. dispose(): void;
  127365. /**
  127366. * Gets the name of the VRExperienceHelper class
  127367. * @returns "VRExperienceHelper"
  127368. */
  127369. getClassName(): string;
  127370. }
  127371. }
  127372. declare module BABYLON {
  127373. /**
  127374. * Contains an array of blocks representing the octree
  127375. */
  127376. export interface IOctreeContainer<T> {
  127377. /**
  127378. * Blocks within the octree
  127379. */
  127380. blocks: Array<OctreeBlock<T>>;
  127381. }
  127382. /**
  127383. * Class used to store a cell in an octree
  127384. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127385. */
  127386. export class OctreeBlock<T> {
  127387. /**
  127388. * Gets the content of the current block
  127389. */
  127390. entries: T[];
  127391. /**
  127392. * Gets the list of block children
  127393. */
  127394. blocks: Array<OctreeBlock<T>>;
  127395. private _depth;
  127396. private _maxDepth;
  127397. private _capacity;
  127398. private _minPoint;
  127399. private _maxPoint;
  127400. private _boundingVectors;
  127401. private _creationFunc;
  127402. /**
  127403. * Creates a new block
  127404. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  127405. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  127406. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  127407. * @param depth defines the current depth of this block in the octree
  127408. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  127409. * @param creationFunc defines a callback to call when an element is added to the block
  127410. */
  127411. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  127412. /**
  127413. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  127414. */
  127415. get capacity(): number;
  127416. /**
  127417. * Gets the minimum vector (in world space) of the block's bounding box
  127418. */
  127419. get minPoint(): Vector3;
  127420. /**
  127421. * Gets the maximum vector (in world space) of the block's bounding box
  127422. */
  127423. get maxPoint(): Vector3;
  127424. /**
  127425. * Add a new element to this block
  127426. * @param entry defines the element to add
  127427. */
  127428. addEntry(entry: T): void;
  127429. /**
  127430. * Remove an element from this block
  127431. * @param entry defines the element to remove
  127432. */
  127433. removeEntry(entry: T): void;
  127434. /**
  127435. * Add an array of elements to this block
  127436. * @param entries defines the array of elements to add
  127437. */
  127438. addEntries(entries: T[]): void;
  127439. /**
  127440. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  127441. * @param frustumPlanes defines the frustum planes to test
  127442. * @param selection defines the array to store current content if selection is positive
  127443. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127444. */
  127445. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127446. /**
  127447. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  127448. * @param sphereCenter defines the bounding sphere center
  127449. * @param sphereRadius defines the bounding sphere radius
  127450. * @param selection defines the array to store current content if selection is positive
  127451. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127452. */
  127453. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127454. /**
  127455. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  127456. * @param ray defines the ray to test with
  127457. * @param selection defines the array to store current content if selection is positive
  127458. */
  127459. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  127460. /**
  127461. * Subdivide the content into child blocks (this block will then be empty)
  127462. */
  127463. createInnerBlocks(): void;
  127464. /**
  127465. * @hidden
  127466. */
  127467. 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;
  127468. }
  127469. }
  127470. declare module BABYLON {
  127471. /**
  127472. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  127473. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127474. */
  127475. export class Octree<T> {
  127476. /** 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.) */
  127477. maxDepth: number;
  127478. /**
  127479. * Blocks within the octree containing objects
  127480. */
  127481. blocks: Array<OctreeBlock<T>>;
  127482. /**
  127483. * Content stored in the octree
  127484. */
  127485. dynamicContent: T[];
  127486. private _maxBlockCapacity;
  127487. private _selectionContent;
  127488. private _creationFunc;
  127489. /**
  127490. * Creates a octree
  127491. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127492. * @param creationFunc function to be used to instatiate the octree
  127493. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  127494. * @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.)
  127495. */
  127496. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  127497. /** 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.) */
  127498. maxDepth?: number);
  127499. /**
  127500. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  127501. * @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);
  127502. * @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);
  127503. * @param entries meshes to be added to the octree blocks
  127504. */
  127505. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  127506. /**
  127507. * Adds a mesh to the octree
  127508. * @param entry Mesh to add to the octree
  127509. */
  127510. addMesh(entry: T): void;
  127511. /**
  127512. * Remove an element from the octree
  127513. * @param entry defines the element to remove
  127514. */
  127515. removeMesh(entry: T): void;
  127516. /**
  127517. * Selects an array of meshes within the frustum
  127518. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  127519. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  127520. * @returns array of meshes within the frustum
  127521. */
  127522. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  127523. /**
  127524. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  127525. * @param sphereCenter defines the bounding sphere center
  127526. * @param sphereRadius defines the bounding sphere radius
  127527. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127528. * @returns an array of objects that intersect the sphere
  127529. */
  127530. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  127531. /**
  127532. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  127533. * @param ray defines the ray to test with
  127534. * @returns array of intersected objects
  127535. */
  127536. intersectsRay(ray: Ray): SmartArray<T>;
  127537. /**
  127538. * Adds a mesh into the octree block if it intersects the block
  127539. */
  127540. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  127541. /**
  127542. * Adds a submesh into the octree block if it intersects the block
  127543. */
  127544. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  127545. }
  127546. }
  127547. declare module BABYLON {
  127548. interface Scene {
  127549. /**
  127550. * @hidden
  127551. * Backing Filed
  127552. */
  127553. _selectionOctree: Octree<AbstractMesh>;
  127554. /**
  127555. * Gets the octree used to boost mesh selection (picking)
  127556. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127557. */
  127558. selectionOctree: Octree<AbstractMesh>;
  127559. /**
  127560. * Creates or updates the octree used to boost selection (picking)
  127561. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127562. * @param maxCapacity defines the maximum capacity per leaf
  127563. * @param maxDepth defines the maximum depth of the octree
  127564. * @returns an octree of AbstractMesh
  127565. */
  127566. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  127567. }
  127568. interface AbstractMesh {
  127569. /**
  127570. * @hidden
  127571. * Backing Field
  127572. */
  127573. _submeshesOctree: Octree<SubMesh>;
  127574. /**
  127575. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  127576. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  127577. * @param maxCapacity defines the maximum size of each block (64 by default)
  127578. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  127579. * @returns the new octree
  127580. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  127581. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127582. */
  127583. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  127584. }
  127585. /**
  127586. * Defines the octree scene component responsible to manage any octrees
  127587. * in a given scene.
  127588. */
  127589. export class OctreeSceneComponent {
  127590. /**
  127591. * The component name help to identify the component in the list of scene components.
  127592. */
  127593. readonly name: string;
  127594. /**
  127595. * The scene the component belongs to.
  127596. */
  127597. scene: Scene;
  127598. /**
  127599. * Indicates if the meshes have been checked to make sure they are isEnabled()
  127600. */
  127601. readonly checksIsEnabled: boolean;
  127602. /**
  127603. * Creates a new instance of the component for the given scene
  127604. * @param scene Defines the scene to register the component in
  127605. */
  127606. constructor(scene: Scene);
  127607. /**
  127608. * Registers the component in a given scene
  127609. */
  127610. register(): void;
  127611. /**
  127612. * Return the list of active meshes
  127613. * @returns the list of active meshes
  127614. */
  127615. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  127616. /**
  127617. * Return the list of active sub meshes
  127618. * @param mesh The mesh to get the candidates sub meshes from
  127619. * @returns the list of active sub meshes
  127620. */
  127621. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  127622. private _tempRay;
  127623. /**
  127624. * Return the list of sub meshes intersecting with a given local ray
  127625. * @param mesh defines the mesh to find the submesh for
  127626. * @param localRay defines the ray in local space
  127627. * @returns the list of intersecting sub meshes
  127628. */
  127629. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  127630. /**
  127631. * Return the list of sub meshes colliding with a collider
  127632. * @param mesh defines the mesh to find the submesh for
  127633. * @param collider defines the collider to evaluate the collision against
  127634. * @returns the list of colliding sub meshes
  127635. */
  127636. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  127637. /**
  127638. * Rebuilds the elements related to this component in case of
  127639. * context lost for instance.
  127640. */
  127641. rebuild(): void;
  127642. /**
  127643. * Disposes the component and the associated ressources.
  127644. */
  127645. dispose(): void;
  127646. }
  127647. }
  127648. declare module BABYLON {
  127649. /**
  127650. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  127651. */
  127652. export class Gizmo implements IDisposable {
  127653. /** The utility layer the gizmo will be added to */
  127654. gizmoLayer: UtilityLayerRenderer;
  127655. /**
  127656. * The root mesh of the gizmo
  127657. */
  127658. _rootMesh: Mesh;
  127659. private _attachedMesh;
  127660. /**
  127661. * Ratio for the scale of the gizmo (Default: 1)
  127662. */
  127663. scaleRatio: number;
  127664. /**
  127665. * If a custom mesh has been set (Default: false)
  127666. */
  127667. protected _customMeshSet: boolean;
  127668. /**
  127669. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  127670. * * When set, interactions will be enabled
  127671. */
  127672. get attachedMesh(): Nullable<AbstractMesh>;
  127673. set attachedMesh(value: Nullable<AbstractMesh>);
  127674. /**
  127675. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  127676. * @param mesh The mesh to replace the default mesh of the gizmo
  127677. */
  127678. setCustomMesh(mesh: Mesh): void;
  127679. /**
  127680. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  127681. */
  127682. updateGizmoRotationToMatchAttachedMesh: boolean;
  127683. /**
  127684. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  127685. */
  127686. updateGizmoPositionToMatchAttachedMesh: boolean;
  127687. /**
  127688. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  127689. */
  127690. updateScale: boolean;
  127691. protected _interactionsEnabled: boolean;
  127692. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127693. private _beforeRenderObserver;
  127694. private _tempVector;
  127695. /**
  127696. * Creates a gizmo
  127697. * @param gizmoLayer The utility layer the gizmo will be added to
  127698. */
  127699. constructor(
  127700. /** The utility layer the gizmo will be added to */
  127701. gizmoLayer?: UtilityLayerRenderer);
  127702. /**
  127703. * Updates the gizmo to match the attached mesh's position/rotation
  127704. */
  127705. protected _update(): void;
  127706. /**
  127707. * Disposes of the gizmo
  127708. */
  127709. dispose(): void;
  127710. }
  127711. }
  127712. declare module BABYLON {
  127713. /**
  127714. * Single plane drag gizmo
  127715. */
  127716. export class PlaneDragGizmo extends Gizmo {
  127717. /**
  127718. * Drag behavior responsible for the gizmos dragging interactions
  127719. */
  127720. dragBehavior: PointerDragBehavior;
  127721. private _pointerObserver;
  127722. /**
  127723. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127724. */
  127725. snapDistance: number;
  127726. /**
  127727. * Event that fires each time the gizmo snaps to a new location.
  127728. * * snapDistance is the the change in distance
  127729. */
  127730. onSnapObservable: Observable<{
  127731. snapDistance: number;
  127732. }>;
  127733. private _plane;
  127734. private _coloredMaterial;
  127735. private _hoverMaterial;
  127736. private _isEnabled;
  127737. private _parent;
  127738. /** @hidden */
  127739. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  127740. /** @hidden */
  127741. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127742. /**
  127743. * Creates a PlaneDragGizmo
  127744. * @param gizmoLayer The utility layer the gizmo will be added to
  127745. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  127746. * @param color The color of the gizmo
  127747. */
  127748. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127749. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127750. /**
  127751. * If the gizmo is enabled
  127752. */
  127753. set isEnabled(value: boolean);
  127754. get isEnabled(): boolean;
  127755. /**
  127756. * Disposes of the gizmo
  127757. */
  127758. dispose(): void;
  127759. }
  127760. }
  127761. declare module BABYLON {
  127762. /**
  127763. * Gizmo that enables dragging a mesh along 3 axis
  127764. */
  127765. export class PositionGizmo extends Gizmo {
  127766. /**
  127767. * Internal gizmo used for interactions on the x axis
  127768. */
  127769. xGizmo: AxisDragGizmo;
  127770. /**
  127771. * Internal gizmo used for interactions on the y axis
  127772. */
  127773. yGizmo: AxisDragGizmo;
  127774. /**
  127775. * Internal gizmo used for interactions on the z axis
  127776. */
  127777. zGizmo: AxisDragGizmo;
  127778. /**
  127779. * Internal gizmo used for interactions on the yz plane
  127780. */
  127781. xPlaneGizmo: PlaneDragGizmo;
  127782. /**
  127783. * Internal gizmo used for interactions on the xz plane
  127784. */
  127785. yPlaneGizmo: PlaneDragGizmo;
  127786. /**
  127787. * Internal gizmo used for interactions on the xy plane
  127788. */
  127789. zPlaneGizmo: PlaneDragGizmo;
  127790. /**
  127791. * private variables
  127792. */
  127793. private _meshAttached;
  127794. private _updateGizmoRotationToMatchAttachedMesh;
  127795. private _snapDistance;
  127796. private _scaleRatio;
  127797. /** Fires an event when any of it's sub gizmos are dragged */
  127798. onDragStartObservable: Observable<unknown>;
  127799. /** Fires an event when any of it's sub gizmos are released from dragging */
  127800. onDragEndObservable: Observable<unknown>;
  127801. /**
  127802. * If set to true, planar drag is enabled
  127803. */
  127804. private _planarGizmoEnabled;
  127805. get attachedMesh(): Nullable<AbstractMesh>;
  127806. set attachedMesh(mesh: Nullable<AbstractMesh>);
  127807. /**
  127808. * Creates a PositionGizmo
  127809. * @param gizmoLayer The utility layer the gizmo will be added to
  127810. */
  127811. constructor(gizmoLayer?: UtilityLayerRenderer);
  127812. /**
  127813. * If the planar drag gizmo is enabled
  127814. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  127815. */
  127816. set planarGizmoEnabled(value: boolean);
  127817. get planarGizmoEnabled(): boolean;
  127818. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  127819. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  127820. /**
  127821. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127822. */
  127823. set snapDistance(value: number);
  127824. get snapDistance(): number;
  127825. /**
  127826. * Ratio for the scale of the gizmo (Default: 1)
  127827. */
  127828. set scaleRatio(value: number);
  127829. get scaleRatio(): number;
  127830. /**
  127831. * Disposes of the gizmo
  127832. */
  127833. dispose(): void;
  127834. /**
  127835. * CustomMeshes are not supported by this gizmo
  127836. * @param mesh The mesh to replace the default mesh of the gizmo
  127837. */
  127838. setCustomMesh(mesh: Mesh): void;
  127839. }
  127840. }
  127841. declare module BABYLON {
  127842. /**
  127843. * Single axis drag gizmo
  127844. */
  127845. export class AxisDragGizmo extends Gizmo {
  127846. /**
  127847. * Drag behavior responsible for the gizmos dragging interactions
  127848. */
  127849. dragBehavior: PointerDragBehavior;
  127850. private _pointerObserver;
  127851. /**
  127852. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127853. */
  127854. snapDistance: number;
  127855. /**
  127856. * Event that fires each time the gizmo snaps to a new location.
  127857. * * snapDistance is the the change in distance
  127858. */
  127859. onSnapObservable: Observable<{
  127860. snapDistance: number;
  127861. }>;
  127862. private _isEnabled;
  127863. private _parent;
  127864. private _arrow;
  127865. private _coloredMaterial;
  127866. private _hoverMaterial;
  127867. /** @hidden */
  127868. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  127869. /** @hidden */
  127870. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127871. /**
  127872. * Creates an AxisDragGizmo
  127873. * @param gizmoLayer The utility layer the gizmo will be added to
  127874. * @param dragAxis The axis which the gizmo will be able to drag on
  127875. * @param color The color of the gizmo
  127876. */
  127877. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127878. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127879. /**
  127880. * If the gizmo is enabled
  127881. */
  127882. set isEnabled(value: boolean);
  127883. get isEnabled(): boolean;
  127884. /**
  127885. * Disposes of the gizmo
  127886. */
  127887. dispose(): void;
  127888. }
  127889. }
  127890. declare module BABYLON.Debug {
  127891. /**
  127892. * The Axes viewer will show 3 axes in a specific point in space
  127893. */
  127894. export class AxesViewer {
  127895. private _xAxis;
  127896. private _yAxis;
  127897. private _zAxis;
  127898. private _scaleLinesFactor;
  127899. private _instanced;
  127900. /**
  127901. * Gets the hosting scene
  127902. */
  127903. scene: Scene;
  127904. /**
  127905. * Gets or sets a number used to scale line length
  127906. */
  127907. scaleLines: number;
  127908. /** Gets the node hierarchy used to render x-axis */
  127909. get xAxis(): TransformNode;
  127910. /** Gets the node hierarchy used to render y-axis */
  127911. get yAxis(): TransformNode;
  127912. /** Gets the node hierarchy used to render z-axis */
  127913. get zAxis(): TransformNode;
  127914. /**
  127915. * Creates a new AxesViewer
  127916. * @param scene defines the hosting scene
  127917. * @param scaleLines defines a number used to scale line length (1 by default)
  127918. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  127919. * @param xAxis defines the node hierarchy used to render the x-axis
  127920. * @param yAxis defines the node hierarchy used to render the y-axis
  127921. * @param zAxis defines the node hierarchy used to render the z-axis
  127922. */
  127923. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  127924. /**
  127925. * Force the viewer to update
  127926. * @param position defines the position of the viewer
  127927. * @param xaxis defines the x axis of the viewer
  127928. * @param yaxis defines the y axis of the viewer
  127929. * @param zaxis defines the z axis of the viewer
  127930. */
  127931. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  127932. /**
  127933. * Creates an instance of this axes viewer.
  127934. * @returns a new axes viewer with instanced meshes
  127935. */
  127936. createInstance(): AxesViewer;
  127937. /** Releases resources */
  127938. dispose(): void;
  127939. private static _SetRenderingGroupId;
  127940. }
  127941. }
  127942. declare module BABYLON.Debug {
  127943. /**
  127944. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  127945. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  127946. */
  127947. export class BoneAxesViewer extends AxesViewer {
  127948. /**
  127949. * Gets or sets the target mesh where to display the axes viewer
  127950. */
  127951. mesh: Nullable<Mesh>;
  127952. /**
  127953. * Gets or sets the target bone where to display the axes viewer
  127954. */
  127955. bone: Nullable<Bone>;
  127956. /** Gets current position */
  127957. pos: Vector3;
  127958. /** Gets direction of X axis */
  127959. xaxis: Vector3;
  127960. /** Gets direction of Y axis */
  127961. yaxis: Vector3;
  127962. /** Gets direction of Z axis */
  127963. zaxis: Vector3;
  127964. /**
  127965. * Creates a new BoneAxesViewer
  127966. * @param scene defines the hosting scene
  127967. * @param bone defines the target bone
  127968. * @param mesh defines the target mesh
  127969. * @param scaleLines defines a scaling factor for line length (1 by default)
  127970. */
  127971. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  127972. /**
  127973. * Force the viewer to update
  127974. */
  127975. update(): void;
  127976. /** Releases resources */
  127977. dispose(): void;
  127978. }
  127979. }
  127980. declare module BABYLON {
  127981. /**
  127982. * Interface used to define scene explorer extensibility option
  127983. */
  127984. export interface IExplorerExtensibilityOption {
  127985. /**
  127986. * Define the option label
  127987. */
  127988. label: string;
  127989. /**
  127990. * Defines the action to execute on click
  127991. */
  127992. action: (entity: any) => void;
  127993. }
  127994. /**
  127995. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  127996. */
  127997. export interface IExplorerExtensibilityGroup {
  127998. /**
  127999. * Defines a predicate to test if a given type mut be extended
  128000. */
  128001. predicate: (entity: any) => boolean;
  128002. /**
  128003. * Gets the list of options added to a type
  128004. */
  128005. entries: IExplorerExtensibilityOption[];
  128006. }
  128007. /**
  128008. * Interface used to define the options to use to create the Inspector
  128009. */
  128010. export interface IInspectorOptions {
  128011. /**
  128012. * Display in overlay mode (default: false)
  128013. */
  128014. overlay?: boolean;
  128015. /**
  128016. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  128017. */
  128018. globalRoot?: HTMLElement;
  128019. /**
  128020. * Display the Scene explorer
  128021. */
  128022. showExplorer?: boolean;
  128023. /**
  128024. * Display the property inspector
  128025. */
  128026. showInspector?: boolean;
  128027. /**
  128028. * Display in embed mode (both panes on the right)
  128029. */
  128030. embedMode?: boolean;
  128031. /**
  128032. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  128033. */
  128034. handleResize?: boolean;
  128035. /**
  128036. * Allow the panes to popup (default: true)
  128037. */
  128038. enablePopup?: boolean;
  128039. /**
  128040. * Allow the panes to be closed by users (default: true)
  128041. */
  128042. enableClose?: boolean;
  128043. /**
  128044. * Optional list of extensibility entries
  128045. */
  128046. explorerExtensibility?: IExplorerExtensibilityGroup[];
  128047. /**
  128048. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  128049. */
  128050. inspectorURL?: string;
  128051. /**
  128052. * Optional initial tab (default to DebugLayerTab.Properties)
  128053. */
  128054. initialTab?: DebugLayerTab;
  128055. }
  128056. interface Scene {
  128057. /**
  128058. * @hidden
  128059. * Backing field
  128060. */
  128061. _debugLayer: DebugLayer;
  128062. /**
  128063. * Gets the debug layer (aka Inspector) associated with the scene
  128064. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128065. */
  128066. debugLayer: DebugLayer;
  128067. }
  128068. /**
  128069. * Enum of inspector action tab
  128070. */
  128071. export enum DebugLayerTab {
  128072. /**
  128073. * Properties tag (default)
  128074. */
  128075. Properties = 0,
  128076. /**
  128077. * Debug tab
  128078. */
  128079. Debug = 1,
  128080. /**
  128081. * Statistics tab
  128082. */
  128083. Statistics = 2,
  128084. /**
  128085. * Tools tab
  128086. */
  128087. Tools = 3,
  128088. /**
  128089. * Settings tab
  128090. */
  128091. Settings = 4
  128092. }
  128093. /**
  128094. * The debug layer (aka Inspector) is the go to tool in order to better understand
  128095. * what is happening in your scene
  128096. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128097. */
  128098. export class DebugLayer {
  128099. /**
  128100. * Define the url to get the inspector script from.
  128101. * By default it uses the babylonjs CDN.
  128102. * @ignoreNaming
  128103. */
  128104. static InspectorURL: string;
  128105. private _scene;
  128106. private BJSINSPECTOR;
  128107. private _onPropertyChangedObservable?;
  128108. /**
  128109. * Observable triggered when a property is changed through the inspector.
  128110. */
  128111. get onPropertyChangedObservable(): any;
  128112. /**
  128113. * Instantiates a new debug layer.
  128114. * The debug layer (aka Inspector) is the go to tool in order to better understand
  128115. * what is happening in your scene
  128116. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128117. * @param scene Defines the scene to inspect
  128118. */
  128119. constructor(scene: Scene);
  128120. /** Creates the inspector window. */
  128121. private _createInspector;
  128122. /**
  128123. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  128124. * @param entity defines the entity to select
  128125. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  128126. */
  128127. select(entity: any, lineContainerTitles?: string | string[]): void;
  128128. /** Get the inspector from bundle or global */
  128129. private _getGlobalInspector;
  128130. /**
  128131. * Get if the inspector is visible or not.
  128132. * @returns true if visible otherwise, false
  128133. */
  128134. isVisible(): boolean;
  128135. /**
  128136. * Hide the inspector and close its window.
  128137. */
  128138. hide(): void;
  128139. /**
  128140. * Update the scene in the inspector
  128141. */
  128142. setAsActiveScene(): void;
  128143. /**
  128144. * Launch the debugLayer.
  128145. * @param config Define the configuration of the inspector
  128146. * @return a promise fulfilled when the debug layer is visible
  128147. */
  128148. show(config?: IInspectorOptions): Promise<DebugLayer>;
  128149. }
  128150. }
  128151. declare module BABYLON {
  128152. /**
  128153. * Class containing static functions to help procedurally build meshes
  128154. */
  128155. export class BoxBuilder {
  128156. /**
  128157. * Creates a box mesh
  128158. * * The parameter `size` sets the size (float) of each box side (default 1)
  128159. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  128160. * * 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)
  128161. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  128162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128165. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  128166. * @param name defines the name of the mesh
  128167. * @param options defines the options used to create the mesh
  128168. * @param scene defines the hosting scene
  128169. * @returns the box mesh
  128170. */
  128171. static CreateBox(name: string, options: {
  128172. size?: number;
  128173. width?: number;
  128174. height?: number;
  128175. depth?: number;
  128176. faceUV?: Vector4[];
  128177. faceColors?: Color4[];
  128178. sideOrientation?: number;
  128179. frontUVs?: Vector4;
  128180. backUVs?: Vector4;
  128181. wrap?: boolean;
  128182. topBaseAt?: number;
  128183. bottomBaseAt?: number;
  128184. updatable?: boolean;
  128185. }, scene?: Nullable<Scene>): Mesh;
  128186. }
  128187. }
  128188. declare module BABYLON.Debug {
  128189. /**
  128190. * Used to show the physics impostor around the specific mesh
  128191. */
  128192. export class PhysicsViewer {
  128193. /** @hidden */
  128194. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  128195. /** @hidden */
  128196. protected _meshes: Array<Nullable<AbstractMesh>>;
  128197. /** @hidden */
  128198. protected _scene: Nullable<Scene>;
  128199. /** @hidden */
  128200. protected _numMeshes: number;
  128201. /** @hidden */
  128202. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  128203. private _renderFunction;
  128204. private _utilityLayer;
  128205. private _debugBoxMesh;
  128206. private _debugSphereMesh;
  128207. private _debugCylinderMesh;
  128208. private _debugMaterial;
  128209. private _debugMeshMeshes;
  128210. /**
  128211. * Creates a new PhysicsViewer
  128212. * @param scene defines the hosting scene
  128213. */
  128214. constructor(scene: Scene);
  128215. /** @hidden */
  128216. protected _updateDebugMeshes(): void;
  128217. /**
  128218. * Renders a specified physic impostor
  128219. * @param impostor defines the impostor to render
  128220. * @param targetMesh defines the mesh represented by the impostor
  128221. * @returns the new debug mesh used to render the impostor
  128222. */
  128223. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  128224. /**
  128225. * Hides a specified physic impostor
  128226. * @param impostor defines the impostor to hide
  128227. */
  128228. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  128229. private _getDebugMaterial;
  128230. private _getDebugBoxMesh;
  128231. private _getDebugSphereMesh;
  128232. private _getDebugCylinderMesh;
  128233. private _getDebugMeshMesh;
  128234. private _getDebugMesh;
  128235. /** Releases all resources */
  128236. dispose(): void;
  128237. }
  128238. }
  128239. declare module BABYLON {
  128240. /**
  128241. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  128242. * in order to better appreciate the issue one might have.
  128243. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  128244. */
  128245. export class RayHelper {
  128246. /**
  128247. * Defines the ray we are currently tryin to visualize.
  128248. */
  128249. ray: Nullable<Ray>;
  128250. private _renderPoints;
  128251. private _renderLine;
  128252. private _renderFunction;
  128253. private _scene;
  128254. private _updateToMeshFunction;
  128255. private _attachedToMesh;
  128256. private _meshSpaceDirection;
  128257. private _meshSpaceOrigin;
  128258. /**
  128259. * Helper function to create a colored helper in a scene in one line.
  128260. * @param ray Defines the ray we are currently tryin to visualize
  128261. * @param scene Defines the scene the ray is used in
  128262. * @param color Defines the color we want to see the ray in
  128263. * @returns The newly created ray helper.
  128264. */
  128265. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  128266. /**
  128267. * Instantiate a new ray helper.
  128268. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  128269. * in order to better appreciate the issue one might have.
  128270. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  128271. * @param ray Defines the ray we are currently tryin to visualize
  128272. */
  128273. constructor(ray: Ray);
  128274. /**
  128275. * Shows the ray we are willing to debug.
  128276. * @param scene Defines the scene the ray needs to be rendered in
  128277. * @param color Defines the color the ray needs to be rendered in
  128278. */
  128279. show(scene: Scene, color?: Color3): void;
  128280. /**
  128281. * Hides the ray we are debugging.
  128282. */
  128283. hide(): void;
  128284. private _render;
  128285. /**
  128286. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  128287. * @param mesh Defines the mesh we want the helper attached to
  128288. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  128289. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  128290. * @param length Defines the length of the ray
  128291. */
  128292. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  128293. /**
  128294. * Detach the ray helper from the mesh it has previously been attached to.
  128295. */
  128296. detachFromMesh(): void;
  128297. private _updateToMesh;
  128298. /**
  128299. * Dispose the helper and release its associated resources.
  128300. */
  128301. dispose(): void;
  128302. }
  128303. }
  128304. declare module BABYLON.Debug {
  128305. /**
  128306. * Class used to render a debug view of a given skeleton
  128307. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  128308. */
  128309. export class SkeletonViewer {
  128310. /** defines the skeleton to render */
  128311. skeleton: Skeleton;
  128312. /** defines the mesh attached to the skeleton */
  128313. mesh: AbstractMesh;
  128314. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  128315. autoUpdateBonesMatrices: boolean;
  128316. /** defines the rendering group id to use with the viewer */
  128317. renderingGroupId: number;
  128318. /** Gets or sets the color used to render the skeleton */
  128319. color: Color3;
  128320. private _scene;
  128321. private _debugLines;
  128322. private _debugMesh;
  128323. private _isEnabled;
  128324. private _renderFunction;
  128325. private _utilityLayer;
  128326. /**
  128327. * Returns the mesh used to render the bones
  128328. */
  128329. get debugMesh(): Nullable<LinesMesh>;
  128330. /**
  128331. * Creates a new SkeletonViewer
  128332. * @param skeleton defines the skeleton to render
  128333. * @param mesh defines the mesh attached to the skeleton
  128334. * @param scene defines the hosting scene
  128335. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  128336. * @param renderingGroupId defines the rendering group id to use with the viewer
  128337. */
  128338. constructor(
  128339. /** defines the skeleton to render */
  128340. skeleton: Skeleton,
  128341. /** defines the mesh attached to the skeleton */
  128342. mesh: AbstractMesh, scene: Scene,
  128343. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  128344. autoUpdateBonesMatrices?: boolean,
  128345. /** defines the rendering group id to use with the viewer */
  128346. renderingGroupId?: number);
  128347. /** Gets or sets a boolean indicating if the viewer is enabled */
  128348. set isEnabled(value: boolean);
  128349. get isEnabled(): boolean;
  128350. private _getBonePosition;
  128351. private _getLinesForBonesWithLength;
  128352. private _getLinesForBonesNoLength;
  128353. /** Update the viewer to sync with current skeleton state */
  128354. update(): void;
  128355. /** Release associated resources */
  128356. dispose(): void;
  128357. }
  128358. }
  128359. declare module BABYLON {
  128360. /**
  128361. * Enum for Device Types
  128362. */
  128363. export enum DeviceType {
  128364. /** Generic */
  128365. Generic = 0,
  128366. /** Keyboard */
  128367. Keyboard = 1,
  128368. /** Mouse */
  128369. Mouse = 2,
  128370. /** Touch Pointers */
  128371. Touch = 3,
  128372. /** PS4 Dual Shock */
  128373. DualShock = 4,
  128374. /** Xbox */
  128375. Xbox = 5,
  128376. /** Switch Controller */
  128377. Switch = 6
  128378. }
  128379. /**
  128380. * Enum for All Pointers (Touch/Mouse)
  128381. */
  128382. export enum PointerInput {
  128383. /** Horizontal Axis */
  128384. Horizontal = 0,
  128385. /** Vertical Axis */
  128386. Vertical = 1,
  128387. /** Left Click or Touch */
  128388. LeftClick = 2,
  128389. /** Middle Click */
  128390. MiddleClick = 3,
  128391. /** Right Click */
  128392. RightClick = 4,
  128393. /** Browser Back */
  128394. BrowserBack = 5,
  128395. /** Browser Forward */
  128396. BrowserForward = 6
  128397. }
  128398. /**
  128399. * Enum for Dual Shock Gamepad
  128400. */
  128401. export enum DualShockInput {
  128402. /** Cross */
  128403. Cross = 0,
  128404. /** Circle */
  128405. Circle = 1,
  128406. /** Square */
  128407. Square = 2,
  128408. /** Triangle */
  128409. Triangle = 3,
  128410. /** L1 */
  128411. L1 = 4,
  128412. /** R1 */
  128413. R1 = 5,
  128414. /** L2 */
  128415. L2 = 6,
  128416. /** R2 */
  128417. R2 = 7,
  128418. /** Share */
  128419. Share = 8,
  128420. /** Options */
  128421. Options = 9,
  128422. /** L3 */
  128423. L3 = 10,
  128424. /** R3 */
  128425. R3 = 11,
  128426. /** DPadUp */
  128427. DPadUp = 12,
  128428. /** DPadDown */
  128429. DPadDown = 13,
  128430. /** DPadLeft */
  128431. DPadLeft = 14,
  128432. /** DRight */
  128433. DPadRight = 15,
  128434. /** Home */
  128435. Home = 16,
  128436. /** TouchPad */
  128437. TouchPad = 17,
  128438. /** LStickXAxis */
  128439. LStickXAxis = 18,
  128440. /** LStickYAxis */
  128441. LStickYAxis = 19,
  128442. /** RStickXAxis */
  128443. RStickXAxis = 20,
  128444. /** RStickYAxis */
  128445. RStickYAxis = 21
  128446. }
  128447. /**
  128448. * Enum for Xbox Gamepad
  128449. */
  128450. export enum XboxInput {
  128451. /** A */
  128452. A = 0,
  128453. /** B */
  128454. B = 1,
  128455. /** X */
  128456. X = 2,
  128457. /** Y */
  128458. Y = 3,
  128459. /** LB */
  128460. LB = 4,
  128461. /** RB */
  128462. RB = 5,
  128463. /** LT */
  128464. LT = 6,
  128465. /** RT */
  128466. RT = 7,
  128467. /** Back */
  128468. Back = 8,
  128469. /** Start */
  128470. Start = 9,
  128471. /** LS */
  128472. LS = 10,
  128473. /** RS */
  128474. RS = 11,
  128475. /** DPadUp */
  128476. DPadUp = 12,
  128477. /** DPadDown */
  128478. DPadDown = 13,
  128479. /** DPadLeft */
  128480. DPadLeft = 14,
  128481. /** DRight */
  128482. DPadRight = 15,
  128483. /** Home */
  128484. Home = 16,
  128485. /** LStickXAxis */
  128486. LStickXAxis = 17,
  128487. /** LStickYAxis */
  128488. LStickYAxis = 18,
  128489. /** RStickXAxis */
  128490. RStickXAxis = 19,
  128491. /** RStickYAxis */
  128492. RStickYAxis = 20
  128493. }
  128494. /**
  128495. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  128496. */
  128497. export enum SwitchInput {
  128498. /** B */
  128499. B = 0,
  128500. /** A */
  128501. A = 1,
  128502. /** Y */
  128503. Y = 2,
  128504. /** X */
  128505. X = 3,
  128506. /** L */
  128507. L = 4,
  128508. /** R */
  128509. R = 5,
  128510. /** ZL */
  128511. ZL = 6,
  128512. /** ZR */
  128513. ZR = 7,
  128514. /** Minus */
  128515. Minus = 8,
  128516. /** Plus */
  128517. Plus = 9,
  128518. /** LS */
  128519. LS = 10,
  128520. /** RS */
  128521. RS = 11,
  128522. /** DPadUp */
  128523. DPadUp = 12,
  128524. /** DPadDown */
  128525. DPadDown = 13,
  128526. /** DPadLeft */
  128527. DPadLeft = 14,
  128528. /** DRight */
  128529. DPadRight = 15,
  128530. /** Home */
  128531. Home = 16,
  128532. /** Capture */
  128533. Capture = 17,
  128534. /** LStickXAxis */
  128535. LStickXAxis = 18,
  128536. /** LStickYAxis */
  128537. LStickYAxis = 19,
  128538. /** RStickXAxis */
  128539. RStickXAxis = 20,
  128540. /** RStickYAxis */
  128541. RStickYAxis = 21
  128542. }
  128543. }
  128544. declare module BABYLON {
  128545. /**
  128546. * This class will take all inputs from Keyboard, Pointer, and
  128547. * any Gamepads and provide a polling system that all devices
  128548. * will use. This class assumes that there will only be one
  128549. * pointer device and one keyboard.
  128550. */
  128551. export class DeviceInputSystem implements IDisposable {
  128552. /**
  128553. * Callback to be triggered when a device is connected
  128554. */
  128555. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128556. /**
  128557. * Callback to be triggered when a device is disconnected
  128558. */
  128559. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128560. /**
  128561. * Callback to be triggered when event driven input is updated
  128562. */
  128563. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  128564. private _inputs;
  128565. private _gamepads;
  128566. private _keyboardActive;
  128567. private _pointerActive;
  128568. private _elementToAttachTo;
  128569. private _keyboardDownEvent;
  128570. private _keyboardUpEvent;
  128571. private _pointerMoveEvent;
  128572. private _pointerDownEvent;
  128573. private _pointerUpEvent;
  128574. private _gamepadConnectedEvent;
  128575. private _gamepadDisconnectedEvent;
  128576. private static _MAX_KEYCODES;
  128577. private static _MAX_POINTER_INPUTS;
  128578. private constructor();
  128579. /**
  128580. * Creates a new DeviceInputSystem instance
  128581. * @param engine Engine to pull input element from
  128582. * @returns The new instance
  128583. */
  128584. static Create(engine: Engine): DeviceInputSystem;
  128585. /**
  128586. * Checks for current device input value, given an id and input index
  128587. * @param deviceName Id of connected device
  128588. * @param inputIndex Index of device input
  128589. * @returns Current value of input
  128590. */
  128591. /**
  128592. * Checks for current device input value, given an id and input index
  128593. * @param deviceType Enum specifiying device type
  128594. * @param deviceSlot "Slot" or index that device is referenced in
  128595. * @param inputIndex Id of input to be checked
  128596. * @returns Current value of input
  128597. */
  128598. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  128599. /**
  128600. * Dispose of all the eventlisteners
  128601. */
  128602. dispose(): void;
  128603. /**
  128604. * Add device and inputs to device array
  128605. * @param deviceType Enum specifiying device type
  128606. * @param deviceSlot "Slot" or index that device is referenced in
  128607. * @param numberOfInputs Number of input entries to create for given device
  128608. */
  128609. private _registerDevice;
  128610. /**
  128611. * Given a specific device name, remove that device from the device map
  128612. * @param deviceType Enum specifiying device type
  128613. * @param deviceSlot "Slot" or index that device is referenced in
  128614. */
  128615. private _unregisterDevice;
  128616. /**
  128617. * Handle all actions that come from keyboard interaction
  128618. */
  128619. private _handleKeyActions;
  128620. /**
  128621. * Handle all actions that come from pointer interaction
  128622. */
  128623. private _handlePointerActions;
  128624. /**
  128625. * Handle all actions that come from gamepad interaction
  128626. */
  128627. private _handleGamepadActions;
  128628. /**
  128629. * Update all non-event based devices with each frame
  128630. * @param deviceType Enum specifiying device type
  128631. * @param deviceSlot "Slot" or index that device is referenced in
  128632. * @param inputIndex Id of input to be checked
  128633. */
  128634. private _updateDevice;
  128635. /**
  128636. * Gets DeviceType from the device name
  128637. * @param deviceName Name of Device from DeviceInputSystem
  128638. * @returns DeviceType enum value
  128639. */
  128640. private _getGamepadDeviceType;
  128641. }
  128642. }
  128643. declare module BABYLON {
  128644. /**
  128645. * Type to handle enforcement of inputs
  128646. */
  128647. 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;
  128648. }
  128649. declare module BABYLON {
  128650. /**
  128651. * Class that handles all input for a specific device
  128652. */
  128653. export class DeviceSource<T extends DeviceType> {
  128654. /** Type of device */
  128655. readonly deviceType: DeviceType;
  128656. /** "Slot" or index that device is referenced in */
  128657. readonly deviceSlot: number;
  128658. /**
  128659. * Observable to handle device input changes per device
  128660. */
  128661. readonly onInputChangedObservable: Observable<{
  128662. inputIndex: DeviceInput<T>;
  128663. previousState: Nullable<number>;
  128664. currentState: Nullable<number>;
  128665. }>;
  128666. private readonly _deviceInputSystem;
  128667. /**
  128668. * Default Constructor
  128669. * @param deviceInputSystem Reference to DeviceInputSystem
  128670. * @param deviceType Type of device
  128671. * @param deviceSlot "Slot" or index that device is referenced in
  128672. */
  128673. constructor(deviceInputSystem: DeviceInputSystem,
  128674. /** Type of device */
  128675. deviceType: DeviceType,
  128676. /** "Slot" or index that device is referenced in */
  128677. deviceSlot?: number);
  128678. /**
  128679. * Get input for specific input
  128680. * @param inputIndex index of specific input on device
  128681. * @returns Input value from DeviceInputSystem
  128682. */
  128683. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  128684. }
  128685. /**
  128686. * Class to keep track of devices
  128687. */
  128688. export class DeviceSourceManager implements IDisposable {
  128689. /**
  128690. * Observable to be triggered when before a device is connected
  128691. */
  128692. readonly onBeforeDeviceConnectedObservable: Observable<{
  128693. deviceType: DeviceType;
  128694. deviceSlot: number;
  128695. }>;
  128696. /**
  128697. * Observable to be triggered when before a device is disconnected
  128698. */
  128699. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  128700. deviceType: DeviceType;
  128701. deviceSlot: number;
  128702. }>;
  128703. /**
  128704. * Observable to be triggered when after a device is connected
  128705. */
  128706. readonly onAfterDeviceConnectedObservable: Observable<{
  128707. deviceType: DeviceType;
  128708. deviceSlot: number;
  128709. }>;
  128710. /**
  128711. * Observable to be triggered when after a device is disconnected
  128712. */
  128713. readonly onAfterDeviceDisconnectedObservable: Observable<{
  128714. deviceType: DeviceType;
  128715. deviceSlot: number;
  128716. }>;
  128717. private readonly _devices;
  128718. private readonly _firstDevice;
  128719. private readonly _deviceInputSystem;
  128720. /**
  128721. * Default Constructor
  128722. * @param engine engine to pull input element from
  128723. */
  128724. constructor(engine: Engine);
  128725. /**
  128726. * Gets a DeviceSource, given a type and slot
  128727. * @param deviceType Enum specifying device type
  128728. * @param deviceSlot "Slot" or index that device is referenced in
  128729. * @returns DeviceSource object
  128730. */
  128731. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  128732. /**
  128733. * Gets an array of DeviceSource objects for a given device type
  128734. * @param deviceType Enum specifying device type
  128735. * @returns Array of DeviceSource objects
  128736. */
  128737. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  128738. /**
  128739. * Dispose of DeviceInputSystem and other parts
  128740. */
  128741. dispose(): void;
  128742. /**
  128743. * Function to add device name to device list
  128744. * @param deviceType Enum specifying device type
  128745. * @param deviceSlot "Slot" or index that device is referenced in
  128746. */
  128747. private _addDevice;
  128748. /**
  128749. * Function to remove device name to device list
  128750. * @param deviceType Enum specifying device type
  128751. * @param deviceSlot "Slot" or index that device is referenced in
  128752. */
  128753. private _removeDevice;
  128754. /**
  128755. * Updates array storing first connected device of each type
  128756. * @param type Type of Device
  128757. */
  128758. private _updateFirstDevices;
  128759. }
  128760. }
  128761. declare module BABYLON {
  128762. /**
  128763. * Options to create the null engine
  128764. */
  128765. export class NullEngineOptions {
  128766. /**
  128767. * Render width (Default: 512)
  128768. */
  128769. renderWidth: number;
  128770. /**
  128771. * Render height (Default: 256)
  128772. */
  128773. renderHeight: number;
  128774. /**
  128775. * Texture size (Default: 512)
  128776. */
  128777. textureSize: number;
  128778. /**
  128779. * If delta time between frames should be constant
  128780. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128781. */
  128782. deterministicLockstep: boolean;
  128783. /**
  128784. * Maximum about of steps between frames (Default: 4)
  128785. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128786. */
  128787. lockstepMaxSteps: number;
  128788. }
  128789. /**
  128790. * The null engine class provides support for headless version of babylon.js.
  128791. * This can be used in server side scenario or for testing purposes
  128792. */
  128793. export class NullEngine extends Engine {
  128794. private _options;
  128795. /**
  128796. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  128797. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128798. * @returns true if engine is in deterministic lock step mode
  128799. */
  128800. isDeterministicLockStep(): boolean;
  128801. /**
  128802. * Gets the max steps when engine is running in deterministic lock step
  128803. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128804. * @returns the max steps
  128805. */
  128806. getLockstepMaxSteps(): number;
  128807. /**
  128808. * Gets the current hardware scaling level.
  128809. * By default the hardware scaling level is computed from the window device ratio.
  128810. * 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.
  128811. * @returns a number indicating the current hardware scaling level
  128812. */
  128813. getHardwareScalingLevel(): number;
  128814. constructor(options?: NullEngineOptions);
  128815. /**
  128816. * Creates a vertex buffer
  128817. * @param vertices the data for the vertex buffer
  128818. * @returns the new WebGL static buffer
  128819. */
  128820. createVertexBuffer(vertices: FloatArray): DataBuffer;
  128821. /**
  128822. * Creates a new index buffer
  128823. * @param indices defines the content of the index buffer
  128824. * @param updatable defines if the index buffer must be updatable
  128825. * @returns a new webGL buffer
  128826. */
  128827. createIndexBuffer(indices: IndicesArray): DataBuffer;
  128828. /**
  128829. * Clear the current render buffer or the current render target (if any is set up)
  128830. * @param color defines the color to use
  128831. * @param backBuffer defines if the back buffer must be cleared
  128832. * @param depth defines if the depth buffer must be cleared
  128833. * @param stencil defines if the stencil buffer must be cleared
  128834. */
  128835. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128836. /**
  128837. * Gets the current render width
  128838. * @param useScreen defines if screen size must be used (or the current render target if any)
  128839. * @returns a number defining the current render width
  128840. */
  128841. getRenderWidth(useScreen?: boolean): number;
  128842. /**
  128843. * Gets the current render height
  128844. * @param useScreen defines if screen size must be used (or the current render target if any)
  128845. * @returns a number defining the current render height
  128846. */
  128847. getRenderHeight(useScreen?: boolean): number;
  128848. /**
  128849. * Set the WebGL's viewport
  128850. * @param viewport defines the viewport element to be used
  128851. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  128852. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  128853. */
  128854. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  128855. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  128856. /**
  128857. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  128858. * @param pipelineContext defines the pipeline context to use
  128859. * @param uniformsNames defines the list of uniform names
  128860. * @returns an array of webGL uniform locations
  128861. */
  128862. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  128863. /**
  128864. * Gets the lsit of active attributes for a given webGL program
  128865. * @param pipelineContext defines the pipeline context to use
  128866. * @param attributesNames defines the list of attribute names to get
  128867. * @returns an array of indices indicating the offset of each attribute
  128868. */
  128869. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128870. /**
  128871. * Binds an effect to the webGL context
  128872. * @param effect defines the effect to bind
  128873. */
  128874. bindSamplers(effect: Effect): void;
  128875. /**
  128876. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  128877. * @param effect defines the effect to activate
  128878. */
  128879. enableEffect(effect: Effect): void;
  128880. /**
  128881. * Set various states to the webGL context
  128882. * @param culling defines backface culling state
  128883. * @param zOffset defines the value to apply to zOffset (0 by default)
  128884. * @param force defines if states must be applied even if cache is up to date
  128885. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  128886. */
  128887. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128888. /**
  128889. * Set the value of an uniform to an array of int32
  128890. * @param uniform defines the webGL uniform location where to store the value
  128891. * @param array defines the array of int32 to store
  128892. */
  128893. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128894. /**
  128895. * Set the value of an uniform to an array of int32 (stored as vec2)
  128896. * @param uniform defines the webGL uniform location where to store the value
  128897. * @param array defines the array of int32 to store
  128898. */
  128899. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128900. /**
  128901. * Set the value of an uniform to an array of int32 (stored as vec3)
  128902. * @param uniform defines the webGL uniform location where to store the value
  128903. * @param array defines the array of int32 to store
  128904. */
  128905. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128906. /**
  128907. * Set the value of an uniform to an array of int32 (stored as vec4)
  128908. * @param uniform defines the webGL uniform location where to store the value
  128909. * @param array defines the array of int32 to store
  128910. */
  128911. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128912. /**
  128913. * Set the value of an uniform to an array of float32
  128914. * @param uniform defines the webGL uniform location where to store the value
  128915. * @param array defines the array of float32 to store
  128916. */
  128917. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128918. /**
  128919. * Set the value of an uniform to an array of float32 (stored as vec2)
  128920. * @param uniform defines the webGL uniform location where to store the value
  128921. * @param array defines the array of float32 to store
  128922. */
  128923. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128924. /**
  128925. * Set the value of an uniform to an array of float32 (stored as vec3)
  128926. * @param uniform defines the webGL uniform location where to store the value
  128927. * @param array defines the array of float32 to store
  128928. */
  128929. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128930. /**
  128931. * Set the value of an uniform to an array of float32 (stored as vec4)
  128932. * @param uniform defines the webGL uniform location where to store the value
  128933. * @param array defines the array of float32 to store
  128934. */
  128935. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128936. /**
  128937. * Set the value of an uniform to an array of number
  128938. * @param uniform defines the webGL uniform location where to store the value
  128939. * @param array defines the array of number to store
  128940. */
  128941. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128942. /**
  128943. * Set the value of an uniform to an array of number (stored as vec2)
  128944. * @param uniform defines the webGL uniform location where to store the value
  128945. * @param array defines the array of number to store
  128946. */
  128947. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128948. /**
  128949. * Set the value of an uniform to an array of number (stored as vec3)
  128950. * @param uniform defines the webGL uniform location where to store the value
  128951. * @param array defines the array of number to store
  128952. */
  128953. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128954. /**
  128955. * Set the value of an uniform to an array of number (stored as vec4)
  128956. * @param uniform defines the webGL uniform location where to store the value
  128957. * @param array defines the array of number to store
  128958. */
  128959. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128960. /**
  128961. * Set the value of an uniform to an array of float32 (stored as matrices)
  128962. * @param uniform defines the webGL uniform location where to store the value
  128963. * @param matrices defines the array of float32 to store
  128964. */
  128965. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128966. /**
  128967. * Set the value of an uniform to a matrix (3x3)
  128968. * @param uniform defines the webGL uniform location where to store the value
  128969. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  128970. */
  128971. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128972. /**
  128973. * Set the value of an uniform to a matrix (2x2)
  128974. * @param uniform defines the webGL uniform location where to store the value
  128975. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  128976. */
  128977. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128978. /**
  128979. * Set the value of an uniform to a number (float)
  128980. * @param uniform defines the webGL uniform location where to store the value
  128981. * @param value defines the float number to store
  128982. */
  128983. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128984. /**
  128985. * Set the value of an uniform to a vec2
  128986. * @param uniform defines the webGL uniform location where to store the value
  128987. * @param x defines the 1st component of the value
  128988. * @param y defines the 2nd component of the value
  128989. */
  128990. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128991. /**
  128992. * Set the value of an uniform to a vec3
  128993. * @param uniform defines the webGL uniform location where to store the value
  128994. * @param x defines the 1st component of the value
  128995. * @param y defines the 2nd component of the value
  128996. * @param z defines the 3rd component of the value
  128997. */
  128998. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  128999. /**
  129000. * Set the value of an uniform to a boolean
  129001. * @param uniform defines the webGL uniform location where to store the value
  129002. * @param bool defines the boolean to store
  129003. */
  129004. setBool(uniform: WebGLUniformLocation, bool: number): void;
  129005. /**
  129006. * Set the value of an uniform to a vec4
  129007. * @param uniform defines the webGL uniform location where to store the value
  129008. * @param x defines the 1st component of the value
  129009. * @param y defines the 2nd component of the value
  129010. * @param z defines the 3rd component of the value
  129011. * @param w defines the 4th component of the value
  129012. */
  129013. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  129014. /**
  129015. * Sets the current alpha mode
  129016. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  129017. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129018. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129019. */
  129020. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129021. /**
  129022. * Bind webGl buffers directly to the webGL context
  129023. * @param vertexBuffers defines the vertex buffer to bind
  129024. * @param indexBuffer defines the index buffer to bind
  129025. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  129026. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  129027. * @param effect defines the effect associated with the vertex buffer
  129028. */
  129029. bindBuffers(vertexBuffers: {
  129030. [key: string]: VertexBuffer;
  129031. }, indexBuffer: DataBuffer, effect: Effect): void;
  129032. /**
  129033. * Force the entire cache to be cleared
  129034. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  129035. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  129036. */
  129037. wipeCaches(bruteForce?: boolean): void;
  129038. /**
  129039. * Send a draw order
  129040. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  129041. * @param indexStart defines the starting index
  129042. * @param indexCount defines the number of index to draw
  129043. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129044. */
  129045. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  129046. /**
  129047. * Draw a list of indexed primitives
  129048. * @param fillMode defines the primitive to use
  129049. * @param indexStart defines the starting index
  129050. * @param indexCount defines the number of index to draw
  129051. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129052. */
  129053. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129054. /**
  129055. * Draw a list of unindexed primitives
  129056. * @param fillMode defines the primitive to use
  129057. * @param verticesStart defines the index of first vertex to draw
  129058. * @param verticesCount defines the count of vertices to draw
  129059. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129060. */
  129061. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129062. /** @hidden */
  129063. _createTexture(): WebGLTexture;
  129064. /** @hidden */
  129065. _releaseTexture(texture: InternalTexture): void;
  129066. /**
  129067. * Usually called from Texture.ts.
  129068. * Passed information to create a WebGLTexture
  129069. * @param urlArg defines a value which contains one of the following:
  129070. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129071. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129072. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129073. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129074. * @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)
  129075. * @param scene needed for loading to the correct scene
  129076. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129077. * @param onLoad optional callback to be called upon successful completion
  129078. * @param onError optional callback to be called upon failure
  129079. * @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
  129080. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129081. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129082. * @param forcedExtension defines the extension to use to pick the right loader
  129083. * @param mimeType defines an optional mime type
  129084. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129085. */
  129086. 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;
  129087. /**
  129088. * Creates a new render target texture
  129089. * @param size defines the size of the texture
  129090. * @param options defines the options used to create the texture
  129091. * @returns a new render target texture stored in an InternalTexture
  129092. */
  129093. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  129094. /**
  129095. * Update the sampling mode of a given texture
  129096. * @param samplingMode defines the required sampling mode
  129097. * @param texture defines the texture to update
  129098. */
  129099. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  129100. /**
  129101. * Binds the frame buffer to the specified texture.
  129102. * @param texture The texture to render to or null for the default canvas
  129103. * @param faceIndex The face of the texture to render to in case of cube texture
  129104. * @param requiredWidth The width of the target to render to
  129105. * @param requiredHeight The height of the target to render to
  129106. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  129107. * @param lodLevel defines le lod level to bind to the frame buffer
  129108. */
  129109. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  129110. /**
  129111. * Unbind the current render target texture from the webGL context
  129112. * @param texture defines the render target texture to unbind
  129113. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129114. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129115. */
  129116. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129117. /**
  129118. * Creates a dynamic vertex buffer
  129119. * @param vertices the data for the dynamic vertex buffer
  129120. * @returns the new WebGL dynamic buffer
  129121. */
  129122. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  129123. /**
  129124. * Update the content of a dynamic texture
  129125. * @param texture defines the texture to update
  129126. * @param canvas defines the canvas containing the source
  129127. * @param invertY defines if data must be stored with Y axis inverted
  129128. * @param premulAlpha defines if alpha is stored as premultiplied
  129129. * @param format defines the format of the data
  129130. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  129131. */
  129132. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  129133. /**
  129134. * Gets a boolean indicating if all created effects are ready
  129135. * @returns true if all effects are ready
  129136. */
  129137. areAllEffectsReady(): boolean;
  129138. /**
  129139. * @hidden
  129140. * Get the current error code of the webGL context
  129141. * @returns the error code
  129142. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  129143. */
  129144. getError(): number;
  129145. /** @hidden */
  129146. _getUnpackAlignement(): number;
  129147. /** @hidden */
  129148. _unpackFlipY(value: boolean): void;
  129149. /**
  129150. * Update a dynamic index buffer
  129151. * @param indexBuffer defines the target index buffer
  129152. * @param indices defines the data to update
  129153. * @param offset defines the offset in the target index buffer where update should start
  129154. */
  129155. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  129156. /**
  129157. * Updates a dynamic vertex buffer.
  129158. * @param vertexBuffer the vertex buffer to update
  129159. * @param vertices the data used to update the vertex buffer
  129160. * @param byteOffset the byte offset of the data (optional)
  129161. * @param byteLength the byte length of the data (optional)
  129162. */
  129163. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  129164. /** @hidden */
  129165. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  129166. /** @hidden */
  129167. _bindTexture(channel: number, texture: InternalTexture): void;
  129168. protected _deleteBuffer(buffer: WebGLBuffer): void;
  129169. /**
  129170. * 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
  129171. */
  129172. releaseEffects(): void;
  129173. displayLoadingUI(): void;
  129174. hideLoadingUI(): void;
  129175. /** @hidden */
  129176. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129177. /** @hidden */
  129178. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129179. /** @hidden */
  129180. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129181. /** @hidden */
  129182. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  129183. }
  129184. }
  129185. declare module BABYLON {
  129186. /**
  129187. * @hidden
  129188. **/
  129189. export class _TimeToken {
  129190. _startTimeQuery: Nullable<WebGLQuery>;
  129191. _endTimeQuery: Nullable<WebGLQuery>;
  129192. _timeElapsedQuery: Nullable<WebGLQuery>;
  129193. _timeElapsedQueryEnded: boolean;
  129194. }
  129195. }
  129196. declare module BABYLON {
  129197. /** @hidden */
  129198. export class _OcclusionDataStorage {
  129199. /** @hidden */
  129200. occlusionInternalRetryCounter: number;
  129201. /** @hidden */
  129202. isOcclusionQueryInProgress: boolean;
  129203. /** @hidden */
  129204. isOccluded: boolean;
  129205. /** @hidden */
  129206. occlusionRetryCount: number;
  129207. /** @hidden */
  129208. occlusionType: number;
  129209. /** @hidden */
  129210. occlusionQueryAlgorithmType: number;
  129211. }
  129212. interface Engine {
  129213. /**
  129214. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  129215. * @return the new query
  129216. */
  129217. createQuery(): WebGLQuery;
  129218. /**
  129219. * Delete and release a webGL query
  129220. * @param query defines the query to delete
  129221. * @return the current engine
  129222. */
  129223. deleteQuery(query: WebGLQuery): Engine;
  129224. /**
  129225. * Check if a given query has resolved and got its value
  129226. * @param query defines the query to check
  129227. * @returns true if the query got its value
  129228. */
  129229. isQueryResultAvailable(query: WebGLQuery): boolean;
  129230. /**
  129231. * Gets the value of a given query
  129232. * @param query defines the query to check
  129233. * @returns the value of the query
  129234. */
  129235. getQueryResult(query: WebGLQuery): number;
  129236. /**
  129237. * Initiates an occlusion query
  129238. * @param algorithmType defines the algorithm to use
  129239. * @param query defines the query to use
  129240. * @returns the current engine
  129241. * @see https://doc.babylonjs.com/features/occlusionquery
  129242. */
  129243. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  129244. /**
  129245. * Ends an occlusion query
  129246. * @see https://doc.babylonjs.com/features/occlusionquery
  129247. * @param algorithmType defines the algorithm to use
  129248. * @returns the current engine
  129249. */
  129250. endOcclusionQuery(algorithmType: number): Engine;
  129251. /**
  129252. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  129253. * Please note that only one query can be issued at a time
  129254. * @returns a time token used to track the time span
  129255. */
  129256. startTimeQuery(): Nullable<_TimeToken>;
  129257. /**
  129258. * Ends a time query
  129259. * @param token defines the token used to measure the time span
  129260. * @returns the time spent (in ns)
  129261. */
  129262. endTimeQuery(token: _TimeToken): int;
  129263. /** @hidden */
  129264. _currentNonTimestampToken: Nullable<_TimeToken>;
  129265. /** @hidden */
  129266. _createTimeQuery(): WebGLQuery;
  129267. /** @hidden */
  129268. _deleteTimeQuery(query: WebGLQuery): void;
  129269. /** @hidden */
  129270. _getGlAlgorithmType(algorithmType: number): number;
  129271. /** @hidden */
  129272. _getTimeQueryResult(query: WebGLQuery): any;
  129273. /** @hidden */
  129274. _getTimeQueryAvailability(query: WebGLQuery): any;
  129275. }
  129276. interface AbstractMesh {
  129277. /**
  129278. * Backing filed
  129279. * @hidden
  129280. */
  129281. __occlusionDataStorage: _OcclusionDataStorage;
  129282. /**
  129283. * Access property
  129284. * @hidden
  129285. */
  129286. _occlusionDataStorage: _OcclusionDataStorage;
  129287. /**
  129288. * 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.
  129289. * The default value is -1 which means don't break the query and wait till the result
  129290. * @see https://doc.babylonjs.com/features/occlusionquery
  129291. */
  129292. occlusionRetryCount: number;
  129293. /**
  129294. * 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:
  129295. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  129296. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  129297. * * 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.
  129298. * @see https://doc.babylonjs.com/features/occlusionquery
  129299. */
  129300. occlusionType: number;
  129301. /**
  129302. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  129303. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  129304. * * 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.
  129305. * @see https://doc.babylonjs.com/features/occlusionquery
  129306. */
  129307. occlusionQueryAlgorithmType: number;
  129308. /**
  129309. * 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
  129310. * @see https://doc.babylonjs.com/features/occlusionquery
  129311. */
  129312. isOccluded: boolean;
  129313. /**
  129314. * Flag to check the progress status of the query
  129315. * @see https://doc.babylonjs.com/features/occlusionquery
  129316. */
  129317. isOcclusionQueryInProgress: boolean;
  129318. }
  129319. }
  129320. declare module BABYLON {
  129321. /** @hidden */
  129322. export var _forceTransformFeedbackToBundle: boolean;
  129323. interface Engine {
  129324. /**
  129325. * Creates a webGL transform feedback object
  129326. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  129327. * @returns the webGL transform feedback object
  129328. */
  129329. createTransformFeedback(): WebGLTransformFeedback;
  129330. /**
  129331. * Delete a webGL transform feedback object
  129332. * @param value defines the webGL transform feedback object to delete
  129333. */
  129334. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  129335. /**
  129336. * Bind a webGL transform feedback object to the webgl context
  129337. * @param value defines the webGL transform feedback object to bind
  129338. */
  129339. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  129340. /**
  129341. * Begins a transform feedback operation
  129342. * @param usePoints defines if points or triangles must be used
  129343. */
  129344. beginTransformFeedback(usePoints: boolean): void;
  129345. /**
  129346. * Ends a transform feedback operation
  129347. */
  129348. endTransformFeedback(): void;
  129349. /**
  129350. * Specify the varyings to use with transform feedback
  129351. * @param program defines the associated webGL program
  129352. * @param value defines the list of strings representing the varying names
  129353. */
  129354. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  129355. /**
  129356. * Bind a webGL buffer for a transform feedback operation
  129357. * @param value defines the webGL buffer to bind
  129358. */
  129359. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  129360. }
  129361. }
  129362. declare module BABYLON {
  129363. /**
  129364. * Creation options of the multi render target texture.
  129365. */
  129366. export interface IMultiRenderTargetOptions {
  129367. /**
  129368. * Define if the texture needs to create mip maps after render.
  129369. */
  129370. generateMipMaps?: boolean;
  129371. /**
  129372. * Define the types of all the draw buffers we want to create
  129373. */
  129374. types?: number[];
  129375. /**
  129376. * Define the sampling modes of all the draw buffers we want to create
  129377. */
  129378. samplingModes?: number[];
  129379. /**
  129380. * Define if a depth buffer is required
  129381. */
  129382. generateDepthBuffer?: boolean;
  129383. /**
  129384. * Define if a stencil buffer is required
  129385. */
  129386. generateStencilBuffer?: boolean;
  129387. /**
  129388. * Define if a depth texture is required instead of a depth buffer
  129389. */
  129390. generateDepthTexture?: boolean;
  129391. /**
  129392. * Define the number of desired draw buffers
  129393. */
  129394. textureCount?: number;
  129395. /**
  129396. * Define if aspect ratio should be adapted to the texture or stay the scene one
  129397. */
  129398. doNotChangeAspectRatio?: boolean;
  129399. /**
  129400. * Define the default type of the buffers we are creating
  129401. */
  129402. defaultType?: number;
  129403. }
  129404. /**
  129405. * A multi render target, like a render target provides the ability to render to a texture.
  129406. * Unlike the render target, it can render to several draw buffers in one draw.
  129407. * This is specially interesting in deferred rendering or for any effects requiring more than
  129408. * just one color from a single pass.
  129409. */
  129410. export class MultiRenderTarget extends RenderTargetTexture {
  129411. private _internalTextures;
  129412. private _textures;
  129413. private _multiRenderTargetOptions;
  129414. private _count;
  129415. /**
  129416. * Get if draw buffers are currently supported by the used hardware and browser.
  129417. */
  129418. get isSupported(): boolean;
  129419. /**
  129420. * Get the list of textures generated by the multi render target.
  129421. */
  129422. get textures(): Texture[];
  129423. /**
  129424. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  129425. */
  129426. get count(): number;
  129427. /**
  129428. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  129429. */
  129430. get depthTexture(): Texture;
  129431. /**
  129432. * Set the wrapping mode on U of all the textures we are rendering to.
  129433. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129434. */
  129435. set wrapU(wrap: number);
  129436. /**
  129437. * Set the wrapping mode on V of all the textures we are rendering to.
  129438. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129439. */
  129440. set wrapV(wrap: number);
  129441. /**
  129442. * Instantiate a new multi render target texture.
  129443. * A multi render target, like a render target provides the ability to render to a texture.
  129444. * Unlike the render target, it can render to several draw buffers in one draw.
  129445. * This is specially interesting in deferred rendering or for any effects requiring more than
  129446. * just one color from a single pass.
  129447. * @param name Define the name of the texture
  129448. * @param size Define the size of the buffers to render to
  129449. * @param count Define the number of target we are rendering into
  129450. * @param scene Define the scene the texture belongs to
  129451. * @param options Define the options used to create the multi render target
  129452. */
  129453. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  129454. /** @hidden */
  129455. _rebuild(): void;
  129456. private _createInternalTextures;
  129457. private _createTextures;
  129458. /**
  129459. * Define the number of samples used if MSAA is enabled.
  129460. */
  129461. get samples(): number;
  129462. set samples(value: number);
  129463. /**
  129464. * Resize all the textures in the multi render target.
  129465. * Be carrefull as it will recreate all the data in the new texture.
  129466. * @param size Define the new size
  129467. */
  129468. resize(size: any): void;
  129469. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  129470. /**
  129471. * Dispose the render targets and their associated resources
  129472. */
  129473. dispose(): void;
  129474. /**
  129475. * Release all the underlying texture used as draw buffers.
  129476. */
  129477. releaseInternalTextures(): void;
  129478. }
  129479. }
  129480. declare module BABYLON {
  129481. interface ThinEngine {
  129482. /**
  129483. * Unbind a list of render target textures from the webGL context
  129484. * This is used only when drawBuffer extension or webGL2 are active
  129485. * @param textures defines the render target textures to unbind
  129486. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129487. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129488. */
  129489. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  129490. /**
  129491. * Create a multi render target texture
  129492. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  129493. * @param size defines the size of the texture
  129494. * @param options defines the creation options
  129495. * @returns the cube texture as an InternalTexture
  129496. */
  129497. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  129498. /**
  129499. * Update the sample count for a given multiple render target texture
  129500. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  129501. * @param textures defines the textures to update
  129502. * @param samples defines the sample count to set
  129503. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  129504. */
  129505. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  129506. /**
  129507. * Select a subsets of attachments to draw to.
  129508. * @param attachments gl attachments
  129509. */
  129510. bindAttachments(attachments: number[]): void;
  129511. }
  129512. }
  129513. declare module BABYLON {
  129514. /**
  129515. * Class used to define an additional view for the engine
  129516. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129517. */
  129518. export class EngineView {
  129519. /** Defines the canvas where to render the view */
  129520. target: HTMLCanvasElement;
  129521. /** Defines an optional camera used to render the view (will use active camera else) */
  129522. camera?: Camera;
  129523. }
  129524. interface Engine {
  129525. /**
  129526. * Gets or sets the HTML element to use for attaching events
  129527. */
  129528. inputElement: Nullable<HTMLElement>;
  129529. /**
  129530. * Gets the current engine view
  129531. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129532. */
  129533. activeView: Nullable<EngineView>;
  129534. /** Gets or sets the list of views */
  129535. views: EngineView[];
  129536. /**
  129537. * Register a new child canvas
  129538. * @param canvas defines the canvas to register
  129539. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  129540. * @returns the associated view
  129541. */
  129542. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  129543. /**
  129544. * Remove a registered child canvas
  129545. * @param canvas defines the canvas to remove
  129546. * @returns the current engine
  129547. */
  129548. unRegisterView(canvas: HTMLCanvasElement): Engine;
  129549. }
  129550. }
  129551. declare module BABYLON {
  129552. interface Engine {
  129553. /** @hidden */
  129554. _excludedCompressedTextures: string[];
  129555. /** @hidden */
  129556. _textureFormatInUse: string;
  129557. /**
  129558. * Gets the list of texture formats supported
  129559. */
  129560. readonly texturesSupported: Array<string>;
  129561. /**
  129562. * Gets the texture format in use
  129563. */
  129564. readonly textureFormatInUse: Nullable<string>;
  129565. /**
  129566. * Set the compressed texture extensions or file names to skip.
  129567. *
  129568. * @param skippedFiles defines the list of those texture files you want to skip
  129569. * Example: [".dds", ".env", "myfile.png"]
  129570. */
  129571. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  129572. /**
  129573. * Set the compressed texture format to use, based on the formats you have, and the formats
  129574. * supported by the hardware / browser.
  129575. *
  129576. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  129577. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  129578. * to API arguments needed to compressed textures. This puts the burden on the container
  129579. * generator to house the arcane code for determining these for current & future formats.
  129580. *
  129581. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  129582. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  129583. *
  129584. * Note: The result of this call is not taken into account when a texture is base64.
  129585. *
  129586. * @param formatsAvailable defines the list of those format families you have created
  129587. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  129588. *
  129589. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  129590. * @returns The extension selected.
  129591. */
  129592. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  129593. }
  129594. }
  129595. declare module BABYLON {
  129596. /**
  129597. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  129598. */
  129599. export interface CubeMapInfo {
  129600. /**
  129601. * The pixel array for the front face.
  129602. * This is stored in format, left to right, up to down format.
  129603. */
  129604. front: Nullable<ArrayBufferView>;
  129605. /**
  129606. * The pixel array for the back face.
  129607. * This is stored in format, left to right, up to down format.
  129608. */
  129609. back: Nullable<ArrayBufferView>;
  129610. /**
  129611. * The pixel array for the left face.
  129612. * This is stored in format, left to right, up to down format.
  129613. */
  129614. left: Nullable<ArrayBufferView>;
  129615. /**
  129616. * The pixel array for the right face.
  129617. * This is stored in format, left to right, up to down format.
  129618. */
  129619. right: Nullable<ArrayBufferView>;
  129620. /**
  129621. * The pixel array for the up face.
  129622. * This is stored in format, left to right, up to down format.
  129623. */
  129624. up: Nullable<ArrayBufferView>;
  129625. /**
  129626. * The pixel array for the down face.
  129627. * This is stored in format, left to right, up to down format.
  129628. */
  129629. down: Nullable<ArrayBufferView>;
  129630. /**
  129631. * The size of the cubemap stored.
  129632. *
  129633. * Each faces will be size * size pixels.
  129634. */
  129635. size: number;
  129636. /**
  129637. * The format of the texture.
  129638. *
  129639. * RGBA, RGB.
  129640. */
  129641. format: number;
  129642. /**
  129643. * The type of the texture data.
  129644. *
  129645. * UNSIGNED_INT, FLOAT.
  129646. */
  129647. type: number;
  129648. /**
  129649. * Specifies whether the texture is in gamma space.
  129650. */
  129651. gammaSpace: boolean;
  129652. }
  129653. /**
  129654. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  129655. */
  129656. export class PanoramaToCubeMapTools {
  129657. private static FACE_LEFT;
  129658. private static FACE_RIGHT;
  129659. private static FACE_FRONT;
  129660. private static FACE_BACK;
  129661. private static FACE_DOWN;
  129662. private static FACE_UP;
  129663. /**
  129664. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  129665. *
  129666. * @param float32Array The source data.
  129667. * @param inputWidth The width of the input panorama.
  129668. * @param inputHeight The height of the input panorama.
  129669. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  129670. * @return The cubemap data
  129671. */
  129672. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  129673. private static CreateCubemapTexture;
  129674. private static CalcProjectionSpherical;
  129675. }
  129676. }
  129677. declare module BABYLON {
  129678. /**
  129679. * Helper class dealing with the extraction of spherical polynomial dataArray
  129680. * from a cube map.
  129681. */
  129682. export class CubeMapToSphericalPolynomialTools {
  129683. private static FileFaces;
  129684. /**
  129685. * Converts a texture to the according Spherical Polynomial data.
  129686. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129687. *
  129688. * @param texture The texture to extract the information from.
  129689. * @return The Spherical Polynomial data.
  129690. */
  129691. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  129692. /**
  129693. * Converts a cubemap to the according Spherical Polynomial data.
  129694. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129695. *
  129696. * @param cubeInfo The Cube map to extract the information from.
  129697. * @return The Spherical Polynomial data.
  129698. */
  129699. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  129700. }
  129701. }
  129702. declare module BABYLON {
  129703. interface BaseTexture {
  129704. /**
  129705. * Get the polynomial representation of the texture data.
  129706. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  129707. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  129708. */
  129709. sphericalPolynomial: Nullable<SphericalPolynomial>;
  129710. }
  129711. }
  129712. declare module BABYLON {
  129713. /** @hidden */
  129714. export var rgbdEncodePixelShader: {
  129715. name: string;
  129716. shader: string;
  129717. };
  129718. }
  129719. declare module BABYLON {
  129720. /** @hidden */
  129721. export var rgbdDecodePixelShader: {
  129722. name: string;
  129723. shader: string;
  129724. };
  129725. }
  129726. declare module BABYLON {
  129727. /**
  129728. * Raw texture data and descriptor sufficient for WebGL texture upload
  129729. */
  129730. export interface EnvironmentTextureInfo {
  129731. /**
  129732. * Version of the environment map
  129733. */
  129734. version: number;
  129735. /**
  129736. * Width of image
  129737. */
  129738. width: number;
  129739. /**
  129740. * Irradiance information stored in the file.
  129741. */
  129742. irradiance: any;
  129743. /**
  129744. * Specular information stored in the file.
  129745. */
  129746. specular: any;
  129747. }
  129748. /**
  129749. * Defines One Image in the file. It requires only the position in the file
  129750. * as well as the length.
  129751. */
  129752. interface BufferImageData {
  129753. /**
  129754. * Length of the image data.
  129755. */
  129756. length: number;
  129757. /**
  129758. * Position of the data from the null terminator delimiting the end of the JSON.
  129759. */
  129760. position: number;
  129761. }
  129762. /**
  129763. * Defines the specular data enclosed in the file.
  129764. * This corresponds to the version 1 of the data.
  129765. */
  129766. export interface EnvironmentTextureSpecularInfoV1 {
  129767. /**
  129768. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  129769. */
  129770. specularDataPosition?: number;
  129771. /**
  129772. * This contains all the images data needed to reconstruct the cubemap.
  129773. */
  129774. mipmaps: Array<BufferImageData>;
  129775. /**
  129776. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  129777. */
  129778. lodGenerationScale: number;
  129779. }
  129780. /**
  129781. * Sets of helpers addressing the serialization and deserialization of environment texture
  129782. * stored in a BabylonJS env file.
  129783. * Those files are usually stored as .env files.
  129784. */
  129785. export class EnvironmentTextureTools {
  129786. /**
  129787. * Magic number identifying the env file.
  129788. */
  129789. private static _MagicBytes;
  129790. /**
  129791. * Gets the environment info from an env file.
  129792. * @param data The array buffer containing the .env bytes.
  129793. * @returns the environment file info (the json header) if successfully parsed.
  129794. */
  129795. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  129796. /**
  129797. * Creates an environment texture from a loaded cube texture.
  129798. * @param texture defines the cube texture to convert in env file
  129799. * @return a promise containing the environment data if succesfull.
  129800. */
  129801. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  129802. /**
  129803. * Creates a JSON representation of the spherical data.
  129804. * @param texture defines the texture containing the polynomials
  129805. * @return the JSON representation of the spherical info
  129806. */
  129807. private static _CreateEnvTextureIrradiance;
  129808. /**
  129809. * Creates the ArrayBufferViews used for initializing environment texture image data.
  129810. * @param data the image data
  129811. * @param info parameters that determine what views will be created for accessing the underlying buffer
  129812. * @return the views described by info providing access to the underlying buffer
  129813. */
  129814. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  129815. /**
  129816. * Uploads the texture info contained in the env file to the GPU.
  129817. * @param texture defines the internal texture to upload to
  129818. * @param data defines the data to load
  129819. * @param info defines the texture info retrieved through the GetEnvInfo method
  129820. * @returns a promise
  129821. */
  129822. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  129823. private static _OnImageReadyAsync;
  129824. /**
  129825. * Uploads the levels of image data to the GPU.
  129826. * @param texture defines the internal texture to upload to
  129827. * @param imageData defines the array buffer views of image data [mipmap][face]
  129828. * @returns a promise
  129829. */
  129830. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  129831. /**
  129832. * Uploads spherical polynomials information to the texture.
  129833. * @param texture defines the texture we are trying to upload the information to
  129834. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  129835. */
  129836. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  129837. /** @hidden */
  129838. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129839. }
  129840. }
  129841. declare module BABYLON {
  129842. /**
  129843. * Class used to inline functions in shader code
  129844. */
  129845. export class ShaderCodeInliner {
  129846. private static readonly _RegexpFindFunctionNameAndType;
  129847. private _sourceCode;
  129848. private _functionDescr;
  129849. private _numMaxIterations;
  129850. /** Gets or sets the token used to mark the functions to inline */
  129851. inlineToken: string;
  129852. /** Gets or sets the debug mode */
  129853. debug: boolean;
  129854. /** Gets the code after the inlining process */
  129855. get code(): string;
  129856. /**
  129857. * Initializes the inliner
  129858. * @param sourceCode shader code source to inline
  129859. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  129860. */
  129861. constructor(sourceCode: string, numMaxIterations?: number);
  129862. /**
  129863. * Start the processing of the shader code
  129864. */
  129865. processCode(): void;
  129866. private _collectFunctions;
  129867. private _processInlining;
  129868. private _extractBetweenMarkers;
  129869. private _skipWhitespaces;
  129870. private _removeComments;
  129871. private _replaceFunctionCallsByCode;
  129872. private _findBackward;
  129873. private _escapeRegExp;
  129874. private _replaceNames;
  129875. }
  129876. }
  129877. declare module BABYLON {
  129878. /**
  129879. * Container for accessors for natively-stored mesh data buffers.
  129880. */
  129881. class NativeDataBuffer extends DataBuffer {
  129882. /**
  129883. * Accessor value used to identify/retrieve a natively-stored index buffer.
  129884. */
  129885. nativeIndexBuffer?: any;
  129886. /**
  129887. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  129888. */
  129889. nativeVertexBuffer?: any;
  129890. }
  129891. /** @hidden */
  129892. class NativeTexture extends InternalTexture {
  129893. getInternalTexture(): InternalTexture;
  129894. getViewCount(): number;
  129895. }
  129896. /** @hidden */
  129897. export class NativeEngine extends Engine {
  129898. private readonly _native;
  129899. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  129900. private readonly INVALID_HANDLE;
  129901. getHardwareScalingLevel(): number;
  129902. constructor();
  129903. dispose(): void;
  129904. /**
  129905. * Can be used to override the current requestAnimationFrame requester.
  129906. * @hidden
  129907. */
  129908. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  129909. /**
  129910. * Override default engine behavior.
  129911. * @param color
  129912. * @param backBuffer
  129913. * @param depth
  129914. * @param stencil
  129915. */
  129916. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  129917. /**
  129918. * Gets host document
  129919. * @returns the host document object
  129920. */
  129921. getHostDocument(): Nullable<Document>;
  129922. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129923. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  129924. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  129925. recordVertexArrayObject(vertexBuffers: {
  129926. [key: string]: VertexBuffer;
  129927. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  129928. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129929. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129930. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129931. /**
  129932. * Draw a list of indexed primitives
  129933. * @param fillMode defines the primitive to use
  129934. * @param indexStart defines the starting index
  129935. * @param indexCount defines the number of index to draw
  129936. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129937. */
  129938. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129939. /**
  129940. * Draw a list of unindexed primitives
  129941. * @param fillMode defines the primitive to use
  129942. * @param verticesStart defines the index of first vertex to draw
  129943. * @param verticesCount defines the count of vertices to draw
  129944. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129945. */
  129946. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129947. createPipelineContext(): IPipelineContext;
  129948. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  129949. /** @hidden */
  129950. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  129951. /** @hidden */
  129952. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  129953. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129954. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129955. protected _setProgram(program: WebGLProgram): void;
  129956. _releaseEffect(effect: Effect): void;
  129957. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  129958. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  129959. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  129960. bindSamplers(effect: Effect): void;
  129961. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  129962. getRenderWidth(useScreen?: boolean): number;
  129963. getRenderHeight(useScreen?: boolean): number;
  129964. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  129965. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129966. /**
  129967. * Set the z offset to apply to current rendering
  129968. * @param value defines the offset to apply
  129969. */
  129970. setZOffset(value: number): void;
  129971. /**
  129972. * Gets the current value of the zOffset
  129973. * @returns the current zOffset state
  129974. */
  129975. getZOffset(): number;
  129976. /**
  129977. * Enable or disable depth buffering
  129978. * @param enable defines the state to set
  129979. */
  129980. setDepthBuffer(enable: boolean): void;
  129981. /**
  129982. * Gets a boolean indicating if depth writing is enabled
  129983. * @returns the current depth writing state
  129984. */
  129985. getDepthWrite(): boolean;
  129986. /**
  129987. * Enable or disable depth writing
  129988. * @param enable defines the state to set
  129989. */
  129990. setDepthWrite(enable: boolean): void;
  129991. /**
  129992. * Enable or disable color writing
  129993. * @param enable defines the state to set
  129994. */
  129995. setColorWrite(enable: boolean): void;
  129996. /**
  129997. * Gets a boolean indicating if color writing is enabled
  129998. * @returns the current color writing state
  129999. */
  130000. getColorWrite(): boolean;
  130001. /**
  130002. * Sets alpha constants used by some alpha blending modes
  130003. * @param r defines the red component
  130004. * @param g defines the green component
  130005. * @param b defines the blue component
  130006. * @param a defines the alpha component
  130007. */
  130008. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  130009. /**
  130010. * Sets the current alpha mode
  130011. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  130012. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130013. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130014. */
  130015. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130016. /**
  130017. * Gets the current alpha mode
  130018. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130019. * @returns the current alpha mode
  130020. */
  130021. getAlphaMode(): number;
  130022. setInt(uniform: WebGLUniformLocation, int: number): void;
  130023. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130024. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130025. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130026. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130027. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130028. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130029. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130030. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130031. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130032. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130033. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130034. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130035. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130036. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130037. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130038. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130039. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130040. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130041. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130042. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  130043. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  130044. wipeCaches(bruteForce?: boolean): void;
  130045. _createTexture(): WebGLTexture;
  130046. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  130047. /**
  130048. * Usually called from Texture.ts.
  130049. * Passed information to create a WebGLTexture
  130050. * @param url defines a value which contains one of the following:
  130051. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130052. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130053. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130054. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130055. * @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)
  130056. * @param scene needed for loading to the correct scene
  130057. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130058. * @param onLoad optional callback to be called upon successful completion
  130059. * @param onError optional callback to be called upon failure
  130060. * @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
  130061. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130062. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130063. * @param forcedExtension defines the extension to use to pick the right loader
  130064. * @param mimeType defines an optional mime type
  130065. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130066. */
  130067. 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;
  130068. /**
  130069. * Creates a cube texture
  130070. * @param rootUrl defines the url where the files to load is located
  130071. * @param scene defines the current scene
  130072. * @param files defines the list of files to load (1 per face)
  130073. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  130074. * @param onLoad defines an optional callback raised when the texture is loaded
  130075. * @param onError defines an optional callback raised if there is an issue to load the texture
  130076. * @param format defines the format of the data
  130077. * @param forcedExtension defines the extension to use to pick the right loader
  130078. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  130079. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  130080. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  130081. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  130082. * @returns the cube texture as an InternalTexture
  130083. */
  130084. 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;
  130085. private _getSamplingFilter;
  130086. private static _GetNativeTextureFormat;
  130087. createRenderTargetTexture(size: number | {
  130088. width: number;
  130089. height: number;
  130090. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  130091. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130092. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130093. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130094. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  130095. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  130096. /**
  130097. * Updates a dynamic vertex buffer.
  130098. * @param vertexBuffer the vertex buffer to update
  130099. * @param data the data used to update the vertex buffer
  130100. * @param byteOffset the byte offset of the data (optional)
  130101. * @param byteLength the byte length of the data (optional)
  130102. */
  130103. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  130104. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  130105. private _updateAnisotropicLevel;
  130106. private _getAddressMode;
  130107. /** @hidden */
  130108. _bindTexture(channel: number, texture: InternalTexture): void;
  130109. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  130110. releaseEffects(): void;
  130111. /** @hidden */
  130112. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130113. /** @hidden */
  130114. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130115. /** @hidden */
  130116. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130117. /** @hidden */
  130118. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130119. }
  130120. }
  130121. declare module BABYLON {
  130122. /**
  130123. * Gather the list of clipboard event types as constants.
  130124. */
  130125. export class ClipboardEventTypes {
  130126. /**
  130127. * The clipboard event is fired when a copy command is active (pressed).
  130128. */
  130129. static readonly COPY: number;
  130130. /**
  130131. * The clipboard event is fired when a cut command is active (pressed).
  130132. */
  130133. static readonly CUT: number;
  130134. /**
  130135. * The clipboard event is fired when a paste command is active (pressed).
  130136. */
  130137. static readonly PASTE: number;
  130138. }
  130139. /**
  130140. * This class is used to store clipboard related info for the onClipboardObservable event.
  130141. */
  130142. export class ClipboardInfo {
  130143. /**
  130144. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130145. */
  130146. type: number;
  130147. /**
  130148. * Defines the related dom event
  130149. */
  130150. event: ClipboardEvent;
  130151. /**
  130152. *Creates an instance of ClipboardInfo.
  130153. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  130154. * @param event Defines the related dom event
  130155. */
  130156. constructor(
  130157. /**
  130158. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130159. */
  130160. type: number,
  130161. /**
  130162. * Defines the related dom event
  130163. */
  130164. event: ClipboardEvent);
  130165. /**
  130166. * Get the clipboard event's type from the keycode.
  130167. * @param keyCode Defines the keyCode for the current keyboard event.
  130168. * @return {number}
  130169. */
  130170. static GetTypeFromCharacter(keyCode: number): number;
  130171. }
  130172. }
  130173. declare module BABYLON {
  130174. /**
  130175. * Google Daydream controller
  130176. */
  130177. export class DaydreamController extends WebVRController {
  130178. /**
  130179. * Base Url for the controller model.
  130180. */
  130181. static MODEL_BASE_URL: string;
  130182. /**
  130183. * File name for the controller model.
  130184. */
  130185. static MODEL_FILENAME: string;
  130186. /**
  130187. * Gamepad Id prefix used to identify Daydream Controller.
  130188. */
  130189. static readonly GAMEPAD_ID_PREFIX: string;
  130190. /**
  130191. * Creates a new DaydreamController from a gamepad
  130192. * @param vrGamepad the gamepad that the controller should be created from
  130193. */
  130194. constructor(vrGamepad: any);
  130195. /**
  130196. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130197. * @param scene scene in which to add meshes
  130198. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130199. */
  130200. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130201. /**
  130202. * Called once for each button that changed state since the last frame
  130203. * @param buttonIdx Which button index changed
  130204. * @param state New state of the button
  130205. * @param changes Which properties on the state changed since last frame
  130206. */
  130207. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130208. }
  130209. }
  130210. declare module BABYLON {
  130211. /**
  130212. * Gear VR Controller
  130213. */
  130214. export class GearVRController extends WebVRController {
  130215. /**
  130216. * Base Url for the controller model.
  130217. */
  130218. static MODEL_BASE_URL: string;
  130219. /**
  130220. * File name for the controller model.
  130221. */
  130222. static MODEL_FILENAME: string;
  130223. /**
  130224. * Gamepad Id prefix used to identify this controller.
  130225. */
  130226. static readonly GAMEPAD_ID_PREFIX: string;
  130227. private readonly _buttonIndexToObservableNameMap;
  130228. /**
  130229. * Creates a new GearVRController from a gamepad
  130230. * @param vrGamepad the gamepad that the controller should be created from
  130231. */
  130232. constructor(vrGamepad: any);
  130233. /**
  130234. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130235. * @param scene scene in which to add meshes
  130236. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130237. */
  130238. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130239. /**
  130240. * Called once for each button that changed state since the last frame
  130241. * @param buttonIdx Which button index changed
  130242. * @param state New state of the button
  130243. * @param changes Which properties on the state changed since last frame
  130244. */
  130245. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130246. }
  130247. }
  130248. declare module BABYLON {
  130249. /**
  130250. * Generic Controller
  130251. */
  130252. export class GenericController extends WebVRController {
  130253. /**
  130254. * Base Url for the controller model.
  130255. */
  130256. static readonly MODEL_BASE_URL: string;
  130257. /**
  130258. * File name for the controller model.
  130259. */
  130260. static readonly MODEL_FILENAME: string;
  130261. /**
  130262. * Creates a new GenericController from a gamepad
  130263. * @param vrGamepad the gamepad that the controller should be created from
  130264. */
  130265. constructor(vrGamepad: any);
  130266. /**
  130267. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130268. * @param scene scene in which to add meshes
  130269. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130270. */
  130271. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130272. /**
  130273. * Called once for each button that changed state since the last frame
  130274. * @param buttonIdx Which button index changed
  130275. * @param state New state of the button
  130276. * @param changes Which properties on the state changed since last frame
  130277. */
  130278. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130279. }
  130280. }
  130281. declare module BABYLON {
  130282. /**
  130283. * Oculus Touch Controller
  130284. */
  130285. export class OculusTouchController extends WebVRController {
  130286. /**
  130287. * Base Url for the controller model.
  130288. */
  130289. static MODEL_BASE_URL: string;
  130290. /**
  130291. * File name for the left controller model.
  130292. */
  130293. static MODEL_LEFT_FILENAME: string;
  130294. /**
  130295. * File name for the right controller model.
  130296. */
  130297. static MODEL_RIGHT_FILENAME: string;
  130298. /**
  130299. * Base Url for the Quest controller model.
  130300. */
  130301. static QUEST_MODEL_BASE_URL: string;
  130302. /**
  130303. * @hidden
  130304. * If the controllers are running on a device that needs the updated Quest controller models
  130305. */
  130306. static _IsQuest: boolean;
  130307. /**
  130308. * Fired when the secondary trigger on this controller is modified
  130309. */
  130310. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  130311. /**
  130312. * Fired when the thumb rest on this controller is modified
  130313. */
  130314. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  130315. /**
  130316. * Creates a new OculusTouchController from a gamepad
  130317. * @param vrGamepad the gamepad that the controller should be created from
  130318. */
  130319. constructor(vrGamepad: any);
  130320. /**
  130321. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130322. * @param scene scene in which to add meshes
  130323. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130324. */
  130325. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130326. /**
  130327. * Fired when the A button on this controller is modified
  130328. */
  130329. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130330. /**
  130331. * Fired when the B button on this controller is modified
  130332. */
  130333. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130334. /**
  130335. * Fired when the X button on this controller is modified
  130336. */
  130337. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130338. /**
  130339. * Fired when the Y button on this controller is modified
  130340. */
  130341. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130342. /**
  130343. * Called once for each button that changed state since the last frame
  130344. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  130345. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  130346. * 2) secondary trigger (same)
  130347. * 3) A (right) X (left), touch, pressed = value
  130348. * 4) B / Y
  130349. * 5) thumb rest
  130350. * @param buttonIdx Which button index changed
  130351. * @param state New state of the button
  130352. * @param changes Which properties on the state changed since last frame
  130353. */
  130354. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130355. }
  130356. }
  130357. declare module BABYLON {
  130358. /**
  130359. * Vive Controller
  130360. */
  130361. export class ViveController extends WebVRController {
  130362. /**
  130363. * Base Url for the controller model.
  130364. */
  130365. static MODEL_BASE_URL: string;
  130366. /**
  130367. * File name for the controller model.
  130368. */
  130369. static MODEL_FILENAME: string;
  130370. /**
  130371. * Creates a new ViveController from a gamepad
  130372. * @param vrGamepad the gamepad that the controller should be created from
  130373. */
  130374. constructor(vrGamepad: any);
  130375. /**
  130376. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130377. * @param scene scene in which to add meshes
  130378. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130379. */
  130380. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130381. /**
  130382. * Fired when the left button on this controller is modified
  130383. */
  130384. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130385. /**
  130386. * Fired when the right button on this controller is modified
  130387. */
  130388. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130389. /**
  130390. * Fired when the menu button on this controller is modified
  130391. */
  130392. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130393. /**
  130394. * Called once for each button that changed state since the last frame
  130395. * Vive mapping:
  130396. * 0: touchpad
  130397. * 1: trigger
  130398. * 2: left AND right buttons
  130399. * 3: menu button
  130400. * @param buttonIdx Which button index changed
  130401. * @param state New state of the button
  130402. * @param changes Which properties on the state changed since last frame
  130403. */
  130404. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130405. }
  130406. }
  130407. declare module BABYLON {
  130408. /**
  130409. * Defines the WindowsMotionController object that the state of the windows motion controller
  130410. */
  130411. export class WindowsMotionController extends WebVRController {
  130412. /**
  130413. * The base url used to load the left and right controller models
  130414. */
  130415. static MODEL_BASE_URL: string;
  130416. /**
  130417. * The name of the left controller model file
  130418. */
  130419. static MODEL_LEFT_FILENAME: string;
  130420. /**
  130421. * The name of the right controller model file
  130422. */
  130423. static MODEL_RIGHT_FILENAME: string;
  130424. /**
  130425. * The controller name prefix for this controller type
  130426. */
  130427. static readonly GAMEPAD_ID_PREFIX: string;
  130428. /**
  130429. * The controller id pattern for this controller type
  130430. */
  130431. private static readonly GAMEPAD_ID_PATTERN;
  130432. private _loadedMeshInfo;
  130433. protected readonly _mapping: {
  130434. buttons: string[];
  130435. buttonMeshNames: {
  130436. trigger: string;
  130437. menu: string;
  130438. grip: string;
  130439. thumbstick: string;
  130440. trackpad: string;
  130441. };
  130442. buttonObservableNames: {
  130443. trigger: string;
  130444. menu: string;
  130445. grip: string;
  130446. thumbstick: string;
  130447. trackpad: string;
  130448. };
  130449. axisMeshNames: string[];
  130450. pointingPoseMeshName: string;
  130451. };
  130452. /**
  130453. * Fired when the trackpad on this controller is clicked
  130454. */
  130455. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130456. /**
  130457. * Fired when the trackpad on this controller is modified
  130458. */
  130459. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130460. /**
  130461. * The current x and y values of this controller's trackpad
  130462. */
  130463. trackpad: StickValues;
  130464. /**
  130465. * Creates a new WindowsMotionController from a gamepad
  130466. * @param vrGamepad the gamepad that the controller should be created from
  130467. */
  130468. constructor(vrGamepad: any);
  130469. /**
  130470. * Fired when the trigger on this controller is modified
  130471. */
  130472. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130473. /**
  130474. * Fired when the menu button on this controller is modified
  130475. */
  130476. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130477. /**
  130478. * Fired when the grip button on this controller is modified
  130479. */
  130480. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130481. /**
  130482. * Fired when the thumbstick button on this controller is modified
  130483. */
  130484. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130485. /**
  130486. * Fired when the touchpad button on this controller is modified
  130487. */
  130488. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130489. /**
  130490. * Fired when the touchpad values on this controller are modified
  130491. */
  130492. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  130493. protected _updateTrackpad(): void;
  130494. /**
  130495. * Called once per frame by the engine.
  130496. */
  130497. update(): void;
  130498. /**
  130499. * Called once for each button that changed state since the last frame
  130500. * @param buttonIdx Which button index changed
  130501. * @param state New state of the button
  130502. * @param changes Which properties on the state changed since last frame
  130503. */
  130504. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130505. /**
  130506. * Moves the buttons on the controller mesh based on their current state
  130507. * @param buttonName the name of the button to move
  130508. * @param buttonValue the value of the button which determines the buttons new position
  130509. */
  130510. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  130511. /**
  130512. * Moves the axis on the controller mesh based on its current state
  130513. * @param axis the index of the axis
  130514. * @param axisValue the value of the axis which determines the meshes new position
  130515. * @hidden
  130516. */
  130517. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  130518. /**
  130519. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130520. * @param scene scene in which to add meshes
  130521. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130522. */
  130523. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  130524. /**
  130525. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  130526. * can be transformed by button presses and axes values, based on this._mapping.
  130527. *
  130528. * @param scene scene in which the meshes exist
  130529. * @param meshes list of meshes that make up the controller model to process
  130530. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  130531. */
  130532. private processModel;
  130533. private createMeshInfo;
  130534. /**
  130535. * Gets the ray of the controller in the direction the controller is pointing
  130536. * @param length the length the resulting ray should be
  130537. * @returns a ray in the direction the controller is pointing
  130538. */
  130539. getForwardRay(length?: number): Ray;
  130540. /**
  130541. * Disposes of the controller
  130542. */
  130543. dispose(): void;
  130544. }
  130545. /**
  130546. * This class represents a new windows motion controller in XR.
  130547. */
  130548. export class XRWindowsMotionController extends WindowsMotionController {
  130549. /**
  130550. * Changing the original WIndowsMotionController mapping to fir the new mapping
  130551. */
  130552. protected readonly _mapping: {
  130553. buttons: string[];
  130554. buttonMeshNames: {
  130555. trigger: string;
  130556. menu: string;
  130557. grip: string;
  130558. thumbstick: string;
  130559. trackpad: string;
  130560. };
  130561. buttonObservableNames: {
  130562. trigger: string;
  130563. menu: string;
  130564. grip: string;
  130565. thumbstick: string;
  130566. trackpad: string;
  130567. };
  130568. axisMeshNames: string[];
  130569. pointingPoseMeshName: string;
  130570. };
  130571. /**
  130572. * Construct a new XR-Based windows motion controller
  130573. *
  130574. * @param gamepadInfo the gamepad object from the browser
  130575. */
  130576. constructor(gamepadInfo: any);
  130577. /**
  130578. * holds the thumbstick values (X,Y)
  130579. */
  130580. thumbstickValues: StickValues;
  130581. /**
  130582. * Fired when the thumbstick on this controller is clicked
  130583. */
  130584. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  130585. /**
  130586. * Fired when the thumbstick on this controller is modified
  130587. */
  130588. onThumbstickValuesChangedObservable: Observable<StickValues>;
  130589. /**
  130590. * Fired when the touchpad button on this controller is modified
  130591. */
  130592. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130593. /**
  130594. * Fired when the touchpad values on this controller are modified
  130595. */
  130596. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130597. /**
  130598. * Fired when the thumbstick button on this controller is modified
  130599. * here to prevent breaking changes
  130600. */
  130601. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130602. /**
  130603. * updating the thumbstick(!) and not the trackpad.
  130604. * This is named this way due to the difference between WebVR and XR and to avoid
  130605. * changing the parent class.
  130606. */
  130607. protected _updateTrackpad(): void;
  130608. /**
  130609. * Disposes the class with joy
  130610. */
  130611. dispose(): void;
  130612. }
  130613. }
  130614. declare module BABYLON {
  130615. /**
  130616. * Class containing static functions to help procedurally build meshes
  130617. */
  130618. export class PolyhedronBuilder {
  130619. /**
  130620. * Creates a polyhedron mesh
  130621. * * 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
  130622. * * The parameter `size` (positive float, default 1) sets the polygon size
  130623. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130624. * * 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`
  130625. * * 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
  130626. * * 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)`)
  130627. * * 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
  130628. * * 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
  130629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130632. * @param name defines the name of the mesh
  130633. * @param options defines the options used to create the mesh
  130634. * @param scene defines the hosting scene
  130635. * @returns the polyhedron mesh
  130636. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130637. */
  130638. static CreatePolyhedron(name: string, options: {
  130639. type?: number;
  130640. size?: number;
  130641. sizeX?: number;
  130642. sizeY?: number;
  130643. sizeZ?: number;
  130644. custom?: any;
  130645. faceUV?: Vector4[];
  130646. faceColors?: Color4[];
  130647. flat?: boolean;
  130648. updatable?: boolean;
  130649. sideOrientation?: number;
  130650. frontUVs?: Vector4;
  130651. backUVs?: Vector4;
  130652. }, scene?: Nullable<Scene>): Mesh;
  130653. }
  130654. }
  130655. declare module BABYLON {
  130656. /**
  130657. * Gizmo that enables scaling a mesh along 3 axis
  130658. */
  130659. export class ScaleGizmo extends Gizmo {
  130660. /**
  130661. * Internal gizmo used for interactions on the x axis
  130662. */
  130663. xGizmo: AxisScaleGizmo;
  130664. /**
  130665. * Internal gizmo used for interactions on the y axis
  130666. */
  130667. yGizmo: AxisScaleGizmo;
  130668. /**
  130669. * Internal gizmo used for interactions on the z axis
  130670. */
  130671. zGizmo: AxisScaleGizmo;
  130672. /**
  130673. * Internal gizmo used to scale all axis equally
  130674. */
  130675. uniformScaleGizmo: AxisScaleGizmo;
  130676. private _meshAttached;
  130677. private _updateGizmoRotationToMatchAttachedMesh;
  130678. private _snapDistance;
  130679. private _scaleRatio;
  130680. private _uniformScalingMesh;
  130681. private _octahedron;
  130682. private _sensitivity;
  130683. /** Fires an event when any of it's sub gizmos are dragged */
  130684. onDragStartObservable: Observable<unknown>;
  130685. /** Fires an event when any of it's sub gizmos are released from dragging */
  130686. onDragEndObservable: Observable<unknown>;
  130687. get attachedMesh(): Nullable<AbstractMesh>;
  130688. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130689. /**
  130690. * Creates a ScaleGizmo
  130691. * @param gizmoLayer The utility layer the gizmo will be added to
  130692. */
  130693. constructor(gizmoLayer?: UtilityLayerRenderer);
  130694. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130695. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130696. /**
  130697. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130698. */
  130699. set snapDistance(value: number);
  130700. get snapDistance(): number;
  130701. /**
  130702. * Ratio for the scale of the gizmo (Default: 1)
  130703. */
  130704. set scaleRatio(value: number);
  130705. get scaleRatio(): number;
  130706. /**
  130707. * Sensitivity factor for dragging (Default: 1)
  130708. */
  130709. set sensitivity(value: number);
  130710. get sensitivity(): number;
  130711. /**
  130712. * Disposes of the gizmo
  130713. */
  130714. dispose(): void;
  130715. }
  130716. }
  130717. declare module BABYLON {
  130718. /**
  130719. * Single axis scale gizmo
  130720. */
  130721. export class AxisScaleGizmo extends Gizmo {
  130722. /**
  130723. * Drag behavior responsible for the gizmos dragging interactions
  130724. */
  130725. dragBehavior: PointerDragBehavior;
  130726. private _pointerObserver;
  130727. /**
  130728. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130729. */
  130730. snapDistance: number;
  130731. /**
  130732. * Event that fires each time the gizmo snaps to a new location.
  130733. * * snapDistance is the the change in distance
  130734. */
  130735. onSnapObservable: Observable<{
  130736. snapDistance: number;
  130737. }>;
  130738. /**
  130739. * If the scaling operation should be done on all axis (default: false)
  130740. */
  130741. uniformScaling: boolean;
  130742. /**
  130743. * Custom sensitivity value for the drag strength
  130744. */
  130745. sensitivity: number;
  130746. private _isEnabled;
  130747. private _parent;
  130748. private _arrow;
  130749. private _coloredMaterial;
  130750. private _hoverMaterial;
  130751. /**
  130752. * Creates an AxisScaleGizmo
  130753. * @param gizmoLayer The utility layer the gizmo will be added to
  130754. * @param dragAxis The axis which the gizmo will be able to scale on
  130755. * @param color The color of the gizmo
  130756. */
  130757. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  130758. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130759. /**
  130760. * If the gizmo is enabled
  130761. */
  130762. set isEnabled(value: boolean);
  130763. get isEnabled(): boolean;
  130764. /**
  130765. * Disposes of the gizmo
  130766. */
  130767. dispose(): void;
  130768. /**
  130769. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130770. * @param mesh The mesh to replace the default mesh of the gizmo
  130771. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  130772. */
  130773. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  130774. }
  130775. }
  130776. declare module BABYLON {
  130777. /**
  130778. * Bounding box gizmo
  130779. */
  130780. export class BoundingBoxGizmo extends Gizmo {
  130781. private _lineBoundingBox;
  130782. private _rotateSpheresParent;
  130783. private _scaleBoxesParent;
  130784. private _boundingDimensions;
  130785. private _renderObserver;
  130786. private _pointerObserver;
  130787. private _scaleDragSpeed;
  130788. private _tmpQuaternion;
  130789. private _tmpVector;
  130790. private _tmpRotationMatrix;
  130791. /**
  130792. * 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)
  130793. */
  130794. ignoreChildren: boolean;
  130795. /**
  130796. * 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)
  130797. */
  130798. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  130799. /**
  130800. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  130801. */
  130802. rotationSphereSize: number;
  130803. /**
  130804. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  130805. */
  130806. scaleBoxSize: number;
  130807. /**
  130808. * 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)
  130809. */
  130810. fixedDragMeshScreenSize: boolean;
  130811. /**
  130812. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  130813. */
  130814. fixedDragMeshScreenSizeDistanceFactor: number;
  130815. /**
  130816. * Fired when a rotation sphere or scale box is dragged
  130817. */
  130818. onDragStartObservable: Observable<{}>;
  130819. /**
  130820. * Fired when a scale box is dragged
  130821. */
  130822. onScaleBoxDragObservable: Observable<{}>;
  130823. /**
  130824. * Fired when a scale box drag is ended
  130825. */
  130826. onScaleBoxDragEndObservable: Observable<{}>;
  130827. /**
  130828. * Fired when a rotation sphere is dragged
  130829. */
  130830. onRotationSphereDragObservable: Observable<{}>;
  130831. /**
  130832. * Fired when a rotation sphere drag is ended
  130833. */
  130834. onRotationSphereDragEndObservable: Observable<{}>;
  130835. /**
  130836. * Relative bounding box pivot used when scaling the attached mesh. 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)
  130837. */
  130838. scalePivot: Nullable<Vector3>;
  130839. /**
  130840. * Mesh used as a pivot to rotate the attached mesh
  130841. */
  130842. private _anchorMesh;
  130843. private _existingMeshScale;
  130844. private _dragMesh;
  130845. private pointerDragBehavior;
  130846. private coloredMaterial;
  130847. private hoverColoredMaterial;
  130848. /**
  130849. * Sets the color of the bounding box gizmo
  130850. * @param color the color to set
  130851. */
  130852. setColor(color: Color3): void;
  130853. /**
  130854. * Creates an BoundingBoxGizmo
  130855. * @param gizmoLayer The utility layer the gizmo will be added to
  130856. * @param color The color of the gizmo
  130857. */
  130858. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  130859. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130860. private _selectNode;
  130861. /**
  130862. * Updates the bounding box information for the Gizmo
  130863. */
  130864. updateBoundingBox(): void;
  130865. private _updateRotationSpheres;
  130866. private _updateScaleBoxes;
  130867. /**
  130868. * Enables rotation on the specified axis and disables rotation on the others
  130869. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  130870. */
  130871. setEnabledRotationAxis(axis: string): void;
  130872. /**
  130873. * Enables/disables scaling
  130874. * @param enable if scaling should be enabled
  130875. * @param homogeneousScaling defines if scaling should only be homogeneous
  130876. */
  130877. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  130878. private _updateDummy;
  130879. /**
  130880. * Enables a pointer drag behavior on the bounding box of the gizmo
  130881. */
  130882. enableDragBehavior(): void;
  130883. /**
  130884. * Disposes of the gizmo
  130885. */
  130886. dispose(): void;
  130887. /**
  130888. * 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)
  130889. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  130890. * @returns the bounding box mesh with the passed in mesh as a child
  130891. */
  130892. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  130893. /**
  130894. * CustomMeshes are not supported by this gizmo
  130895. * @param mesh The mesh to replace the default mesh of the gizmo
  130896. */
  130897. setCustomMesh(mesh: Mesh): void;
  130898. }
  130899. }
  130900. declare module BABYLON {
  130901. /**
  130902. * Single plane rotation gizmo
  130903. */
  130904. export class PlaneRotationGizmo extends Gizmo {
  130905. /**
  130906. * Drag behavior responsible for the gizmos dragging interactions
  130907. */
  130908. dragBehavior: PointerDragBehavior;
  130909. private _pointerObserver;
  130910. /**
  130911. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  130912. */
  130913. snapDistance: number;
  130914. /**
  130915. * Event that fires each time the gizmo snaps to a new location.
  130916. * * snapDistance is the the change in distance
  130917. */
  130918. onSnapObservable: Observable<{
  130919. snapDistance: number;
  130920. }>;
  130921. private _isEnabled;
  130922. private _parent;
  130923. /**
  130924. * Creates a PlaneRotationGizmo
  130925. * @param gizmoLayer The utility layer the gizmo will be added to
  130926. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  130927. * @param color The color of the gizmo
  130928. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130929. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130930. */
  130931. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  130932. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130933. /**
  130934. * If the gizmo is enabled
  130935. */
  130936. set isEnabled(value: boolean);
  130937. get isEnabled(): boolean;
  130938. /**
  130939. * Disposes of the gizmo
  130940. */
  130941. dispose(): void;
  130942. }
  130943. }
  130944. declare module BABYLON {
  130945. /**
  130946. * Gizmo that enables rotating a mesh along 3 axis
  130947. */
  130948. export class RotationGizmo extends Gizmo {
  130949. /**
  130950. * Internal gizmo used for interactions on the x axis
  130951. */
  130952. xGizmo: PlaneRotationGizmo;
  130953. /**
  130954. * Internal gizmo used for interactions on the y axis
  130955. */
  130956. yGizmo: PlaneRotationGizmo;
  130957. /**
  130958. * Internal gizmo used for interactions on the z axis
  130959. */
  130960. zGizmo: PlaneRotationGizmo;
  130961. /** Fires an event when any of it's sub gizmos are dragged */
  130962. onDragStartObservable: Observable<unknown>;
  130963. /** Fires an event when any of it's sub gizmos are released from dragging */
  130964. onDragEndObservable: Observable<unknown>;
  130965. private _meshAttached;
  130966. get attachedMesh(): Nullable<AbstractMesh>;
  130967. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130968. /**
  130969. * Creates a RotationGizmo
  130970. * @param gizmoLayer The utility layer the gizmo will be added to
  130971. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130972. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130973. */
  130974. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  130975. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130976. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130977. /**
  130978. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130979. */
  130980. set snapDistance(value: number);
  130981. get snapDistance(): number;
  130982. /**
  130983. * Ratio for the scale of the gizmo (Default: 1)
  130984. */
  130985. set scaleRatio(value: number);
  130986. get scaleRatio(): number;
  130987. /**
  130988. * Disposes of the gizmo
  130989. */
  130990. dispose(): void;
  130991. /**
  130992. * CustomMeshes are not supported by this gizmo
  130993. * @param mesh The mesh to replace the default mesh of the gizmo
  130994. */
  130995. setCustomMesh(mesh: Mesh): void;
  130996. }
  130997. }
  130998. declare module BABYLON {
  130999. /**
  131000. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  131001. */
  131002. export class GizmoManager implements IDisposable {
  131003. private scene;
  131004. /**
  131005. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  131006. */
  131007. gizmos: {
  131008. positionGizmo: Nullable<PositionGizmo>;
  131009. rotationGizmo: Nullable<RotationGizmo>;
  131010. scaleGizmo: Nullable<ScaleGizmo>;
  131011. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  131012. };
  131013. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  131014. clearGizmoOnEmptyPointerEvent: boolean;
  131015. /** Fires an event when the manager is attached to a mesh */
  131016. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  131017. private _gizmosEnabled;
  131018. private _pointerObserver;
  131019. private _attachedMesh;
  131020. private _boundingBoxColor;
  131021. private _defaultUtilityLayer;
  131022. private _defaultKeepDepthUtilityLayer;
  131023. /**
  131024. * When bounding box gizmo is enabled, this can be used to track drag/end events
  131025. */
  131026. boundingBoxDragBehavior: SixDofDragBehavior;
  131027. /**
  131028. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  131029. */
  131030. attachableMeshes: Nullable<Array<AbstractMesh>>;
  131031. /**
  131032. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  131033. */
  131034. usePointerToAttachGizmos: boolean;
  131035. /**
  131036. * Utility layer that the bounding box gizmo belongs to
  131037. */
  131038. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  131039. /**
  131040. * Utility layer that all gizmos besides bounding box belong to
  131041. */
  131042. get utilityLayer(): UtilityLayerRenderer;
  131043. /**
  131044. * Instatiates a gizmo manager
  131045. * @param scene the scene to overlay the gizmos on top of
  131046. */
  131047. constructor(scene: Scene);
  131048. /**
  131049. * Attaches a set of gizmos to the specified mesh
  131050. * @param mesh The mesh the gizmo's should be attached to
  131051. */
  131052. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  131053. /**
  131054. * If the position gizmo is enabled
  131055. */
  131056. set positionGizmoEnabled(value: boolean);
  131057. get positionGizmoEnabled(): boolean;
  131058. /**
  131059. * If the rotation gizmo is enabled
  131060. */
  131061. set rotationGizmoEnabled(value: boolean);
  131062. get rotationGizmoEnabled(): boolean;
  131063. /**
  131064. * If the scale gizmo is enabled
  131065. */
  131066. set scaleGizmoEnabled(value: boolean);
  131067. get scaleGizmoEnabled(): boolean;
  131068. /**
  131069. * If the boundingBox gizmo is enabled
  131070. */
  131071. set boundingBoxGizmoEnabled(value: boolean);
  131072. get boundingBoxGizmoEnabled(): boolean;
  131073. /**
  131074. * Disposes of the gizmo manager
  131075. */
  131076. dispose(): void;
  131077. }
  131078. }
  131079. declare module BABYLON {
  131080. /**
  131081. * A directional light is defined by a direction (what a surprise!).
  131082. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  131083. * 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.
  131084. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131085. */
  131086. export class DirectionalLight extends ShadowLight {
  131087. private _shadowFrustumSize;
  131088. /**
  131089. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  131090. */
  131091. get shadowFrustumSize(): number;
  131092. /**
  131093. * Specifies a fix frustum size for the shadow generation.
  131094. */
  131095. set shadowFrustumSize(value: number);
  131096. private _shadowOrthoScale;
  131097. /**
  131098. * Gets the shadow projection scale against the optimal computed one.
  131099. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131100. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131101. */
  131102. get shadowOrthoScale(): number;
  131103. /**
  131104. * Sets the shadow projection scale against the optimal computed one.
  131105. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131106. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131107. */
  131108. set shadowOrthoScale(value: number);
  131109. /**
  131110. * Automatically compute the projection matrix to best fit (including all the casters)
  131111. * on each frame.
  131112. */
  131113. autoUpdateExtends: boolean;
  131114. /**
  131115. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  131116. * on each frame. autoUpdateExtends must be set to true for this to work
  131117. */
  131118. autoCalcShadowZBounds: boolean;
  131119. private _orthoLeft;
  131120. private _orthoRight;
  131121. private _orthoTop;
  131122. private _orthoBottom;
  131123. /**
  131124. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  131125. * The directional light is emitted from everywhere in the given direction.
  131126. * It can cast shadows.
  131127. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131128. * @param name The friendly name of the light
  131129. * @param direction The direction of the light
  131130. * @param scene The scene the light belongs to
  131131. */
  131132. constructor(name: string, direction: Vector3, scene: Scene);
  131133. /**
  131134. * Returns the string "DirectionalLight".
  131135. * @return The class name
  131136. */
  131137. getClassName(): string;
  131138. /**
  131139. * Returns the integer 1.
  131140. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131141. */
  131142. getTypeID(): number;
  131143. /**
  131144. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  131145. * Returns the DirectionalLight Shadow projection matrix.
  131146. */
  131147. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131148. /**
  131149. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  131150. * Returns the DirectionalLight Shadow projection matrix.
  131151. */
  131152. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  131153. /**
  131154. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  131155. * Returns the DirectionalLight Shadow projection matrix.
  131156. */
  131157. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131158. protected _buildUniformLayout(): void;
  131159. /**
  131160. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  131161. * @param effect The effect to update
  131162. * @param lightIndex The index of the light in the effect to update
  131163. * @returns The directional light
  131164. */
  131165. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  131166. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  131167. /**
  131168. * Gets the minZ used for shadow according to both the scene and the light.
  131169. *
  131170. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131171. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131172. * @param activeCamera The camera we are returning the min for
  131173. * @returns the depth min z
  131174. */
  131175. getDepthMinZ(activeCamera: Camera): number;
  131176. /**
  131177. * Gets the maxZ used for shadow according to both the scene and the light.
  131178. *
  131179. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131180. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131181. * @param activeCamera The camera we are returning the max for
  131182. * @returns the depth max z
  131183. */
  131184. getDepthMaxZ(activeCamera: Camera): number;
  131185. /**
  131186. * Prepares the list of defines specific to the light type.
  131187. * @param defines the list of defines
  131188. * @param lightIndex defines the index of the light for the effect
  131189. */
  131190. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131191. }
  131192. }
  131193. declare module BABYLON {
  131194. /**
  131195. * Class containing static functions to help procedurally build meshes
  131196. */
  131197. export class HemisphereBuilder {
  131198. /**
  131199. * Creates a hemisphere mesh
  131200. * @param name defines the name of the mesh
  131201. * @param options defines the options used to create the mesh
  131202. * @param scene defines the hosting scene
  131203. * @returns the hemisphere mesh
  131204. */
  131205. static CreateHemisphere(name: string, options: {
  131206. segments?: number;
  131207. diameter?: number;
  131208. sideOrientation?: number;
  131209. }, scene: any): Mesh;
  131210. }
  131211. }
  131212. declare module BABYLON {
  131213. /**
  131214. * A spot light is defined by a position, a direction, an angle, and an exponent.
  131215. * These values define a cone of light starting from the position, emitting toward the direction.
  131216. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  131217. * and the exponent defines the speed of the decay of the light with distance (reach).
  131218. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131219. */
  131220. export class SpotLight extends ShadowLight {
  131221. private _angle;
  131222. private _innerAngle;
  131223. private _cosHalfAngle;
  131224. private _lightAngleScale;
  131225. private _lightAngleOffset;
  131226. /**
  131227. * Gets the cone angle of the spot light in Radians.
  131228. */
  131229. get angle(): number;
  131230. /**
  131231. * Sets the cone angle of the spot light in Radians.
  131232. */
  131233. set angle(value: number);
  131234. /**
  131235. * Only used in gltf falloff mode, this defines the angle where
  131236. * the directional falloff will start before cutting at angle which could be seen
  131237. * as outer angle.
  131238. */
  131239. get innerAngle(): number;
  131240. /**
  131241. * Only used in gltf falloff mode, this defines the angle where
  131242. * the directional falloff will start before cutting at angle which could be seen
  131243. * as outer angle.
  131244. */
  131245. set innerAngle(value: number);
  131246. private _shadowAngleScale;
  131247. /**
  131248. * Allows scaling the angle of the light for shadow generation only.
  131249. */
  131250. get shadowAngleScale(): number;
  131251. /**
  131252. * Allows scaling the angle of the light for shadow generation only.
  131253. */
  131254. set shadowAngleScale(value: number);
  131255. /**
  131256. * The light decay speed with the distance from the emission spot.
  131257. */
  131258. exponent: number;
  131259. private _projectionTextureMatrix;
  131260. /**
  131261. * Allows reading the projecton texture
  131262. */
  131263. get projectionTextureMatrix(): Matrix;
  131264. protected _projectionTextureLightNear: number;
  131265. /**
  131266. * Gets the near clip of the Spotlight for texture projection.
  131267. */
  131268. get projectionTextureLightNear(): number;
  131269. /**
  131270. * Sets the near clip of the Spotlight for texture projection.
  131271. */
  131272. set projectionTextureLightNear(value: number);
  131273. protected _projectionTextureLightFar: number;
  131274. /**
  131275. * Gets the far clip of the Spotlight for texture projection.
  131276. */
  131277. get projectionTextureLightFar(): number;
  131278. /**
  131279. * Sets the far clip of the Spotlight for texture projection.
  131280. */
  131281. set projectionTextureLightFar(value: number);
  131282. protected _projectionTextureUpDirection: Vector3;
  131283. /**
  131284. * Gets the Up vector of the Spotlight for texture projection.
  131285. */
  131286. get projectionTextureUpDirection(): Vector3;
  131287. /**
  131288. * Sets the Up vector of the Spotlight for texture projection.
  131289. */
  131290. set projectionTextureUpDirection(value: Vector3);
  131291. private _projectionTexture;
  131292. /**
  131293. * Gets the projection texture of the light.
  131294. */
  131295. get projectionTexture(): Nullable<BaseTexture>;
  131296. /**
  131297. * Sets the projection texture of the light.
  131298. */
  131299. set projectionTexture(value: Nullable<BaseTexture>);
  131300. private _projectionTextureViewLightDirty;
  131301. private _projectionTextureProjectionLightDirty;
  131302. private _projectionTextureDirty;
  131303. private _projectionTextureViewTargetVector;
  131304. private _projectionTextureViewLightMatrix;
  131305. private _projectionTextureProjectionLightMatrix;
  131306. private _projectionTextureScalingMatrix;
  131307. /**
  131308. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  131309. * It can cast shadows.
  131310. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131311. * @param name The light friendly name
  131312. * @param position The position of the spot light in the scene
  131313. * @param direction The direction of the light in the scene
  131314. * @param angle The cone angle of the light in Radians
  131315. * @param exponent The light decay speed with the distance from the emission spot
  131316. * @param scene The scene the lights belongs to
  131317. */
  131318. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  131319. /**
  131320. * Returns the string "SpotLight".
  131321. * @returns the class name
  131322. */
  131323. getClassName(): string;
  131324. /**
  131325. * Returns the integer 2.
  131326. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131327. */
  131328. getTypeID(): number;
  131329. /**
  131330. * Overrides the direction setter to recompute the projection texture view light Matrix.
  131331. */
  131332. protected _setDirection(value: Vector3): void;
  131333. /**
  131334. * Overrides the position setter to recompute the projection texture view light Matrix.
  131335. */
  131336. protected _setPosition(value: Vector3): void;
  131337. /**
  131338. * 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.
  131339. * Returns the SpotLight.
  131340. */
  131341. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131342. protected _computeProjectionTextureViewLightMatrix(): void;
  131343. protected _computeProjectionTextureProjectionLightMatrix(): void;
  131344. /**
  131345. * Main function for light texture projection matrix computing.
  131346. */
  131347. protected _computeProjectionTextureMatrix(): void;
  131348. protected _buildUniformLayout(): void;
  131349. private _computeAngleValues;
  131350. /**
  131351. * Sets the passed Effect "effect" with the Light textures.
  131352. * @param effect The effect to update
  131353. * @param lightIndex The index of the light in the effect to update
  131354. * @returns The light
  131355. */
  131356. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  131357. /**
  131358. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  131359. * @param effect The effect to update
  131360. * @param lightIndex The index of the light in the effect to update
  131361. * @returns The spot light
  131362. */
  131363. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  131364. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  131365. /**
  131366. * Disposes the light and the associated resources.
  131367. */
  131368. dispose(): void;
  131369. /**
  131370. * Prepares the list of defines specific to the light type.
  131371. * @param defines the list of defines
  131372. * @param lightIndex defines the index of the light for the effect
  131373. */
  131374. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131375. }
  131376. }
  131377. declare module BABYLON {
  131378. /**
  131379. * Gizmo that enables viewing a light
  131380. */
  131381. export class LightGizmo extends Gizmo {
  131382. private _lightMesh;
  131383. private _material;
  131384. private _cachedPosition;
  131385. private _cachedForward;
  131386. private _attachedMeshParent;
  131387. /**
  131388. * Creates a LightGizmo
  131389. * @param gizmoLayer The utility layer the gizmo will be added to
  131390. */
  131391. constructor(gizmoLayer?: UtilityLayerRenderer);
  131392. private _light;
  131393. /**
  131394. * The light that the gizmo is attached to
  131395. */
  131396. set light(light: Nullable<Light>);
  131397. get light(): Nullable<Light>;
  131398. /**
  131399. * Gets the material used to render the light gizmo
  131400. */
  131401. get material(): StandardMaterial;
  131402. /**
  131403. * @hidden
  131404. * Updates the gizmo to match the attached mesh's position/rotation
  131405. */
  131406. protected _update(): void;
  131407. private static _Scale;
  131408. /**
  131409. * Creates the lines for a light mesh
  131410. */
  131411. private static _CreateLightLines;
  131412. /**
  131413. * Disposes of the light gizmo
  131414. */
  131415. dispose(): void;
  131416. private static _CreateHemisphericLightMesh;
  131417. private static _CreatePointLightMesh;
  131418. private static _CreateSpotLightMesh;
  131419. private static _CreateDirectionalLightMesh;
  131420. }
  131421. }
  131422. declare module BABYLON {
  131423. /** @hidden */
  131424. export var backgroundFragmentDeclaration: {
  131425. name: string;
  131426. shader: string;
  131427. };
  131428. }
  131429. declare module BABYLON {
  131430. /** @hidden */
  131431. export var backgroundUboDeclaration: {
  131432. name: string;
  131433. shader: string;
  131434. };
  131435. }
  131436. declare module BABYLON {
  131437. /** @hidden */
  131438. export var backgroundPixelShader: {
  131439. name: string;
  131440. shader: string;
  131441. };
  131442. }
  131443. declare module BABYLON {
  131444. /** @hidden */
  131445. export var backgroundVertexDeclaration: {
  131446. name: string;
  131447. shader: string;
  131448. };
  131449. }
  131450. declare module BABYLON {
  131451. /** @hidden */
  131452. export var backgroundVertexShader: {
  131453. name: string;
  131454. shader: string;
  131455. };
  131456. }
  131457. declare module BABYLON {
  131458. /**
  131459. * Background material used to create an efficient environement around your scene.
  131460. */
  131461. export class BackgroundMaterial extends PushMaterial {
  131462. /**
  131463. * Standard reflectance value at parallel view angle.
  131464. */
  131465. static StandardReflectance0: number;
  131466. /**
  131467. * Standard reflectance value at grazing angle.
  131468. */
  131469. static StandardReflectance90: number;
  131470. protected _primaryColor: Color3;
  131471. /**
  131472. * Key light Color (multiply against the environement texture)
  131473. */
  131474. primaryColor: Color3;
  131475. protected __perceptualColor: Nullable<Color3>;
  131476. /**
  131477. * Experimental Internal Use Only.
  131478. *
  131479. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  131480. * This acts as a helper to set the primary color to a more "human friendly" value.
  131481. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  131482. * output color as close as possible from the chosen value.
  131483. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  131484. * part of lighting setup.)
  131485. */
  131486. get _perceptualColor(): Nullable<Color3>;
  131487. set _perceptualColor(value: Nullable<Color3>);
  131488. protected _primaryColorShadowLevel: float;
  131489. /**
  131490. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  131491. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  131492. */
  131493. get primaryColorShadowLevel(): float;
  131494. set primaryColorShadowLevel(value: float);
  131495. protected _primaryColorHighlightLevel: float;
  131496. /**
  131497. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  131498. * The primary color is used at the level chosen to define what the white area would look.
  131499. */
  131500. get primaryColorHighlightLevel(): float;
  131501. set primaryColorHighlightLevel(value: float);
  131502. protected _reflectionTexture: Nullable<BaseTexture>;
  131503. /**
  131504. * Reflection Texture used in the material.
  131505. * Should be author in a specific way for the best result (refer to the documentation).
  131506. */
  131507. reflectionTexture: Nullable<BaseTexture>;
  131508. protected _reflectionBlur: float;
  131509. /**
  131510. * Reflection Texture level of blur.
  131511. *
  131512. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  131513. * texture twice.
  131514. */
  131515. reflectionBlur: float;
  131516. protected _diffuseTexture: Nullable<BaseTexture>;
  131517. /**
  131518. * Diffuse Texture used in the material.
  131519. * Should be author in a specific way for the best result (refer to the documentation).
  131520. */
  131521. diffuseTexture: Nullable<BaseTexture>;
  131522. protected _shadowLights: Nullable<IShadowLight[]>;
  131523. /**
  131524. * Specify the list of lights casting shadow on the material.
  131525. * All scene shadow lights will be included if null.
  131526. */
  131527. shadowLights: Nullable<IShadowLight[]>;
  131528. protected _shadowLevel: float;
  131529. /**
  131530. * Helps adjusting the shadow to a softer level if required.
  131531. * 0 means black shadows and 1 means no shadows.
  131532. */
  131533. shadowLevel: float;
  131534. protected _sceneCenter: Vector3;
  131535. /**
  131536. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  131537. * It is usually zero but might be interesting to modify according to your setup.
  131538. */
  131539. sceneCenter: Vector3;
  131540. protected _opacityFresnel: boolean;
  131541. /**
  131542. * This helps specifying that the material is falling off to the sky box at grazing angle.
  131543. * This helps ensuring a nice transition when the camera goes under the ground.
  131544. */
  131545. opacityFresnel: boolean;
  131546. protected _reflectionFresnel: boolean;
  131547. /**
  131548. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  131549. * This helps adding a mirror texture on the ground.
  131550. */
  131551. reflectionFresnel: boolean;
  131552. protected _reflectionFalloffDistance: number;
  131553. /**
  131554. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  131555. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  131556. */
  131557. reflectionFalloffDistance: number;
  131558. protected _reflectionAmount: number;
  131559. /**
  131560. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  131561. */
  131562. reflectionAmount: number;
  131563. protected _reflectionReflectance0: number;
  131564. /**
  131565. * This specifies the weight of the reflection at grazing angle.
  131566. */
  131567. reflectionReflectance0: number;
  131568. protected _reflectionReflectance90: number;
  131569. /**
  131570. * This specifies the weight of the reflection at a perpendicular point of view.
  131571. */
  131572. reflectionReflectance90: number;
  131573. /**
  131574. * Sets the reflection reflectance fresnel values according to the default standard
  131575. * empirically know to work well :-)
  131576. */
  131577. set reflectionStandardFresnelWeight(value: number);
  131578. protected _useRGBColor: boolean;
  131579. /**
  131580. * Helps to directly use the maps channels instead of their level.
  131581. */
  131582. useRGBColor: boolean;
  131583. protected _enableNoise: boolean;
  131584. /**
  131585. * This helps reducing the banding effect that could occur on the background.
  131586. */
  131587. enableNoise: boolean;
  131588. /**
  131589. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  131590. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  131591. * Recommended to be keep at 1.0 except for special cases.
  131592. */
  131593. get fovMultiplier(): number;
  131594. set fovMultiplier(value: number);
  131595. private _fovMultiplier;
  131596. /**
  131597. * Enable the FOV adjustment feature controlled by fovMultiplier.
  131598. */
  131599. useEquirectangularFOV: boolean;
  131600. private _maxSimultaneousLights;
  131601. /**
  131602. * Number of Simultaneous lights allowed on the material.
  131603. */
  131604. maxSimultaneousLights: int;
  131605. private _shadowOnly;
  131606. /**
  131607. * Make the material only render shadows
  131608. */
  131609. shadowOnly: boolean;
  131610. /**
  131611. * Default configuration related to image processing available in the Background Material.
  131612. */
  131613. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131614. /**
  131615. * Keep track of the image processing observer to allow dispose and replace.
  131616. */
  131617. private _imageProcessingObserver;
  131618. /**
  131619. * Attaches a new image processing configuration to the PBR Material.
  131620. * @param configuration (if null the scene configuration will be use)
  131621. */
  131622. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131623. /**
  131624. * Gets the image processing configuration used either in this material.
  131625. */
  131626. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  131627. /**
  131628. * Sets the Default image processing configuration used either in the this material.
  131629. *
  131630. * If sets to null, the scene one is in use.
  131631. */
  131632. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  131633. /**
  131634. * Gets wether the color curves effect is enabled.
  131635. */
  131636. get cameraColorCurvesEnabled(): boolean;
  131637. /**
  131638. * Sets wether the color curves effect is enabled.
  131639. */
  131640. set cameraColorCurvesEnabled(value: boolean);
  131641. /**
  131642. * Gets wether the color grading effect is enabled.
  131643. */
  131644. get cameraColorGradingEnabled(): boolean;
  131645. /**
  131646. * Gets wether the color grading effect is enabled.
  131647. */
  131648. set cameraColorGradingEnabled(value: boolean);
  131649. /**
  131650. * Gets wether tonemapping is enabled or not.
  131651. */
  131652. get cameraToneMappingEnabled(): boolean;
  131653. /**
  131654. * Sets wether tonemapping is enabled or not
  131655. */
  131656. set cameraToneMappingEnabled(value: boolean);
  131657. /**
  131658. * The camera exposure used on this material.
  131659. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  131660. * This corresponds to a photographic exposure.
  131661. */
  131662. get cameraExposure(): float;
  131663. /**
  131664. * The camera exposure used on this material.
  131665. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  131666. * This corresponds to a photographic exposure.
  131667. */
  131668. set cameraExposure(value: float);
  131669. /**
  131670. * Gets The camera contrast used on this material.
  131671. */
  131672. get cameraContrast(): float;
  131673. /**
  131674. * Sets The camera contrast used on this material.
  131675. */
  131676. set cameraContrast(value: float);
  131677. /**
  131678. * Gets the Color Grading 2D Lookup Texture.
  131679. */
  131680. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  131681. /**
  131682. * Sets the Color Grading 2D Lookup Texture.
  131683. */
  131684. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  131685. /**
  131686. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131687. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131688. * 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;
  131689. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131690. */
  131691. get cameraColorCurves(): Nullable<ColorCurves>;
  131692. /**
  131693. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131694. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131695. * 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;
  131696. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131697. */
  131698. set cameraColorCurves(value: Nullable<ColorCurves>);
  131699. /**
  131700. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  131701. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  131702. */
  131703. switchToBGR: boolean;
  131704. private _renderTargets;
  131705. private _reflectionControls;
  131706. private _white;
  131707. private _primaryShadowColor;
  131708. private _primaryHighlightColor;
  131709. /**
  131710. * Instantiates a Background Material in the given scene
  131711. * @param name The friendly name of the material
  131712. * @param scene The scene to add the material to
  131713. */
  131714. constructor(name: string, scene: Scene);
  131715. /**
  131716. * Gets a boolean indicating that current material needs to register RTT
  131717. */
  131718. get hasRenderTargetTextures(): boolean;
  131719. /**
  131720. * The entire material has been created in order to prevent overdraw.
  131721. * @returns false
  131722. */
  131723. needAlphaTesting(): boolean;
  131724. /**
  131725. * The entire material has been created in order to prevent overdraw.
  131726. * @returns true if blending is enable
  131727. */
  131728. needAlphaBlending(): boolean;
  131729. /**
  131730. * Checks wether the material is ready to be rendered for a given mesh.
  131731. * @param mesh The mesh to render
  131732. * @param subMesh The submesh to check against
  131733. * @param useInstances Specify wether or not the material is used with instances
  131734. * @returns true if all the dependencies are ready (Textures, Effects...)
  131735. */
  131736. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  131737. /**
  131738. * Compute the primary color according to the chosen perceptual color.
  131739. */
  131740. private _computePrimaryColorFromPerceptualColor;
  131741. /**
  131742. * Compute the highlights and shadow colors according to their chosen levels.
  131743. */
  131744. private _computePrimaryColors;
  131745. /**
  131746. * Build the uniform buffer used in the material.
  131747. */
  131748. buildUniformLayout(): void;
  131749. /**
  131750. * Unbind the material.
  131751. */
  131752. unbind(): void;
  131753. /**
  131754. * Bind only the world matrix to the material.
  131755. * @param world The world matrix to bind.
  131756. */
  131757. bindOnlyWorldMatrix(world: Matrix): void;
  131758. /**
  131759. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  131760. * @param world The world matrix to bind.
  131761. * @param subMesh The submesh to bind for.
  131762. */
  131763. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  131764. /**
  131765. * Checks to see if a texture is used in the material.
  131766. * @param texture - Base texture to use.
  131767. * @returns - Boolean specifying if a texture is used in the material.
  131768. */
  131769. hasTexture(texture: BaseTexture): boolean;
  131770. /**
  131771. * Dispose the material.
  131772. * @param forceDisposeEffect Force disposal of the associated effect.
  131773. * @param forceDisposeTextures Force disposal of the associated textures.
  131774. */
  131775. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  131776. /**
  131777. * Clones the material.
  131778. * @param name The cloned name.
  131779. * @returns The cloned material.
  131780. */
  131781. clone(name: string): BackgroundMaterial;
  131782. /**
  131783. * Serializes the current material to its JSON representation.
  131784. * @returns The JSON representation.
  131785. */
  131786. serialize(): any;
  131787. /**
  131788. * Gets the class name of the material
  131789. * @returns "BackgroundMaterial"
  131790. */
  131791. getClassName(): string;
  131792. /**
  131793. * Parse a JSON input to create back a background material.
  131794. * @param source The JSON data to parse
  131795. * @param scene The scene to create the parsed material in
  131796. * @param rootUrl The root url of the assets the material depends upon
  131797. * @returns the instantiated BackgroundMaterial.
  131798. */
  131799. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  131800. }
  131801. }
  131802. declare module BABYLON {
  131803. /**
  131804. * Represents the different options available during the creation of
  131805. * a Environment helper.
  131806. *
  131807. * This can control the default ground, skybox and image processing setup of your scene.
  131808. */
  131809. export interface IEnvironmentHelperOptions {
  131810. /**
  131811. * Specifies whether or not to create a ground.
  131812. * True by default.
  131813. */
  131814. createGround: boolean;
  131815. /**
  131816. * Specifies the ground size.
  131817. * 15 by default.
  131818. */
  131819. groundSize: number;
  131820. /**
  131821. * The texture used on the ground for the main color.
  131822. * Comes from the BabylonJS CDN by default.
  131823. *
  131824. * Remarks: Can be either a texture or a url.
  131825. */
  131826. groundTexture: string | BaseTexture;
  131827. /**
  131828. * The color mixed in the ground texture by default.
  131829. * BabylonJS clearColor by default.
  131830. */
  131831. groundColor: Color3;
  131832. /**
  131833. * Specifies the ground opacity.
  131834. * 1 by default.
  131835. */
  131836. groundOpacity: number;
  131837. /**
  131838. * Enables the ground to receive shadows.
  131839. * True by default.
  131840. */
  131841. enableGroundShadow: boolean;
  131842. /**
  131843. * Helps preventing the shadow to be fully black on the ground.
  131844. * 0.5 by default.
  131845. */
  131846. groundShadowLevel: number;
  131847. /**
  131848. * Creates a mirror texture attach to the ground.
  131849. * false by default.
  131850. */
  131851. enableGroundMirror: boolean;
  131852. /**
  131853. * Specifies the ground mirror size ratio.
  131854. * 0.3 by default as the default kernel is 64.
  131855. */
  131856. groundMirrorSizeRatio: number;
  131857. /**
  131858. * Specifies the ground mirror blur kernel size.
  131859. * 64 by default.
  131860. */
  131861. groundMirrorBlurKernel: number;
  131862. /**
  131863. * Specifies the ground mirror visibility amount.
  131864. * 1 by default
  131865. */
  131866. groundMirrorAmount: number;
  131867. /**
  131868. * Specifies the ground mirror reflectance weight.
  131869. * This uses the standard weight of the background material to setup the fresnel effect
  131870. * of the mirror.
  131871. * 1 by default.
  131872. */
  131873. groundMirrorFresnelWeight: number;
  131874. /**
  131875. * Specifies the ground mirror Falloff distance.
  131876. * This can helps reducing the size of the reflection.
  131877. * 0 by Default.
  131878. */
  131879. groundMirrorFallOffDistance: number;
  131880. /**
  131881. * Specifies the ground mirror texture type.
  131882. * Unsigned Int by Default.
  131883. */
  131884. groundMirrorTextureType: number;
  131885. /**
  131886. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  131887. * the shown objects.
  131888. */
  131889. groundYBias: number;
  131890. /**
  131891. * Specifies whether or not to create a skybox.
  131892. * True by default.
  131893. */
  131894. createSkybox: boolean;
  131895. /**
  131896. * Specifies the skybox size.
  131897. * 20 by default.
  131898. */
  131899. skyboxSize: number;
  131900. /**
  131901. * The texture used on the skybox for the main color.
  131902. * Comes from the BabylonJS CDN by default.
  131903. *
  131904. * Remarks: Can be either a texture or a url.
  131905. */
  131906. skyboxTexture: string | BaseTexture;
  131907. /**
  131908. * The color mixed in the skybox texture by default.
  131909. * BabylonJS clearColor by default.
  131910. */
  131911. skyboxColor: Color3;
  131912. /**
  131913. * The background rotation around the Y axis of the scene.
  131914. * This helps aligning the key lights of your scene with the background.
  131915. * 0 by default.
  131916. */
  131917. backgroundYRotation: number;
  131918. /**
  131919. * Compute automatically the size of the elements to best fit with the scene.
  131920. */
  131921. sizeAuto: boolean;
  131922. /**
  131923. * Default position of the rootMesh if autoSize is not true.
  131924. */
  131925. rootPosition: Vector3;
  131926. /**
  131927. * Sets up the image processing in the scene.
  131928. * true by default.
  131929. */
  131930. setupImageProcessing: boolean;
  131931. /**
  131932. * The texture used as your environment texture in the scene.
  131933. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  131934. *
  131935. * Remarks: Can be either a texture or a url.
  131936. */
  131937. environmentTexture: string | BaseTexture;
  131938. /**
  131939. * The value of the exposure to apply to the scene.
  131940. * 0.6 by default if setupImageProcessing is true.
  131941. */
  131942. cameraExposure: number;
  131943. /**
  131944. * The value of the contrast to apply to the scene.
  131945. * 1.6 by default if setupImageProcessing is true.
  131946. */
  131947. cameraContrast: number;
  131948. /**
  131949. * Specifies whether or not tonemapping should be enabled in the scene.
  131950. * true by default if setupImageProcessing is true.
  131951. */
  131952. toneMappingEnabled: boolean;
  131953. }
  131954. /**
  131955. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  131956. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  131957. * It also helps with the default setup of your imageProcessing configuration.
  131958. */
  131959. export class EnvironmentHelper {
  131960. /**
  131961. * Default ground texture URL.
  131962. */
  131963. private static _groundTextureCDNUrl;
  131964. /**
  131965. * Default skybox texture URL.
  131966. */
  131967. private static _skyboxTextureCDNUrl;
  131968. /**
  131969. * Default environment texture URL.
  131970. */
  131971. private static _environmentTextureCDNUrl;
  131972. /**
  131973. * Creates the default options for the helper.
  131974. */
  131975. private static _getDefaultOptions;
  131976. private _rootMesh;
  131977. /**
  131978. * Gets the root mesh created by the helper.
  131979. */
  131980. get rootMesh(): Mesh;
  131981. private _skybox;
  131982. /**
  131983. * Gets the skybox created by the helper.
  131984. */
  131985. get skybox(): Nullable<Mesh>;
  131986. private _skyboxTexture;
  131987. /**
  131988. * Gets the skybox texture created by the helper.
  131989. */
  131990. get skyboxTexture(): Nullable<BaseTexture>;
  131991. private _skyboxMaterial;
  131992. /**
  131993. * Gets the skybox material created by the helper.
  131994. */
  131995. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  131996. private _ground;
  131997. /**
  131998. * Gets the ground mesh created by the helper.
  131999. */
  132000. get ground(): Nullable<Mesh>;
  132001. private _groundTexture;
  132002. /**
  132003. * Gets the ground texture created by the helper.
  132004. */
  132005. get groundTexture(): Nullable<BaseTexture>;
  132006. private _groundMirror;
  132007. /**
  132008. * Gets the ground mirror created by the helper.
  132009. */
  132010. get groundMirror(): Nullable<MirrorTexture>;
  132011. /**
  132012. * Gets the ground mirror render list to helps pushing the meshes
  132013. * you wish in the ground reflection.
  132014. */
  132015. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  132016. private _groundMaterial;
  132017. /**
  132018. * Gets the ground material created by the helper.
  132019. */
  132020. get groundMaterial(): Nullable<BackgroundMaterial>;
  132021. /**
  132022. * Stores the creation options.
  132023. */
  132024. private readonly _scene;
  132025. private _options;
  132026. /**
  132027. * This observable will be notified with any error during the creation of the environment,
  132028. * mainly texture creation errors.
  132029. */
  132030. onErrorObservable: Observable<{
  132031. message?: string;
  132032. exception?: any;
  132033. }>;
  132034. /**
  132035. * constructor
  132036. * @param options Defines the options we want to customize the helper
  132037. * @param scene The scene to add the material to
  132038. */
  132039. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  132040. /**
  132041. * Updates the background according to the new options
  132042. * @param options
  132043. */
  132044. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  132045. /**
  132046. * Sets the primary color of all the available elements.
  132047. * @param color the main color to affect to the ground and the background
  132048. */
  132049. setMainColor(color: Color3): void;
  132050. /**
  132051. * Setup the image processing according to the specified options.
  132052. */
  132053. private _setupImageProcessing;
  132054. /**
  132055. * Setup the environment texture according to the specified options.
  132056. */
  132057. private _setupEnvironmentTexture;
  132058. /**
  132059. * Setup the background according to the specified options.
  132060. */
  132061. private _setupBackground;
  132062. /**
  132063. * Get the scene sizes according to the setup.
  132064. */
  132065. private _getSceneSize;
  132066. /**
  132067. * Setup the ground according to the specified options.
  132068. */
  132069. private _setupGround;
  132070. /**
  132071. * Setup the ground material according to the specified options.
  132072. */
  132073. private _setupGroundMaterial;
  132074. /**
  132075. * Setup the ground diffuse texture according to the specified options.
  132076. */
  132077. private _setupGroundDiffuseTexture;
  132078. /**
  132079. * Setup the ground mirror texture according to the specified options.
  132080. */
  132081. private _setupGroundMirrorTexture;
  132082. /**
  132083. * Setup the ground to receive the mirror texture.
  132084. */
  132085. private _setupMirrorInGroundMaterial;
  132086. /**
  132087. * Setup the skybox according to the specified options.
  132088. */
  132089. private _setupSkybox;
  132090. /**
  132091. * Setup the skybox material according to the specified options.
  132092. */
  132093. private _setupSkyboxMaterial;
  132094. /**
  132095. * Setup the skybox reflection texture according to the specified options.
  132096. */
  132097. private _setupSkyboxReflectionTexture;
  132098. private _errorHandler;
  132099. /**
  132100. * Dispose all the elements created by the Helper.
  132101. */
  132102. dispose(): void;
  132103. }
  132104. }
  132105. declare module BABYLON {
  132106. /**
  132107. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  132108. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  132109. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  132110. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  132111. */
  132112. export class PhotoDome extends TransformNode {
  132113. /**
  132114. * Define the image as a Monoscopic panoramic 360 image.
  132115. */
  132116. static readonly MODE_MONOSCOPIC: number;
  132117. /**
  132118. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132119. */
  132120. static readonly MODE_TOPBOTTOM: number;
  132121. /**
  132122. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132123. */
  132124. static readonly MODE_SIDEBYSIDE: number;
  132125. private _useDirectMapping;
  132126. /**
  132127. * The texture being displayed on the sphere
  132128. */
  132129. protected _photoTexture: Texture;
  132130. /**
  132131. * Gets or sets the texture being displayed on the sphere
  132132. */
  132133. get photoTexture(): Texture;
  132134. set photoTexture(value: Texture);
  132135. /**
  132136. * Observable raised when an error occured while loading the 360 image
  132137. */
  132138. onLoadErrorObservable: Observable<string>;
  132139. /**
  132140. * The skybox material
  132141. */
  132142. protected _material: BackgroundMaterial;
  132143. /**
  132144. * The surface used for the skybox
  132145. */
  132146. protected _mesh: Mesh;
  132147. /**
  132148. * Gets the mesh used for the skybox.
  132149. */
  132150. get mesh(): Mesh;
  132151. /**
  132152. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132153. * Also see the options.resolution property.
  132154. */
  132155. get fovMultiplier(): number;
  132156. set fovMultiplier(value: number);
  132157. private _imageMode;
  132158. /**
  132159. * Gets or set the current video mode for the video. It can be:
  132160. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  132161. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132162. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132163. */
  132164. get imageMode(): number;
  132165. set imageMode(value: number);
  132166. /**
  132167. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  132168. * @param name Element's name, child elements will append suffixes for their own names.
  132169. * @param urlsOfPhoto defines the url of the photo to display
  132170. * @param options defines an object containing optional or exposed sub element properties
  132171. * @param onError defines a callback called when an error occured while loading the texture
  132172. */
  132173. constructor(name: string, urlOfPhoto: string, options: {
  132174. resolution?: number;
  132175. size?: number;
  132176. useDirectMapping?: boolean;
  132177. faceForward?: boolean;
  132178. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  132179. private _onBeforeCameraRenderObserver;
  132180. private _changeImageMode;
  132181. /**
  132182. * Releases resources associated with this node.
  132183. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  132184. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  132185. */
  132186. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  132187. }
  132188. }
  132189. declare module BABYLON {
  132190. /**
  132191. * Class used to host RGBD texture specific utilities
  132192. */
  132193. export class RGBDTextureTools {
  132194. /**
  132195. * Expand the RGBD Texture from RGBD to Half Float if possible.
  132196. * @param texture the texture to expand.
  132197. */
  132198. static ExpandRGBDTexture(texture: Texture): void;
  132199. }
  132200. }
  132201. declare module BABYLON {
  132202. /**
  132203. * Class used to host texture specific utilities
  132204. */
  132205. export class BRDFTextureTools {
  132206. /**
  132207. * Prevents texture cache collision
  132208. */
  132209. private static _instanceNumber;
  132210. /**
  132211. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  132212. * @param scene defines the hosting scene
  132213. * @returns the environment BRDF texture
  132214. */
  132215. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  132216. private static _environmentBRDFBase64Texture;
  132217. }
  132218. }
  132219. declare module BABYLON {
  132220. /**
  132221. * @hidden
  132222. */
  132223. export interface IMaterialClearCoatDefines {
  132224. CLEARCOAT: boolean;
  132225. CLEARCOAT_DEFAULTIOR: boolean;
  132226. CLEARCOAT_TEXTURE: boolean;
  132227. CLEARCOAT_TEXTUREDIRECTUV: number;
  132228. CLEARCOAT_BUMP: boolean;
  132229. CLEARCOAT_BUMPDIRECTUV: number;
  132230. CLEARCOAT_TINT: boolean;
  132231. CLEARCOAT_TINT_TEXTURE: boolean;
  132232. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  132233. /** @hidden */
  132234. _areTexturesDirty: boolean;
  132235. }
  132236. /**
  132237. * Define the code related to the clear coat parameters of the pbr material.
  132238. */
  132239. export class PBRClearCoatConfiguration {
  132240. /**
  132241. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  132242. * The default fits with a polyurethane material.
  132243. */
  132244. private static readonly _DefaultIndexOfRefraction;
  132245. private _isEnabled;
  132246. /**
  132247. * Defines if the clear coat is enabled in the material.
  132248. */
  132249. isEnabled: boolean;
  132250. /**
  132251. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  132252. */
  132253. intensity: number;
  132254. /**
  132255. * Defines the clear coat layer roughness.
  132256. */
  132257. roughness: number;
  132258. private _indexOfRefraction;
  132259. /**
  132260. * Defines the index of refraction of the clear coat.
  132261. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  132262. * The default fits with a polyurethane material.
  132263. * Changing the default value is more performance intensive.
  132264. */
  132265. indexOfRefraction: number;
  132266. private _texture;
  132267. /**
  132268. * Stores the clear coat values in a texture.
  132269. */
  132270. texture: Nullable<BaseTexture>;
  132271. private _bumpTexture;
  132272. /**
  132273. * Define the clear coat specific bump texture.
  132274. */
  132275. bumpTexture: Nullable<BaseTexture>;
  132276. private _isTintEnabled;
  132277. /**
  132278. * Defines if the clear coat tint is enabled in the material.
  132279. */
  132280. isTintEnabled: boolean;
  132281. /**
  132282. * Defines the clear coat tint of the material.
  132283. * This is only use if tint is enabled
  132284. */
  132285. tintColor: Color3;
  132286. /**
  132287. * Defines the distance at which the tint color should be found in the
  132288. * clear coat media.
  132289. * This is only use if tint is enabled
  132290. */
  132291. tintColorAtDistance: number;
  132292. /**
  132293. * Defines the clear coat layer thickness.
  132294. * This is only use if tint is enabled
  132295. */
  132296. tintThickness: number;
  132297. private _tintTexture;
  132298. /**
  132299. * Stores the clear tint values in a texture.
  132300. * rgb is tint
  132301. * a is a thickness factor
  132302. */
  132303. tintTexture: Nullable<BaseTexture>;
  132304. /** @hidden */
  132305. private _internalMarkAllSubMeshesAsTexturesDirty;
  132306. /** @hidden */
  132307. _markAllSubMeshesAsTexturesDirty(): void;
  132308. /**
  132309. * Instantiate a new istance of clear coat configuration.
  132310. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132311. */
  132312. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132313. /**
  132314. * Gets wehter the submesh is ready to be used or not.
  132315. * @param defines the list of "defines" to update.
  132316. * @param scene defines the scene the material belongs to.
  132317. * @param engine defines the engine the material belongs to.
  132318. * @param disableBumpMap defines wether the material disables bump or not.
  132319. * @returns - boolean indicating that the submesh is ready or not.
  132320. */
  132321. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  132322. /**
  132323. * Checks to see if a texture is used in the material.
  132324. * @param defines the list of "defines" to update.
  132325. * @param scene defines the scene to the material belongs to.
  132326. */
  132327. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  132328. /**
  132329. * Binds the material data.
  132330. * @param uniformBuffer defines the Uniform buffer to fill in.
  132331. * @param scene defines the scene the material belongs to.
  132332. * @param engine defines the engine the material belongs to.
  132333. * @param disableBumpMap defines wether the material disables bump or not.
  132334. * @param isFrozen defines wether the material is frozen or not.
  132335. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  132336. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  132337. */
  132338. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  132339. /**
  132340. * Checks to see if a texture is used in the material.
  132341. * @param texture - Base texture to use.
  132342. * @returns - Boolean specifying if a texture is used in the material.
  132343. */
  132344. hasTexture(texture: BaseTexture): boolean;
  132345. /**
  132346. * Returns an array of the actively used textures.
  132347. * @param activeTextures Array of BaseTextures
  132348. */
  132349. getActiveTextures(activeTextures: BaseTexture[]): void;
  132350. /**
  132351. * Returns the animatable textures.
  132352. * @param animatables Array of animatable textures.
  132353. */
  132354. getAnimatables(animatables: IAnimatable[]): void;
  132355. /**
  132356. * Disposes the resources of the material.
  132357. * @param forceDisposeTextures - Forces the disposal of all textures.
  132358. */
  132359. dispose(forceDisposeTextures?: boolean): void;
  132360. /**
  132361. * Get the current class name of the texture useful for serialization or dynamic coding.
  132362. * @returns "PBRClearCoatConfiguration"
  132363. */
  132364. getClassName(): string;
  132365. /**
  132366. * Add fallbacks to the effect fallbacks list.
  132367. * @param defines defines the Base texture to use.
  132368. * @param fallbacks defines the current fallback list.
  132369. * @param currentRank defines the current fallback rank.
  132370. * @returns the new fallback rank.
  132371. */
  132372. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132373. /**
  132374. * Add the required uniforms to the current list.
  132375. * @param uniforms defines the current uniform list.
  132376. */
  132377. static AddUniforms(uniforms: string[]): void;
  132378. /**
  132379. * Add the required samplers to the current list.
  132380. * @param samplers defines the current sampler list.
  132381. */
  132382. static AddSamplers(samplers: string[]): void;
  132383. /**
  132384. * Add the required uniforms to the current buffer.
  132385. * @param uniformBuffer defines the current uniform buffer.
  132386. */
  132387. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132388. /**
  132389. * Makes a duplicate of the current configuration into another one.
  132390. * @param clearCoatConfiguration define the config where to copy the info
  132391. */
  132392. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  132393. /**
  132394. * Serializes this clear coat configuration.
  132395. * @returns - An object with the serialized config.
  132396. */
  132397. serialize(): any;
  132398. /**
  132399. * Parses a anisotropy Configuration from a serialized object.
  132400. * @param source - Serialized object.
  132401. * @param scene Defines the scene we are parsing for
  132402. * @param rootUrl Defines the rootUrl to load from
  132403. */
  132404. parse(source: any, scene: Scene, rootUrl: string): void;
  132405. }
  132406. }
  132407. declare module BABYLON {
  132408. /**
  132409. * @hidden
  132410. */
  132411. export interface IMaterialAnisotropicDefines {
  132412. ANISOTROPIC: boolean;
  132413. ANISOTROPIC_TEXTURE: boolean;
  132414. ANISOTROPIC_TEXTUREDIRECTUV: number;
  132415. MAINUV1: boolean;
  132416. _areTexturesDirty: boolean;
  132417. _needUVs: boolean;
  132418. }
  132419. /**
  132420. * Define the code related to the anisotropic parameters of the pbr material.
  132421. */
  132422. export class PBRAnisotropicConfiguration {
  132423. private _isEnabled;
  132424. /**
  132425. * Defines if the anisotropy is enabled in the material.
  132426. */
  132427. isEnabled: boolean;
  132428. /**
  132429. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  132430. */
  132431. intensity: number;
  132432. /**
  132433. * Defines if the effect is along the tangents, bitangents or in between.
  132434. * By default, the effect is "strectching" the highlights along the tangents.
  132435. */
  132436. direction: Vector2;
  132437. private _texture;
  132438. /**
  132439. * Stores the anisotropy values in a texture.
  132440. * rg is direction (like normal from -1 to 1)
  132441. * b is a intensity
  132442. */
  132443. texture: Nullable<BaseTexture>;
  132444. /** @hidden */
  132445. private _internalMarkAllSubMeshesAsTexturesDirty;
  132446. /** @hidden */
  132447. _markAllSubMeshesAsTexturesDirty(): void;
  132448. /**
  132449. * Instantiate a new istance of anisotropy configuration.
  132450. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132451. */
  132452. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132453. /**
  132454. * Specifies that the submesh is ready to be used.
  132455. * @param defines the list of "defines" to update.
  132456. * @param scene defines the scene the material belongs to.
  132457. * @returns - boolean indicating that the submesh is ready or not.
  132458. */
  132459. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  132460. /**
  132461. * Checks to see if a texture is used in the material.
  132462. * @param defines the list of "defines" to update.
  132463. * @param mesh the mesh we are preparing the defines for.
  132464. * @param scene defines the scene the material belongs to.
  132465. */
  132466. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  132467. /**
  132468. * Binds the material data.
  132469. * @param uniformBuffer defines the Uniform buffer to fill in.
  132470. * @param scene defines the scene the material belongs to.
  132471. * @param isFrozen defines wether the material is frozen or not.
  132472. */
  132473. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132474. /**
  132475. * Checks to see if a texture is used in the material.
  132476. * @param texture - Base texture to use.
  132477. * @returns - Boolean specifying if a texture is used in the material.
  132478. */
  132479. hasTexture(texture: BaseTexture): boolean;
  132480. /**
  132481. * Returns an array of the actively used textures.
  132482. * @param activeTextures Array of BaseTextures
  132483. */
  132484. getActiveTextures(activeTextures: BaseTexture[]): void;
  132485. /**
  132486. * Returns the animatable textures.
  132487. * @param animatables Array of animatable textures.
  132488. */
  132489. getAnimatables(animatables: IAnimatable[]): void;
  132490. /**
  132491. * Disposes the resources of the material.
  132492. * @param forceDisposeTextures - Forces the disposal of all textures.
  132493. */
  132494. dispose(forceDisposeTextures?: boolean): void;
  132495. /**
  132496. * Get the current class name of the texture useful for serialization or dynamic coding.
  132497. * @returns "PBRAnisotropicConfiguration"
  132498. */
  132499. getClassName(): string;
  132500. /**
  132501. * Add fallbacks to the effect fallbacks list.
  132502. * @param defines defines the Base texture to use.
  132503. * @param fallbacks defines the current fallback list.
  132504. * @param currentRank defines the current fallback rank.
  132505. * @returns the new fallback rank.
  132506. */
  132507. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132508. /**
  132509. * Add the required uniforms to the current list.
  132510. * @param uniforms defines the current uniform list.
  132511. */
  132512. static AddUniforms(uniforms: string[]): void;
  132513. /**
  132514. * Add the required uniforms to the current buffer.
  132515. * @param uniformBuffer defines the current uniform buffer.
  132516. */
  132517. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132518. /**
  132519. * Add the required samplers to the current list.
  132520. * @param samplers defines the current sampler list.
  132521. */
  132522. static AddSamplers(samplers: string[]): void;
  132523. /**
  132524. * Makes a duplicate of the current configuration into another one.
  132525. * @param anisotropicConfiguration define the config where to copy the info
  132526. */
  132527. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  132528. /**
  132529. * Serializes this anisotropy configuration.
  132530. * @returns - An object with the serialized config.
  132531. */
  132532. serialize(): any;
  132533. /**
  132534. * Parses a anisotropy Configuration from a serialized object.
  132535. * @param source - Serialized object.
  132536. * @param scene Defines the scene we are parsing for
  132537. * @param rootUrl Defines the rootUrl to load from
  132538. */
  132539. parse(source: any, scene: Scene, rootUrl: string): void;
  132540. }
  132541. }
  132542. declare module BABYLON {
  132543. /**
  132544. * @hidden
  132545. */
  132546. export interface IMaterialBRDFDefines {
  132547. BRDF_V_HEIGHT_CORRELATED: boolean;
  132548. MS_BRDF_ENERGY_CONSERVATION: boolean;
  132549. SPHERICAL_HARMONICS: boolean;
  132550. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  132551. /** @hidden */
  132552. _areMiscDirty: boolean;
  132553. }
  132554. /**
  132555. * Define the code related to the BRDF parameters of the pbr material.
  132556. */
  132557. export class PBRBRDFConfiguration {
  132558. /**
  132559. * Default value used for the energy conservation.
  132560. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132561. */
  132562. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  132563. /**
  132564. * Default value used for the Smith Visibility Height Correlated mode.
  132565. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132566. */
  132567. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  132568. /**
  132569. * Default value used for the IBL diffuse part.
  132570. * This can help switching back to the polynomials mode globally which is a tiny bit
  132571. * less GPU intensive at the drawback of a lower quality.
  132572. */
  132573. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  132574. /**
  132575. * Default value used for activating energy conservation for the specular workflow.
  132576. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132577. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132578. */
  132579. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  132580. private _useEnergyConservation;
  132581. /**
  132582. * Defines if the material uses energy conservation.
  132583. */
  132584. useEnergyConservation: boolean;
  132585. private _useSmithVisibilityHeightCorrelated;
  132586. /**
  132587. * LEGACY Mode set to false
  132588. * Defines if the material uses height smith correlated visibility term.
  132589. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  132590. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  132591. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  132592. * Not relying on height correlated will also disable energy conservation.
  132593. */
  132594. useSmithVisibilityHeightCorrelated: boolean;
  132595. private _useSphericalHarmonics;
  132596. /**
  132597. * LEGACY Mode set to false
  132598. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  132599. * diffuse part of the IBL.
  132600. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  132601. * to the ground truth.
  132602. */
  132603. useSphericalHarmonics: boolean;
  132604. private _useSpecularGlossinessInputEnergyConservation;
  132605. /**
  132606. * Defines if the material uses energy conservation, when the specular workflow is active.
  132607. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132608. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132609. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  132610. */
  132611. useSpecularGlossinessInputEnergyConservation: boolean;
  132612. /** @hidden */
  132613. private _internalMarkAllSubMeshesAsMiscDirty;
  132614. /** @hidden */
  132615. _markAllSubMeshesAsMiscDirty(): void;
  132616. /**
  132617. * Instantiate a new istance of clear coat configuration.
  132618. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  132619. */
  132620. constructor(markAllSubMeshesAsMiscDirty: () => void);
  132621. /**
  132622. * Checks to see if a texture is used in the material.
  132623. * @param defines the list of "defines" to update.
  132624. */
  132625. prepareDefines(defines: IMaterialBRDFDefines): void;
  132626. /**
  132627. * Get the current class name of the texture useful for serialization or dynamic coding.
  132628. * @returns "PBRClearCoatConfiguration"
  132629. */
  132630. getClassName(): string;
  132631. /**
  132632. * Makes a duplicate of the current configuration into another one.
  132633. * @param brdfConfiguration define the config where to copy the info
  132634. */
  132635. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  132636. /**
  132637. * Serializes this BRDF configuration.
  132638. * @returns - An object with the serialized config.
  132639. */
  132640. serialize(): any;
  132641. /**
  132642. * Parses a anisotropy Configuration from a serialized object.
  132643. * @param source - Serialized object.
  132644. * @param scene Defines the scene we are parsing for
  132645. * @param rootUrl Defines the rootUrl to load from
  132646. */
  132647. parse(source: any, scene: Scene, rootUrl: string): void;
  132648. }
  132649. }
  132650. declare module BABYLON {
  132651. /**
  132652. * @hidden
  132653. */
  132654. export interface IMaterialSheenDefines {
  132655. SHEEN: boolean;
  132656. SHEEN_TEXTURE: boolean;
  132657. SHEEN_TEXTUREDIRECTUV: number;
  132658. SHEEN_LINKWITHALBEDO: boolean;
  132659. SHEEN_ROUGHNESS: boolean;
  132660. SHEEN_ALBEDOSCALING: boolean;
  132661. /** @hidden */
  132662. _areTexturesDirty: boolean;
  132663. }
  132664. /**
  132665. * Define the code related to the Sheen parameters of the pbr material.
  132666. */
  132667. export class PBRSheenConfiguration {
  132668. private _isEnabled;
  132669. /**
  132670. * Defines if the material uses sheen.
  132671. */
  132672. isEnabled: boolean;
  132673. private _linkSheenWithAlbedo;
  132674. /**
  132675. * Defines if the sheen is linked to the sheen color.
  132676. */
  132677. linkSheenWithAlbedo: boolean;
  132678. /**
  132679. * Defines the sheen intensity.
  132680. */
  132681. intensity: number;
  132682. /**
  132683. * Defines the sheen color.
  132684. */
  132685. color: Color3;
  132686. private _texture;
  132687. /**
  132688. * Stores the sheen tint values in a texture.
  132689. * rgb is tint
  132690. * a is a intensity or roughness if roughness has been defined
  132691. */
  132692. texture: Nullable<BaseTexture>;
  132693. private _roughness;
  132694. /**
  132695. * Defines the sheen roughness.
  132696. * It is not taken into account if linkSheenWithAlbedo is true.
  132697. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  132698. */
  132699. roughness: Nullable<number>;
  132700. private _albedoScaling;
  132701. /**
  132702. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  132703. * It allows the strength of the sheen effect to not depend on the base color of the material,
  132704. * making it easier to setup and tweak the effect
  132705. */
  132706. albedoScaling: boolean;
  132707. /** @hidden */
  132708. private _internalMarkAllSubMeshesAsTexturesDirty;
  132709. /** @hidden */
  132710. _markAllSubMeshesAsTexturesDirty(): void;
  132711. /**
  132712. * Instantiate a new istance of clear coat configuration.
  132713. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132714. */
  132715. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132716. /**
  132717. * Specifies that the submesh is ready to be used.
  132718. * @param defines the list of "defines" to update.
  132719. * @param scene defines the scene the material belongs to.
  132720. * @returns - boolean indicating that the submesh is ready or not.
  132721. */
  132722. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  132723. /**
  132724. * Checks to see if a texture is used in the material.
  132725. * @param defines the list of "defines" to update.
  132726. * @param scene defines the scene the material belongs to.
  132727. */
  132728. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  132729. /**
  132730. * Binds the material data.
  132731. * @param uniformBuffer defines the Uniform buffer to fill in.
  132732. * @param scene defines the scene the material belongs to.
  132733. * @param isFrozen defines wether the material is frozen or not.
  132734. */
  132735. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132736. /**
  132737. * Checks to see if a texture is used in the material.
  132738. * @param texture - Base texture to use.
  132739. * @returns - Boolean specifying if a texture is used in the material.
  132740. */
  132741. hasTexture(texture: BaseTexture): boolean;
  132742. /**
  132743. * Returns an array of the actively used textures.
  132744. * @param activeTextures Array of BaseTextures
  132745. */
  132746. getActiveTextures(activeTextures: BaseTexture[]): void;
  132747. /**
  132748. * Returns the animatable textures.
  132749. * @param animatables Array of animatable textures.
  132750. */
  132751. getAnimatables(animatables: IAnimatable[]): void;
  132752. /**
  132753. * Disposes the resources of the material.
  132754. * @param forceDisposeTextures - Forces the disposal of all textures.
  132755. */
  132756. dispose(forceDisposeTextures?: boolean): void;
  132757. /**
  132758. * Get the current class name of the texture useful for serialization or dynamic coding.
  132759. * @returns "PBRSheenConfiguration"
  132760. */
  132761. getClassName(): string;
  132762. /**
  132763. * Add fallbacks to the effect fallbacks list.
  132764. * @param defines defines the Base texture to use.
  132765. * @param fallbacks defines the current fallback list.
  132766. * @param currentRank defines the current fallback rank.
  132767. * @returns the new fallback rank.
  132768. */
  132769. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132770. /**
  132771. * Add the required uniforms to the current list.
  132772. * @param uniforms defines the current uniform list.
  132773. */
  132774. static AddUniforms(uniforms: string[]): void;
  132775. /**
  132776. * Add the required uniforms to the current buffer.
  132777. * @param uniformBuffer defines the current uniform buffer.
  132778. */
  132779. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132780. /**
  132781. * Add the required samplers to the current list.
  132782. * @param samplers defines the current sampler list.
  132783. */
  132784. static AddSamplers(samplers: string[]): void;
  132785. /**
  132786. * Makes a duplicate of the current configuration into another one.
  132787. * @param sheenConfiguration define the config where to copy the info
  132788. */
  132789. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  132790. /**
  132791. * Serializes this BRDF configuration.
  132792. * @returns - An object with the serialized config.
  132793. */
  132794. serialize(): any;
  132795. /**
  132796. * Parses a anisotropy Configuration from a serialized object.
  132797. * @param source - Serialized object.
  132798. * @param scene Defines the scene we are parsing for
  132799. * @param rootUrl Defines the rootUrl to load from
  132800. */
  132801. parse(source: any, scene: Scene, rootUrl: string): void;
  132802. }
  132803. }
  132804. declare module BABYLON {
  132805. /**
  132806. * @hidden
  132807. */
  132808. export interface IMaterialSubSurfaceDefines {
  132809. SUBSURFACE: boolean;
  132810. SS_REFRACTION: boolean;
  132811. SS_TRANSLUCENCY: boolean;
  132812. SS_SCATTERING: boolean;
  132813. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132814. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132815. SS_REFRACTIONMAP_3D: boolean;
  132816. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132817. SS_LODINREFRACTIONALPHA: boolean;
  132818. SS_GAMMAREFRACTION: boolean;
  132819. SS_RGBDREFRACTION: boolean;
  132820. SS_LINEARSPECULARREFRACTION: boolean;
  132821. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132822. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132823. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132824. /** @hidden */
  132825. _areTexturesDirty: boolean;
  132826. }
  132827. /**
  132828. * Define the code related to the sub surface parameters of the pbr material.
  132829. */
  132830. export class PBRSubSurfaceConfiguration {
  132831. private _isRefractionEnabled;
  132832. /**
  132833. * Defines if the refraction is enabled in the material.
  132834. */
  132835. isRefractionEnabled: boolean;
  132836. private _isTranslucencyEnabled;
  132837. /**
  132838. * Defines if the translucency is enabled in the material.
  132839. */
  132840. isTranslucencyEnabled: boolean;
  132841. private _isScatteringEnabled;
  132842. /**
  132843. * Defines if the sub surface scattering is enabled in the material.
  132844. */
  132845. isScatteringEnabled: boolean;
  132846. private _scatteringDiffusionProfileIndex;
  132847. /**
  132848. * Diffusion profile for subsurface scattering.
  132849. * Useful for better scattering in the skins or foliages.
  132850. */
  132851. get scatteringDiffusionProfile(): Nullable<Color3>;
  132852. set scatteringDiffusionProfile(c: Nullable<Color3>);
  132853. /**
  132854. * Defines the refraction intensity of the material.
  132855. * The refraction when enabled replaces the Diffuse part of the material.
  132856. * The intensity helps transitionning between diffuse and refraction.
  132857. */
  132858. refractionIntensity: number;
  132859. /**
  132860. * Defines the translucency intensity of the material.
  132861. * When translucency has been enabled, this defines how much of the "translucency"
  132862. * is addded to the diffuse part of the material.
  132863. */
  132864. translucencyIntensity: number;
  132865. /**
  132866. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  132867. */
  132868. useAlbedoToTintRefraction: boolean;
  132869. private _thicknessTexture;
  132870. /**
  132871. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  132872. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  132873. * 0 would mean minimumThickness
  132874. * 1 would mean maximumThickness
  132875. * The other channels might be use as a mask to vary the different effects intensity.
  132876. */
  132877. thicknessTexture: Nullable<BaseTexture>;
  132878. private _refractionTexture;
  132879. /**
  132880. * Defines the texture to use for refraction.
  132881. */
  132882. refractionTexture: Nullable<BaseTexture>;
  132883. private _indexOfRefraction;
  132884. /**
  132885. * Index of refraction of the material base layer.
  132886. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132887. *
  132888. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132889. *
  132890. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132891. */
  132892. indexOfRefraction: number;
  132893. private _volumeIndexOfRefraction;
  132894. /**
  132895. * Index of refraction of the material's volume.
  132896. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132897. *
  132898. * This ONLY impacts refraction. If not provided or given a non-valid value,
  132899. * the volume will use the same IOR as the surface.
  132900. */
  132901. get volumeIndexOfRefraction(): number;
  132902. set volumeIndexOfRefraction(value: number);
  132903. private _invertRefractionY;
  132904. /**
  132905. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132906. */
  132907. invertRefractionY: boolean;
  132908. private _linkRefractionWithTransparency;
  132909. /**
  132910. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132911. * Materials half opaque for instance using refraction could benefit from this control.
  132912. */
  132913. linkRefractionWithTransparency: boolean;
  132914. /**
  132915. * Defines the minimum thickness stored in the thickness map.
  132916. * If no thickness map is defined, this value will be used to simulate thickness.
  132917. */
  132918. minimumThickness: number;
  132919. /**
  132920. * Defines the maximum thickness stored in the thickness map.
  132921. */
  132922. maximumThickness: number;
  132923. /**
  132924. * Defines the volume tint of the material.
  132925. * This is used for both translucency and scattering.
  132926. */
  132927. tintColor: Color3;
  132928. /**
  132929. * Defines the distance at which the tint color should be found in the media.
  132930. * This is used for refraction only.
  132931. */
  132932. tintColorAtDistance: number;
  132933. /**
  132934. * Defines how far each channel transmit through the media.
  132935. * It is defined as a color to simplify it selection.
  132936. */
  132937. diffusionDistance: Color3;
  132938. private _useMaskFromThicknessTexture;
  132939. /**
  132940. * Stores the intensity of the different subsurface effects in the thickness texture.
  132941. * * the green channel is the translucency intensity.
  132942. * * the blue channel is the scattering intensity.
  132943. * * the alpha channel is the refraction intensity.
  132944. */
  132945. useMaskFromThicknessTexture: boolean;
  132946. private _scene;
  132947. /** @hidden */
  132948. private _internalMarkAllSubMeshesAsTexturesDirty;
  132949. private _internalMarkScenePrePassDirty;
  132950. /** @hidden */
  132951. _markAllSubMeshesAsTexturesDirty(): void;
  132952. /** @hidden */
  132953. _markScenePrePassDirty(): void;
  132954. /**
  132955. * Instantiate a new istance of sub surface configuration.
  132956. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132957. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  132958. * @param scene The scene
  132959. */
  132960. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  132961. /**
  132962. * Gets wehter the submesh is ready to be used or not.
  132963. * @param defines the list of "defines" to update.
  132964. * @param scene defines the scene the material belongs to.
  132965. * @returns - boolean indicating that the submesh is ready or not.
  132966. */
  132967. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  132968. /**
  132969. * Checks to see if a texture is used in the material.
  132970. * @param defines the list of "defines" to update.
  132971. * @param scene defines the scene to the material belongs to.
  132972. */
  132973. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  132974. /**
  132975. * Binds the material data.
  132976. * @param uniformBuffer defines the Uniform buffer to fill in.
  132977. * @param scene defines the scene the material belongs to.
  132978. * @param engine defines the engine the material belongs to.
  132979. * @param isFrozen defines whether the material is frozen or not.
  132980. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  132981. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  132982. */
  132983. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  132984. /**
  132985. * Unbinds the material from the mesh.
  132986. * @param activeEffect defines the effect that should be unbound from.
  132987. * @returns true if unbound, otherwise false
  132988. */
  132989. unbind(activeEffect: Effect): boolean;
  132990. /**
  132991. * Returns the texture used for refraction or null if none is used.
  132992. * @param scene defines the scene the material belongs to.
  132993. * @returns - Refraction texture if present. If no refraction texture and refraction
  132994. * is linked with transparency, returns environment texture. Otherwise, returns null.
  132995. */
  132996. private _getRefractionTexture;
  132997. /**
  132998. * Returns true if alpha blending should be disabled.
  132999. */
  133000. get disableAlphaBlending(): boolean;
  133001. /**
  133002. * Fills the list of render target textures.
  133003. * @param renderTargets the list of render targets to update
  133004. */
  133005. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  133006. /**
  133007. * Checks to see if a texture is used in the material.
  133008. * @param texture - Base texture to use.
  133009. * @returns - Boolean specifying if a texture is used in the material.
  133010. */
  133011. hasTexture(texture: BaseTexture): boolean;
  133012. /**
  133013. * Gets a boolean indicating that current material needs to register RTT
  133014. * @returns true if this uses a render target otherwise false.
  133015. */
  133016. hasRenderTargetTextures(): boolean;
  133017. /**
  133018. * Returns an array of the actively used textures.
  133019. * @param activeTextures Array of BaseTextures
  133020. */
  133021. getActiveTextures(activeTextures: BaseTexture[]): void;
  133022. /**
  133023. * Returns the animatable textures.
  133024. * @param animatables Array of animatable textures.
  133025. */
  133026. getAnimatables(animatables: IAnimatable[]): void;
  133027. /**
  133028. * Disposes the resources of the material.
  133029. * @param forceDisposeTextures - Forces the disposal of all textures.
  133030. */
  133031. dispose(forceDisposeTextures?: boolean): void;
  133032. /**
  133033. * Get the current class name of the texture useful for serialization or dynamic coding.
  133034. * @returns "PBRSubSurfaceConfiguration"
  133035. */
  133036. getClassName(): string;
  133037. /**
  133038. * Add fallbacks to the effect fallbacks list.
  133039. * @param defines defines the Base texture to use.
  133040. * @param fallbacks defines the current fallback list.
  133041. * @param currentRank defines the current fallback rank.
  133042. * @returns the new fallback rank.
  133043. */
  133044. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133045. /**
  133046. * Add the required uniforms to the current list.
  133047. * @param uniforms defines the current uniform list.
  133048. */
  133049. static AddUniforms(uniforms: string[]): void;
  133050. /**
  133051. * Add the required samplers to the current list.
  133052. * @param samplers defines the current sampler list.
  133053. */
  133054. static AddSamplers(samplers: string[]): void;
  133055. /**
  133056. * Add the required uniforms to the current buffer.
  133057. * @param uniformBuffer defines the current uniform buffer.
  133058. */
  133059. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133060. /**
  133061. * Makes a duplicate of the current configuration into another one.
  133062. * @param configuration define the config where to copy the info
  133063. */
  133064. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  133065. /**
  133066. * Serializes this Sub Surface configuration.
  133067. * @returns - An object with the serialized config.
  133068. */
  133069. serialize(): any;
  133070. /**
  133071. * Parses a anisotropy Configuration from a serialized object.
  133072. * @param source - Serialized object.
  133073. * @param scene Defines the scene we are parsing for
  133074. * @param rootUrl Defines the rootUrl to load from
  133075. */
  133076. parse(source: any, scene: Scene, rootUrl: string): void;
  133077. }
  133078. }
  133079. declare module BABYLON {
  133080. /** @hidden */
  133081. export var prePassDeclaration: {
  133082. name: string;
  133083. shader: string;
  133084. };
  133085. }
  133086. declare module BABYLON {
  133087. /** @hidden */
  133088. export var pbrFragmentDeclaration: {
  133089. name: string;
  133090. shader: string;
  133091. };
  133092. }
  133093. declare module BABYLON {
  133094. /** @hidden */
  133095. export var pbrUboDeclaration: {
  133096. name: string;
  133097. shader: string;
  133098. };
  133099. }
  133100. declare module BABYLON {
  133101. /** @hidden */
  133102. export var pbrFragmentExtraDeclaration: {
  133103. name: string;
  133104. shader: string;
  133105. };
  133106. }
  133107. declare module BABYLON {
  133108. /** @hidden */
  133109. export var pbrFragmentSamplersDeclaration: {
  133110. name: string;
  133111. shader: string;
  133112. };
  133113. }
  133114. declare module BABYLON {
  133115. /** @hidden */
  133116. export var subSurfaceScatteringFunctions: {
  133117. name: string;
  133118. shader: string;
  133119. };
  133120. }
  133121. declare module BABYLON {
  133122. /** @hidden */
  133123. export var importanceSampling: {
  133124. name: string;
  133125. shader: string;
  133126. };
  133127. }
  133128. declare module BABYLON {
  133129. /** @hidden */
  133130. export var pbrHelperFunctions: {
  133131. name: string;
  133132. shader: string;
  133133. };
  133134. }
  133135. declare module BABYLON {
  133136. /** @hidden */
  133137. export var harmonicsFunctions: {
  133138. name: string;
  133139. shader: string;
  133140. };
  133141. }
  133142. declare module BABYLON {
  133143. /** @hidden */
  133144. export var pbrDirectLightingSetupFunctions: {
  133145. name: string;
  133146. shader: string;
  133147. };
  133148. }
  133149. declare module BABYLON {
  133150. /** @hidden */
  133151. export var pbrDirectLightingFalloffFunctions: {
  133152. name: string;
  133153. shader: string;
  133154. };
  133155. }
  133156. declare module BABYLON {
  133157. /** @hidden */
  133158. export var pbrBRDFFunctions: {
  133159. name: string;
  133160. shader: string;
  133161. };
  133162. }
  133163. declare module BABYLON {
  133164. /** @hidden */
  133165. export var hdrFilteringFunctions: {
  133166. name: string;
  133167. shader: string;
  133168. };
  133169. }
  133170. declare module BABYLON {
  133171. /** @hidden */
  133172. export var pbrDirectLightingFunctions: {
  133173. name: string;
  133174. shader: string;
  133175. };
  133176. }
  133177. declare module BABYLON {
  133178. /** @hidden */
  133179. export var pbrIBLFunctions: {
  133180. name: string;
  133181. shader: string;
  133182. };
  133183. }
  133184. declare module BABYLON {
  133185. /** @hidden */
  133186. export var pbrBlockAlbedoOpacity: {
  133187. name: string;
  133188. shader: string;
  133189. };
  133190. }
  133191. declare module BABYLON {
  133192. /** @hidden */
  133193. export var pbrBlockReflectivity: {
  133194. name: string;
  133195. shader: string;
  133196. };
  133197. }
  133198. declare module BABYLON {
  133199. /** @hidden */
  133200. export var pbrBlockAmbientOcclusion: {
  133201. name: string;
  133202. shader: string;
  133203. };
  133204. }
  133205. declare module BABYLON {
  133206. /** @hidden */
  133207. export var pbrBlockAlphaFresnel: {
  133208. name: string;
  133209. shader: string;
  133210. };
  133211. }
  133212. declare module BABYLON {
  133213. /** @hidden */
  133214. export var pbrBlockAnisotropic: {
  133215. name: string;
  133216. shader: string;
  133217. };
  133218. }
  133219. declare module BABYLON {
  133220. /** @hidden */
  133221. export var pbrBlockReflection: {
  133222. name: string;
  133223. shader: string;
  133224. };
  133225. }
  133226. declare module BABYLON {
  133227. /** @hidden */
  133228. export var pbrBlockSheen: {
  133229. name: string;
  133230. shader: string;
  133231. };
  133232. }
  133233. declare module BABYLON {
  133234. /** @hidden */
  133235. export var pbrBlockClearcoat: {
  133236. name: string;
  133237. shader: string;
  133238. };
  133239. }
  133240. declare module BABYLON {
  133241. /** @hidden */
  133242. export var pbrBlockSubSurface: {
  133243. name: string;
  133244. shader: string;
  133245. };
  133246. }
  133247. declare module BABYLON {
  133248. /** @hidden */
  133249. export var pbrBlockNormalGeometric: {
  133250. name: string;
  133251. shader: string;
  133252. };
  133253. }
  133254. declare module BABYLON {
  133255. /** @hidden */
  133256. export var pbrBlockNormalFinal: {
  133257. name: string;
  133258. shader: string;
  133259. };
  133260. }
  133261. declare module BABYLON {
  133262. /** @hidden */
  133263. export var pbrBlockGeometryInfo: {
  133264. name: string;
  133265. shader: string;
  133266. };
  133267. }
  133268. declare module BABYLON {
  133269. /** @hidden */
  133270. export var pbrBlockReflectance0: {
  133271. name: string;
  133272. shader: string;
  133273. };
  133274. }
  133275. declare module BABYLON {
  133276. /** @hidden */
  133277. export var pbrBlockReflectance: {
  133278. name: string;
  133279. shader: string;
  133280. };
  133281. }
  133282. declare module BABYLON {
  133283. /** @hidden */
  133284. export var pbrBlockDirectLighting: {
  133285. name: string;
  133286. shader: string;
  133287. };
  133288. }
  133289. declare module BABYLON {
  133290. /** @hidden */
  133291. export var pbrBlockFinalLitComponents: {
  133292. name: string;
  133293. shader: string;
  133294. };
  133295. }
  133296. declare module BABYLON {
  133297. /** @hidden */
  133298. export var pbrBlockFinalUnlitComponents: {
  133299. name: string;
  133300. shader: string;
  133301. };
  133302. }
  133303. declare module BABYLON {
  133304. /** @hidden */
  133305. export var pbrBlockFinalColorComposition: {
  133306. name: string;
  133307. shader: string;
  133308. };
  133309. }
  133310. declare module BABYLON {
  133311. /** @hidden */
  133312. export var pbrBlockImageProcessing: {
  133313. name: string;
  133314. shader: string;
  133315. };
  133316. }
  133317. declare module BABYLON {
  133318. /** @hidden */
  133319. export var pbrDebug: {
  133320. name: string;
  133321. shader: string;
  133322. };
  133323. }
  133324. declare module BABYLON {
  133325. /** @hidden */
  133326. export var pbrPixelShader: {
  133327. name: string;
  133328. shader: string;
  133329. };
  133330. }
  133331. declare module BABYLON {
  133332. /** @hidden */
  133333. export var pbrVertexDeclaration: {
  133334. name: string;
  133335. shader: string;
  133336. };
  133337. }
  133338. declare module BABYLON {
  133339. /** @hidden */
  133340. export var pbrVertexShader: {
  133341. name: string;
  133342. shader: string;
  133343. };
  133344. }
  133345. declare module BABYLON {
  133346. /**
  133347. * Manages the defines for the PBR Material.
  133348. * @hidden
  133349. */
  133350. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  133351. PBR: boolean;
  133352. NUM_SAMPLES: string;
  133353. REALTIME_FILTERING: boolean;
  133354. MAINUV1: boolean;
  133355. MAINUV2: boolean;
  133356. UV1: boolean;
  133357. UV2: boolean;
  133358. ALBEDO: boolean;
  133359. GAMMAALBEDO: boolean;
  133360. ALBEDODIRECTUV: number;
  133361. VERTEXCOLOR: boolean;
  133362. DETAIL: boolean;
  133363. DETAILDIRECTUV: number;
  133364. DETAIL_NORMALBLENDMETHOD: number;
  133365. AMBIENT: boolean;
  133366. AMBIENTDIRECTUV: number;
  133367. AMBIENTINGRAYSCALE: boolean;
  133368. OPACITY: boolean;
  133369. VERTEXALPHA: boolean;
  133370. OPACITYDIRECTUV: number;
  133371. OPACITYRGB: boolean;
  133372. ALPHATEST: boolean;
  133373. DEPTHPREPASS: boolean;
  133374. ALPHABLEND: boolean;
  133375. ALPHAFROMALBEDO: boolean;
  133376. ALPHATESTVALUE: string;
  133377. SPECULAROVERALPHA: boolean;
  133378. RADIANCEOVERALPHA: boolean;
  133379. ALPHAFRESNEL: boolean;
  133380. LINEARALPHAFRESNEL: boolean;
  133381. PREMULTIPLYALPHA: boolean;
  133382. EMISSIVE: boolean;
  133383. EMISSIVEDIRECTUV: number;
  133384. REFLECTIVITY: boolean;
  133385. REFLECTIVITYDIRECTUV: number;
  133386. SPECULARTERM: boolean;
  133387. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  133388. MICROSURFACEAUTOMATIC: boolean;
  133389. LODBASEDMICROSFURACE: boolean;
  133390. MICROSURFACEMAP: boolean;
  133391. MICROSURFACEMAPDIRECTUV: number;
  133392. METALLICWORKFLOW: boolean;
  133393. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  133394. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  133395. METALLNESSSTOREINMETALMAPBLUE: boolean;
  133396. AOSTOREINMETALMAPRED: boolean;
  133397. METALLIC_REFLECTANCE: boolean;
  133398. METALLIC_REFLECTANCEDIRECTUV: number;
  133399. ENVIRONMENTBRDF: boolean;
  133400. ENVIRONMENTBRDF_RGBD: boolean;
  133401. NORMAL: boolean;
  133402. TANGENT: boolean;
  133403. BUMP: boolean;
  133404. BUMPDIRECTUV: number;
  133405. OBJECTSPACE_NORMALMAP: boolean;
  133406. PARALLAX: boolean;
  133407. PARALLAXOCCLUSION: boolean;
  133408. NORMALXYSCALE: boolean;
  133409. LIGHTMAP: boolean;
  133410. LIGHTMAPDIRECTUV: number;
  133411. USELIGHTMAPASSHADOWMAP: boolean;
  133412. GAMMALIGHTMAP: boolean;
  133413. RGBDLIGHTMAP: boolean;
  133414. REFLECTION: boolean;
  133415. REFLECTIONMAP_3D: boolean;
  133416. REFLECTIONMAP_SPHERICAL: boolean;
  133417. REFLECTIONMAP_PLANAR: boolean;
  133418. REFLECTIONMAP_CUBIC: boolean;
  133419. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  133420. REFLECTIONMAP_PROJECTION: boolean;
  133421. REFLECTIONMAP_SKYBOX: boolean;
  133422. REFLECTIONMAP_EXPLICIT: boolean;
  133423. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  133424. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  133425. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  133426. INVERTCUBICMAP: boolean;
  133427. USESPHERICALFROMREFLECTIONMAP: boolean;
  133428. USEIRRADIANCEMAP: boolean;
  133429. SPHERICAL_HARMONICS: boolean;
  133430. USESPHERICALINVERTEX: boolean;
  133431. REFLECTIONMAP_OPPOSITEZ: boolean;
  133432. LODINREFLECTIONALPHA: boolean;
  133433. GAMMAREFLECTION: boolean;
  133434. RGBDREFLECTION: boolean;
  133435. LINEARSPECULARREFLECTION: boolean;
  133436. RADIANCEOCCLUSION: boolean;
  133437. HORIZONOCCLUSION: boolean;
  133438. INSTANCES: boolean;
  133439. THIN_INSTANCES: boolean;
  133440. PREPASS: boolean;
  133441. SCENE_MRT_COUNT: number;
  133442. NUM_BONE_INFLUENCERS: number;
  133443. BonesPerMesh: number;
  133444. BONETEXTURE: boolean;
  133445. NONUNIFORMSCALING: boolean;
  133446. MORPHTARGETS: boolean;
  133447. MORPHTARGETS_NORMAL: boolean;
  133448. MORPHTARGETS_TANGENT: boolean;
  133449. MORPHTARGETS_UV: boolean;
  133450. NUM_MORPH_INFLUENCERS: number;
  133451. IMAGEPROCESSING: boolean;
  133452. VIGNETTE: boolean;
  133453. VIGNETTEBLENDMODEMULTIPLY: boolean;
  133454. VIGNETTEBLENDMODEOPAQUE: boolean;
  133455. TONEMAPPING: boolean;
  133456. TONEMAPPING_ACES: boolean;
  133457. CONTRAST: boolean;
  133458. COLORCURVES: boolean;
  133459. COLORGRADING: boolean;
  133460. COLORGRADING3D: boolean;
  133461. SAMPLER3DGREENDEPTH: boolean;
  133462. SAMPLER3DBGRMAP: boolean;
  133463. IMAGEPROCESSINGPOSTPROCESS: boolean;
  133464. EXPOSURE: boolean;
  133465. MULTIVIEW: boolean;
  133466. USEPHYSICALLIGHTFALLOFF: boolean;
  133467. USEGLTFLIGHTFALLOFF: boolean;
  133468. TWOSIDEDLIGHTING: boolean;
  133469. SHADOWFLOAT: boolean;
  133470. CLIPPLANE: boolean;
  133471. CLIPPLANE2: boolean;
  133472. CLIPPLANE3: boolean;
  133473. CLIPPLANE4: boolean;
  133474. CLIPPLANE5: boolean;
  133475. CLIPPLANE6: boolean;
  133476. POINTSIZE: boolean;
  133477. FOG: boolean;
  133478. LOGARITHMICDEPTH: boolean;
  133479. FORCENORMALFORWARD: boolean;
  133480. SPECULARAA: boolean;
  133481. CLEARCOAT: boolean;
  133482. CLEARCOAT_DEFAULTIOR: boolean;
  133483. CLEARCOAT_TEXTURE: boolean;
  133484. CLEARCOAT_TEXTUREDIRECTUV: number;
  133485. CLEARCOAT_BUMP: boolean;
  133486. CLEARCOAT_BUMPDIRECTUV: number;
  133487. CLEARCOAT_TINT: boolean;
  133488. CLEARCOAT_TINT_TEXTURE: boolean;
  133489. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133490. ANISOTROPIC: boolean;
  133491. ANISOTROPIC_TEXTURE: boolean;
  133492. ANISOTROPIC_TEXTUREDIRECTUV: number;
  133493. BRDF_V_HEIGHT_CORRELATED: boolean;
  133494. MS_BRDF_ENERGY_CONSERVATION: boolean;
  133495. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  133496. SHEEN: boolean;
  133497. SHEEN_TEXTURE: boolean;
  133498. SHEEN_TEXTUREDIRECTUV: number;
  133499. SHEEN_LINKWITHALBEDO: boolean;
  133500. SHEEN_ROUGHNESS: boolean;
  133501. SHEEN_ALBEDOSCALING: boolean;
  133502. SUBSURFACE: boolean;
  133503. SS_REFRACTION: boolean;
  133504. SS_TRANSLUCENCY: boolean;
  133505. SS_SCATTERING: boolean;
  133506. SS_THICKNESSANDMASK_TEXTURE: boolean;
  133507. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  133508. SS_REFRACTIONMAP_3D: boolean;
  133509. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  133510. SS_LODINREFRACTIONALPHA: boolean;
  133511. SS_GAMMAREFRACTION: boolean;
  133512. SS_RGBDREFRACTION: boolean;
  133513. SS_LINEARSPECULARREFRACTION: boolean;
  133514. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  133515. SS_ALBEDOFORREFRACTIONTINT: boolean;
  133516. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  133517. UNLIT: boolean;
  133518. DEBUGMODE: number;
  133519. /**
  133520. * Initializes the PBR Material defines.
  133521. */
  133522. constructor();
  133523. /**
  133524. * Resets the PBR Material defines.
  133525. */
  133526. reset(): void;
  133527. }
  133528. /**
  133529. * The Physically based material base class of BJS.
  133530. *
  133531. * This offers the main features of a standard PBR material.
  133532. * For more information, please refer to the documentation :
  133533. * https://doc.babylonjs.com/how_to/physically_based_rendering
  133534. */
  133535. export abstract class PBRBaseMaterial extends PushMaterial {
  133536. /**
  133537. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  133538. */
  133539. static readonly PBRMATERIAL_OPAQUE: number;
  133540. /**
  133541. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  133542. */
  133543. static readonly PBRMATERIAL_ALPHATEST: number;
  133544. /**
  133545. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133546. */
  133547. static readonly PBRMATERIAL_ALPHABLEND: number;
  133548. /**
  133549. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133550. * They are also discarded below the alpha cutoff threshold to improve performances.
  133551. */
  133552. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  133553. /**
  133554. * Defines the default value of how much AO map is occluding the analytical lights
  133555. * (point spot...).
  133556. */
  133557. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  133558. /**
  133559. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  133560. */
  133561. static readonly LIGHTFALLOFF_PHYSICAL: number;
  133562. /**
  133563. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  133564. * to enhance interoperability with other engines.
  133565. */
  133566. static readonly LIGHTFALLOFF_GLTF: number;
  133567. /**
  133568. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  133569. * to enhance interoperability with other materials.
  133570. */
  133571. static readonly LIGHTFALLOFF_STANDARD: number;
  133572. /**
  133573. * Intensity of the direct lights e.g. the four lights available in your scene.
  133574. * This impacts both the direct diffuse and specular highlights.
  133575. */
  133576. protected _directIntensity: number;
  133577. /**
  133578. * Intensity of the emissive part of the material.
  133579. * This helps controlling the emissive effect without modifying the emissive color.
  133580. */
  133581. protected _emissiveIntensity: number;
  133582. /**
  133583. * Intensity of the environment e.g. how much the environment will light the object
  133584. * either through harmonics for rough material or through the refelction for shiny ones.
  133585. */
  133586. protected _environmentIntensity: number;
  133587. /**
  133588. * This is a special control allowing the reduction of the specular highlights coming from the
  133589. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  133590. */
  133591. protected _specularIntensity: number;
  133592. /**
  133593. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  133594. */
  133595. private _lightingInfos;
  133596. /**
  133597. * Debug Control allowing disabling the bump map on this material.
  133598. */
  133599. protected _disableBumpMap: boolean;
  133600. /**
  133601. * AKA Diffuse Texture in standard nomenclature.
  133602. */
  133603. protected _albedoTexture: Nullable<BaseTexture>;
  133604. /**
  133605. * AKA Occlusion Texture in other nomenclature.
  133606. */
  133607. protected _ambientTexture: Nullable<BaseTexture>;
  133608. /**
  133609. * AKA Occlusion Texture Intensity in other nomenclature.
  133610. */
  133611. protected _ambientTextureStrength: number;
  133612. /**
  133613. * Defines how much the AO map is occluding the analytical lights (point spot...).
  133614. * 1 means it completely occludes it
  133615. * 0 mean it has no impact
  133616. */
  133617. protected _ambientTextureImpactOnAnalyticalLights: number;
  133618. /**
  133619. * Stores the alpha values in a texture.
  133620. */
  133621. protected _opacityTexture: Nullable<BaseTexture>;
  133622. /**
  133623. * Stores the reflection values in a texture.
  133624. */
  133625. protected _reflectionTexture: Nullable<BaseTexture>;
  133626. /**
  133627. * Stores the emissive values in a texture.
  133628. */
  133629. protected _emissiveTexture: Nullable<BaseTexture>;
  133630. /**
  133631. * AKA Specular texture in other nomenclature.
  133632. */
  133633. protected _reflectivityTexture: Nullable<BaseTexture>;
  133634. /**
  133635. * Used to switch from specular/glossiness to metallic/roughness workflow.
  133636. */
  133637. protected _metallicTexture: Nullable<BaseTexture>;
  133638. /**
  133639. * Specifies the metallic scalar of the metallic/roughness workflow.
  133640. * Can also be used to scale the metalness values of the metallic texture.
  133641. */
  133642. protected _metallic: Nullable<number>;
  133643. /**
  133644. * Specifies the roughness scalar of the metallic/roughness workflow.
  133645. * Can also be used to scale the roughness values of the metallic texture.
  133646. */
  133647. protected _roughness: Nullable<number>;
  133648. /**
  133649. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  133650. * By default the indexOfrefraction is used to compute F0;
  133651. *
  133652. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  133653. *
  133654. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  133655. * F90 = metallicReflectanceColor;
  133656. */
  133657. protected _metallicF0Factor: number;
  133658. /**
  133659. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  133660. * By default the F90 is always 1;
  133661. *
  133662. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  133663. *
  133664. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  133665. * F90 = metallicReflectanceColor;
  133666. */
  133667. protected _metallicReflectanceColor: Color3;
  133668. /**
  133669. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  133670. * This is multiply against the scalar values defined in the material.
  133671. */
  133672. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  133673. /**
  133674. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  133675. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  133676. */
  133677. protected _microSurfaceTexture: Nullable<BaseTexture>;
  133678. /**
  133679. * Stores surface normal data used to displace a mesh in a texture.
  133680. */
  133681. protected _bumpTexture: Nullable<BaseTexture>;
  133682. /**
  133683. * Stores the pre-calculated light information of a mesh in a texture.
  133684. */
  133685. protected _lightmapTexture: Nullable<BaseTexture>;
  133686. /**
  133687. * The color of a material in ambient lighting.
  133688. */
  133689. protected _ambientColor: Color3;
  133690. /**
  133691. * AKA Diffuse Color in other nomenclature.
  133692. */
  133693. protected _albedoColor: Color3;
  133694. /**
  133695. * AKA Specular Color in other nomenclature.
  133696. */
  133697. protected _reflectivityColor: Color3;
  133698. /**
  133699. * The color applied when light is reflected from a material.
  133700. */
  133701. protected _reflectionColor: Color3;
  133702. /**
  133703. * The color applied when light is emitted from a material.
  133704. */
  133705. protected _emissiveColor: Color3;
  133706. /**
  133707. * AKA Glossiness in other nomenclature.
  133708. */
  133709. protected _microSurface: number;
  133710. /**
  133711. * Specifies that the material will use the light map as a show map.
  133712. */
  133713. protected _useLightmapAsShadowmap: boolean;
  133714. /**
  133715. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133716. * makes the reflect vector face the model (under horizon).
  133717. */
  133718. protected _useHorizonOcclusion: boolean;
  133719. /**
  133720. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133721. * too much the area relying on ambient texture to define their ambient occlusion.
  133722. */
  133723. protected _useRadianceOcclusion: boolean;
  133724. /**
  133725. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133726. */
  133727. protected _useAlphaFromAlbedoTexture: boolean;
  133728. /**
  133729. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  133730. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133731. */
  133732. protected _useSpecularOverAlpha: boolean;
  133733. /**
  133734. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133735. */
  133736. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133737. /**
  133738. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133739. */
  133740. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  133741. /**
  133742. * Specifies if the metallic texture contains the roughness information in its green channel.
  133743. */
  133744. protected _useRoughnessFromMetallicTextureGreen: boolean;
  133745. /**
  133746. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133747. */
  133748. protected _useMetallnessFromMetallicTextureBlue: boolean;
  133749. /**
  133750. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133751. */
  133752. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  133753. /**
  133754. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133755. */
  133756. protected _useAmbientInGrayScale: boolean;
  133757. /**
  133758. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133759. * The material will try to infer what glossiness each pixel should be.
  133760. */
  133761. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  133762. /**
  133763. * Defines the falloff type used in this material.
  133764. * It by default is Physical.
  133765. */
  133766. protected _lightFalloff: number;
  133767. /**
  133768. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133769. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133770. */
  133771. protected _useRadianceOverAlpha: boolean;
  133772. /**
  133773. * Allows using an object space normal map (instead of tangent space).
  133774. */
  133775. protected _useObjectSpaceNormalMap: boolean;
  133776. /**
  133777. * Allows using the bump map in parallax mode.
  133778. */
  133779. protected _useParallax: boolean;
  133780. /**
  133781. * Allows using the bump map in parallax occlusion mode.
  133782. */
  133783. protected _useParallaxOcclusion: boolean;
  133784. /**
  133785. * Controls the scale bias of the parallax mode.
  133786. */
  133787. protected _parallaxScaleBias: number;
  133788. /**
  133789. * If sets to true, disables all the lights affecting the material.
  133790. */
  133791. protected _disableLighting: boolean;
  133792. /**
  133793. * Number of Simultaneous lights allowed on the material.
  133794. */
  133795. protected _maxSimultaneousLights: number;
  133796. /**
  133797. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133798. */
  133799. protected _invertNormalMapX: boolean;
  133800. /**
  133801. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133802. */
  133803. protected _invertNormalMapY: boolean;
  133804. /**
  133805. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133806. */
  133807. protected _twoSidedLighting: boolean;
  133808. /**
  133809. * Defines the alpha limits in alpha test mode.
  133810. */
  133811. protected _alphaCutOff: number;
  133812. /**
  133813. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133814. */
  133815. protected _forceAlphaTest: boolean;
  133816. /**
  133817. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133818. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133819. */
  133820. protected _useAlphaFresnel: boolean;
  133821. /**
  133822. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133823. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133824. */
  133825. protected _useLinearAlphaFresnel: boolean;
  133826. /**
  133827. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  133828. * from cos thetav and roughness:
  133829. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  133830. */
  133831. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  133832. /**
  133833. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133834. */
  133835. protected _forceIrradianceInFragment: boolean;
  133836. private _realTimeFiltering;
  133837. /**
  133838. * Enables realtime filtering on the texture.
  133839. */
  133840. get realTimeFiltering(): boolean;
  133841. set realTimeFiltering(b: boolean);
  133842. private _realTimeFilteringQuality;
  133843. /**
  133844. * Quality switch for realtime filtering
  133845. */
  133846. get realTimeFilteringQuality(): number;
  133847. set realTimeFilteringQuality(n: number);
  133848. /**
  133849. * Should this material render to several textures at once
  133850. */
  133851. get shouldRenderToMRT(): boolean;
  133852. /**
  133853. * Force normal to face away from face.
  133854. */
  133855. protected _forceNormalForward: boolean;
  133856. /**
  133857. * Enables specular anti aliasing in the PBR shader.
  133858. * It will both interacts on the Geometry for analytical and IBL lighting.
  133859. * It also prefilter the roughness map based on the bump values.
  133860. */
  133861. protected _enableSpecularAntiAliasing: boolean;
  133862. /**
  133863. * Default configuration related to image processing available in the PBR Material.
  133864. */
  133865. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133866. /**
  133867. * Keep track of the image processing observer to allow dispose and replace.
  133868. */
  133869. private _imageProcessingObserver;
  133870. /**
  133871. * Attaches a new image processing configuration to the PBR Material.
  133872. * @param configuration
  133873. */
  133874. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133875. /**
  133876. * Stores the available render targets.
  133877. */
  133878. private _renderTargets;
  133879. /**
  133880. * Sets the global ambient color for the material used in lighting calculations.
  133881. */
  133882. private _globalAmbientColor;
  133883. /**
  133884. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  133885. */
  133886. private _useLogarithmicDepth;
  133887. /**
  133888. * If set to true, no lighting calculations will be applied.
  133889. */
  133890. private _unlit;
  133891. private _debugMode;
  133892. /**
  133893. * @hidden
  133894. * This is reserved for the inspector.
  133895. * Defines the material debug mode.
  133896. * It helps seeing only some components of the material while troubleshooting.
  133897. */
  133898. debugMode: number;
  133899. /**
  133900. * @hidden
  133901. * This is reserved for the inspector.
  133902. * Specify from where on screen the debug mode should start.
  133903. * The value goes from -1 (full screen) to 1 (not visible)
  133904. * It helps with side by side comparison against the final render
  133905. * This defaults to -1
  133906. */
  133907. private debugLimit;
  133908. /**
  133909. * @hidden
  133910. * This is reserved for the inspector.
  133911. * As the default viewing range might not be enough (if the ambient is really small for instance)
  133912. * You can use the factor to better multiply the final value.
  133913. */
  133914. private debugFactor;
  133915. /**
  133916. * Defines the clear coat layer parameters for the material.
  133917. */
  133918. readonly clearCoat: PBRClearCoatConfiguration;
  133919. /**
  133920. * Defines the anisotropic parameters for the material.
  133921. */
  133922. readonly anisotropy: PBRAnisotropicConfiguration;
  133923. /**
  133924. * Defines the BRDF parameters for the material.
  133925. */
  133926. readonly brdf: PBRBRDFConfiguration;
  133927. /**
  133928. * Defines the Sheen parameters for the material.
  133929. */
  133930. readonly sheen: PBRSheenConfiguration;
  133931. /**
  133932. * Defines the SubSurface parameters for the material.
  133933. */
  133934. readonly subSurface: PBRSubSurfaceConfiguration;
  133935. /**
  133936. * Defines the detail map parameters for the material.
  133937. */
  133938. readonly detailMap: DetailMapConfiguration;
  133939. protected _rebuildInParallel: boolean;
  133940. /**
  133941. * Instantiates a new PBRMaterial instance.
  133942. *
  133943. * @param name The material name
  133944. * @param scene The scene the material will be use in.
  133945. */
  133946. constructor(name: string, scene: Scene);
  133947. /**
  133948. * Gets a boolean indicating that current material needs to register RTT
  133949. */
  133950. get hasRenderTargetTextures(): boolean;
  133951. /**
  133952. * Gets the name of the material class.
  133953. */
  133954. getClassName(): string;
  133955. /**
  133956. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133957. */
  133958. get useLogarithmicDepth(): boolean;
  133959. /**
  133960. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133961. */
  133962. set useLogarithmicDepth(value: boolean);
  133963. /**
  133964. * Returns true if alpha blending should be disabled.
  133965. */
  133966. protected get _disableAlphaBlending(): boolean;
  133967. /**
  133968. * Specifies whether or not this material should be rendered in alpha blend mode.
  133969. */
  133970. needAlphaBlending(): boolean;
  133971. /**
  133972. * Specifies whether or not this material should be rendered in alpha test mode.
  133973. */
  133974. needAlphaTesting(): boolean;
  133975. /**
  133976. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  133977. */
  133978. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  133979. /**
  133980. * Gets the texture used for the alpha test.
  133981. */
  133982. getAlphaTestTexture(): Nullable<BaseTexture>;
  133983. /**
  133984. * Specifies that the submesh is ready to be used.
  133985. * @param mesh - BJS mesh.
  133986. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  133987. * @param useInstances - Specifies that instances should be used.
  133988. * @returns - boolean indicating that the submesh is ready or not.
  133989. */
  133990. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133991. /**
  133992. * Specifies if the material uses metallic roughness workflow.
  133993. * @returns boolean specifiying if the material uses metallic roughness workflow.
  133994. */
  133995. isMetallicWorkflow(): boolean;
  133996. private _prepareEffect;
  133997. private _prepareDefines;
  133998. /**
  133999. * Force shader compilation
  134000. */
  134001. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  134002. /**
  134003. * Initializes the uniform buffer layout for the shader.
  134004. */
  134005. buildUniformLayout(): void;
  134006. /**
  134007. * Unbinds the material from the mesh
  134008. */
  134009. unbind(): void;
  134010. /**
  134011. * Binds the submesh data.
  134012. * @param world - The world matrix.
  134013. * @param mesh - The BJS mesh.
  134014. * @param subMesh - A submesh of the BJS mesh.
  134015. */
  134016. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134017. /**
  134018. * Returns the animatable textures.
  134019. * @returns - Array of animatable textures.
  134020. */
  134021. getAnimatables(): IAnimatable[];
  134022. /**
  134023. * Returns the texture used for reflections.
  134024. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  134025. */
  134026. private _getReflectionTexture;
  134027. /**
  134028. * Returns an array of the actively used textures.
  134029. * @returns - Array of BaseTextures
  134030. */
  134031. getActiveTextures(): BaseTexture[];
  134032. /**
  134033. * Checks to see if a texture is used in the material.
  134034. * @param texture - Base texture to use.
  134035. * @returns - Boolean specifying if a texture is used in the material.
  134036. */
  134037. hasTexture(texture: BaseTexture): boolean;
  134038. /**
  134039. * Disposes the resources of the material.
  134040. * @param forceDisposeEffect - Forces the disposal of effects.
  134041. * @param forceDisposeTextures - Forces the disposal of all textures.
  134042. */
  134043. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134044. }
  134045. }
  134046. declare module BABYLON {
  134047. /**
  134048. * The Physically based material of BJS.
  134049. *
  134050. * This offers the main features of a standard PBR material.
  134051. * For more information, please refer to the documentation :
  134052. * https://doc.babylonjs.com/how_to/physically_based_rendering
  134053. */
  134054. export class PBRMaterial extends PBRBaseMaterial {
  134055. /**
  134056. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  134057. */
  134058. static readonly PBRMATERIAL_OPAQUE: number;
  134059. /**
  134060. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  134061. */
  134062. static readonly PBRMATERIAL_ALPHATEST: number;
  134063. /**
  134064. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134065. */
  134066. static readonly PBRMATERIAL_ALPHABLEND: number;
  134067. /**
  134068. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134069. * They are also discarded below the alpha cutoff threshold to improve performances.
  134070. */
  134071. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  134072. /**
  134073. * Defines the default value of how much AO map is occluding the analytical lights
  134074. * (point spot...).
  134075. */
  134076. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  134077. /**
  134078. * Intensity of the direct lights e.g. the four lights available in your scene.
  134079. * This impacts both the direct diffuse and specular highlights.
  134080. */
  134081. directIntensity: number;
  134082. /**
  134083. * Intensity of the emissive part of the material.
  134084. * This helps controlling the emissive effect without modifying the emissive color.
  134085. */
  134086. emissiveIntensity: number;
  134087. /**
  134088. * Intensity of the environment e.g. how much the environment will light the object
  134089. * either through harmonics for rough material or through the refelction for shiny ones.
  134090. */
  134091. environmentIntensity: number;
  134092. /**
  134093. * This is a special control allowing the reduction of the specular highlights coming from the
  134094. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  134095. */
  134096. specularIntensity: number;
  134097. /**
  134098. * Debug Control allowing disabling the bump map on this material.
  134099. */
  134100. disableBumpMap: boolean;
  134101. /**
  134102. * AKA Diffuse Texture in standard nomenclature.
  134103. */
  134104. albedoTexture: BaseTexture;
  134105. /**
  134106. * AKA Occlusion Texture in other nomenclature.
  134107. */
  134108. ambientTexture: BaseTexture;
  134109. /**
  134110. * AKA Occlusion Texture Intensity in other nomenclature.
  134111. */
  134112. ambientTextureStrength: number;
  134113. /**
  134114. * Defines how much the AO map is occluding the analytical lights (point spot...).
  134115. * 1 means it completely occludes it
  134116. * 0 mean it has no impact
  134117. */
  134118. ambientTextureImpactOnAnalyticalLights: number;
  134119. /**
  134120. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  134121. */
  134122. opacityTexture: BaseTexture;
  134123. /**
  134124. * Stores the reflection values in a texture.
  134125. */
  134126. reflectionTexture: Nullable<BaseTexture>;
  134127. /**
  134128. * Stores the emissive values in a texture.
  134129. */
  134130. emissiveTexture: BaseTexture;
  134131. /**
  134132. * AKA Specular texture in other nomenclature.
  134133. */
  134134. reflectivityTexture: BaseTexture;
  134135. /**
  134136. * Used to switch from specular/glossiness to metallic/roughness workflow.
  134137. */
  134138. metallicTexture: BaseTexture;
  134139. /**
  134140. * Specifies the metallic scalar of the metallic/roughness workflow.
  134141. * Can also be used to scale the metalness values of the metallic texture.
  134142. */
  134143. metallic: Nullable<number>;
  134144. /**
  134145. * Specifies the roughness scalar of the metallic/roughness workflow.
  134146. * Can also be used to scale the roughness values of the metallic texture.
  134147. */
  134148. roughness: Nullable<number>;
  134149. /**
  134150. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  134151. * By default the indexOfrefraction is used to compute F0;
  134152. *
  134153. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  134154. *
  134155. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  134156. * F90 = metallicReflectanceColor;
  134157. */
  134158. metallicF0Factor: number;
  134159. /**
  134160. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  134161. * By default the F90 is always 1;
  134162. *
  134163. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  134164. *
  134165. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  134166. * F90 = metallicReflectanceColor;
  134167. */
  134168. metallicReflectanceColor: Color3;
  134169. /**
  134170. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  134171. * This is multiply against the scalar values defined in the material.
  134172. */
  134173. metallicReflectanceTexture: Nullable<BaseTexture>;
  134174. /**
  134175. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  134176. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  134177. */
  134178. microSurfaceTexture: BaseTexture;
  134179. /**
  134180. * Stores surface normal data used to displace a mesh in a texture.
  134181. */
  134182. bumpTexture: BaseTexture;
  134183. /**
  134184. * Stores the pre-calculated light information of a mesh in a texture.
  134185. */
  134186. lightmapTexture: BaseTexture;
  134187. /**
  134188. * Stores the refracted light information in a texture.
  134189. */
  134190. get refractionTexture(): Nullable<BaseTexture>;
  134191. set refractionTexture(value: Nullable<BaseTexture>);
  134192. /**
  134193. * The color of a material in ambient lighting.
  134194. */
  134195. ambientColor: Color3;
  134196. /**
  134197. * AKA Diffuse Color in other nomenclature.
  134198. */
  134199. albedoColor: Color3;
  134200. /**
  134201. * AKA Specular Color in other nomenclature.
  134202. */
  134203. reflectivityColor: Color3;
  134204. /**
  134205. * The color reflected from the material.
  134206. */
  134207. reflectionColor: Color3;
  134208. /**
  134209. * The color emitted from the material.
  134210. */
  134211. emissiveColor: Color3;
  134212. /**
  134213. * AKA Glossiness in other nomenclature.
  134214. */
  134215. microSurface: number;
  134216. /**
  134217. * Index of refraction of the material base layer.
  134218. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134219. *
  134220. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134221. *
  134222. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134223. */
  134224. get indexOfRefraction(): number;
  134225. set indexOfRefraction(value: number);
  134226. /**
  134227. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134228. */
  134229. get invertRefractionY(): boolean;
  134230. set invertRefractionY(value: boolean);
  134231. /**
  134232. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134233. * Materials half opaque for instance using refraction could benefit from this control.
  134234. */
  134235. get linkRefractionWithTransparency(): boolean;
  134236. set linkRefractionWithTransparency(value: boolean);
  134237. /**
  134238. * If true, the light map contains occlusion information instead of lighting info.
  134239. */
  134240. useLightmapAsShadowmap: boolean;
  134241. /**
  134242. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  134243. */
  134244. useAlphaFromAlbedoTexture: boolean;
  134245. /**
  134246. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  134247. */
  134248. forceAlphaTest: boolean;
  134249. /**
  134250. * Defines the alpha limits in alpha test mode.
  134251. */
  134252. alphaCutOff: number;
  134253. /**
  134254. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  134255. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  134256. */
  134257. useSpecularOverAlpha: boolean;
  134258. /**
  134259. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  134260. */
  134261. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  134262. /**
  134263. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  134264. */
  134265. useRoughnessFromMetallicTextureAlpha: boolean;
  134266. /**
  134267. * Specifies if the metallic texture contains the roughness information in its green channel.
  134268. */
  134269. useRoughnessFromMetallicTextureGreen: boolean;
  134270. /**
  134271. * Specifies if the metallic texture contains the metallness information in its blue channel.
  134272. */
  134273. useMetallnessFromMetallicTextureBlue: boolean;
  134274. /**
  134275. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  134276. */
  134277. useAmbientOcclusionFromMetallicTextureRed: boolean;
  134278. /**
  134279. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  134280. */
  134281. useAmbientInGrayScale: boolean;
  134282. /**
  134283. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  134284. * The material will try to infer what glossiness each pixel should be.
  134285. */
  134286. useAutoMicroSurfaceFromReflectivityMap: boolean;
  134287. /**
  134288. * BJS is using an harcoded light falloff based on a manually sets up range.
  134289. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  134290. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  134291. */
  134292. get usePhysicalLightFalloff(): boolean;
  134293. /**
  134294. * BJS is using an harcoded light falloff based on a manually sets up range.
  134295. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  134296. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  134297. */
  134298. set usePhysicalLightFalloff(value: boolean);
  134299. /**
  134300. * In order to support the falloff compatibility with gltf, a special mode has been added
  134301. * to reproduce the gltf light falloff.
  134302. */
  134303. get useGLTFLightFalloff(): boolean;
  134304. /**
  134305. * In order to support the falloff compatibility with gltf, a special mode has been added
  134306. * to reproduce the gltf light falloff.
  134307. */
  134308. set useGLTFLightFalloff(value: boolean);
  134309. /**
  134310. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  134311. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  134312. */
  134313. useRadianceOverAlpha: boolean;
  134314. /**
  134315. * Allows using an object space normal map (instead of tangent space).
  134316. */
  134317. useObjectSpaceNormalMap: boolean;
  134318. /**
  134319. * Allows using the bump map in parallax mode.
  134320. */
  134321. useParallax: boolean;
  134322. /**
  134323. * Allows using the bump map in parallax occlusion mode.
  134324. */
  134325. useParallaxOcclusion: boolean;
  134326. /**
  134327. * Controls the scale bias of the parallax mode.
  134328. */
  134329. parallaxScaleBias: number;
  134330. /**
  134331. * If sets to true, disables all the lights affecting the material.
  134332. */
  134333. disableLighting: boolean;
  134334. /**
  134335. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  134336. */
  134337. forceIrradianceInFragment: boolean;
  134338. /**
  134339. * Number of Simultaneous lights allowed on the material.
  134340. */
  134341. maxSimultaneousLights: number;
  134342. /**
  134343. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  134344. */
  134345. invertNormalMapX: boolean;
  134346. /**
  134347. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  134348. */
  134349. invertNormalMapY: boolean;
  134350. /**
  134351. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  134352. */
  134353. twoSidedLighting: boolean;
  134354. /**
  134355. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134356. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  134357. */
  134358. useAlphaFresnel: boolean;
  134359. /**
  134360. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134361. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  134362. */
  134363. useLinearAlphaFresnel: boolean;
  134364. /**
  134365. * Let user defines the brdf lookup texture used for IBL.
  134366. * A default 8bit version is embedded but you could point at :
  134367. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  134368. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  134369. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  134370. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  134371. */
  134372. environmentBRDFTexture: Nullable<BaseTexture>;
  134373. /**
  134374. * Force normal to face away from face.
  134375. */
  134376. forceNormalForward: boolean;
  134377. /**
  134378. * Enables specular anti aliasing in the PBR shader.
  134379. * It will both interacts on the Geometry for analytical and IBL lighting.
  134380. * It also prefilter the roughness map based on the bump values.
  134381. */
  134382. enableSpecularAntiAliasing: boolean;
  134383. /**
  134384. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  134385. * makes the reflect vector face the model (under horizon).
  134386. */
  134387. useHorizonOcclusion: boolean;
  134388. /**
  134389. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  134390. * too much the area relying on ambient texture to define their ambient occlusion.
  134391. */
  134392. useRadianceOcclusion: boolean;
  134393. /**
  134394. * If set to true, no lighting calculations will be applied.
  134395. */
  134396. unlit: boolean;
  134397. /**
  134398. * Gets the image processing configuration used either in this material.
  134399. */
  134400. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  134401. /**
  134402. * Sets the Default image processing configuration used either in the this material.
  134403. *
  134404. * If sets to null, the scene one is in use.
  134405. */
  134406. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  134407. /**
  134408. * Gets wether the color curves effect is enabled.
  134409. */
  134410. get cameraColorCurvesEnabled(): boolean;
  134411. /**
  134412. * Sets wether the color curves effect is enabled.
  134413. */
  134414. set cameraColorCurvesEnabled(value: boolean);
  134415. /**
  134416. * Gets wether the color grading effect is enabled.
  134417. */
  134418. get cameraColorGradingEnabled(): boolean;
  134419. /**
  134420. * Gets wether the color grading effect is enabled.
  134421. */
  134422. set cameraColorGradingEnabled(value: boolean);
  134423. /**
  134424. * Gets wether tonemapping is enabled or not.
  134425. */
  134426. get cameraToneMappingEnabled(): boolean;
  134427. /**
  134428. * Sets wether tonemapping is enabled or not
  134429. */
  134430. set cameraToneMappingEnabled(value: boolean);
  134431. /**
  134432. * The camera exposure used on this material.
  134433. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134434. * This corresponds to a photographic exposure.
  134435. */
  134436. get cameraExposure(): number;
  134437. /**
  134438. * The camera exposure used on this material.
  134439. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134440. * This corresponds to a photographic exposure.
  134441. */
  134442. set cameraExposure(value: number);
  134443. /**
  134444. * Gets The camera contrast used on this material.
  134445. */
  134446. get cameraContrast(): number;
  134447. /**
  134448. * Sets The camera contrast used on this material.
  134449. */
  134450. set cameraContrast(value: number);
  134451. /**
  134452. * Gets the Color Grading 2D Lookup Texture.
  134453. */
  134454. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134455. /**
  134456. * Sets the Color Grading 2D Lookup Texture.
  134457. */
  134458. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134459. /**
  134460. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134461. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134462. * 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;
  134463. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134464. */
  134465. get cameraColorCurves(): Nullable<ColorCurves>;
  134466. /**
  134467. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134468. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134469. * 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;
  134470. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134471. */
  134472. set cameraColorCurves(value: Nullable<ColorCurves>);
  134473. /**
  134474. * Instantiates a new PBRMaterial instance.
  134475. *
  134476. * @param name The material name
  134477. * @param scene The scene the material will be use in.
  134478. */
  134479. constructor(name: string, scene: Scene);
  134480. /**
  134481. * Returns the name of this material class.
  134482. */
  134483. getClassName(): string;
  134484. /**
  134485. * Makes a duplicate of the current material.
  134486. * @param name - name to use for the new material.
  134487. */
  134488. clone(name: string): PBRMaterial;
  134489. /**
  134490. * Serializes this PBR Material.
  134491. * @returns - An object with the serialized material.
  134492. */
  134493. serialize(): any;
  134494. /**
  134495. * Parses a PBR Material from a serialized object.
  134496. * @param source - Serialized object.
  134497. * @param scene - BJS scene instance.
  134498. * @param rootUrl - url for the scene object
  134499. * @returns - PBRMaterial
  134500. */
  134501. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  134502. }
  134503. }
  134504. declare module BABYLON {
  134505. /**
  134506. * Direct draw surface info
  134507. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  134508. */
  134509. export interface DDSInfo {
  134510. /**
  134511. * Width of the texture
  134512. */
  134513. width: number;
  134514. /**
  134515. * Width of the texture
  134516. */
  134517. height: number;
  134518. /**
  134519. * Number of Mipmaps for the texture
  134520. * @see https://en.wikipedia.org/wiki/Mipmap
  134521. */
  134522. mipmapCount: number;
  134523. /**
  134524. * If the textures format is a known fourCC format
  134525. * @see https://www.fourcc.org/
  134526. */
  134527. isFourCC: boolean;
  134528. /**
  134529. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  134530. */
  134531. isRGB: boolean;
  134532. /**
  134533. * If the texture is a lumincance format
  134534. */
  134535. isLuminance: boolean;
  134536. /**
  134537. * If this is a cube texture
  134538. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  134539. */
  134540. isCube: boolean;
  134541. /**
  134542. * If the texture is a compressed format eg. FOURCC_DXT1
  134543. */
  134544. isCompressed: boolean;
  134545. /**
  134546. * The dxgiFormat of the texture
  134547. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  134548. */
  134549. dxgiFormat: number;
  134550. /**
  134551. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  134552. */
  134553. textureType: number;
  134554. /**
  134555. * Sphericle polynomial created for the dds texture
  134556. */
  134557. sphericalPolynomial?: SphericalPolynomial;
  134558. }
  134559. /**
  134560. * Class used to provide DDS decompression tools
  134561. */
  134562. export class DDSTools {
  134563. /**
  134564. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  134565. */
  134566. static StoreLODInAlphaChannel: boolean;
  134567. /**
  134568. * Gets DDS information from an array buffer
  134569. * @param data defines the array buffer view to read data from
  134570. * @returns the DDS information
  134571. */
  134572. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  134573. private static _FloatView;
  134574. private static _Int32View;
  134575. private static _ToHalfFloat;
  134576. private static _FromHalfFloat;
  134577. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  134578. private static _GetHalfFloatRGBAArrayBuffer;
  134579. private static _GetFloatRGBAArrayBuffer;
  134580. private static _GetFloatAsUIntRGBAArrayBuffer;
  134581. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  134582. private static _GetRGBAArrayBuffer;
  134583. private static _ExtractLongWordOrder;
  134584. private static _GetRGBArrayBuffer;
  134585. private static _GetLuminanceArrayBuffer;
  134586. /**
  134587. * Uploads DDS Levels to a Babylon Texture
  134588. * @hidden
  134589. */
  134590. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  134591. }
  134592. interface ThinEngine {
  134593. /**
  134594. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  134595. * @param rootUrl defines the url where the file to load is located
  134596. * @param scene defines the current scene
  134597. * @param lodScale defines scale to apply to the mip map selection
  134598. * @param lodOffset defines offset to apply to the mip map selection
  134599. * @param onLoad defines an optional callback raised when the texture is loaded
  134600. * @param onError defines an optional callback raised if there is an issue to load the texture
  134601. * @param format defines the format of the data
  134602. * @param forcedExtension defines the extension to use to pick the right loader
  134603. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  134604. * @returns the cube texture as an InternalTexture
  134605. */
  134606. 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;
  134607. }
  134608. }
  134609. declare module BABYLON {
  134610. /**
  134611. * Implementation of the DDS Texture Loader.
  134612. * @hidden
  134613. */
  134614. export class _DDSTextureLoader implements IInternalTextureLoader {
  134615. /**
  134616. * Defines wether the loader supports cascade loading the different faces.
  134617. */
  134618. readonly supportCascades: boolean;
  134619. /**
  134620. * This returns if the loader support the current file information.
  134621. * @param extension defines the file extension of the file being loaded
  134622. * @returns true if the loader can load the specified file
  134623. */
  134624. canLoad(extension: string): boolean;
  134625. /**
  134626. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134627. * @param data contains the texture data
  134628. * @param texture defines the BabylonJS internal texture
  134629. * @param createPolynomials will be true if polynomials have been requested
  134630. * @param onLoad defines the callback to trigger once the texture is ready
  134631. * @param onError defines the callback to trigger in case of error
  134632. */
  134633. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134634. /**
  134635. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134636. * @param data contains the texture data
  134637. * @param texture defines the BabylonJS internal texture
  134638. * @param callback defines the method to call once ready to upload
  134639. */
  134640. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134641. }
  134642. }
  134643. declare module BABYLON {
  134644. /**
  134645. * Implementation of the ENV Texture Loader.
  134646. * @hidden
  134647. */
  134648. export class _ENVTextureLoader implements IInternalTextureLoader {
  134649. /**
  134650. * Defines wether the loader supports cascade loading the different faces.
  134651. */
  134652. readonly supportCascades: boolean;
  134653. /**
  134654. * This returns if the loader support the current file information.
  134655. * @param extension defines the file extension of the file being loaded
  134656. * @returns true if the loader can load the specified file
  134657. */
  134658. canLoad(extension: string): boolean;
  134659. /**
  134660. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134661. * @param data contains the texture data
  134662. * @param texture defines the BabylonJS internal texture
  134663. * @param createPolynomials will be true if polynomials have been requested
  134664. * @param onLoad defines the callback to trigger once the texture is ready
  134665. * @param onError defines the callback to trigger in case of error
  134666. */
  134667. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134668. /**
  134669. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134670. * @param data contains the texture data
  134671. * @param texture defines the BabylonJS internal texture
  134672. * @param callback defines the method to call once ready to upload
  134673. */
  134674. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134675. }
  134676. }
  134677. declare module BABYLON {
  134678. /**
  134679. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  134680. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  134681. */
  134682. export class KhronosTextureContainer {
  134683. /** contents of the KTX container file */
  134684. data: ArrayBufferView;
  134685. private static HEADER_LEN;
  134686. private static COMPRESSED_2D;
  134687. private static COMPRESSED_3D;
  134688. private static TEX_2D;
  134689. private static TEX_3D;
  134690. /**
  134691. * Gets the openGL type
  134692. */
  134693. glType: number;
  134694. /**
  134695. * Gets the openGL type size
  134696. */
  134697. glTypeSize: number;
  134698. /**
  134699. * Gets the openGL format
  134700. */
  134701. glFormat: number;
  134702. /**
  134703. * Gets the openGL internal format
  134704. */
  134705. glInternalFormat: number;
  134706. /**
  134707. * Gets the base internal format
  134708. */
  134709. glBaseInternalFormat: number;
  134710. /**
  134711. * Gets image width in pixel
  134712. */
  134713. pixelWidth: number;
  134714. /**
  134715. * Gets image height in pixel
  134716. */
  134717. pixelHeight: number;
  134718. /**
  134719. * Gets image depth in pixels
  134720. */
  134721. pixelDepth: number;
  134722. /**
  134723. * Gets the number of array elements
  134724. */
  134725. numberOfArrayElements: number;
  134726. /**
  134727. * Gets the number of faces
  134728. */
  134729. numberOfFaces: number;
  134730. /**
  134731. * Gets the number of mipmap levels
  134732. */
  134733. numberOfMipmapLevels: number;
  134734. /**
  134735. * Gets the bytes of key value data
  134736. */
  134737. bytesOfKeyValueData: number;
  134738. /**
  134739. * Gets the load type
  134740. */
  134741. loadType: number;
  134742. /**
  134743. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  134744. */
  134745. isInvalid: boolean;
  134746. /**
  134747. * Creates a new KhronosTextureContainer
  134748. * @param data contents of the KTX container file
  134749. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  134750. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  134751. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  134752. */
  134753. constructor(
  134754. /** contents of the KTX container file */
  134755. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  134756. /**
  134757. * Uploads KTX content to a Babylon Texture.
  134758. * It is assumed that the texture has already been created & is currently bound
  134759. * @hidden
  134760. */
  134761. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  134762. private _upload2DCompressedLevels;
  134763. /**
  134764. * Checks if the given data starts with a KTX file identifier.
  134765. * @param data the data to check
  134766. * @returns true if the data is a KTX file or false otherwise
  134767. */
  134768. static IsValid(data: ArrayBufferView): boolean;
  134769. }
  134770. }
  134771. declare module BABYLON {
  134772. /**
  134773. * Class for loading KTX2 files
  134774. * !!! Experimental Extension Subject to Changes !!!
  134775. * @hidden
  134776. */
  134777. export class KhronosTextureContainer2 {
  134778. private static _ModulePromise;
  134779. private static _TranscodeFormat;
  134780. constructor(engine: ThinEngine);
  134781. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  134782. private _determineTranscodeFormat;
  134783. /**
  134784. * Checks if the given data starts with a KTX2 file identifier.
  134785. * @param data the data to check
  134786. * @returns true if the data is a KTX2 file or false otherwise
  134787. */
  134788. static IsValid(data: ArrayBufferView): boolean;
  134789. }
  134790. }
  134791. declare module BABYLON {
  134792. /**
  134793. * Implementation of the KTX Texture Loader.
  134794. * @hidden
  134795. */
  134796. export class _KTXTextureLoader implements IInternalTextureLoader {
  134797. /**
  134798. * Defines wether the loader supports cascade loading the different faces.
  134799. */
  134800. readonly supportCascades: boolean;
  134801. /**
  134802. * This returns if the loader support the current file information.
  134803. * @param extension defines the file extension of the file being loaded
  134804. * @param mimeType defines the optional mime type of the file being loaded
  134805. * @returns true if the loader can load the specified file
  134806. */
  134807. canLoad(extension: string, mimeType?: string): boolean;
  134808. /**
  134809. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134810. * @param data contains the texture data
  134811. * @param texture defines the BabylonJS internal texture
  134812. * @param createPolynomials will be true if polynomials have been requested
  134813. * @param onLoad defines the callback to trigger once the texture is ready
  134814. * @param onError defines the callback to trigger in case of error
  134815. */
  134816. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134817. /**
  134818. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134819. * @param data contains the texture data
  134820. * @param texture defines the BabylonJS internal texture
  134821. * @param callback defines the method to call once ready to upload
  134822. */
  134823. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  134824. }
  134825. }
  134826. declare module BABYLON {
  134827. /** @hidden */
  134828. export var _forceSceneHelpersToBundle: boolean;
  134829. interface Scene {
  134830. /**
  134831. * Creates a default light for the scene.
  134832. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  134833. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  134834. */
  134835. createDefaultLight(replace?: boolean): void;
  134836. /**
  134837. * Creates a default camera for the scene.
  134838. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  134839. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134840. * @param replace has default false, when true replaces the active camera in the scene
  134841. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  134842. */
  134843. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134844. /**
  134845. * Creates a default camera and a default light.
  134846. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  134847. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134848. * @param replace has the default false, when true replaces the active camera/light in the scene
  134849. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  134850. */
  134851. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134852. /**
  134853. * Creates a new sky box
  134854. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  134855. * @param environmentTexture defines the texture to use as environment texture
  134856. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  134857. * @param scale defines the overall scale of the skybox
  134858. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  134859. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  134860. * @returns a new mesh holding the sky box
  134861. */
  134862. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  134863. /**
  134864. * Creates a new environment
  134865. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  134866. * @param options defines the options you can use to configure the environment
  134867. * @returns the new EnvironmentHelper
  134868. */
  134869. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  134870. /**
  134871. * Creates a new VREXperienceHelper
  134872. * @see https://doc.babylonjs.com/how_to/webvr_helper
  134873. * @param webVROptions defines the options used to create the new VREXperienceHelper
  134874. * @returns a new VREXperienceHelper
  134875. */
  134876. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  134877. /**
  134878. * Creates a new WebXRDefaultExperience
  134879. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  134880. * @param options experience options
  134881. * @returns a promise for a new WebXRDefaultExperience
  134882. */
  134883. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134884. }
  134885. }
  134886. declare module BABYLON {
  134887. /**
  134888. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  134889. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  134890. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  134891. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134892. */
  134893. export class VideoDome extends TransformNode {
  134894. /**
  134895. * Define the video source as a Monoscopic panoramic 360 video.
  134896. */
  134897. static readonly MODE_MONOSCOPIC: number;
  134898. /**
  134899. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134900. */
  134901. static readonly MODE_TOPBOTTOM: number;
  134902. /**
  134903. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134904. */
  134905. static readonly MODE_SIDEBYSIDE: number;
  134906. private _halfDome;
  134907. private _useDirectMapping;
  134908. /**
  134909. * The video texture being displayed on the sphere
  134910. */
  134911. protected _videoTexture: VideoTexture;
  134912. /**
  134913. * Gets the video texture being displayed on the sphere
  134914. */
  134915. get videoTexture(): VideoTexture;
  134916. /**
  134917. * The skybox material
  134918. */
  134919. protected _material: BackgroundMaterial;
  134920. /**
  134921. * The surface used for the skybox
  134922. */
  134923. protected _mesh: Mesh;
  134924. /**
  134925. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  134926. */
  134927. private _halfDomeMask;
  134928. /**
  134929. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134930. * Also see the options.resolution property.
  134931. */
  134932. get fovMultiplier(): number;
  134933. set fovMultiplier(value: number);
  134934. private _videoMode;
  134935. /**
  134936. * Gets or set the current video mode for the video. It can be:
  134937. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  134938. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134939. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134940. */
  134941. get videoMode(): number;
  134942. set videoMode(value: number);
  134943. /**
  134944. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  134945. *
  134946. */
  134947. get halfDome(): boolean;
  134948. /**
  134949. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  134950. */
  134951. set halfDome(enabled: boolean);
  134952. /**
  134953. * Oberserver used in Stereoscopic VR Mode.
  134954. */
  134955. private _onBeforeCameraRenderObserver;
  134956. /**
  134957. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  134958. * @param name Element's name, child elements will append suffixes for their own names.
  134959. * @param urlsOrVideo defines the url(s) or the video element to use
  134960. * @param options An object containing optional or exposed sub element properties
  134961. */
  134962. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  134963. resolution?: number;
  134964. clickToPlay?: boolean;
  134965. autoPlay?: boolean;
  134966. loop?: boolean;
  134967. size?: number;
  134968. poster?: string;
  134969. faceForward?: boolean;
  134970. useDirectMapping?: boolean;
  134971. halfDomeMode?: boolean;
  134972. }, scene: Scene);
  134973. private _changeVideoMode;
  134974. /**
  134975. * Releases resources associated with this node.
  134976. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134977. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134978. */
  134979. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134980. }
  134981. }
  134982. declare module BABYLON {
  134983. /**
  134984. * This class can be used to get instrumentation data from a Babylon engine
  134985. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134986. */
  134987. export class EngineInstrumentation implements IDisposable {
  134988. /**
  134989. * Define the instrumented engine.
  134990. */
  134991. engine: Engine;
  134992. private _captureGPUFrameTime;
  134993. private _gpuFrameTimeToken;
  134994. private _gpuFrameTime;
  134995. private _captureShaderCompilationTime;
  134996. private _shaderCompilationTime;
  134997. private _onBeginFrameObserver;
  134998. private _onEndFrameObserver;
  134999. private _onBeforeShaderCompilationObserver;
  135000. private _onAfterShaderCompilationObserver;
  135001. /**
  135002. * Gets the perf counter used for GPU frame time
  135003. */
  135004. get gpuFrameTimeCounter(): PerfCounter;
  135005. /**
  135006. * Gets the GPU frame time capture status
  135007. */
  135008. get captureGPUFrameTime(): boolean;
  135009. /**
  135010. * Enable or disable the GPU frame time capture
  135011. */
  135012. set captureGPUFrameTime(value: boolean);
  135013. /**
  135014. * Gets the perf counter used for shader compilation time
  135015. */
  135016. get shaderCompilationTimeCounter(): PerfCounter;
  135017. /**
  135018. * Gets the shader compilation time capture status
  135019. */
  135020. get captureShaderCompilationTime(): boolean;
  135021. /**
  135022. * Enable or disable the shader compilation time capture
  135023. */
  135024. set captureShaderCompilationTime(value: boolean);
  135025. /**
  135026. * Instantiates a new engine instrumentation.
  135027. * This class can be used to get instrumentation data from a Babylon engine
  135028. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  135029. * @param engine Defines the engine to instrument
  135030. */
  135031. constructor(
  135032. /**
  135033. * Define the instrumented engine.
  135034. */
  135035. engine: Engine);
  135036. /**
  135037. * Dispose and release associated resources.
  135038. */
  135039. dispose(): void;
  135040. }
  135041. }
  135042. declare module BABYLON {
  135043. /**
  135044. * This class can be used to get instrumentation data from a Babylon engine
  135045. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135046. */
  135047. export class SceneInstrumentation implements IDisposable {
  135048. /**
  135049. * Defines the scene to instrument
  135050. */
  135051. scene: Scene;
  135052. private _captureActiveMeshesEvaluationTime;
  135053. private _activeMeshesEvaluationTime;
  135054. private _captureRenderTargetsRenderTime;
  135055. private _renderTargetsRenderTime;
  135056. private _captureFrameTime;
  135057. private _frameTime;
  135058. private _captureRenderTime;
  135059. private _renderTime;
  135060. private _captureInterFrameTime;
  135061. private _interFrameTime;
  135062. private _captureParticlesRenderTime;
  135063. private _particlesRenderTime;
  135064. private _captureSpritesRenderTime;
  135065. private _spritesRenderTime;
  135066. private _capturePhysicsTime;
  135067. private _physicsTime;
  135068. private _captureAnimationsTime;
  135069. private _animationsTime;
  135070. private _captureCameraRenderTime;
  135071. private _cameraRenderTime;
  135072. private _onBeforeActiveMeshesEvaluationObserver;
  135073. private _onAfterActiveMeshesEvaluationObserver;
  135074. private _onBeforeRenderTargetsRenderObserver;
  135075. private _onAfterRenderTargetsRenderObserver;
  135076. private _onAfterRenderObserver;
  135077. private _onBeforeDrawPhaseObserver;
  135078. private _onAfterDrawPhaseObserver;
  135079. private _onBeforeAnimationsObserver;
  135080. private _onBeforeParticlesRenderingObserver;
  135081. private _onAfterParticlesRenderingObserver;
  135082. private _onBeforeSpritesRenderingObserver;
  135083. private _onAfterSpritesRenderingObserver;
  135084. private _onBeforePhysicsObserver;
  135085. private _onAfterPhysicsObserver;
  135086. private _onAfterAnimationsObserver;
  135087. private _onBeforeCameraRenderObserver;
  135088. private _onAfterCameraRenderObserver;
  135089. /**
  135090. * Gets the perf counter used for active meshes evaluation time
  135091. */
  135092. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  135093. /**
  135094. * Gets the active meshes evaluation time capture status
  135095. */
  135096. get captureActiveMeshesEvaluationTime(): boolean;
  135097. /**
  135098. * Enable or disable the active meshes evaluation time capture
  135099. */
  135100. set captureActiveMeshesEvaluationTime(value: boolean);
  135101. /**
  135102. * Gets the perf counter used for render targets render time
  135103. */
  135104. get renderTargetsRenderTimeCounter(): PerfCounter;
  135105. /**
  135106. * Gets the render targets render time capture status
  135107. */
  135108. get captureRenderTargetsRenderTime(): boolean;
  135109. /**
  135110. * Enable or disable the render targets render time capture
  135111. */
  135112. set captureRenderTargetsRenderTime(value: boolean);
  135113. /**
  135114. * Gets the perf counter used for particles render time
  135115. */
  135116. get particlesRenderTimeCounter(): PerfCounter;
  135117. /**
  135118. * Gets the particles render time capture status
  135119. */
  135120. get captureParticlesRenderTime(): boolean;
  135121. /**
  135122. * Enable or disable the particles render time capture
  135123. */
  135124. set captureParticlesRenderTime(value: boolean);
  135125. /**
  135126. * Gets the perf counter used for sprites render time
  135127. */
  135128. get spritesRenderTimeCounter(): PerfCounter;
  135129. /**
  135130. * Gets the sprites render time capture status
  135131. */
  135132. get captureSpritesRenderTime(): boolean;
  135133. /**
  135134. * Enable or disable the sprites render time capture
  135135. */
  135136. set captureSpritesRenderTime(value: boolean);
  135137. /**
  135138. * Gets the perf counter used for physics time
  135139. */
  135140. get physicsTimeCounter(): PerfCounter;
  135141. /**
  135142. * Gets the physics time capture status
  135143. */
  135144. get capturePhysicsTime(): boolean;
  135145. /**
  135146. * Enable or disable the physics time capture
  135147. */
  135148. set capturePhysicsTime(value: boolean);
  135149. /**
  135150. * Gets the perf counter used for animations time
  135151. */
  135152. get animationsTimeCounter(): PerfCounter;
  135153. /**
  135154. * Gets the animations time capture status
  135155. */
  135156. get captureAnimationsTime(): boolean;
  135157. /**
  135158. * Enable or disable the animations time capture
  135159. */
  135160. set captureAnimationsTime(value: boolean);
  135161. /**
  135162. * Gets the perf counter used for frame time capture
  135163. */
  135164. get frameTimeCounter(): PerfCounter;
  135165. /**
  135166. * Gets the frame time capture status
  135167. */
  135168. get captureFrameTime(): boolean;
  135169. /**
  135170. * Enable or disable the frame time capture
  135171. */
  135172. set captureFrameTime(value: boolean);
  135173. /**
  135174. * Gets the perf counter used for inter-frames time capture
  135175. */
  135176. get interFrameTimeCounter(): PerfCounter;
  135177. /**
  135178. * Gets the inter-frames time capture status
  135179. */
  135180. get captureInterFrameTime(): boolean;
  135181. /**
  135182. * Enable or disable the inter-frames time capture
  135183. */
  135184. set captureInterFrameTime(value: boolean);
  135185. /**
  135186. * Gets the perf counter used for render time capture
  135187. */
  135188. get renderTimeCounter(): PerfCounter;
  135189. /**
  135190. * Gets the render time capture status
  135191. */
  135192. get captureRenderTime(): boolean;
  135193. /**
  135194. * Enable or disable the render time capture
  135195. */
  135196. set captureRenderTime(value: boolean);
  135197. /**
  135198. * Gets the perf counter used for camera render time capture
  135199. */
  135200. get cameraRenderTimeCounter(): PerfCounter;
  135201. /**
  135202. * Gets the camera render time capture status
  135203. */
  135204. get captureCameraRenderTime(): boolean;
  135205. /**
  135206. * Enable or disable the camera render time capture
  135207. */
  135208. set captureCameraRenderTime(value: boolean);
  135209. /**
  135210. * Gets the perf counter used for draw calls
  135211. */
  135212. get drawCallsCounter(): PerfCounter;
  135213. /**
  135214. * Instantiates a new scene instrumentation.
  135215. * This class can be used to get instrumentation data from a Babylon engine
  135216. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135217. * @param scene Defines the scene to instrument
  135218. */
  135219. constructor(
  135220. /**
  135221. * Defines the scene to instrument
  135222. */
  135223. scene: Scene);
  135224. /**
  135225. * Dispose and release associated resources.
  135226. */
  135227. dispose(): void;
  135228. }
  135229. }
  135230. declare module BABYLON {
  135231. /** @hidden */
  135232. export var glowMapGenerationPixelShader: {
  135233. name: string;
  135234. shader: string;
  135235. };
  135236. }
  135237. declare module BABYLON {
  135238. /** @hidden */
  135239. export var glowMapGenerationVertexShader: {
  135240. name: string;
  135241. shader: string;
  135242. };
  135243. }
  135244. declare module BABYLON {
  135245. /**
  135246. * Effect layer options. This helps customizing the behaviour
  135247. * of the effect layer.
  135248. */
  135249. export interface IEffectLayerOptions {
  135250. /**
  135251. * Multiplication factor apply to the canvas size to compute the render target size
  135252. * used to generated the objects (the smaller the faster).
  135253. */
  135254. mainTextureRatio: number;
  135255. /**
  135256. * Enforces a fixed size texture to ensure effect stability across devices.
  135257. */
  135258. mainTextureFixedSize?: number;
  135259. /**
  135260. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  135261. */
  135262. alphaBlendingMode: number;
  135263. /**
  135264. * The camera attached to the layer.
  135265. */
  135266. camera: Nullable<Camera>;
  135267. /**
  135268. * The rendering group to draw the layer in.
  135269. */
  135270. renderingGroupId: number;
  135271. }
  135272. /**
  135273. * The effect layer Helps adding post process effect blended with the main pass.
  135274. *
  135275. * This can be for instance use to generate glow or higlight effects on the scene.
  135276. *
  135277. * The effect layer class can not be used directly and is intented to inherited from to be
  135278. * customized per effects.
  135279. */
  135280. export abstract class EffectLayer {
  135281. private _vertexBuffers;
  135282. private _indexBuffer;
  135283. private _cachedDefines;
  135284. private _effectLayerMapGenerationEffect;
  135285. private _effectLayerOptions;
  135286. private _mergeEffect;
  135287. protected _scene: Scene;
  135288. protected _engine: Engine;
  135289. protected _maxSize: number;
  135290. protected _mainTextureDesiredSize: ISize;
  135291. protected _mainTexture: RenderTargetTexture;
  135292. protected _shouldRender: boolean;
  135293. protected _postProcesses: PostProcess[];
  135294. protected _textures: BaseTexture[];
  135295. protected _emissiveTextureAndColor: {
  135296. texture: Nullable<BaseTexture>;
  135297. color: Color4;
  135298. };
  135299. /**
  135300. * The name of the layer
  135301. */
  135302. name: string;
  135303. /**
  135304. * The clear color of the texture used to generate the glow map.
  135305. */
  135306. neutralColor: Color4;
  135307. /**
  135308. * Specifies whether the highlight layer is enabled or not.
  135309. */
  135310. isEnabled: boolean;
  135311. /**
  135312. * Gets the camera attached to the layer.
  135313. */
  135314. get camera(): Nullable<Camera>;
  135315. /**
  135316. * Gets the rendering group id the layer should render in.
  135317. */
  135318. get renderingGroupId(): number;
  135319. set renderingGroupId(renderingGroupId: number);
  135320. /**
  135321. * An event triggered when the effect layer has been disposed.
  135322. */
  135323. onDisposeObservable: Observable<EffectLayer>;
  135324. /**
  135325. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  135326. */
  135327. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  135328. /**
  135329. * An event triggered when the generated texture is being merged in the scene.
  135330. */
  135331. onBeforeComposeObservable: Observable<EffectLayer>;
  135332. /**
  135333. * An event triggered when the mesh is rendered into the effect render target.
  135334. */
  135335. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  135336. /**
  135337. * An event triggered after the mesh has been rendered into the effect render target.
  135338. */
  135339. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  135340. /**
  135341. * An event triggered when the generated texture has been merged in the scene.
  135342. */
  135343. onAfterComposeObservable: Observable<EffectLayer>;
  135344. /**
  135345. * An event triggered when the efffect layer changes its size.
  135346. */
  135347. onSizeChangedObservable: Observable<EffectLayer>;
  135348. /** @hidden */
  135349. static _SceneComponentInitialization: (scene: Scene) => void;
  135350. /**
  135351. * Instantiates a new effect Layer and references it in the scene.
  135352. * @param name The name of the layer
  135353. * @param scene The scene to use the layer in
  135354. */
  135355. constructor(
  135356. /** The Friendly of the effect in the scene */
  135357. name: string, scene: Scene);
  135358. /**
  135359. * Get the effect name of the layer.
  135360. * @return The effect name
  135361. */
  135362. abstract getEffectName(): string;
  135363. /**
  135364. * Checks for the readiness of the element composing the layer.
  135365. * @param subMesh the mesh to check for
  135366. * @param useInstances specify whether or not to use instances to render the mesh
  135367. * @return true if ready otherwise, false
  135368. */
  135369. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135370. /**
  135371. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135372. * @returns true if the effect requires stencil during the main canvas render pass.
  135373. */
  135374. abstract needStencil(): boolean;
  135375. /**
  135376. * Create the merge effect. This is the shader use to blit the information back
  135377. * to the main canvas at the end of the scene rendering.
  135378. * @returns The effect containing the shader used to merge the effect on the main canvas
  135379. */
  135380. protected abstract _createMergeEffect(): Effect;
  135381. /**
  135382. * Creates the render target textures and post processes used in the effect layer.
  135383. */
  135384. protected abstract _createTextureAndPostProcesses(): void;
  135385. /**
  135386. * Implementation specific of rendering the generating effect on the main canvas.
  135387. * @param effect The effect used to render through
  135388. */
  135389. protected abstract _internalRender(effect: Effect): void;
  135390. /**
  135391. * Sets the required values for both the emissive texture and and the main color.
  135392. */
  135393. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135394. /**
  135395. * Free any resources and references associated to a mesh.
  135396. * Internal use
  135397. * @param mesh The mesh to free.
  135398. */
  135399. abstract _disposeMesh(mesh: Mesh): void;
  135400. /**
  135401. * Serializes this layer (Glow or Highlight for example)
  135402. * @returns a serialized layer object
  135403. */
  135404. abstract serialize?(): any;
  135405. /**
  135406. * Initializes the effect layer with the required options.
  135407. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  135408. */
  135409. protected _init(options: Partial<IEffectLayerOptions>): void;
  135410. /**
  135411. * Generates the index buffer of the full screen quad blending to the main canvas.
  135412. */
  135413. private _generateIndexBuffer;
  135414. /**
  135415. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  135416. */
  135417. private _generateVertexBuffer;
  135418. /**
  135419. * Sets the main texture desired size which is the closest power of two
  135420. * of the engine canvas size.
  135421. */
  135422. private _setMainTextureSize;
  135423. /**
  135424. * Creates the main texture for the effect layer.
  135425. */
  135426. protected _createMainTexture(): void;
  135427. /**
  135428. * Adds specific effects defines.
  135429. * @param defines The defines to add specifics to.
  135430. */
  135431. protected _addCustomEffectDefines(defines: string[]): void;
  135432. /**
  135433. * Checks for the readiness of the element composing the layer.
  135434. * @param subMesh the mesh to check for
  135435. * @param useInstances specify whether or not to use instances to render the mesh
  135436. * @param emissiveTexture the associated emissive texture used to generate the glow
  135437. * @return true if ready otherwise, false
  135438. */
  135439. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  135440. /**
  135441. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  135442. */
  135443. render(): void;
  135444. /**
  135445. * Determine if a given mesh will be used in the current effect.
  135446. * @param mesh mesh to test
  135447. * @returns true if the mesh will be used
  135448. */
  135449. hasMesh(mesh: AbstractMesh): boolean;
  135450. /**
  135451. * Returns true if the layer contains information to display, otherwise false.
  135452. * @returns true if the glow layer should be rendered
  135453. */
  135454. shouldRender(): boolean;
  135455. /**
  135456. * Returns true if the mesh should render, otherwise false.
  135457. * @param mesh The mesh to render
  135458. * @returns true if it should render otherwise false
  135459. */
  135460. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  135461. /**
  135462. * Returns true if the mesh can be rendered, otherwise false.
  135463. * @param mesh The mesh to render
  135464. * @param material The material used on the mesh
  135465. * @returns true if it can be rendered otherwise false
  135466. */
  135467. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135468. /**
  135469. * Returns true if the mesh should render, otherwise false.
  135470. * @param mesh The mesh to render
  135471. * @returns true if it should render otherwise false
  135472. */
  135473. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  135474. /**
  135475. * Renders the submesh passed in parameter to the generation map.
  135476. */
  135477. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  135478. /**
  135479. * Defines whether the current material of the mesh should be use to render the effect.
  135480. * @param mesh defines the current mesh to render
  135481. */
  135482. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135483. /**
  135484. * Rebuild the required buffers.
  135485. * @hidden Internal use only.
  135486. */
  135487. _rebuild(): void;
  135488. /**
  135489. * Dispose only the render target textures and post process.
  135490. */
  135491. private _disposeTextureAndPostProcesses;
  135492. /**
  135493. * Dispose the highlight layer and free resources.
  135494. */
  135495. dispose(): void;
  135496. /**
  135497. * Gets the class name of the effect layer
  135498. * @returns the string with the class name of the effect layer
  135499. */
  135500. getClassName(): string;
  135501. /**
  135502. * Creates an effect layer from parsed effect layer data
  135503. * @param parsedEffectLayer defines effect layer data
  135504. * @param scene defines the current scene
  135505. * @param rootUrl defines the root URL containing the effect layer information
  135506. * @returns a parsed effect Layer
  135507. */
  135508. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  135509. }
  135510. }
  135511. declare module BABYLON {
  135512. interface AbstractScene {
  135513. /**
  135514. * The list of effect layers (highlights/glow) added to the scene
  135515. * @see https://doc.babylonjs.com/how_to/highlight_layer
  135516. * @see https://doc.babylonjs.com/how_to/glow_layer
  135517. */
  135518. effectLayers: Array<EffectLayer>;
  135519. /**
  135520. * Removes the given effect layer from this scene.
  135521. * @param toRemove defines the effect layer to remove
  135522. * @returns the index of the removed effect layer
  135523. */
  135524. removeEffectLayer(toRemove: EffectLayer): number;
  135525. /**
  135526. * Adds the given effect layer to this scene
  135527. * @param newEffectLayer defines the effect layer to add
  135528. */
  135529. addEffectLayer(newEffectLayer: EffectLayer): void;
  135530. }
  135531. /**
  135532. * Defines the layer scene component responsible to manage any effect layers
  135533. * in a given scene.
  135534. */
  135535. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  135536. /**
  135537. * The component name helpfull to identify the component in the list of scene components.
  135538. */
  135539. readonly name: string;
  135540. /**
  135541. * The scene the component belongs to.
  135542. */
  135543. scene: Scene;
  135544. private _engine;
  135545. private _renderEffects;
  135546. private _needStencil;
  135547. private _previousStencilState;
  135548. /**
  135549. * Creates a new instance of the component for the given scene
  135550. * @param scene Defines the scene to register the component in
  135551. */
  135552. constructor(scene: Scene);
  135553. /**
  135554. * Registers the component in a given scene
  135555. */
  135556. register(): void;
  135557. /**
  135558. * Rebuilds the elements related to this component in case of
  135559. * context lost for instance.
  135560. */
  135561. rebuild(): void;
  135562. /**
  135563. * Serializes the component data to the specified json object
  135564. * @param serializationObject The object to serialize to
  135565. */
  135566. serialize(serializationObject: any): void;
  135567. /**
  135568. * Adds all the elements from the container to the scene
  135569. * @param container the container holding the elements
  135570. */
  135571. addFromContainer(container: AbstractScene): void;
  135572. /**
  135573. * Removes all the elements in the container from the scene
  135574. * @param container contains the elements to remove
  135575. * @param dispose if the removed element should be disposed (default: false)
  135576. */
  135577. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135578. /**
  135579. * Disposes the component and the associated ressources.
  135580. */
  135581. dispose(): void;
  135582. private _isReadyForMesh;
  135583. private _renderMainTexture;
  135584. private _setStencil;
  135585. private _setStencilBack;
  135586. private _draw;
  135587. private _drawCamera;
  135588. private _drawRenderingGroup;
  135589. }
  135590. }
  135591. declare module BABYLON {
  135592. /** @hidden */
  135593. export var glowMapMergePixelShader: {
  135594. name: string;
  135595. shader: string;
  135596. };
  135597. }
  135598. declare module BABYLON {
  135599. /** @hidden */
  135600. export var glowMapMergeVertexShader: {
  135601. name: string;
  135602. shader: string;
  135603. };
  135604. }
  135605. declare module BABYLON {
  135606. interface AbstractScene {
  135607. /**
  135608. * Return a the first highlight layer of the scene with a given name.
  135609. * @param name The name of the highlight layer to look for.
  135610. * @return The highlight layer if found otherwise null.
  135611. */
  135612. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  135613. }
  135614. /**
  135615. * Glow layer options. This helps customizing the behaviour
  135616. * of the glow layer.
  135617. */
  135618. export interface IGlowLayerOptions {
  135619. /**
  135620. * Multiplication factor apply to the canvas size to compute the render target size
  135621. * used to generated the glowing objects (the smaller the faster).
  135622. */
  135623. mainTextureRatio: number;
  135624. /**
  135625. * Enforces a fixed size texture to ensure resize independant blur.
  135626. */
  135627. mainTextureFixedSize?: number;
  135628. /**
  135629. * How big is the kernel of the blur texture.
  135630. */
  135631. blurKernelSize: number;
  135632. /**
  135633. * The camera attached to the layer.
  135634. */
  135635. camera: Nullable<Camera>;
  135636. /**
  135637. * Enable MSAA by chosing the number of samples.
  135638. */
  135639. mainTextureSamples?: number;
  135640. /**
  135641. * The rendering group to draw the layer in.
  135642. */
  135643. renderingGroupId: number;
  135644. }
  135645. /**
  135646. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  135647. *
  135648. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  135649. *
  135650. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  135651. */
  135652. export class GlowLayer extends EffectLayer {
  135653. /**
  135654. * Effect Name of the layer.
  135655. */
  135656. static readonly EffectName: string;
  135657. /**
  135658. * The default blur kernel size used for the glow.
  135659. */
  135660. static DefaultBlurKernelSize: number;
  135661. /**
  135662. * The default texture size ratio used for the glow.
  135663. */
  135664. static DefaultTextureRatio: number;
  135665. /**
  135666. * Sets the kernel size of the blur.
  135667. */
  135668. set blurKernelSize(value: number);
  135669. /**
  135670. * Gets the kernel size of the blur.
  135671. */
  135672. get blurKernelSize(): number;
  135673. /**
  135674. * Sets the glow intensity.
  135675. */
  135676. set intensity(value: number);
  135677. /**
  135678. * Gets the glow intensity.
  135679. */
  135680. get intensity(): number;
  135681. private _options;
  135682. private _intensity;
  135683. private _horizontalBlurPostprocess1;
  135684. private _verticalBlurPostprocess1;
  135685. private _horizontalBlurPostprocess2;
  135686. private _verticalBlurPostprocess2;
  135687. private _blurTexture1;
  135688. private _blurTexture2;
  135689. private _postProcesses1;
  135690. private _postProcesses2;
  135691. private _includedOnlyMeshes;
  135692. private _excludedMeshes;
  135693. private _meshesUsingTheirOwnMaterials;
  135694. /**
  135695. * Callback used to let the user override the color selection on a per mesh basis
  135696. */
  135697. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  135698. /**
  135699. * Callback used to let the user override the texture selection on a per mesh basis
  135700. */
  135701. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  135702. /**
  135703. * Instantiates a new glow Layer and references it to the scene.
  135704. * @param name The name of the layer
  135705. * @param scene The scene to use the layer in
  135706. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  135707. */
  135708. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  135709. /**
  135710. * Get the effect name of the layer.
  135711. * @return The effect name
  135712. */
  135713. getEffectName(): string;
  135714. /**
  135715. * Create the merge effect. This is the shader use to blit the information back
  135716. * to the main canvas at the end of the scene rendering.
  135717. */
  135718. protected _createMergeEffect(): Effect;
  135719. /**
  135720. * Creates the render target textures and post processes used in the glow layer.
  135721. */
  135722. protected _createTextureAndPostProcesses(): void;
  135723. /**
  135724. * Checks for the readiness of the element composing the layer.
  135725. * @param subMesh the mesh to check for
  135726. * @param useInstances specify wether or not to use instances to render the mesh
  135727. * @param emissiveTexture the associated emissive texture used to generate the glow
  135728. * @return true if ready otherwise, false
  135729. */
  135730. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135731. /**
  135732. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135733. */
  135734. needStencil(): boolean;
  135735. /**
  135736. * Returns true if the mesh can be rendered, otherwise false.
  135737. * @param mesh The mesh to render
  135738. * @param material The material used on the mesh
  135739. * @returns true if it can be rendered otherwise false
  135740. */
  135741. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135742. /**
  135743. * Implementation specific of rendering the generating effect on the main canvas.
  135744. * @param effect The effect used to render through
  135745. */
  135746. protected _internalRender(effect: Effect): void;
  135747. /**
  135748. * Sets the required values for both the emissive texture and and the main color.
  135749. */
  135750. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135751. /**
  135752. * Returns true if the mesh should render, otherwise false.
  135753. * @param mesh The mesh to render
  135754. * @returns true if it should render otherwise false
  135755. */
  135756. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135757. /**
  135758. * Adds specific effects defines.
  135759. * @param defines The defines to add specifics to.
  135760. */
  135761. protected _addCustomEffectDefines(defines: string[]): void;
  135762. /**
  135763. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  135764. * @param mesh The mesh to exclude from the glow layer
  135765. */
  135766. addExcludedMesh(mesh: Mesh): void;
  135767. /**
  135768. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  135769. * @param mesh The mesh to remove
  135770. */
  135771. removeExcludedMesh(mesh: Mesh): void;
  135772. /**
  135773. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  135774. * @param mesh The mesh to include in the glow layer
  135775. */
  135776. addIncludedOnlyMesh(mesh: Mesh): void;
  135777. /**
  135778. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  135779. * @param mesh The mesh to remove
  135780. */
  135781. removeIncludedOnlyMesh(mesh: Mesh): void;
  135782. /**
  135783. * Determine if a given mesh will be used in the glow layer
  135784. * @param mesh The mesh to test
  135785. * @returns true if the mesh will be highlighted by the current glow layer
  135786. */
  135787. hasMesh(mesh: AbstractMesh): boolean;
  135788. /**
  135789. * Defines whether the current material of the mesh should be use to render the effect.
  135790. * @param mesh defines the current mesh to render
  135791. */
  135792. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135793. /**
  135794. * Add a mesh to be rendered through its own material and not with emissive only.
  135795. * @param mesh The mesh for which we need to use its material
  135796. */
  135797. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  135798. /**
  135799. * Remove a mesh from being rendered through its own material and not with emissive only.
  135800. * @param mesh The mesh for which we need to not use its material
  135801. */
  135802. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  135803. /**
  135804. * Free any resources and references associated to a mesh.
  135805. * Internal use
  135806. * @param mesh The mesh to free.
  135807. * @hidden
  135808. */
  135809. _disposeMesh(mesh: Mesh): void;
  135810. /**
  135811. * Gets the class name of the effect layer
  135812. * @returns the string with the class name of the effect layer
  135813. */
  135814. getClassName(): string;
  135815. /**
  135816. * Serializes this glow layer
  135817. * @returns a serialized glow layer object
  135818. */
  135819. serialize(): any;
  135820. /**
  135821. * Creates a Glow Layer from parsed glow layer data
  135822. * @param parsedGlowLayer defines glow layer data
  135823. * @param scene defines the current scene
  135824. * @param rootUrl defines the root URL containing the glow layer information
  135825. * @returns a parsed Glow Layer
  135826. */
  135827. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  135828. }
  135829. }
  135830. declare module BABYLON {
  135831. /** @hidden */
  135832. export var glowBlurPostProcessPixelShader: {
  135833. name: string;
  135834. shader: string;
  135835. };
  135836. }
  135837. declare module BABYLON {
  135838. interface AbstractScene {
  135839. /**
  135840. * Return a the first highlight layer of the scene with a given name.
  135841. * @param name The name of the highlight layer to look for.
  135842. * @return The highlight layer if found otherwise null.
  135843. */
  135844. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  135845. }
  135846. /**
  135847. * Highlight layer options. This helps customizing the behaviour
  135848. * of the highlight layer.
  135849. */
  135850. export interface IHighlightLayerOptions {
  135851. /**
  135852. * Multiplication factor apply to the canvas size to compute the render target size
  135853. * used to generated the glowing objects (the smaller the faster).
  135854. */
  135855. mainTextureRatio: number;
  135856. /**
  135857. * Enforces a fixed size texture to ensure resize independant blur.
  135858. */
  135859. mainTextureFixedSize?: number;
  135860. /**
  135861. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  135862. * of the picture to blur (the smaller the faster).
  135863. */
  135864. blurTextureSizeRatio: number;
  135865. /**
  135866. * How big in texel of the blur texture is the vertical blur.
  135867. */
  135868. blurVerticalSize: number;
  135869. /**
  135870. * How big in texel of the blur texture is the horizontal blur.
  135871. */
  135872. blurHorizontalSize: number;
  135873. /**
  135874. * Alpha blending mode used to apply the blur. Default is combine.
  135875. */
  135876. alphaBlendingMode: number;
  135877. /**
  135878. * The camera attached to the layer.
  135879. */
  135880. camera: Nullable<Camera>;
  135881. /**
  135882. * Should we display highlight as a solid stroke?
  135883. */
  135884. isStroke?: boolean;
  135885. /**
  135886. * The rendering group to draw the layer in.
  135887. */
  135888. renderingGroupId: number;
  135889. }
  135890. /**
  135891. * The highlight layer Helps adding a glow effect around a mesh.
  135892. *
  135893. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  135894. * glowy meshes to your scene.
  135895. *
  135896. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  135897. */
  135898. export class HighlightLayer extends EffectLayer {
  135899. name: string;
  135900. /**
  135901. * Effect Name of the highlight layer.
  135902. */
  135903. static readonly EffectName: string;
  135904. /**
  135905. * The neutral color used during the preparation of the glow effect.
  135906. * This is black by default as the blend operation is a blend operation.
  135907. */
  135908. static NeutralColor: Color4;
  135909. /**
  135910. * Stencil value used for glowing meshes.
  135911. */
  135912. static GlowingMeshStencilReference: number;
  135913. /**
  135914. * Stencil value used for the other meshes in the scene.
  135915. */
  135916. static NormalMeshStencilReference: number;
  135917. /**
  135918. * Specifies whether or not the inner glow is ACTIVE in the layer.
  135919. */
  135920. innerGlow: boolean;
  135921. /**
  135922. * Specifies whether or not the outer glow is ACTIVE in the layer.
  135923. */
  135924. outerGlow: boolean;
  135925. /**
  135926. * Specifies the horizontal size of the blur.
  135927. */
  135928. set blurHorizontalSize(value: number);
  135929. /**
  135930. * Specifies the vertical size of the blur.
  135931. */
  135932. set blurVerticalSize(value: number);
  135933. /**
  135934. * Gets the horizontal size of the blur.
  135935. */
  135936. get blurHorizontalSize(): number;
  135937. /**
  135938. * Gets the vertical size of the blur.
  135939. */
  135940. get blurVerticalSize(): number;
  135941. /**
  135942. * An event triggered when the highlight layer is being blurred.
  135943. */
  135944. onBeforeBlurObservable: Observable<HighlightLayer>;
  135945. /**
  135946. * An event triggered when the highlight layer has been blurred.
  135947. */
  135948. onAfterBlurObservable: Observable<HighlightLayer>;
  135949. private _instanceGlowingMeshStencilReference;
  135950. private _options;
  135951. private _downSamplePostprocess;
  135952. private _horizontalBlurPostprocess;
  135953. private _verticalBlurPostprocess;
  135954. private _blurTexture;
  135955. private _meshes;
  135956. private _excludedMeshes;
  135957. /**
  135958. * Instantiates a new highlight Layer and references it to the scene..
  135959. * @param name The name of the layer
  135960. * @param scene The scene to use the layer in
  135961. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  135962. */
  135963. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  135964. /**
  135965. * Get the effect name of the layer.
  135966. * @return The effect name
  135967. */
  135968. getEffectName(): string;
  135969. /**
  135970. * Create the merge effect. This is the shader use to blit the information back
  135971. * to the main canvas at the end of the scene rendering.
  135972. */
  135973. protected _createMergeEffect(): Effect;
  135974. /**
  135975. * Creates the render target textures and post processes used in the highlight layer.
  135976. */
  135977. protected _createTextureAndPostProcesses(): void;
  135978. /**
  135979. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  135980. */
  135981. needStencil(): boolean;
  135982. /**
  135983. * Checks for the readiness of the element composing the layer.
  135984. * @param subMesh the mesh to check for
  135985. * @param useInstances specify wether or not to use instances to render the mesh
  135986. * @param emissiveTexture the associated emissive texture used to generate the glow
  135987. * @return true if ready otherwise, false
  135988. */
  135989. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135990. /**
  135991. * Implementation specific of rendering the generating effect on the main canvas.
  135992. * @param effect The effect used to render through
  135993. */
  135994. protected _internalRender(effect: Effect): void;
  135995. /**
  135996. * Returns true if the layer contains information to display, otherwise false.
  135997. */
  135998. shouldRender(): boolean;
  135999. /**
  136000. * Returns true if the mesh should render, otherwise false.
  136001. * @param mesh The mesh to render
  136002. * @returns true if it should render otherwise false
  136003. */
  136004. protected _shouldRenderMesh(mesh: Mesh): boolean;
  136005. /**
  136006. * Returns true if the mesh can be rendered, otherwise false.
  136007. * @param mesh The mesh to render
  136008. * @param material The material used on the mesh
  136009. * @returns true if it can be rendered otherwise false
  136010. */
  136011. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136012. /**
  136013. * Adds specific effects defines.
  136014. * @param defines The defines to add specifics to.
  136015. */
  136016. protected _addCustomEffectDefines(defines: string[]): void;
  136017. /**
  136018. * Sets the required values for both the emissive texture and and the main color.
  136019. */
  136020. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136021. /**
  136022. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  136023. * @param mesh The mesh to exclude from the highlight layer
  136024. */
  136025. addExcludedMesh(mesh: Mesh): void;
  136026. /**
  136027. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  136028. * @param mesh The mesh to highlight
  136029. */
  136030. removeExcludedMesh(mesh: Mesh): void;
  136031. /**
  136032. * Determine if a given mesh will be highlighted by the current HighlightLayer
  136033. * @param mesh mesh to test
  136034. * @returns true if the mesh will be highlighted by the current HighlightLayer
  136035. */
  136036. hasMesh(mesh: AbstractMesh): boolean;
  136037. /**
  136038. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  136039. * @param mesh The mesh to highlight
  136040. * @param color The color of the highlight
  136041. * @param glowEmissiveOnly Extract the glow from the emissive texture
  136042. */
  136043. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  136044. /**
  136045. * Remove a mesh from the highlight layer in order to make it stop glowing.
  136046. * @param mesh The mesh to highlight
  136047. */
  136048. removeMesh(mesh: Mesh): void;
  136049. /**
  136050. * Remove all the meshes currently referenced in the highlight layer
  136051. */
  136052. removeAllMeshes(): void;
  136053. /**
  136054. * Force the stencil to the normal expected value for none glowing parts
  136055. */
  136056. private _defaultStencilReference;
  136057. /**
  136058. * Free any resources and references associated to a mesh.
  136059. * Internal use
  136060. * @param mesh The mesh to free.
  136061. * @hidden
  136062. */
  136063. _disposeMesh(mesh: Mesh): void;
  136064. /**
  136065. * Dispose the highlight layer and free resources.
  136066. */
  136067. dispose(): void;
  136068. /**
  136069. * Gets the class name of the effect layer
  136070. * @returns the string with the class name of the effect layer
  136071. */
  136072. getClassName(): string;
  136073. /**
  136074. * Serializes this Highlight layer
  136075. * @returns a serialized Highlight layer object
  136076. */
  136077. serialize(): any;
  136078. /**
  136079. * Creates a Highlight layer from parsed Highlight layer data
  136080. * @param parsedHightlightLayer defines the Highlight layer data
  136081. * @param scene defines the current scene
  136082. * @param rootUrl defines the root URL containing the Highlight layer information
  136083. * @returns a parsed Highlight layer
  136084. */
  136085. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  136086. }
  136087. }
  136088. declare module BABYLON {
  136089. interface AbstractScene {
  136090. /**
  136091. * The list of layers (background and foreground) of the scene
  136092. */
  136093. layers: Array<Layer>;
  136094. }
  136095. /**
  136096. * Defines the layer scene component responsible to manage any layers
  136097. * in a given scene.
  136098. */
  136099. export class LayerSceneComponent implements ISceneComponent {
  136100. /**
  136101. * The component name helpfull to identify the component in the list of scene components.
  136102. */
  136103. readonly name: string;
  136104. /**
  136105. * The scene the component belongs to.
  136106. */
  136107. scene: Scene;
  136108. private _engine;
  136109. /**
  136110. * Creates a new instance of the component for the given scene
  136111. * @param scene Defines the scene to register the component in
  136112. */
  136113. constructor(scene: Scene);
  136114. /**
  136115. * Registers the component in a given scene
  136116. */
  136117. register(): void;
  136118. /**
  136119. * Rebuilds the elements related to this component in case of
  136120. * context lost for instance.
  136121. */
  136122. rebuild(): void;
  136123. /**
  136124. * Disposes the component and the associated ressources.
  136125. */
  136126. dispose(): void;
  136127. private _draw;
  136128. private _drawCameraPredicate;
  136129. private _drawCameraBackground;
  136130. private _drawCameraForeground;
  136131. private _drawRenderTargetPredicate;
  136132. private _drawRenderTargetBackground;
  136133. private _drawRenderTargetForeground;
  136134. /**
  136135. * Adds all the elements from the container to the scene
  136136. * @param container the container holding the elements
  136137. */
  136138. addFromContainer(container: AbstractScene): void;
  136139. /**
  136140. * Removes all the elements in the container from the scene
  136141. * @param container contains the elements to remove
  136142. * @param dispose if the removed element should be disposed (default: false)
  136143. */
  136144. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136145. }
  136146. }
  136147. declare module BABYLON {
  136148. /** @hidden */
  136149. export var layerPixelShader: {
  136150. name: string;
  136151. shader: string;
  136152. };
  136153. }
  136154. declare module BABYLON {
  136155. /** @hidden */
  136156. export var layerVertexShader: {
  136157. name: string;
  136158. shader: string;
  136159. };
  136160. }
  136161. declare module BABYLON {
  136162. /**
  136163. * This represents a full screen 2d layer.
  136164. * This can be useful to display a picture in the background of your scene for instance.
  136165. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136166. */
  136167. export class Layer {
  136168. /**
  136169. * Define the name of the layer.
  136170. */
  136171. name: string;
  136172. /**
  136173. * Define the texture the layer should display.
  136174. */
  136175. texture: Nullable<Texture>;
  136176. /**
  136177. * Is the layer in background or foreground.
  136178. */
  136179. isBackground: boolean;
  136180. /**
  136181. * Define the color of the layer (instead of texture).
  136182. */
  136183. color: Color4;
  136184. /**
  136185. * Define the scale of the layer in order to zoom in out of the texture.
  136186. */
  136187. scale: Vector2;
  136188. /**
  136189. * Define an offset for the layer in order to shift the texture.
  136190. */
  136191. offset: Vector2;
  136192. /**
  136193. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  136194. */
  136195. alphaBlendingMode: number;
  136196. /**
  136197. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  136198. * Alpha test will not mix with the background color in case of transparency.
  136199. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  136200. */
  136201. alphaTest: boolean;
  136202. /**
  136203. * Define a mask to restrict the layer to only some of the scene cameras.
  136204. */
  136205. layerMask: number;
  136206. /**
  136207. * Define the list of render target the layer is visible into.
  136208. */
  136209. renderTargetTextures: RenderTargetTexture[];
  136210. /**
  136211. * Define if the layer is only used in renderTarget or if it also
  136212. * renders in the main frame buffer of the canvas.
  136213. */
  136214. renderOnlyInRenderTargetTextures: boolean;
  136215. private _scene;
  136216. private _vertexBuffers;
  136217. private _indexBuffer;
  136218. private _effect;
  136219. private _previousDefines;
  136220. /**
  136221. * An event triggered when the layer is disposed.
  136222. */
  136223. onDisposeObservable: Observable<Layer>;
  136224. private _onDisposeObserver;
  136225. /**
  136226. * Back compatibility with callback before the onDisposeObservable existed.
  136227. * The set callback will be triggered when the layer has been disposed.
  136228. */
  136229. set onDispose(callback: () => void);
  136230. /**
  136231. * An event triggered before rendering the scene
  136232. */
  136233. onBeforeRenderObservable: Observable<Layer>;
  136234. private _onBeforeRenderObserver;
  136235. /**
  136236. * Back compatibility with callback before the onBeforeRenderObservable existed.
  136237. * The set callback will be triggered just before rendering the layer.
  136238. */
  136239. set onBeforeRender(callback: () => void);
  136240. /**
  136241. * An event triggered after rendering the scene
  136242. */
  136243. onAfterRenderObservable: Observable<Layer>;
  136244. private _onAfterRenderObserver;
  136245. /**
  136246. * Back compatibility with callback before the onAfterRenderObservable existed.
  136247. * The set callback will be triggered just after rendering the layer.
  136248. */
  136249. set onAfterRender(callback: () => void);
  136250. /**
  136251. * Instantiates a new layer.
  136252. * This represents a full screen 2d layer.
  136253. * This can be useful to display a picture in the background of your scene for instance.
  136254. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136255. * @param name Define the name of the layer in the scene
  136256. * @param imgUrl Define the url of the texture to display in the layer
  136257. * @param scene Define the scene the layer belongs to
  136258. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  136259. * @param color Defines a color for the layer
  136260. */
  136261. constructor(
  136262. /**
  136263. * Define the name of the layer.
  136264. */
  136265. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  136266. private _createIndexBuffer;
  136267. /** @hidden */
  136268. _rebuild(): void;
  136269. /**
  136270. * Renders the layer in the scene.
  136271. */
  136272. render(): void;
  136273. /**
  136274. * Disposes and releases the associated ressources.
  136275. */
  136276. dispose(): void;
  136277. }
  136278. }
  136279. declare module BABYLON {
  136280. /** @hidden */
  136281. export var lensFlarePixelShader: {
  136282. name: string;
  136283. shader: string;
  136284. };
  136285. }
  136286. declare module BABYLON {
  136287. /** @hidden */
  136288. export var lensFlareVertexShader: {
  136289. name: string;
  136290. shader: string;
  136291. };
  136292. }
  136293. declare module BABYLON {
  136294. /**
  136295. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  136296. * It is usually composed of several `lensFlare`.
  136297. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136298. */
  136299. export class LensFlareSystem {
  136300. /**
  136301. * Define the name of the lens flare system
  136302. */
  136303. name: string;
  136304. /**
  136305. * List of lens flares used in this system.
  136306. */
  136307. lensFlares: LensFlare[];
  136308. /**
  136309. * Define a limit from the border the lens flare can be visible.
  136310. */
  136311. borderLimit: number;
  136312. /**
  136313. * Define a viewport border we do not want to see the lens flare in.
  136314. */
  136315. viewportBorder: number;
  136316. /**
  136317. * Define a predicate which could limit the list of meshes able to occlude the effect.
  136318. */
  136319. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  136320. /**
  136321. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  136322. */
  136323. layerMask: number;
  136324. /**
  136325. * Define the id of the lens flare system in the scene.
  136326. * (equal to name by default)
  136327. */
  136328. id: string;
  136329. private _scene;
  136330. private _emitter;
  136331. private _vertexBuffers;
  136332. private _indexBuffer;
  136333. private _effect;
  136334. private _positionX;
  136335. private _positionY;
  136336. private _isEnabled;
  136337. /** @hidden */
  136338. static _SceneComponentInitialization: (scene: Scene) => void;
  136339. /**
  136340. * Instantiates a lens flare system.
  136341. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  136342. * It is usually composed of several `lensFlare`.
  136343. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136344. * @param name Define the name of the lens flare system in the scene
  136345. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  136346. * @param scene Define the scene the lens flare system belongs to
  136347. */
  136348. constructor(
  136349. /**
  136350. * Define the name of the lens flare system
  136351. */
  136352. name: string, emitter: any, scene: Scene);
  136353. /**
  136354. * Define if the lens flare system is enabled.
  136355. */
  136356. get isEnabled(): boolean;
  136357. set isEnabled(value: boolean);
  136358. /**
  136359. * Get the scene the effects belongs to.
  136360. * @returns the scene holding the lens flare system
  136361. */
  136362. getScene(): Scene;
  136363. /**
  136364. * Get the emitter of the lens flare system.
  136365. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  136366. * @returns the emitter of the lens flare system
  136367. */
  136368. getEmitter(): any;
  136369. /**
  136370. * Set the emitter of the lens flare system.
  136371. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  136372. * @param newEmitter Define the new emitter of the system
  136373. */
  136374. setEmitter(newEmitter: any): void;
  136375. /**
  136376. * Get the lens flare system emitter position.
  136377. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  136378. * @returns the position
  136379. */
  136380. getEmitterPosition(): Vector3;
  136381. /**
  136382. * @hidden
  136383. */
  136384. computeEffectivePosition(globalViewport: Viewport): boolean;
  136385. /** @hidden */
  136386. _isVisible(): boolean;
  136387. /**
  136388. * @hidden
  136389. */
  136390. render(): boolean;
  136391. /**
  136392. * Dispose and release the lens flare with its associated resources.
  136393. */
  136394. dispose(): void;
  136395. /**
  136396. * Parse a lens flare system from a JSON repressentation
  136397. * @param parsedLensFlareSystem Define the JSON to parse
  136398. * @param scene Define the scene the parsed system should be instantiated in
  136399. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  136400. * @returns the parsed system
  136401. */
  136402. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  136403. /**
  136404. * Serialize the current Lens Flare System into a JSON representation.
  136405. * @returns the serialized JSON
  136406. */
  136407. serialize(): any;
  136408. }
  136409. }
  136410. declare module BABYLON {
  136411. /**
  136412. * This represents one of the lens effect in a `lensFlareSystem`.
  136413. * It controls one of the indiviual texture used in the effect.
  136414. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136415. */
  136416. export class LensFlare {
  136417. /**
  136418. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136419. */
  136420. size: number;
  136421. /**
  136422. * 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.
  136423. */
  136424. position: number;
  136425. /**
  136426. * Define the lens color.
  136427. */
  136428. color: Color3;
  136429. /**
  136430. * Define the lens texture.
  136431. */
  136432. texture: Nullable<Texture>;
  136433. /**
  136434. * Define the alpha mode to render this particular lens.
  136435. */
  136436. alphaMode: number;
  136437. private _system;
  136438. /**
  136439. * Creates a new Lens Flare.
  136440. * This represents one of the lens effect in a `lensFlareSystem`.
  136441. * It controls one of the indiviual texture used in the effect.
  136442. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136443. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  136444. * @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.
  136445. * @param color Define the lens color
  136446. * @param imgUrl Define the lens texture url
  136447. * @param system Define the `lensFlareSystem` this flare is part of
  136448. * @returns The newly created Lens Flare
  136449. */
  136450. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  136451. /**
  136452. * Instantiates a new Lens Flare.
  136453. * This represents one of the lens effect in a `lensFlareSystem`.
  136454. * It controls one of the indiviual texture used in the effect.
  136455. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136456. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  136457. * @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.
  136458. * @param color Define the lens color
  136459. * @param imgUrl Define the lens texture url
  136460. * @param system Define the `lensFlareSystem` this flare is part of
  136461. */
  136462. constructor(
  136463. /**
  136464. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136465. */
  136466. size: number,
  136467. /**
  136468. * 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.
  136469. */
  136470. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  136471. /**
  136472. * Dispose and release the lens flare with its associated resources.
  136473. */
  136474. dispose(): void;
  136475. }
  136476. }
  136477. declare module BABYLON {
  136478. interface AbstractScene {
  136479. /**
  136480. * The list of lens flare system added to the scene
  136481. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136482. */
  136483. lensFlareSystems: Array<LensFlareSystem>;
  136484. /**
  136485. * Removes the given lens flare system from this scene.
  136486. * @param toRemove The lens flare system to remove
  136487. * @returns The index of the removed lens flare system
  136488. */
  136489. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  136490. /**
  136491. * Adds the given lens flare system to this scene
  136492. * @param newLensFlareSystem The lens flare system to add
  136493. */
  136494. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  136495. /**
  136496. * Gets a lens flare system using its name
  136497. * @param name defines the name to look for
  136498. * @returns the lens flare system or null if not found
  136499. */
  136500. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  136501. /**
  136502. * Gets a lens flare system using its id
  136503. * @param id defines the id to look for
  136504. * @returns the lens flare system or null if not found
  136505. */
  136506. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  136507. }
  136508. /**
  136509. * Defines the lens flare scene component responsible to manage any lens flares
  136510. * in a given scene.
  136511. */
  136512. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  136513. /**
  136514. * The component name helpfull to identify the component in the list of scene components.
  136515. */
  136516. readonly name: string;
  136517. /**
  136518. * The scene the component belongs to.
  136519. */
  136520. scene: Scene;
  136521. /**
  136522. * Creates a new instance of the component for the given scene
  136523. * @param scene Defines the scene to register the component in
  136524. */
  136525. constructor(scene: Scene);
  136526. /**
  136527. * Registers the component in a given scene
  136528. */
  136529. register(): void;
  136530. /**
  136531. * Rebuilds the elements related to this component in case of
  136532. * context lost for instance.
  136533. */
  136534. rebuild(): void;
  136535. /**
  136536. * Adds all the elements from the container to the scene
  136537. * @param container the container holding the elements
  136538. */
  136539. addFromContainer(container: AbstractScene): void;
  136540. /**
  136541. * Removes all the elements in the container from the scene
  136542. * @param container contains the elements to remove
  136543. * @param dispose if the removed element should be disposed (default: false)
  136544. */
  136545. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136546. /**
  136547. * Serializes the component data to the specified json object
  136548. * @param serializationObject The object to serialize to
  136549. */
  136550. serialize(serializationObject: any): void;
  136551. /**
  136552. * Disposes the component and the associated ressources.
  136553. */
  136554. dispose(): void;
  136555. private _draw;
  136556. }
  136557. }
  136558. declare module BABYLON {
  136559. /** @hidden */
  136560. export var depthPixelShader: {
  136561. name: string;
  136562. shader: string;
  136563. };
  136564. }
  136565. declare module BABYLON {
  136566. /** @hidden */
  136567. export var depthVertexShader: {
  136568. name: string;
  136569. shader: string;
  136570. };
  136571. }
  136572. declare module BABYLON {
  136573. /**
  136574. * This represents a depth renderer in Babylon.
  136575. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  136576. */
  136577. export class DepthRenderer {
  136578. private _scene;
  136579. private _depthMap;
  136580. private _effect;
  136581. private readonly _storeNonLinearDepth;
  136582. private readonly _clearColor;
  136583. /** Get if the depth renderer is using packed depth or not */
  136584. readonly isPacked: boolean;
  136585. private _cachedDefines;
  136586. private _camera;
  136587. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  136588. enabled: boolean;
  136589. /**
  136590. * Specifiess that the depth renderer will only be used within
  136591. * the camera it is created for.
  136592. * This can help forcing its rendering during the camera processing.
  136593. */
  136594. useOnlyInActiveCamera: boolean;
  136595. /** @hidden */
  136596. static _SceneComponentInitialization: (scene: Scene) => void;
  136597. /**
  136598. * Instantiates a depth renderer
  136599. * @param scene The scene the renderer belongs to
  136600. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  136601. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  136602. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  136603. */
  136604. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  136605. /**
  136606. * Creates the depth rendering effect and checks if the effect is ready.
  136607. * @param subMesh The submesh to be used to render the depth map of
  136608. * @param useInstances If multiple world instances should be used
  136609. * @returns if the depth renderer is ready to render the depth map
  136610. */
  136611. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136612. /**
  136613. * Gets the texture which the depth map will be written to.
  136614. * @returns The depth map texture
  136615. */
  136616. getDepthMap(): RenderTargetTexture;
  136617. /**
  136618. * Disposes of the depth renderer.
  136619. */
  136620. dispose(): void;
  136621. }
  136622. }
  136623. declare module BABYLON {
  136624. /** @hidden */
  136625. export var minmaxReduxPixelShader: {
  136626. name: string;
  136627. shader: string;
  136628. };
  136629. }
  136630. declare module BABYLON {
  136631. /**
  136632. * This class computes a min/max reduction from a texture: it means it computes the minimum
  136633. * and maximum values from all values of the texture.
  136634. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  136635. * The source values are read from the red channel of the texture.
  136636. */
  136637. export class MinMaxReducer {
  136638. /**
  136639. * Observable triggered when the computation has been performed
  136640. */
  136641. onAfterReductionPerformed: Observable<{
  136642. min: number;
  136643. max: number;
  136644. }>;
  136645. protected _camera: Camera;
  136646. protected _sourceTexture: Nullable<RenderTargetTexture>;
  136647. protected _reductionSteps: Nullable<Array<PostProcess>>;
  136648. protected _postProcessManager: PostProcessManager;
  136649. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  136650. protected _forceFullscreenViewport: boolean;
  136651. /**
  136652. * Creates a min/max reducer
  136653. * @param camera The camera to use for the post processes
  136654. */
  136655. constructor(camera: Camera);
  136656. /**
  136657. * Gets the texture used to read the values from.
  136658. */
  136659. get sourceTexture(): Nullable<RenderTargetTexture>;
  136660. /**
  136661. * Sets the source texture to read the values from.
  136662. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  136663. * because in such textures '1' value must not be taken into account to compute the maximum
  136664. * as this value is used to clear the texture.
  136665. * Note that the computation is not activated by calling this function, you must call activate() for that!
  136666. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  136667. * @param depthRedux Indicates if the texture is a depth texture or not
  136668. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  136669. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136670. */
  136671. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136672. /**
  136673. * Defines the refresh rate of the computation.
  136674. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136675. */
  136676. get refreshRate(): number;
  136677. set refreshRate(value: number);
  136678. protected _activated: boolean;
  136679. /**
  136680. * Gets the activation status of the reducer
  136681. */
  136682. get activated(): boolean;
  136683. /**
  136684. * Activates the reduction computation.
  136685. * When activated, the observers registered in onAfterReductionPerformed are
  136686. * called after the compuation is performed
  136687. */
  136688. activate(): void;
  136689. /**
  136690. * Deactivates the reduction computation.
  136691. */
  136692. deactivate(): void;
  136693. /**
  136694. * Disposes the min/max reducer
  136695. * @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.
  136696. */
  136697. dispose(disposeAll?: boolean): void;
  136698. }
  136699. }
  136700. declare module BABYLON {
  136701. /**
  136702. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  136703. */
  136704. export class DepthReducer extends MinMaxReducer {
  136705. private _depthRenderer;
  136706. private _depthRendererId;
  136707. /**
  136708. * Gets the depth renderer used for the computation.
  136709. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  136710. */
  136711. get depthRenderer(): Nullable<DepthRenderer>;
  136712. /**
  136713. * Creates a depth reducer
  136714. * @param camera The camera used to render the depth texture
  136715. */
  136716. constructor(camera: Camera);
  136717. /**
  136718. * Sets the depth renderer to use to generate the depth map
  136719. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  136720. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  136721. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136722. */
  136723. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  136724. /** @hidden */
  136725. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136726. /**
  136727. * Activates the reduction computation.
  136728. * When activated, the observers registered in onAfterReductionPerformed are
  136729. * called after the compuation is performed
  136730. */
  136731. activate(): void;
  136732. /**
  136733. * Deactivates the reduction computation.
  136734. */
  136735. deactivate(): void;
  136736. /**
  136737. * Disposes the depth reducer
  136738. * @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.
  136739. */
  136740. dispose(disposeAll?: boolean): void;
  136741. }
  136742. }
  136743. declare module BABYLON {
  136744. /**
  136745. * A CSM implementation allowing casting shadows on large scenes.
  136746. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136747. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  136748. */
  136749. export class CascadedShadowGenerator extends ShadowGenerator {
  136750. private static readonly frustumCornersNDCSpace;
  136751. /**
  136752. * Name of the CSM class
  136753. */
  136754. static CLASSNAME: string;
  136755. /**
  136756. * Defines the default number of cascades used by the CSM.
  136757. */
  136758. static readonly DEFAULT_CASCADES_COUNT: number;
  136759. /**
  136760. * Defines the minimum number of cascades used by the CSM.
  136761. */
  136762. static readonly MIN_CASCADES_COUNT: number;
  136763. /**
  136764. * Defines the maximum number of cascades used by the CSM.
  136765. */
  136766. static readonly MAX_CASCADES_COUNT: number;
  136767. protected _validateFilter(filter: number): number;
  136768. /**
  136769. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  136770. */
  136771. penumbraDarkness: number;
  136772. private _numCascades;
  136773. /**
  136774. * Gets or set the number of cascades used by the CSM.
  136775. */
  136776. get numCascades(): number;
  136777. set numCascades(value: number);
  136778. /**
  136779. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  136780. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  136781. */
  136782. stabilizeCascades: boolean;
  136783. private _freezeShadowCastersBoundingInfo;
  136784. private _freezeShadowCastersBoundingInfoObservable;
  136785. /**
  136786. * Enables or disables the shadow casters bounding info computation.
  136787. * If your shadow casters don't move, you can disable this feature.
  136788. * If it is enabled, the bounding box computation is done every frame.
  136789. */
  136790. get freezeShadowCastersBoundingInfo(): boolean;
  136791. set freezeShadowCastersBoundingInfo(freeze: boolean);
  136792. private _scbiMin;
  136793. private _scbiMax;
  136794. protected _computeShadowCastersBoundingInfo(): void;
  136795. protected _shadowCastersBoundingInfo: BoundingInfo;
  136796. /**
  136797. * Gets or sets the shadow casters bounding info.
  136798. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  136799. * so that the system won't overwrite the bounds you provide
  136800. */
  136801. get shadowCastersBoundingInfo(): BoundingInfo;
  136802. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  136803. protected _breaksAreDirty: boolean;
  136804. protected _minDistance: number;
  136805. protected _maxDistance: number;
  136806. /**
  136807. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  136808. *
  136809. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  136810. * If you don't know these values, simply leave them to their defaults and don't call this function.
  136811. * @param min minimal distance for the breaks (default to 0.)
  136812. * @param max maximal distance for the breaks (default to 1.)
  136813. */
  136814. setMinMaxDistance(min: number, max: number): void;
  136815. /** Gets the minimal distance used in the cascade break computation */
  136816. get minDistance(): number;
  136817. /** Gets the maximal distance used in the cascade break computation */
  136818. get maxDistance(): number;
  136819. /**
  136820. * Gets the class name of that object
  136821. * @returns "CascadedShadowGenerator"
  136822. */
  136823. getClassName(): string;
  136824. private _cascadeMinExtents;
  136825. private _cascadeMaxExtents;
  136826. /**
  136827. * Gets a cascade minimum extents
  136828. * @param cascadeIndex index of the cascade
  136829. * @returns the minimum cascade extents
  136830. */
  136831. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  136832. /**
  136833. * Gets a cascade maximum extents
  136834. * @param cascadeIndex index of the cascade
  136835. * @returns the maximum cascade extents
  136836. */
  136837. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  136838. private _cascades;
  136839. private _currentLayer;
  136840. private _viewSpaceFrustumsZ;
  136841. private _viewMatrices;
  136842. private _projectionMatrices;
  136843. private _transformMatrices;
  136844. private _transformMatricesAsArray;
  136845. private _frustumLengths;
  136846. private _lightSizeUVCorrection;
  136847. private _depthCorrection;
  136848. private _frustumCornersWorldSpace;
  136849. private _frustumCenter;
  136850. private _shadowCameraPos;
  136851. private _shadowMaxZ;
  136852. /**
  136853. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  136854. * It defaults to camera.maxZ
  136855. */
  136856. get shadowMaxZ(): number;
  136857. /**
  136858. * Sets the shadow max z distance.
  136859. */
  136860. set shadowMaxZ(value: number);
  136861. protected _debug: boolean;
  136862. /**
  136863. * Gets or sets the debug flag.
  136864. * When enabled, the cascades are materialized by different colors on the screen.
  136865. */
  136866. get debug(): boolean;
  136867. set debug(dbg: boolean);
  136868. private _depthClamp;
  136869. /**
  136870. * Gets or sets the depth clamping value.
  136871. *
  136872. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  136873. * to account for the shadow casters far away.
  136874. *
  136875. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  136876. */
  136877. get depthClamp(): boolean;
  136878. set depthClamp(value: boolean);
  136879. private _cascadeBlendPercentage;
  136880. /**
  136881. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  136882. * It defaults to 0.1 (10% blending).
  136883. */
  136884. get cascadeBlendPercentage(): number;
  136885. set cascadeBlendPercentage(value: number);
  136886. private _lambda;
  136887. /**
  136888. * Gets or set the lambda parameter.
  136889. * This parameter is used to split the camera frustum and create the cascades.
  136890. * 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.
  136891. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  136892. */
  136893. get lambda(): number;
  136894. set lambda(value: number);
  136895. /**
  136896. * Gets the view matrix corresponding to a given cascade
  136897. * @param cascadeNum cascade to retrieve the view matrix from
  136898. * @returns the cascade view matrix
  136899. */
  136900. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  136901. /**
  136902. * Gets the projection matrix corresponding to a given cascade
  136903. * @param cascadeNum cascade to retrieve the projection matrix from
  136904. * @returns the cascade projection matrix
  136905. */
  136906. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  136907. /**
  136908. * Gets the transformation matrix corresponding to a given cascade
  136909. * @param cascadeNum cascade to retrieve the transformation matrix from
  136910. * @returns the cascade transformation matrix
  136911. */
  136912. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  136913. private _depthRenderer;
  136914. /**
  136915. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  136916. *
  136917. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  136918. *
  136919. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  136920. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  136921. * @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
  136922. */
  136923. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  136924. private _depthReducer;
  136925. private _autoCalcDepthBounds;
  136926. /**
  136927. * Gets or sets the autoCalcDepthBounds property.
  136928. *
  136929. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  136930. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  136931. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  136932. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  136933. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  136934. */
  136935. get autoCalcDepthBounds(): boolean;
  136936. set autoCalcDepthBounds(value: boolean);
  136937. /**
  136938. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  136939. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136940. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  136941. * for setting the refresh rate on the renderer yourself!
  136942. */
  136943. get autoCalcDepthBoundsRefreshRate(): number;
  136944. set autoCalcDepthBoundsRefreshRate(value: number);
  136945. /**
  136946. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  136947. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  136948. * you change the camera near/far planes!
  136949. */
  136950. splitFrustum(): void;
  136951. private _splitFrustum;
  136952. private _computeMatrices;
  136953. private _computeFrustumInWorldSpace;
  136954. private _computeCascadeFrustum;
  136955. /**
  136956. * Support test.
  136957. */
  136958. static get IsSupported(): boolean;
  136959. /** @hidden */
  136960. static _SceneComponentInitialization: (scene: Scene) => void;
  136961. /**
  136962. * Creates a Cascaded Shadow Generator object.
  136963. * A ShadowGenerator is the required tool to use the shadows.
  136964. * Each directional light casting shadows needs to use its own ShadowGenerator.
  136965. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136966. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  136967. * @param light The directional light object generating the shadows.
  136968. * @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.
  136969. */
  136970. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  136971. protected _initializeGenerator(): void;
  136972. protected _createTargetRenderTexture(): void;
  136973. protected _initializeShadowMap(): void;
  136974. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  136975. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  136976. /**
  136977. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  136978. * @param defines Defines of the material we want to update
  136979. * @param lightIndex Index of the light in the enabled light list of the material
  136980. */
  136981. prepareDefines(defines: any, lightIndex: number): void;
  136982. /**
  136983. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  136984. * defined in the generator but impacting the effect).
  136985. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  136986. * @param effect The effect we are binfing the information for
  136987. */
  136988. bindShadowLight(lightIndex: string, effect: Effect): void;
  136989. /**
  136990. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  136991. * (eq to view projection * shadow projection matrices)
  136992. * @returns The transform matrix used to create the shadow map
  136993. */
  136994. getTransformMatrix(): Matrix;
  136995. /**
  136996. * Disposes the ShadowGenerator.
  136997. * Returns nothing.
  136998. */
  136999. dispose(): void;
  137000. /**
  137001. * Serializes the shadow generator setup to a json object.
  137002. * @returns The serialized JSON object
  137003. */
  137004. serialize(): any;
  137005. /**
  137006. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  137007. * @param parsedShadowGenerator The JSON object to parse
  137008. * @param scene The scene to create the shadow map for
  137009. * @returns The parsed shadow generator
  137010. */
  137011. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  137012. }
  137013. }
  137014. declare module BABYLON {
  137015. /**
  137016. * Defines the shadow generator component responsible to manage any shadow generators
  137017. * in a given scene.
  137018. */
  137019. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  137020. /**
  137021. * The component name helpfull to identify the component in the list of scene components.
  137022. */
  137023. readonly name: string;
  137024. /**
  137025. * The scene the component belongs to.
  137026. */
  137027. scene: Scene;
  137028. /**
  137029. * Creates a new instance of the component for the given scene
  137030. * @param scene Defines the scene to register the component in
  137031. */
  137032. constructor(scene: Scene);
  137033. /**
  137034. * Registers the component in a given scene
  137035. */
  137036. register(): void;
  137037. /**
  137038. * Rebuilds the elements related to this component in case of
  137039. * context lost for instance.
  137040. */
  137041. rebuild(): void;
  137042. /**
  137043. * Serializes the component data to the specified json object
  137044. * @param serializationObject The object to serialize to
  137045. */
  137046. serialize(serializationObject: any): void;
  137047. /**
  137048. * Adds all the elements from the container to the scene
  137049. * @param container the container holding the elements
  137050. */
  137051. addFromContainer(container: AbstractScene): void;
  137052. /**
  137053. * Removes all the elements in the container from the scene
  137054. * @param container contains the elements to remove
  137055. * @param dispose if the removed element should be disposed (default: false)
  137056. */
  137057. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137058. /**
  137059. * Rebuilds the elements related to this component in case of
  137060. * context lost for instance.
  137061. */
  137062. dispose(): void;
  137063. private _gatherRenderTargets;
  137064. }
  137065. }
  137066. declare module BABYLON {
  137067. /**
  137068. * A point light is a light defined by an unique point in world space.
  137069. * The light is emitted in every direction from this point.
  137070. * A good example of a point light is a standard light bulb.
  137071. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137072. */
  137073. export class PointLight extends ShadowLight {
  137074. private _shadowAngle;
  137075. /**
  137076. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137077. * This specifies what angle the shadow will use to be created.
  137078. *
  137079. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137080. */
  137081. get shadowAngle(): number;
  137082. /**
  137083. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137084. * This specifies what angle the shadow will use to be created.
  137085. *
  137086. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137087. */
  137088. set shadowAngle(value: number);
  137089. /**
  137090. * Gets the direction if it has been set.
  137091. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137092. */
  137093. get direction(): Vector3;
  137094. /**
  137095. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137096. */
  137097. set direction(value: Vector3);
  137098. /**
  137099. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  137100. * A PointLight emits the light in every direction.
  137101. * It can cast shadows.
  137102. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  137103. * ```javascript
  137104. * var pointLight = new PointLight("pl", camera.position, scene);
  137105. * ```
  137106. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137107. * @param name The light friendly name
  137108. * @param position The position of the point light in the scene
  137109. * @param scene The scene the lights belongs to
  137110. */
  137111. constructor(name: string, position: Vector3, scene: Scene);
  137112. /**
  137113. * Returns the string "PointLight"
  137114. * @returns the class name
  137115. */
  137116. getClassName(): string;
  137117. /**
  137118. * Returns the integer 0.
  137119. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137120. */
  137121. getTypeID(): number;
  137122. /**
  137123. * Specifies wether or not the shadowmap should be a cube texture.
  137124. * @returns true if the shadowmap needs to be a cube texture.
  137125. */
  137126. needCube(): boolean;
  137127. /**
  137128. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  137129. * @param faceIndex The index of the face we are computed the direction to generate shadow
  137130. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  137131. */
  137132. getShadowDirection(faceIndex?: number): Vector3;
  137133. /**
  137134. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  137135. * - fov = PI / 2
  137136. * - aspect ratio : 1.0
  137137. * - z-near and far equal to the active camera minZ and maxZ.
  137138. * Returns the PointLight.
  137139. */
  137140. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137141. protected _buildUniformLayout(): void;
  137142. /**
  137143. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  137144. * @param effect The effect to update
  137145. * @param lightIndex The index of the light in the effect to update
  137146. * @returns The point light
  137147. */
  137148. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  137149. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  137150. /**
  137151. * Prepares the list of defines specific to the light type.
  137152. * @param defines the list of defines
  137153. * @param lightIndex defines the index of the light for the effect
  137154. */
  137155. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137156. }
  137157. }
  137158. declare module BABYLON {
  137159. /**
  137160. * Header information of HDR texture files.
  137161. */
  137162. export interface HDRInfo {
  137163. /**
  137164. * The height of the texture in pixels.
  137165. */
  137166. height: number;
  137167. /**
  137168. * The width of the texture in pixels.
  137169. */
  137170. width: number;
  137171. /**
  137172. * The index of the beginning of the data in the binary file.
  137173. */
  137174. dataPosition: number;
  137175. }
  137176. /**
  137177. * This groups tools to convert HDR texture to native colors array.
  137178. */
  137179. export class HDRTools {
  137180. private static Ldexp;
  137181. private static Rgbe2float;
  137182. private static readStringLine;
  137183. /**
  137184. * Reads header information from an RGBE texture stored in a native array.
  137185. * More information on this format are available here:
  137186. * https://en.wikipedia.org/wiki/RGBE_image_format
  137187. *
  137188. * @param uint8array The binary file stored in native array.
  137189. * @return The header information.
  137190. */
  137191. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  137192. /**
  137193. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  137194. * This RGBE texture needs to store the information as a panorama.
  137195. *
  137196. * More information on this format are available here:
  137197. * https://en.wikipedia.org/wiki/RGBE_image_format
  137198. *
  137199. * @param buffer The binary file stored in an array buffer.
  137200. * @param size The expected size of the extracted cubemap.
  137201. * @return The Cube Map information.
  137202. */
  137203. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  137204. /**
  137205. * Returns the pixels data extracted from an RGBE texture.
  137206. * This pixels will be stored left to right up to down in the R G B order in one array.
  137207. *
  137208. * More information on this format are available here:
  137209. * https://en.wikipedia.org/wiki/RGBE_image_format
  137210. *
  137211. * @param uint8array The binary file stored in an array buffer.
  137212. * @param hdrInfo The header information of the file.
  137213. * @return The pixels data in RGB right to left up to down order.
  137214. */
  137215. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  137216. private static RGBE_ReadPixels_RLE;
  137217. }
  137218. }
  137219. declare module BABYLON {
  137220. /**
  137221. * Effect Render Options
  137222. */
  137223. export interface IEffectRendererOptions {
  137224. /**
  137225. * Defines the vertices positions.
  137226. */
  137227. positions?: number[];
  137228. /**
  137229. * Defines the indices.
  137230. */
  137231. indices?: number[];
  137232. }
  137233. /**
  137234. * Helper class to render one or more effects.
  137235. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  137236. */
  137237. export class EffectRenderer {
  137238. private engine;
  137239. private static _DefaultOptions;
  137240. private _vertexBuffers;
  137241. private _indexBuffer;
  137242. private _fullscreenViewport;
  137243. /**
  137244. * Creates an effect renderer
  137245. * @param engine the engine to use for rendering
  137246. * @param options defines the options of the effect renderer
  137247. */
  137248. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  137249. /**
  137250. * Sets the current viewport in normalized coordinates 0-1
  137251. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  137252. */
  137253. setViewport(viewport?: Viewport): void;
  137254. /**
  137255. * Binds the embedded attributes buffer to the effect.
  137256. * @param effect Defines the effect to bind the attributes for
  137257. */
  137258. bindBuffers(effect: Effect): void;
  137259. /**
  137260. * Sets the current effect wrapper to use during draw.
  137261. * The effect needs to be ready before calling this api.
  137262. * This also sets the default full screen position attribute.
  137263. * @param effectWrapper Defines the effect to draw with
  137264. */
  137265. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  137266. /**
  137267. * Restores engine states
  137268. */
  137269. restoreStates(): void;
  137270. /**
  137271. * Draws a full screen quad.
  137272. */
  137273. draw(): void;
  137274. private isRenderTargetTexture;
  137275. /**
  137276. * renders one or more effects to a specified texture
  137277. * @param effectWrapper the effect to renderer
  137278. * @param outputTexture texture to draw to, if null it will render to the screen.
  137279. */
  137280. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  137281. /**
  137282. * Disposes of the effect renderer
  137283. */
  137284. dispose(): void;
  137285. }
  137286. /**
  137287. * Options to create an EffectWrapper
  137288. */
  137289. interface EffectWrapperCreationOptions {
  137290. /**
  137291. * Engine to use to create the effect
  137292. */
  137293. engine: ThinEngine;
  137294. /**
  137295. * Fragment shader for the effect
  137296. */
  137297. fragmentShader: string;
  137298. /**
  137299. * Use the shader store instead of direct source code
  137300. */
  137301. useShaderStore?: boolean;
  137302. /**
  137303. * Vertex shader for the effect
  137304. */
  137305. vertexShader?: string;
  137306. /**
  137307. * Attributes to use in the shader
  137308. */
  137309. attributeNames?: Array<string>;
  137310. /**
  137311. * Uniforms to use in the shader
  137312. */
  137313. uniformNames?: Array<string>;
  137314. /**
  137315. * Texture sampler names to use in the shader
  137316. */
  137317. samplerNames?: Array<string>;
  137318. /**
  137319. * Defines to use in the shader
  137320. */
  137321. defines?: Array<string>;
  137322. /**
  137323. * Callback when effect is compiled
  137324. */
  137325. onCompiled?: Nullable<(effect: Effect) => void>;
  137326. /**
  137327. * The friendly name of the effect displayed in Spector.
  137328. */
  137329. name?: string;
  137330. }
  137331. /**
  137332. * Wraps an effect to be used for rendering
  137333. */
  137334. export class EffectWrapper {
  137335. /**
  137336. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  137337. */
  137338. onApplyObservable: Observable<{}>;
  137339. /**
  137340. * The underlying effect
  137341. */
  137342. effect: Effect;
  137343. /**
  137344. * Creates an effect to be renderer
  137345. * @param creationOptions options to create the effect
  137346. */
  137347. constructor(creationOptions: EffectWrapperCreationOptions);
  137348. /**
  137349. * Disposes of the effect wrapper
  137350. */
  137351. dispose(): void;
  137352. }
  137353. }
  137354. declare module BABYLON {
  137355. /** @hidden */
  137356. export var hdrFilteringVertexShader: {
  137357. name: string;
  137358. shader: string;
  137359. };
  137360. }
  137361. declare module BABYLON {
  137362. /** @hidden */
  137363. export var hdrFilteringPixelShader: {
  137364. name: string;
  137365. shader: string;
  137366. };
  137367. }
  137368. declare module BABYLON {
  137369. /**
  137370. * Options for texture filtering
  137371. */
  137372. interface IHDRFilteringOptions {
  137373. /**
  137374. * Scales pixel intensity for the input HDR map.
  137375. */
  137376. hdrScale?: number;
  137377. /**
  137378. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  137379. */
  137380. quality?: number;
  137381. }
  137382. /**
  137383. * Filters HDR maps to get correct renderings of PBR reflections
  137384. */
  137385. export class HDRFiltering {
  137386. private _engine;
  137387. private _effectRenderer;
  137388. private _effectWrapper;
  137389. private _lodGenerationOffset;
  137390. private _lodGenerationScale;
  137391. /**
  137392. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  137393. * you care about baking speed.
  137394. */
  137395. quality: number;
  137396. /**
  137397. * Scales pixel intensity for the input HDR map.
  137398. */
  137399. hdrScale: number;
  137400. /**
  137401. * Instantiates HDR filter for reflection maps
  137402. *
  137403. * @param engine Thin engine
  137404. * @param options Options
  137405. */
  137406. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  137407. private _createRenderTarget;
  137408. private _prefilterInternal;
  137409. private _createEffect;
  137410. /**
  137411. * Get a value indicating if the filter is ready to be used
  137412. * @param texture Texture to filter
  137413. * @returns true if the filter is ready
  137414. */
  137415. isReady(texture: BaseTexture): boolean;
  137416. /**
  137417. * Prefilters a cube texture to have mipmap levels representing roughness values.
  137418. * Prefiltering will be invoked at the end of next rendering pass.
  137419. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  137420. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  137421. * @param texture Texture to filter
  137422. * @param onFinished Callback when filtering is done
  137423. * @return Promise called when prefiltering is done
  137424. */
  137425. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  137426. }
  137427. }
  137428. declare module BABYLON {
  137429. /**
  137430. * This represents a texture coming from an HDR input.
  137431. *
  137432. * The only supported format is currently panorama picture stored in RGBE format.
  137433. * Example of such files can be found on HDRLib: http://hdrlib.com/
  137434. */
  137435. export class HDRCubeTexture extends BaseTexture {
  137436. private static _facesMapping;
  137437. private _generateHarmonics;
  137438. private _noMipmap;
  137439. private _prefilterOnLoad;
  137440. private _textureMatrix;
  137441. private _size;
  137442. private _onLoad;
  137443. private _onError;
  137444. /**
  137445. * The texture URL.
  137446. */
  137447. url: string;
  137448. /**
  137449. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  137450. */
  137451. coordinatesMode: number;
  137452. protected _isBlocking: boolean;
  137453. /**
  137454. * Sets wether or not the texture is blocking during loading.
  137455. */
  137456. set isBlocking(value: boolean);
  137457. /**
  137458. * Gets wether or not the texture is blocking during loading.
  137459. */
  137460. get isBlocking(): boolean;
  137461. protected _rotationY: number;
  137462. /**
  137463. * Sets texture matrix rotation angle around Y axis in radians.
  137464. */
  137465. set rotationY(value: number);
  137466. /**
  137467. * Gets texture matrix rotation angle around Y axis radians.
  137468. */
  137469. get rotationY(): number;
  137470. /**
  137471. * Gets or sets the center of the bounding box associated with the cube texture
  137472. * It must define where the camera used to render the texture was set
  137473. */
  137474. boundingBoxPosition: Vector3;
  137475. private _boundingBoxSize;
  137476. /**
  137477. * Gets or sets the size of the bounding box associated with the cube texture
  137478. * When defined, the cubemap will switch to local mode
  137479. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  137480. * @example https://www.babylonjs-playground.com/#RNASML
  137481. */
  137482. set boundingBoxSize(value: Vector3);
  137483. get boundingBoxSize(): Vector3;
  137484. /**
  137485. * Instantiates an HDRTexture from the following parameters.
  137486. *
  137487. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  137488. * @param sceneOrEngine The scene or engine the texture will be used in
  137489. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137490. * @param noMipmap Forces to not generate the mipmap if true
  137491. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  137492. * @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)
  137493. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  137494. */
  137495. 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>);
  137496. /**
  137497. * Get the current class name of the texture useful for serialization or dynamic coding.
  137498. * @returns "HDRCubeTexture"
  137499. */
  137500. getClassName(): string;
  137501. /**
  137502. * Occurs when the file is raw .hdr file.
  137503. */
  137504. private loadTexture;
  137505. clone(): HDRCubeTexture;
  137506. delayLoad(): void;
  137507. /**
  137508. * Get the texture reflection matrix used to rotate/transform the reflection.
  137509. * @returns the reflection matrix
  137510. */
  137511. getReflectionTextureMatrix(): Matrix;
  137512. /**
  137513. * Set the texture reflection matrix used to rotate/transform the reflection.
  137514. * @param value Define the reflection matrix to set
  137515. */
  137516. setReflectionTextureMatrix(value: Matrix): void;
  137517. /**
  137518. * Parses a JSON representation of an HDR Texture in order to create the texture
  137519. * @param parsedTexture Define the JSON representation
  137520. * @param scene Define the scene the texture should be created in
  137521. * @param rootUrl Define the root url in case we need to load relative dependencies
  137522. * @returns the newly created texture after parsing
  137523. */
  137524. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  137525. serialize(): any;
  137526. }
  137527. }
  137528. declare module BABYLON {
  137529. /**
  137530. * Class used to control physics engine
  137531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137532. */
  137533. export class PhysicsEngine implements IPhysicsEngine {
  137534. private _physicsPlugin;
  137535. /**
  137536. * Global value used to control the smallest number supported by the simulation
  137537. */
  137538. static Epsilon: number;
  137539. private _impostors;
  137540. private _joints;
  137541. private _subTimeStep;
  137542. /**
  137543. * Gets the gravity vector used by the simulation
  137544. */
  137545. gravity: Vector3;
  137546. /**
  137547. * Factory used to create the default physics plugin.
  137548. * @returns The default physics plugin
  137549. */
  137550. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  137551. /**
  137552. * Creates a new Physics Engine
  137553. * @param gravity defines the gravity vector used by the simulation
  137554. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  137555. */
  137556. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  137557. /**
  137558. * Sets the gravity vector used by the simulation
  137559. * @param gravity defines the gravity vector to use
  137560. */
  137561. setGravity(gravity: Vector3): void;
  137562. /**
  137563. * Set the time step of the physics engine.
  137564. * Default is 1/60.
  137565. * To slow it down, enter 1/600 for example.
  137566. * To speed it up, 1/30
  137567. * @param newTimeStep defines the new timestep to apply to this world.
  137568. */
  137569. setTimeStep(newTimeStep?: number): void;
  137570. /**
  137571. * Get the time step of the physics engine.
  137572. * @returns the current time step
  137573. */
  137574. getTimeStep(): number;
  137575. /**
  137576. * Set the sub time step of the physics engine.
  137577. * Default is 0 meaning there is no sub steps
  137578. * To increase physics resolution precision, set a small value (like 1 ms)
  137579. * @param subTimeStep defines the new sub timestep used for physics resolution.
  137580. */
  137581. setSubTimeStep(subTimeStep?: number): void;
  137582. /**
  137583. * Get the sub time step of the physics engine.
  137584. * @returns the current sub time step
  137585. */
  137586. getSubTimeStep(): number;
  137587. /**
  137588. * Release all resources
  137589. */
  137590. dispose(): void;
  137591. /**
  137592. * Gets the name of the current physics plugin
  137593. * @returns the name of the plugin
  137594. */
  137595. getPhysicsPluginName(): string;
  137596. /**
  137597. * Adding a new impostor for the impostor tracking.
  137598. * This will be done by the impostor itself.
  137599. * @param impostor the impostor to add
  137600. */
  137601. addImpostor(impostor: PhysicsImpostor): void;
  137602. /**
  137603. * Remove an impostor from the engine.
  137604. * This impostor and its mesh will not longer be updated by the physics engine.
  137605. * @param impostor the impostor to remove
  137606. */
  137607. removeImpostor(impostor: PhysicsImpostor): void;
  137608. /**
  137609. * Add a joint to the physics engine
  137610. * @param mainImpostor defines the main impostor to which the joint is added.
  137611. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  137612. * @param joint defines the joint that will connect both impostors.
  137613. */
  137614. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137615. /**
  137616. * Removes a joint from the simulation
  137617. * @param mainImpostor defines the impostor used with the joint
  137618. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  137619. * @param joint defines the joint to remove
  137620. */
  137621. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137622. /**
  137623. * Called by the scene. No need to call it.
  137624. * @param delta defines the timespam between frames
  137625. */
  137626. _step(delta: number): void;
  137627. /**
  137628. * Gets the current plugin used to run the simulation
  137629. * @returns current plugin
  137630. */
  137631. getPhysicsPlugin(): IPhysicsEnginePlugin;
  137632. /**
  137633. * Gets the list of physic impostors
  137634. * @returns an array of PhysicsImpostor
  137635. */
  137636. getImpostors(): Array<PhysicsImpostor>;
  137637. /**
  137638. * Gets the impostor for a physics enabled object
  137639. * @param object defines the object impersonated by the impostor
  137640. * @returns the PhysicsImpostor or null if not found
  137641. */
  137642. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  137643. /**
  137644. * Gets the impostor for a physics body object
  137645. * @param body defines physics body used by the impostor
  137646. * @returns the PhysicsImpostor or null if not found
  137647. */
  137648. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  137649. /**
  137650. * Does a raycast in the physics world
  137651. * @param from when should the ray start?
  137652. * @param to when should the ray end?
  137653. * @returns PhysicsRaycastResult
  137654. */
  137655. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137656. }
  137657. }
  137658. declare module BABYLON {
  137659. /** @hidden */
  137660. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  137661. private _useDeltaForWorldStep;
  137662. world: any;
  137663. name: string;
  137664. private _physicsMaterials;
  137665. private _fixedTimeStep;
  137666. private _cannonRaycastResult;
  137667. private _raycastResult;
  137668. private _physicsBodysToRemoveAfterStep;
  137669. private _firstFrame;
  137670. BJSCANNON: any;
  137671. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  137672. setGravity(gravity: Vector3): void;
  137673. setTimeStep(timeStep: number): void;
  137674. getTimeStep(): number;
  137675. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137676. private _removeMarkedPhysicsBodiesFromWorld;
  137677. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137678. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137679. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137680. private _processChildMeshes;
  137681. removePhysicsBody(impostor: PhysicsImpostor): void;
  137682. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137683. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137684. private _addMaterial;
  137685. private _checkWithEpsilon;
  137686. private _createShape;
  137687. private _createHeightmap;
  137688. private _minus90X;
  137689. private _plus90X;
  137690. private _tmpPosition;
  137691. private _tmpDeltaPosition;
  137692. private _tmpUnityRotation;
  137693. private _updatePhysicsBodyTransformation;
  137694. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137695. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137696. isSupported(): boolean;
  137697. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137698. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137699. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137700. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137701. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137702. getBodyMass(impostor: PhysicsImpostor): number;
  137703. getBodyFriction(impostor: PhysicsImpostor): number;
  137704. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137705. getBodyRestitution(impostor: PhysicsImpostor): number;
  137706. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137707. sleepBody(impostor: PhysicsImpostor): void;
  137708. wakeUpBody(impostor: PhysicsImpostor): void;
  137709. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  137710. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137711. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137712. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137713. getRadius(impostor: PhysicsImpostor): number;
  137714. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137715. dispose(): void;
  137716. private _extendNamespace;
  137717. /**
  137718. * Does a raycast in the physics world
  137719. * @param from when should the ray start?
  137720. * @param to when should the ray end?
  137721. * @returns PhysicsRaycastResult
  137722. */
  137723. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137724. }
  137725. }
  137726. declare module BABYLON {
  137727. /** @hidden */
  137728. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  137729. private _useDeltaForWorldStep;
  137730. world: any;
  137731. name: string;
  137732. BJSOIMO: any;
  137733. private _raycastResult;
  137734. private _fixedTimeStep;
  137735. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  137736. setGravity(gravity: Vector3): void;
  137737. setTimeStep(timeStep: number): void;
  137738. getTimeStep(): number;
  137739. private _tmpImpostorsArray;
  137740. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137741. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137742. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137743. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137744. private _tmpPositionVector;
  137745. removePhysicsBody(impostor: PhysicsImpostor): void;
  137746. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137747. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137748. isSupported(): boolean;
  137749. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137750. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137751. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137752. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137753. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137754. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137755. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137756. getBodyMass(impostor: PhysicsImpostor): number;
  137757. getBodyFriction(impostor: PhysicsImpostor): number;
  137758. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137759. getBodyRestitution(impostor: PhysicsImpostor): number;
  137760. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137761. sleepBody(impostor: PhysicsImpostor): void;
  137762. wakeUpBody(impostor: PhysicsImpostor): void;
  137763. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137764. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  137765. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  137766. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137767. getRadius(impostor: PhysicsImpostor): number;
  137768. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137769. dispose(): void;
  137770. /**
  137771. * Does a raycast in the physics world
  137772. * @param from when should the ray start?
  137773. * @param to when should the ray end?
  137774. * @returns PhysicsRaycastResult
  137775. */
  137776. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137777. }
  137778. }
  137779. declare module BABYLON {
  137780. /**
  137781. * Class containing static functions to help procedurally build meshes
  137782. */
  137783. export class RibbonBuilder {
  137784. /**
  137785. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137786. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  137787. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  137788. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  137789. * * 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
  137790. * * 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
  137791. * * 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
  137792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137793. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137794. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137795. * * 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
  137796. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  137797. * * 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
  137798. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  137799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137800. * @param name defines the name of the mesh
  137801. * @param options defines the options used to create the mesh
  137802. * @param scene defines the hosting scene
  137803. * @returns the ribbon mesh
  137804. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  137805. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137806. */
  137807. static CreateRibbon(name: string, options: {
  137808. pathArray: Vector3[][];
  137809. closeArray?: boolean;
  137810. closePath?: boolean;
  137811. offset?: number;
  137812. updatable?: boolean;
  137813. sideOrientation?: number;
  137814. frontUVs?: Vector4;
  137815. backUVs?: Vector4;
  137816. instance?: Mesh;
  137817. invertUV?: boolean;
  137818. uvs?: Vector2[];
  137819. colors?: Color4[];
  137820. }, scene?: Nullable<Scene>): Mesh;
  137821. }
  137822. }
  137823. declare module BABYLON {
  137824. /**
  137825. * Class containing static functions to help procedurally build meshes
  137826. */
  137827. export class ShapeBuilder {
  137828. /**
  137829. * 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.
  137830. * * 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.
  137831. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137832. * * 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.
  137833. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  137834. * * 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
  137835. * * 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
  137836. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  137837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137839. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  137840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137841. * @param name defines the name of the mesh
  137842. * @param options defines the options used to create the mesh
  137843. * @param scene defines the hosting scene
  137844. * @returns the extruded shape mesh
  137845. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137846. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137847. */
  137848. static ExtrudeShape(name: string, options: {
  137849. shape: Vector3[];
  137850. path: Vector3[];
  137851. scale?: number;
  137852. rotation?: number;
  137853. cap?: number;
  137854. updatable?: boolean;
  137855. sideOrientation?: number;
  137856. frontUVs?: Vector4;
  137857. backUVs?: Vector4;
  137858. instance?: Mesh;
  137859. invertUV?: boolean;
  137860. }, scene?: Nullable<Scene>): Mesh;
  137861. /**
  137862. * Creates an custom extruded shape mesh.
  137863. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  137864. * * 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.
  137865. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137866. * * 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
  137867. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  137868. * * 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
  137869. * * It must returns a float value that will be the scale value applied to the shape on each path point
  137870. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  137871. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  137872. * * 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
  137873. * * 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
  137874. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  137875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137877. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137879. * @param name defines the name of the mesh
  137880. * @param options defines the options used to create the mesh
  137881. * @param scene defines the hosting scene
  137882. * @returns the custom extruded shape mesh
  137883. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  137884. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137885. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137886. */
  137887. static ExtrudeShapeCustom(name: string, options: {
  137888. shape: Vector3[];
  137889. path: Vector3[];
  137890. scaleFunction?: any;
  137891. rotationFunction?: any;
  137892. ribbonCloseArray?: boolean;
  137893. ribbonClosePath?: boolean;
  137894. cap?: number;
  137895. updatable?: boolean;
  137896. sideOrientation?: number;
  137897. frontUVs?: Vector4;
  137898. backUVs?: Vector4;
  137899. instance?: Mesh;
  137900. invertUV?: boolean;
  137901. }, scene?: Nullable<Scene>): Mesh;
  137902. private static _ExtrudeShapeGeneric;
  137903. }
  137904. }
  137905. declare module BABYLON {
  137906. /**
  137907. * AmmoJS Physics plugin
  137908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137909. * @see https://github.com/kripken/ammo.js/
  137910. */
  137911. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  137912. private _useDeltaForWorldStep;
  137913. /**
  137914. * Reference to the Ammo library
  137915. */
  137916. bjsAMMO: any;
  137917. /**
  137918. * Created ammoJS world which physics bodies are added to
  137919. */
  137920. world: any;
  137921. /**
  137922. * Name of the plugin
  137923. */
  137924. name: string;
  137925. private _timeStep;
  137926. private _fixedTimeStep;
  137927. private _maxSteps;
  137928. private _tmpQuaternion;
  137929. private _tmpAmmoTransform;
  137930. private _tmpAmmoQuaternion;
  137931. private _tmpAmmoConcreteContactResultCallback;
  137932. private _collisionConfiguration;
  137933. private _dispatcher;
  137934. private _overlappingPairCache;
  137935. private _solver;
  137936. private _softBodySolver;
  137937. private _tmpAmmoVectorA;
  137938. private _tmpAmmoVectorB;
  137939. private _tmpAmmoVectorC;
  137940. private _tmpAmmoVectorD;
  137941. private _tmpContactCallbackResult;
  137942. private _tmpAmmoVectorRCA;
  137943. private _tmpAmmoVectorRCB;
  137944. private _raycastResult;
  137945. private static readonly DISABLE_COLLISION_FLAG;
  137946. private static readonly KINEMATIC_FLAG;
  137947. private static readonly DISABLE_DEACTIVATION_FLAG;
  137948. /**
  137949. * Initializes the ammoJS plugin
  137950. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  137951. * @param ammoInjection can be used to inject your own ammo reference
  137952. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  137953. */
  137954. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  137955. /**
  137956. * Sets the gravity of the physics world (m/(s^2))
  137957. * @param gravity Gravity to set
  137958. */
  137959. setGravity(gravity: Vector3): void;
  137960. /**
  137961. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  137962. * @param timeStep timestep to use in seconds
  137963. */
  137964. setTimeStep(timeStep: number): void;
  137965. /**
  137966. * 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)
  137967. * @param fixedTimeStep fixedTimeStep to use in seconds
  137968. */
  137969. setFixedTimeStep(fixedTimeStep: number): void;
  137970. /**
  137971. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  137972. * @param maxSteps the maximum number of steps by the physics engine per frame
  137973. */
  137974. setMaxSteps(maxSteps: number): void;
  137975. /**
  137976. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  137977. * @returns the current timestep in seconds
  137978. */
  137979. getTimeStep(): number;
  137980. /**
  137981. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  137982. */
  137983. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  137984. private _isImpostorInContact;
  137985. private _isImpostorPairInContact;
  137986. private _stepSimulation;
  137987. /**
  137988. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  137989. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  137990. * After the step the babylon meshes are set to the position of the physics imposters
  137991. * @param delta amount of time to step forward
  137992. * @param impostors array of imposters to update before/after the step
  137993. */
  137994. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137995. /**
  137996. * Update babylon mesh to match physics world object
  137997. * @param impostor imposter to match
  137998. */
  137999. private _afterSoftStep;
  138000. /**
  138001. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138002. * @param impostor imposter to match
  138003. */
  138004. private _ropeStep;
  138005. /**
  138006. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138007. * @param impostor imposter to match
  138008. */
  138009. private _softbodyOrClothStep;
  138010. private _tmpMatrix;
  138011. /**
  138012. * Applies an impulse on the imposter
  138013. * @param impostor imposter to apply impulse to
  138014. * @param force amount of force to be applied to the imposter
  138015. * @param contactPoint the location to apply the impulse on the imposter
  138016. */
  138017. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138018. /**
  138019. * Applies a force on the imposter
  138020. * @param impostor imposter to apply force
  138021. * @param force amount of force to be applied to the imposter
  138022. * @param contactPoint the location to apply the force on the imposter
  138023. */
  138024. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138025. /**
  138026. * Creates a physics body using the plugin
  138027. * @param impostor the imposter to create the physics body on
  138028. */
  138029. generatePhysicsBody(impostor: PhysicsImpostor): void;
  138030. /**
  138031. * Removes the physics body from the imposter and disposes of the body's memory
  138032. * @param impostor imposter to remove the physics body from
  138033. */
  138034. removePhysicsBody(impostor: PhysicsImpostor): void;
  138035. /**
  138036. * Generates a joint
  138037. * @param impostorJoint the imposter joint to create the joint with
  138038. */
  138039. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  138040. /**
  138041. * Removes a joint
  138042. * @param impostorJoint the imposter joint to remove the joint from
  138043. */
  138044. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  138045. private _addMeshVerts;
  138046. /**
  138047. * Initialise the soft body vertices to match its object's (mesh) vertices
  138048. * Softbody vertices (nodes) are in world space and to match this
  138049. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  138050. * @param impostor to create the softbody for
  138051. */
  138052. private _softVertexData;
  138053. /**
  138054. * Create an impostor's soft body
  138055. * @param impostor to create the softbody for
  138056. */
  138057. private _createSoftbody;
  138058. /**
  138059. * Create cloth for an impostor
  138060. * @param impostor to create the softbody for
  138061. */
  138062. private _createCloth;
  138063. /**
  138064. * Create rope for an impostor
  138065. * @param impostor to create the softbody for
  138066. */
  138067. private _createRope;
  138068. /**
  138069. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  138070. * @param impostor to create the custom physics shape for
  138071. */
  138072. private _createCustom;
  138073. private _addHullVerts;
  138074. private _createShape;
  138075. /**
  138076. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  138077. * @param impostor imposter containing the physics body and babylon object
  138078. */
  138079. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  138080. /**
  138081. * Sets the babylon object's position/rotation from the physics body's position/rotation
  138082. * @param impostor imposter containing the physics body and babylon object
  138083. * @param newPosition new position
  138084. * @param newRotation new rotation
  138085. */
  138086. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  138087. /**
  138088. * If this plugin is supported
  138089. * @returns true if its supported
  138090. */
  138091. isSupported(): boolean;
  138092. /**
  138093. * Sets the linear velocity of the physics body
  138094. * @param impostor imposter to set the velocity on
  138095. * @param velocity velocity to set
  138096. */
  138097. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138098. /**
  138099. * Sets the angular velocity of the physics body
  138100. * @param impostor imposter to set the velocity on
  138101. * @param velocity velocity to set
  138102. */
  138103. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138104. /**
  138105. * gets the linear velocity
  138106. * @param impostor imposter to get linear velocity from
  138107. * @returns linear velocity
  138108. */
  138109. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138110. /**
  138111. * gets the angular velocity
  138112. * @param impostor imposter to get angular velocity from
  138113. * @returns angular velocity
  138114. */
  138115. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138116. /**
  138117. * Sets the mass of physics body
  138118. * @param impostor imposter to set the mass on
  138119. * @param mass mass to set
  138120. */
  138121. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  138122. /**
  138123. * Gets the mass of the physics body
  138124. * @param impostor imposter to get the mass from
  138125. * @returns mass
  138126. */
  138127. getBodyMass(impostor: PhysicsImpostor): number;
  138128. /**
  138129. * Gets friction of the impostor
  138130. * @param impostor impostor to get friction from
  138131. * @returns friction value
  138132. */
  138133. getBodyFriction(impostor: PhysicsImpostor): number;
  138134. /**
  138135. * Sets friction of the impostor
  138136. * @param impostor impostor to set friction on
  138137. * @param friction friction value
  138138. */
  138139. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  138140. /**
  138141. * Gets restitution of the impostor
  138142. * @param impostor impostor to get restitution from
  138143. * @returns restitution value
  138144. */
  138145. getBodyRestitution(impostor: PhysicsImpostor): number;
  138146. /**
  138147. * Sets resitution of the impostor
  138148. * @param impostor impostor to set resitution on
  138149. * @param restitution resitution value
  138150. */
  138151. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  138152. /**
  138153. * Gets pressure inside the impostor
  138154. * @param impostor impostor to get pressure from
  138155. * @returns pressure value
  138156. */
  138157. getBodyPressure(impostor: PhysicsImpostor): number;
  138158. /**
  138159. * Sets pressure inside a soft body impostor
  138160. * Cloth and rope must remain 0 pressure
  138161. * @param impostor impostor to set pressure on
  138162. * @param pressure pressure value
  138163. */
  138164. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  138165. /**
  138166. * Gets stiffness of the impostor
  138167. * @param impostor impostor to get stiffness from
  138168. * @returns pressure value
  138169. */
  138170. getBodyStiffness(impostor: PhysicsImpostor): number;
  138171. /**
  138172. * Sets stiffness of the impostor
  138173. * @param impostor impostor to set stiffness on
  138174. * @param stiffness stiffness value from 0 to 1
  138175. */
  138176. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  138177. /**
  138178. * Gets velocityIterations of the impostor
  138179. * @param impostor impostor to get velocity iterations from
  138180. * @returns velocityIterations value
  138181. */
  138182. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  138183. /**
  138184. * Sets velocityIterations of the impostor
  138185. * @param impostor impostor to set velocity iterations on
  138186. * @param velocityIterations velocityIterations value
  138187. */
  138188. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  138189. /**
  138190. * Gets positionIterations of the impostor
  138191. * @param impostor impostor to get position iterations from
  138192. * @returns positionIterations value
  138193. */
  138194. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  138195. /**
  138196. * Sets positionIterations of the impostor
  138197. * @param impostor impostor to set position on
  138198. * @param positionIterations positionIterations value
  138199. */
  138200. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  138201. /**
  138202. * Append an anchor to a cloth object
  138203. * @param impostor is the cloth impostor to add anchor to
  138204. * @param otherImpostor is the rigid impostor to anchor to
  138205. * @param width ratio across width from 0 to 1
  138206. * @param height ratio up height from 0 to 1
  138207. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  138208. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138209. */
  138210. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138211. /**
  138212. * Append an hook to a rope object
  138213. * @param impostor is the rope impostor to add hook to
  138214. * @param otherImpostor is the rigid impostor to hook to
  138215. * @param length ratio along the rope from 0 to 1
  138216. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  138217. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138218. */
  138219. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138220. /**
  138221. * Sleeps the physics body and stops it from being active
  138222. * @param impostor impostor to sleep
  138223. */
  138224. sleepBody(impostor: PhysicsImpostor): void;
  138225. /**
  138226. * Activates the physics body
  138227. * @param impostor impostor to activate
  138228. */
  138229. wakeUpBody(impostor: PhysicsImpostor): void;
  138230. /**
  138231. * Updates the distance parameters of the joint
  138232. * @param joint joint to update
  138233. * @param maxDistance maximum distance of the joint
  138234. * @param minDistance minimum distance of the joint
  138235. */
  138236. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  138237. /**
  138238. * Sets a motor on the joint
  138239. * @param joint joint to set motor on
  138240. * @param speed speed of the motor
  138241. * @param maxForce maximum force of the motor
  138242. * @param motorIndex index of the motor
  138243. */
  138244. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  138245. /**
  138246. * Sets the motors limit
  138247. * @param joint joint to set limit on
  138248. * @param upperLimit upper limit
  138249. * @param lowerLimit lower limit
  138250. */
  138251. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  138252. /**
  138253. * Syncs the position and rotation of a mesh with the impostor
  138254. * @param mesh mesh to sync
  138255. * @param impostor impostor to update the mesh with
  138256. */
  138257. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  138258. /**
  138259. * Gets the radius of the impostor
  138260. * @param impostor impostor to get radius from
  138261. * @returns the radius
  138262. */
  138263. getRadius(impostor: PhysicsImpostor): number;
  138264. /**
  138265. * Gets the box size of the impostor
  138266. * @param impostor impostor to get box size from
  138267. * @param result the resulting box size
  138268. */
  138269. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  138270. /**
  138271. * Disposes of the impostor
  138272. */
  138273. dispose(): void;
  138274. /**
  138275. * Does a raycast in the physics world
  138276. * @param from when should the ray start?
  138277. * @param to when should the ray end?
  138278. * @returns PhysicsRaycastResult
  138279. */
  138280. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138281. }
  138282. }
  138283. declare module BABYLON {
  138284. interface AbstractScene {
  138285. /**
  138286. * The list of reflection probes added to the scene
  138287. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138288. */
  138289. reflectionProbes: Array<ReflectionProbe>;
  138290. /**
  138291. * Removes the given reflection probe from this scene.
  138292. * @param toRemove The reflection probe to remove
  138293. * @returns The index of the removed reflection probe
  138294. */
  138295. removeReflectionProbe(toRemove: ReflectionProbe): number;
  138296. /**
  138297. * Adds the given reflection probe to this scene.
  138298. * @param newReflectionProbe The reflection probe to add
  138299. */
  138300. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  138301. }
  138302. /**
  138303. * Class used to generate realtime reflection / refraction cube textures
  138304. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138305. */
  138306. export class ReflectionProbe {
  138307. /** defines the name of the probe */
  138308. name: string;
  138309. private _scene;
  138310. private _renderTargetTexture;
  138311. private _projectionMatrix;
  138312. private _viewMatrix;
  138313. private _target;
  138314. private _add;
  138315. private _attachedMesh;
  138316. private _invertYAxis;
  138317. /** Gets or sets probe position (center of the cube map) */
  138318. position: Vector3;
  138319. /**
  138320. * Creates a new reflection probe
  138321. * @param name defines the name of the probe
  138322. * @param size defines the texture resolution (for each face)
  138323. * @param scene defines the hosting scene
  138324. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  138325. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  138326. */
  138327. constructor(
  138328. /** defines the name of the probe */
  138329. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  138330. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  138331. get samples(): number;
  138332. set samples(value: number);
  138333. /** Gets or sets the refresh rate to use (on every frame by default) */
  138334. get refreshRate(): number;
  138335. set refreshRate(value: number);
  138336. /**
  138337. * Gets the hosting scene
  138338. * @returns a Scene
  138339. */
  138340. getScene(): Scene;
  138341. /** Gets the internal CubeTexture used to render to */
  138342. get cubeTexture(): RenderTargetTexture;
  138343. /** Gets the list of meshes to render */
  138344. get renderList(): Nullable<AbstractMesh[]>;
  138345. /**
  138346. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  138347. * @param mesh defines the mesh to attach to
  138348. */
  138349. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  138350. /**
  138351. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  138352. * @param renderingGroupId The rendering group id corresponding to its index
  138353. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  138354. */
  138355. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  138356. /**
  138357. * Clean all associated resources
  138358. */
  138359. dispose(): void;
  138360. /**
  138361. * Converts the reflection probe information to a readable string for debug purpose.
  138362. * @param fullDetails Supports for multiple levels of logging within scene loading
  138363. * @returns the human readable reflection probe info
  138364. */
  138365. toString(fullDetails?: boolean): string;
  138366. /**
  138367. * Get the class name of the relfection probe.
  138368. * @returns "ReflectionProbe"
  138369. */
  138370. getClassName(): string;
  138371. /**
  138372. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  138373. * @returns The JSON representation of the texture
  138374. */
  138375. serialize(): any;
  138376. /**
  138377. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  138378. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  138379. * @param scene Define the scene the parsed reflection probe should be instantiated in
  138380. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  138381. * @returns The parsed reflection probe if successful
  138382. */
  138383. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  138384. }
  138385. }
  138386. declare module BABYLON {
  138387. /** @hidden */
  138388. export var _BabylonLoaderRegistered: boolean;
  138389. /**
  138390. * Helps setting up some configuration for the babylon file loader.
  138391. */
  138392. export class BabylonFileLoaderConfiguration {
  138393. /**
  138394. * The loader does not allow injecting custom physix engine into the plugins.
  138395. * Unfortunately in ES6, we need to manually inject them into the plugin.
  138396. * So you could set this variable to your engine import to make it work.
  138397. */
  138398. static LoaderInjectedPhysicsEngine: any;
  138399. }
  138400. }
  138401. declare module BABYLON {
  138402. /**
  138403. * The Physically based simple base material of BJS.
  138404. *
  138405. * This enables better naming and convention enforcements on top of the pbrMaterial.
  138406. * It is used as the base class for both the specGloss and metalRough conventions.
  138407. */
  138408. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  138409. /**
  138410. * Number of Simultaneous lights allowed on the material.
  138411. */
  138412. maxSimultaneousLights: number;
  138413. /**
  138414. * If sets to true, disables all the lights affecting the material.
  138415. */
  138416. disableLighting: boolean;
  138417. /**
  138418. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  138419. */
  138420. environmentTexture: BaseTexture;
  138421. /**
  138422. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  138423. */
  138424. invertNormalMapX: boolean;
  138425. /**
  138426. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  138427. */
  138428. invertNormalMapY: boolean;
  138429. /**
  138430. * Normal map used in the model.
  138431. */
  138432. normalTexture: BaseTexture;
  138433. /**
  138434. * Emissivie color used to self-illuminate the model.
  138435. */
  138436. emissiveColor: Color3;
  138437. /**
  138438. * Emissivie texture used to self-illuminate the model.
  138439. */
  138440. emissiveTexture: BaseTexture;
  138441. /**
  138442. * Occlusion Channel Strenght.
  138443. */
  138444. occlusionStrength: number;
  138445. /**
  138446. * Occlusion Texture of the material (adding extra occlusion effects).
  138447. */
  138448. occlusionTexture: BaseTexture;
  138449. /**
  138450. * Defines the alpha limits in alpha test mode.
  138451. */
  138452. alphaCutOff: number;
  138453. /**
  138454. * Gets the current double sided mode.
  138455. */
  138456. get doubleSided(): boolean;
  138457. /**
  138458. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  138459. */
  138460. set doubleSided(value: boolean);
  138461. /**
  138462. * Stores the pre-calculated light information of a mesh in a texture.
  138463. */
  138464. lightmapTexture: BaseTexture;
  138465. /**
  138466. * If true, the light map contains occlusion information instead of lighting info.
  138467. */
  138468. useLightmapAsShadowmap: boolean;
  138469. /**
  138470. * Instantiates a new PBRMaterial instance.
  138471. *
  138472. * @param name The material name
  138473. * @param scene The scene the material will be use in.
  138474. */
  138475. constructor(name: string, scene: Scene);
  138476. getClassName(): string;
  138477. }
  138478. }
  138479. declare module BABYLON {
  138480. /**
  138481. * The PBR material of BJS following the metal roughness convention.
  138482. *
  138483. * This fits to the PBR convention in the GLTF definition:
  138484. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  138485. */
  138486. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  138487. /**
  138488. * The base color has two different interpretations depending on the value of metalness.
  138489. * When the material is a metal, the base color is the specific measured reflectance value
  138490. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  138491. * of the material.
  138492. */
  138493. baseColor: Color3;
  138494. /**
  138495. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  138496. * well as opacity information in the alpha channel.
  138497. */
  138498. baseTexture: BaseTexture;
  138499. /**
  138500. * Specifies the metallic scalar value of the material.
  138501. * Can also be used to scale the metalness values of the metallic texture.
  138502. */
  138503. metallic: number;
  138504. /**
  138505. * Specifies the roughness scalar value of the material.
  138506. * Can also be used to scale the roughness values of the metallic texture.
  138507. */
  138508. roughness: number;
  138509. /**
  138510. * Texture containing both the metallic value in the B channel and the
  138511. * roughness value in the G channel to keep better precision.
  138512. */
  138513. metallicRoughnessTexture: BaseTexture;
  138514. /**
  138515. * Instantiates a new PBRMetalRoughnessMaterial instance.
  138516. *
  138517. * @param name The material name
  138518. * @param scene The scene the material will be use in.
  138519. */
  138520. constructor(name: string, scene: Scene);
  138521. /**
  138522. * Return the currrent class name of the material.
  138523. */
  138524. getClassName(): string;
  138525. /**
  138526. * Makes a duplicate of the current material.
  138527. * @param name - name to use for the new material.
  138528. */
  138529. clone(name: string): PBRMetallicRoughnessMaterial;
  138530. /**
  138531. * Serialize the material to a parsable JSON object.
  138532. */
  138533. serialize(): any;
  138534. /**
  138535. * Parses a JSON object correponding to the serialize function.
  138536. */
  138537. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  138538. }
  138539. }
  138540. declare module BABYLON {
  138541. /**
  138542. * The PBR material of BJS following the specular glossiness convention.
  138543. *
  138544. * This fits to the PBR convention in the GLTF definition:
  138545. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  138546. */
  138547. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  138548. /**
  138549. * Specifies the diffuse color of the material.
  138550. */
  138551. diffuseColor: Color3;
  138552. /**
  138553. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  138554. * channel.
  138555. */
  138556. diffuseTexture: BaseTexture;
  138557. /**
  138558. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  138559. */
  138560. specularColor: Color3;
  138561. /**
  138562. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  138563. */
  138564. glossiness: number;
  138565. /**
  138566. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  138567. */
  138568. specularGlossinessTexture: BaseTexture;
  138569. /**
  138570. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  138571. *
  138572. * @param name The material name
  138573. * @param scene The scene the material will be use in.
  138574. */
  138575. constructor(name: string, scene: Scene);
  138576. /**
  138577. * Return the currrent class name of the material.
  138578. */
  138579. getClassName(): string;
  138580. /**
  138581. * Makes a duplicate of the current material.
  138582. * @param name - name to use for the new material.
  138583. */
  138584. clone(name: string): PBRSpecularGlossinessMaterial;
  138585. /**
  138586. * Serialize the material to a parsable JSON object.
  138587. */
  138588. serialize(): any;
  138589. /**
  138590. * Parses a JSON object correponding to the serialize function.
  138591. */
  138592. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  138593. }
  138594. }
  138595. declare module BABYLON {
  138596. /**
  138597. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  138598. * It can help converting any input color in a desired output one. This can then be used to create effects
  138599. * from sepia, black and white to sixties or futuristic rendering...
  138600. *
  138601. * The only supported format is currently 3dl.
  138602. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  138603. */
  138604. export class ColorGradingTexture extends BaseTexture {
  138605. /**
  138606. * The texture URL.
  138607. */
  138608. url: string;
  138609. /**
  138610. * Empty line regex stored for GC.
  138611. */
  138612. private static _noneEmptyLineRegex;
  138613. private _textureMatrix;
  138614. private _onLoad;
  138615. /**
  138616. * Instantiates a ColorGradingTexture from the following parameters.
  138617. *
  138618. * @param url The location of the color gradind data (currently only supporting 3dl)
  138619. * @param sceneOrEngine The scene or engine the texture will be used in
  138620. * @param onLoad defines a callback triggered when the texture has been loaded
  138621. */
  138622. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  138623. /**
  138624. * Fires the onload event from the constructor if requested.
  138625. */
  138626. private _triggerOnLoad;
  138627. /**
  138628. * Returns the texture matrix used in most of the material.
  138629. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  138630. */
  138631. getTextureMatrix(): Matrix;
  138632. /**
  138633. * Occurs when the file being loaded is a .3dl LUT file.
  138634. */
  138635. private load3dlTexture;
  138636. /**
  138637. * Starts the loading process of the texture.
  138638. */
  138639. private loadTexture;
  138640. /**
  138641. * Clones the color gradind texture.
  138642. */
  138643. clone(): ColorGradingTexture;
  138644. /**
  138645. * Called during delayed load for textures.
  138646. */
  138647. delayLoad(): void;
  138648. /**
  138649. * Parses a color grading texture serialized by Babylon.
  138650. * @param parsedTexture The texture information being parsedTexture
  138651. * @param scene The scene to load the texture in
  138652. * @param rootUrl The root url of the data assets to load
  138653. * @return A color gradind texture
  138654. */
  138655. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  138656. /**
  138657. * Serializes the LUT texture to json format.
  138658. */
  138659. serialize(): any;
  138660. }
  138661. }
  138662. declare module BABYLON {
  138663. /**
  138664. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  138665. */
  138666. export class EquiRectangularCubeTexture extends BaseTexture {
  138667. /** The six faces of the cube. */
  138668. private static _FacesMapping;
  138669. private _noMipmap;
  138670. private _onLoad;
  138671. private _onError;
  138672. /** The size of the cubemap. */
  138673. private _size;
  138674. /** The buffer of the image. */
  138675. private _buffer;
  138676. /** The width of the input image. */
  138677. private _width;
  138678. /** The height of the input image. */
  138679. private _height;
  138680. /** The URL to the image. */
  138681. url: string;
  138682. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  138683. coordinatesMode: number;
  138684. /**
  138685. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  138686. * @param url The location of the image
  138687. * @param scene The scene the texture will be used in
  138688. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  138689. * @param noMipmap Forces to not generate the mipmap if true
  138690. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  138691. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  138692. * @param onLoad — defines a callback called when texture is loaded
  138693. * @param onError — defines a callback called if there is an error
  138694. */
  138695. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  138696. /**
  138697. * Load the image data, by putting the image on a canvas and extracting its buffer.
  138698. */
  138699. private loadImage;
  138700. /**
  138701. * Convert the image buffer into a cubemap and create a CubeTexture.
  138702. */
  138703. private loadTexture;
  138704. /**
  138705. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  138706. * @param buffer The ArrayBuffer that should be converted.
  138707. * @returns The buffer as Float32Array.
  138708. */
  138709. private getFloat32ArrayFromArrayBuffer;
  138710. /**
  138711. * Get the current class name of the texture useful for serialization or dynamic coding.
  138712. * @returns "EquiRectangularCubeTexture"
  138713. */
  138714. getClassName(): string;
  138715. /**
  138716. * Create a clone of the current EquiRectangularCubeTexture and return it.
  138717. * @returns A clone of the current EquiRectangularCubeTexture.
  138718. */
  138719. clone(): EquiRectangularCubeTexture;
  138720. }
  138721. }
  138722. declare module BABYLON {
  138723. /**
  138724. * Defines the options related to the creation of an HtmlElementTexture
  138725. */
  138726. export interface IHtmlElementTextureOptions {
  138727. /**
  138728. * Defines wether mip maps should be created or not.
  138729. */
  138730. generateMipMaps?: boolean;
  138731. /**
  138732. * Defines the sampling mode of the texture.
  138733. */
  138734. samplingMode?: number;
  138735. /**
  138736. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  138737. */
  138738. engine: Nullable<ThinEngine>;
  138739. /**
  138740. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  138741. */
  138742. scene: Nullable<Scene>;
  138743. }
  138744. /**
  138745. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  138746. * To be as efficient as possible depending on your constraints nothing aside the first upload
  138747. * is automatically managed.
  138748. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  138749. * in your application.
  138750. *
  138751. * As the update is not automatic, you need to call them manually.
  138752. */
  138753. export class HtmlElementTexture extends BaseTexture {
  138754. /**
  138755. * The texture URL.
  138756. */
  138757. element: HTMLVideoElement | HTMLCanvasElement;
  138758. private static readonly DefaultOptions;
  138759. private _textureMatrix;
  138760. private _isVideo;
  138761. private _generateMipMaps;
  138762. private _samplingMode;
  138763. /**
  138764. * Instantiates a HtmlElementTexture from the following parameters.
  138765. *
  138766. * @param name Defines the name of the texture
  138767. * @param element Defines the video or canvas the texture is filled with
  138768. * @param options Defines the other none mandatory texture creation options
  138769. */
  138770. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  138771. private _createInternalTexture;
  138772. /**
  138773. * Returns the texture matrix used in most of the material.
  138774. */
  138775. getTextureMatrix(): Matrix;
  138776. /**
  138777. * Updates the content of the texture.
  138778. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  138779. */
  138780. update(invertY?: Nullable<boolean>): void;
  138781. }
  138782. }
  138783. declare module BABYLON {
  138784. /**
  138785. * Based on jsTGALoader - Javascript loader for TGA file
  138786. * By Vincent Thibault
  138787. * @see http://blog.robrowser.com/javascript-tga-loader.html
  138788. */
  138789. export class TGATools {
  138790. private static _TYPE_INDEXED;
  138791. private static _TYPE_RGB;
  138792. private static _TYPE_GREY;
  138793. private static _TYPE_RLE_INDEXED;
  138794. private static _TYPE_RLE_RGB;
  138795. private static _TYPE_RLE_GREY;
  138796. private static _ORIGIN_MASK;
  138797. private static _ORIGIN_SHIFT;
  138798. private static _ORIGIN_BL;
  138799. private static _ORIGIN_BR;
  138800. private static _ORIGIN_UL;
  138801. private static _ORIGIN_UR;
  138802. /**
  138803. * Gets the header of a TGA file
  138804. * @param data defines the TGA data
  138805. * @returns the header
  138806. */
  138807. static GetTGAHeader(data: Uint8Array): any;
  138808. /**
  138809. * Uploads TGA content to a Babylon Texture
  138810. * @hidden
  138811. */
  138812. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  138813. /** @hidden */
  138814. 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;
  138815. /** @hidden */
  138816. 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;
  138817. /** @hidden */
  138818. 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;
  138819. /** @hidden */
  138820. 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;
  138821. /** @hidden */
  138822. 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;
  138823. /** @hidden */
  138824. 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;
  138825. }
  138826. }
  138827. declare module BABYLON {
  138828. /**
  138829. * Implementation of the TGA Texture Loader.
  138830. * @hidden
  138831. */
  138832. export class _TGATextureLoader implements IInternalTextureLoader {
  138833. /**
  138834. * Defines wether the loader supports cascade loading the different faces.
  138835. */
  138836. readonly supportCascades: boolean;
  138837. /**
  138838. * This returns if the loader support the current file information.
  138839. * @param extension defines the file extension of the file being loaded
  138840. * @returns true if the loader can load the specified file
  138841. */
  138842. canLoad(extension: string): boolean;
  138843. /**
  138844. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138845. * @param data contains the texture data
  138846. * @param texture defines the BabylonJS internal texture
  138847. * @param createPolynomials will be true if polynomials have been requested
  138848. * @param onLoad defines the callback to trigger once the texture is ready
  138849. * @param onError defines the callback to trigger in case of error
  138850. */
  138851. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138852. /**
  138853. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138854. * @param data contains the texture data
  138855. * @param texture defines the BabylonJS internal texture
  138856. * @param callback defines the method to call once ready to upload
  138857. */
  138858. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138859. }
  138860. }
  138861. declare module BABYLON {
  138862. /**
  138863. * Info about the .basis files
  138864. */
  138865. class BasisFileInfo {
  138866. /**
  138867. * If the file has alpha
  138868. */
  138869. hasAlpha: boolean;
  138870. /**
  138871. * Info about each image of the basis file
  138872. */
  138873. images: Array<{
  138874. levels: Array<{
  138875. width: number;
  138876. height: number;
  138877. transcodedPixels: ArrayBufferView;
  138878. }>;
  138879. }>;
  138880. }
  138881. /**
  138882. * Result of transcoding a basis file
  138883. */
  138884. class TranscodeResult {
  138885. /**
  138886. * Info about the .basis file
  138887. */
  138888. fileInfo: BasisFileInfo;
  138889. /**
  138890. * Format to use when loading the file
  138891. */
  138892. format: number;
  138893. }
  138894. /**
  138895. * Configuration options for the Basis transcoder
  138896. */
  138897. export class BasisTranscodeConfiguration {
  138898. /**
  138899. * Supported compression formats used to determine the supported output format of the transcoder
  138900. */
  138901. supportedCompressionFormats?: {
  138902. /**
  138903. * etc1 compression format
  138904. */
  138905. etc1?: boolean;
  138906. /**
  138907. * s3tc compression format
  138908. */
  138909. s3tc?: boolean;
  138910. /**
  138911. * pvrtc compression format
  138912. */
  138913. pvrtc?: boolean;
  138914. /**
  138915. * etc2 compression format
  138916. */
  138917. etc2?: boolean;
  138918. };
  138919. /**
  138920. * If mipmap levels should be loaded for transcoded images (Default: true)
  138921. */
  138922. loadMipmapLevels?: boolean;
  138923. /**
  138924. * Index of a single image to load (Default: all images)
  138925. */
  138926. loadSingleImage?: number;
  138927. }
  138928. /**
  138929. * Used to load .Basis files
  138930. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  138931. */
  138932. export class BasisTools {
  138933. private static _IgnoreSupportedFormats;
  138934. /**
  138935. * URL to use when loading the basis transcoder
  138936. */
  138937. static JSModuleURL: string;
  138938. /**
  138939. * URL to use when loading the wasm module for the transcoder
  138940. */
  138941. static WasmModuleURL: string;
  138942. /**
  138943. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  138944. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  138945. * @returns internal format corresponding to the Basis format
  138946. */
  138947. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  138948. private static _WorkerPromise;
  138949. private static _Worker;
  138950. private static _actionId;
  138951. private static _CreateWorkerAsync;
  138952. /**
  138953. * Transcodes a loaded image file to compressed pixel data
  138954. * @param data image data to transcode
  138955. * @param config configuration options for the transcoding
  138956. * @returns a promise resulting in the transcoded image
  138957. */
  138958. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  138959. /**
  138960. * Loads a texture from the transcode result
  138961. * @param texture texture load to
  138962. * @param transcodeResult the result of transcoding the basis file to load from
  138963. */
  138964. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  138965. }
  138966. }
  138967. declare module BABYLON {
  138968. /**
  138969. * Loader for .basis file format
  138970. */
  138971. export class _BasisTextureLoader implements IInternalTextureLoader {
  138972. /**
  138973. * Defines whether the loader supports cascade loading the different faces.
  138974. */
  138975. readonly supportCascades: boolean;
  138976. /**
  138977. * This returns if the loader support the current file information.
  138978. * @param extension defines the file extension of the file being loaded
  138979. * @returns true if the loader can load the specified file
  138980. */
  138981. canLoad(extension: string): boolean;
  138982. /**
  138983. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138984. * @param data contains the texture data
  138985. * @param texture defines the BabylonJS internal texture
  138986. * @param createPolynomials will be true if polynomials have been requested
  138987. * @param onLoad defines the callback to trigger once the texture is ready
  138988. * @param onError defines the callback to trigger in case of error
  138989. */
  138990. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138991. /**
  138992. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138993. * @param data contains the texture data
  138994. * @param texture defines the BabylonJS internal texture
  138995. * @param callback defines the method to call once ready to upload
  138996. */
  138997. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138998. }
  138999. }
  139000. declare module BABYLON {
  139001. /**
  139002. * Defines the basic options interface of a TexturePacker Frame
  139003. */
  139004. export interface ITexturePackerFrame {
  139005. /**
  139006. * The frame ID
  139007. */
  139008. id: number;
  139009. /**
  139010. * The frames Scale
  139011. */
  139012. scale: Vector2;
  139013. /**
  139014. * The Frames offset
  139015. */
  139016. offset: Vector2;
  139017. }
  139018. /**
  139019. * This is a support class for frame Data on texture packer sets.
  139020. */
  139021. export class TexturePackerFrame implements ITexturePackerFrame {
  139022. /**
  139023. * The frame ID
  139024. */
  139025. id: number;
  139026. /**
  139027. * The frames Scale
  139028. */
  139029. scale: Vector2;
  139030. /**
  139031. * The Frames offset
  139032. */
  139033. offset: Vector2;
  139034. /**
  139035. * Initializes a texture package frame.
  139036. * @param id The numerical frame identifier
  139037. * @param scale Scalar Vector2 for UV frame
  139038. * @param offset Vector2 for the frame position in UV units.
  139039. * @returns TexturePackerFrame
  139040. */
  139041. constructor(id: number, scale: Vector2, offset: Vector2);
  139042. }
  139043. }
  139044. declare module BABYLON {
  139045. /**
  139046. * Defines the basic options interface of a TexturePacker
  139047. */
  139048. export interface ITexturePackerOptions {
  139049. /**
  139050. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  139051. */
  139052. map?: string[];
  139053. /**
  139054. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139055. */
  139056. uvsIn?: string;
  139057. /**
  139058. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139059. */
  139060. uvsOut?: string;
  139061. /**
  139062. * number representing the layout style. Defaults to LAYOUT_STRIP
  139063. */
  139064. layout?: number;
  139065. /**
  139066. * number of columns if using custom column count layout(2). This defaults to 4.
  139067. */
  139068. colnum?: number;
  139069. /**
  139070. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  139071. */
  139072. updateInputMeshes?: boolean;
  139073. /**
  139074. * boolean flag to dispose all the source textures. Defaults to true.
  139075. */
  139076. disposeSources?: boolean;
  139077. /**
  139078. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  139079. */
  139080. fillBlanks?: boolean;
  139081. /**
  139082. * string value representing the context fill style color. Defaults to 'black'.
  139083. */
  139084. customFillColor?: string;
  139085. /**
  139086. * Width and Height Value of each Frame in the TexturePacker Sets
  139087. */
  139088. frameSize?: number;
  139089. /**
  139090. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  139091. */
  139092. paddingRatio?: number;
  139093. /**
  139094. * Number that declares the fill method for the padding gutter.
  139095. */
  139096. paddingMode?: number;
  139097. /**
  139098. * If in SUBUV_COLOR padding mode what color to use.
  139099. */
  139100. paddingColor?: Color3 | Color4;
  139101. }
  139102. /**
  139103. * Defines the basic interface of a TexturePacker JSON File
  139104. */
  139105. export interface ITexturePackerJSON {
  139106. /**
  139107. * The frame ID
  139108. */
  139109. name: string;
  139110. /**
  139111. * The base64 channel data
  139112. */
  139113. sets: any;
  139114. /**
  139115. * The options of the Packer
  139116. */
  139117. options: ITexturePackerOptions;
  139118. /**
  139119. * The frame data of the Packer
  139120. */
  139121. frames: Array<number>;
  139122. }
  139123. /**
  139124. * This is a support class that generates a series of packed texture sets.
  139125. * @see https://doc.babylonjs.com/babylon101/materials
  139126. */
  139127. export class TexturePacker {
  139128. /** Packer Layout Constant 0 */
  139129. static readonly LAYOUT_STRIP: number;
  139130. /** Packer Layout Constant 1 */
  139131. static readonly LAYOUT_POWER2: number;
  139132. /** Packer Layout Constant 2 */
  139133. static readonly LAYOUT_COLNUM: number;
  139134. /** Packer Layout Constant 0 */
  139135. static readonly SUBUV_WRAP: number;
  139136. /** Packer Layout Constant 1 */
  139137. static readonly SUBUV_EXTEND: number;
  139138. /** Packer Layout Constant 2 */
  139139. static readonly SUBUV_COLOR: number;
  139140. /** The Name of the Texture Package */
  139141. name: string;
  139142. /** The scene scope of the TexturePacker */
  139143. scene: Scene;
  139144. /** The Meshes to target */
  139145. meshes: AbstractMesh[];
  139146. /** Arguments passed with the Constructor */
  139147. options: ITexturePackerOptions;
  139148. /** The promise that is started upon initialization */
  139149. promise: Nullable<Promise<TexturePacker | string>>;
  139150. /** The Container object for the channel sets that are generated */
  139151. sets: object;
  139152. /** The Container array for the frames that are generated */
  139153. frames: TexturePackerFrame[];
  139154. /** The expected number of textures the system is parsing. */
  139155. private _expecting;
  139156. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  139157. private _paddingValue;
  139158. /**
  139159. * Initializes a texture package series from an array of meshes or a single mesh.
  139160. * @param name The name of the package
  139161. * @param meshes The target meshes to compose the package from
  139162. * @param options The arguments that texture packer should follow while building.
  139163. * @param scene The scene which the textures are scoped to.
  139164. * @returns TexturePacker
  139165. */
  139166. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  139167. /**
  139168. * Starts the package process
  139169. * @param resolve The promises resolution function
  139170. * @returns TexturePacker
  139171. */
  139172. private _createFrames;
  139173. /**
  139174. * Calculates the Size of the Channel Sets
  139175. * @returns Vector2
  139176. */
  139177. private _calculateSize;
  139178. /**
  139179. * Calculates the UV data for the frames.
  139180. * @param baseSize the base frameSize
  139181. * @param padding the base frame padding
  139182. * @param dtSize size of the Dynamic Texture for that channel
  139183. * @param dtUnits is 1/dtSize
  139184. * @param update flag to update the input meshes
  139185. */
  139186. private _calculateMeshUVFrames;
  139187. /**
  139188. * Calculates the frames Offset.
  139189. * @param index of the frame
  139190. * @returns Vector2
  139191. */
  139192. private _getFrameOffset;
  139193. /**
  139194. * Updates a Mesh to the frame data
  139195. * @param mesh that is the target
  139196. * @param frameID or the frame index
  139197. */
  139198. private _updateMeshUV;
  139199. /**
  139200. * Updates a Meshes materials to use the texture packer channels
  139201. * @param m is the mesh to target
  139202. * @param force all channels on the packer to be set.
  139203. */
  139204. private _updateTextureReferences;
  139205. /**
  139206. * Public method to set a Mesh to a frame
  139207. * @param m that is the target
  139208. * @param frameID or the frame index
  139209. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  139210. */
  139211. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  139212. /**
  139213. * Starts the async promise to compile the texture packer.
  139214. * @returns Promise<void>
  139215. */
  139216. processAsync(): Promise<void>;
  139217. /**
  139218. * Disposes all textures associated with this packer
  139219. */
  139220. dispose(): void;
  139221. /**
  139222. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  139223. * @param imageType is the image type to use.
  139224. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  139225. */
  139226. download(imageType?: string, quality?: number): void;
  139227. /**
  139228. * Public method to load a texturePacker JSON file.
  139229. * @param data of the JSON file in string format.
  139230. */
  139231. updateFromJSON(data: string): void;
  139232. }
  139233. }
  139234. declare module BABYLON {
  139235. /**
  139236. * 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.
  139237. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  139238. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  139239. */
  139240. export class CustomProceduralTexture extends ProceduralTexture {
  139241. private _animate;
  139242. private _time;
  139243. private _config;
  139244. private _texturePath;
  139245. /**
  139246. * Instantiates a new Custom Procedural Texture.
  139247. * 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.
  139248. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  139249. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  139250. * @param name Define the name of the texture
  139251. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  139252. * @param size Define the size of the texture to create
  139253. * @param scene Define the scene the texture belongs to
  139254. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  139255. * @param generateMipMaps Define if the texture should creates mip maps or not
  139256. */
  139257. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  139258. private _loadJson;
  139259. /**
  139260. * Is the texture ready to be used ? (rendered at least once)
  139261. * @returns true if ready, otherwise, false.
  139262. */
  139263. isReady(): boolean;
  139264. /**
  139265. * Render the texture to its associated render target.
  139266. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  139267. */
  139268. render(useCameraPostProcess?: boolean): void;
  139269. /**
  139270. * Update the list of dependant textures samplers in the shader.
  139271. */
  139272. updateTextures(): void;
  139273. /**
  139274. * Update the uniform values of the procedural texture in the shader.
  139275. */
  139276. updateShaderUniforms(): void;
  139277. /**
  139278. * Define if the texture animates or not.
  139279. */
  139280. get animate(): boolean;
  139281. set animate(value: boolean);
  139282. }
  139283. }
  139284. declare module BABYLON {
  139285. /** @hidden */
  139286. export var noisePixelShader: {
  139287. name: string;
  139288. shader: string;
  139289. };
  139290. }
  139291. declare module BABYLON {
  139292. /**
  139293. * Class used to generate noise procedural textures
  139294. */
  139295. export class NoiseProceduralTexture extends ProceduralTexture {
  139296. private _time;
  139297. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  139298. brightness: number;
  139299. /** Defines the number of octaves to process */
  139300. octaves: number;
  139301. /** Defines the level of persistence (0.8 by default) */
  139302. persistence: number;
  139303. /** Gets or sets animation speed factor (default is 1) */
  139304. animationSpeedFactor: number;
  139305. /**
  139306. * Creates a new NoiseProceduralTexture
  139307. * @param name defines the name fo the texture
  139308. * @param size defines the size of the texture (default is 256)
  139309. * @param scene defines the hosting scene
  139310. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  139311. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  139312. */
  139313. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  139314. private _updateShaderUniforms;
  139315. protected _getDefines(): string;
  139316. /** Generate the current state of the procedural texture */
  139317. render(useCameraPostProcess?: boolean): void;
  139318. /**
  139319. * Serializes this noise procedural texture
  139320. * @returns a serialized noise procedural texture object
  139321. */
  139322. serialize(): any;
  139323. /**
  139324. * Clone the texture.
  139325. * @returns the cloned texture
  139326. */
  139327. clone(): NoiseProceduralTexture;
  139328. /**
  139329. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  139330. * @param parsedTexture defines parsed texture data
  139331. * @param scene defines the current scene
  139332. * @param rootUrl defines the root URL containing noise procedural texture information
  139333. * @returns a parsed NoiseProceduralTexture
  139334. */
  139335. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  139336. }
  139337. }
  139338. declare module BABYLON {
  139339. /**
  139340. * Raw cube texture where the raw buffers are passed in
  139341. */
  139342. export class RawCubeTexture extends CubeTexture {
  139343. /**
  139344. * Creates a cube texture where the raw buffers are passed in.
  139345. * @param scene defines the scene the texture is attached to
  139346. * @param data defines the array of data to use to create each face
  139347. * @param size defines the size of the textures
  139348. * @param format defines the format of the data
  139349. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  139350. * @param generateMipMaps defines if the engine should generate the mip levels
  139351. * @param invertY defines if data must be stored with Y axis inverted
  139352. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  139353. * @param compression defines the compression used (null by default)
  139354. */
  139355. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  139356. /**
  139357. * Updates the raw cube texture.
  139358. * @param data defines the data to store
  139359. * @param format defines the data format
  139360. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139361. * @param invertY defines if data must be stored with Y axis inverted
  139362. * @param compression defines the compression used (null by default)
  139363. * @param level defines which level of the texture to update
  139364. */
  139365. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  139366. /**
  139367. * Updates a raw cube texture with RGBD encoded data.
  139368. * @param data defines the array of data [mipmap][face] to use to create each face
  139369. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  139370. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  139371. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  139372. * @returns a promsie that resolves when the operation is complete
  139373. */
  139374. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  139375. /**
  139376. * Clones the raw cube texture.
  139377. * @return a new cube texture
  139378. */
  139379. clone(): CubeTexture;
  139380. /** @hidden */
  139381. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  139382. }
  139383. }
  139384. declare module BABYLON {
  139385. /**
  139386. * Class used to store 2D array textures containing user data
  139387. */
  139388. export class RawTexture2DArray extends Texture {
  139389. /** Gets or sets the texture format to use */
  139390. format: number;
  139391. /**
  139392. * Create a new RawTexture2DArray
  139393. * @param data defines the data of the texture
  139394. * @param width defines the width of the texture
  139395. * @param height defines the height of the texture
  139396. * @param depth defines the number of layers of the texture
  139397. * @param format defines the texture format to use
  139398. * @param scene defines the hosting scene
  139399. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  139400. * @param invertY defines if texture must be stored with Y axis inverted
  139401. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  139402. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  139403. */
  139404. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  139405. /** Gets or sets the texture format to use */
  139406. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  139407. /**
  139408. * Update the texture with new data
  139409. * @param data defines the data to store in the texture
  139410. */
  139411. update(data: ArrayBufferView): void;
  139412. }
  139413. }
  139414. declare module BABYLON {
  139415. /**
  139416. * Class used to store 3D textures containing user data
  139417. */
  139418. export class RawTexture3D extends Texture {
  139419. /** Gets or sets the texture format to use */
  139420. format: number;
  139421. /**
  139422. * Create a new RawTexture3D
  139423. * @param data defines the data of the texture
  139424. * @param width defines the width of the texture
  139425. * @param height defines the height of the texture
  139426. * @param depth defines the depth of the texture
  139427. * @param format defines the texture format to use
  139428. * @param scene defines the hosting scene
  139429. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  139430. * @param invertY defines if texture must be stored with Y axis inverted
  139431. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  139432. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  139433. */
  139434. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  139435. /** Gets or sets the texture format to use */
  139436. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  139437. /**
  139438. * Update the texture with new data
  139439. * @param data defines the data to store in the texture
  139440. */
  139441. update(data: ArrayBufferView): void;
  139442. }
  139443. }
  139444. declare module BABYLON {
  139445. /**
  139446. * Creates a refraction texture used by refraction channel of the standard material.
  139447. * It is like a mirror but to see through a material.
  139448. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139449. */
  139450. export class RefractionTexture extends RenderTargetTexture {
  139451. /**
  139452. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  139453. * 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.
  139454. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139455. */
  139456. refractionPlane: Plane;
  139457. /**
  139458. * Define how deep under the surface we should see.
  139459. */
  139460. depth: number;
  139461. /**
  139462. * Creates a refraction texture used by refraction channel of the standard material.
  139463. * It is like a mirror but to see through a material.
  139464. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139465. * @param name Define the texture name
  139466. * @param size Define the size of the underlying texture
  139467. * @param scene Define the scene the refraction belongs to
  139468. * @param generateMipMaps Define if we need to generate mips level for the refraction
  139469. */
  139470. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  139471. /**
  139472. * Clone the refraction texture.
  139473. * @returns the cloned texture
  139474. */
  139475. clone(): RefractionTexture;
  139476. /**
  139477. * Serialize the texture to a JSON representation you could use in Parse later on
  139478. * @returns the serialized JSON representation
  139479. */
  139480. serialize(): any;
  139481. }
  139482. }
  139483. declare module BABYLON {
  139484. /**
  139485. * Block used to add support for vertex skinning (bones)
  139486. */
  139487. export class BonesBlock extends NodeMaterialBlock {
  139488. /**
  139489. * Creates a new BonesBlock
  139490. * @param name defines the block name
  139491. */
  139492. constructor(name: string);
  139493. /**
  139494. * Initialize the block and prepare the context for build
  139495. * @param state defines the state that will be used for the build
  139496. */
  139497. initialize(state: NodeMaterialBuildState): void;
  139498. /**
  139499. * Gets the current class name
  139500. * @returns the class name
  139501. */
  139502. getClassName(): string;
  139503. /**
  139504. * Gets the matrix indices input component
  139505. */
  139506. get matricesIndices(): NodeMaterialConnectionPoint;
  139507. /**
  139508. * Gets the matrix weights input component
  139509. */
  139510. get matricesWeights(): NodeMaterialConnectionPoint;
  139511. /**
  139512. * Gets the extra matrix indices input component
  139513. */
  139514. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  139515. /**
  139516. * Gets the extra matrix weights input component
  139517. */
  139518. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  139519. /**
  139520. * Gets the world input component
  139521. */
  139522. get world(): NodeMaterialConnectionPoint;
  139523. /**
  139524. * Gets the output component
  139525. */
  139526. get output(): NodeMaterialConnectionPoint;
  139527. autoConfigure(material: NodeMaterial): void;
  139528. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  139529. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139530. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139531. protected _buildBlock(state: NodeMaterialBuildState): this;
  139532. }
  139533. }
  139534. declare module BABYLON {
  139535. /**
  139536. * Block used to add support for instances
  139537. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  139538. */
  139539. export class InstancesBlock extends NodeMaterialBlock {
  139540. /**
  139541. * Creates a new InstancesBlock
  139542. * @param name defines the block name
  139543. */
  139544. constructor(name: string);
  139545. /**
  139546. * Gets the current class name
  139547. * @returns the class name
  139548. */
  139549. getClassName(): string;
  139550. /**
  139551. * Gets the first world row input component
  139552. */
  139553. get world0(): NodeMaterialConnectionPoint;
  139554. /**
  139555. * Gets the second world row input component
  139556. */
  139557. get world1(): NodeMaterialConnectionPoint;
  139558. /**
  139559. * Gets the third world row input component
  139560. */
  139561. get world2(): NodeMaterialConnectionPoint;
  139562. /**
  139563. * Gets the forth world row input component
  139564. */
  139565. get world3(): NodeMaterialConnectionPoint;
  139566. /**
  139567. * Gets the world input component
  139568. */
  139569. get world(): NodeMaterialConnectionPoint;
  139570. /**
  139571. * Gets the output component
  139572. */
  139573. get output(): NodeMaterialConnectionPoint;
  139574. /**
  139575. * Gets the isntanceID component
  139576. */
  139577. get instanceID(): NodeMaterialConnectionPoint;
  139578. autoConfigure(material: NodeMaterial): void;
  139579. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  139580. protected _buildBlock(state: NodeMaterialBuildState): this;
  139581. }
  139582. }
  139583. declare module BABYLON {
  139584. /**
  139585. * Block used to add morph targets support to vertex shader
  139586. */
  139587. export class MorphTargetsBlock extends NodeMaterialBlock {
  139588. private _repeatableContentAnchor;
  139589. /**
  139590. * Create a new MorphTargetsBlock
  139591. * @param name defines the block name
  139592. */
  139593. constructor(name: string);
  139594. /**
  139595. * Gets the current class name
  139596. * @returns the class name
  139597. */
  139598. getClassName(): string;
  139599. /**
  139600. * Gets the position input component
  139601. */
  139602. get position(): NodeMaterialConnectionPoint;
  139603. /**
  139604. * Gets the normal input component
  139605. */
  139606. get normal(): NodeMaterialConnectionPoint;
  139607. /**
  139608. * Gets the tangent input component
  139609. */
  139610. get tangent(): NodeMaterialConnectionPoint;
  139611. /**
  139612. * Gets the tangent input component
  139613. */
  139614. get uv(): NodeMaterialConnectionPoint;
  139615. /**
  139616. * Gets the position output component
  139617. */
  139618. get positionOutput(): NodeMaterialConnectionPoint;
  139619. /**
  139620. * Gets the normal output component
  139621. */
  139622. get normalOutput(): NodeMaterialConnectionPoint;
  139623. /**
  139624. * Gets the tangent output component
  139625. */
  139626. get tangentOutput(): NodeMaterialConnectionPoint;
  139627. /**
  139628. * Gets the tangent output component
  139629. */
  139630. get uvOutput(): NodeMaterialConnectionPoint;
  139631. initialize(state: NodeMaterialBuildState): void;
  139632. autoConfigure(material: NodeMaterial): void;
  139633. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139634. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139635. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  139636. protected _buildBlock(state: NodeMaterialBuildState): this;
  139637. }
  139638. }
  139639. declare module BABYLON {
  139640. /**
  139641. * Block used to get data information from a light
  139642. */
  139643. export class LightInformationBlock extends NodeMaterialBlock {
  139644. private _lightDataUniformName;
  139645. private _lightColorUniformName;
  139646. private _lightTypeDefineName;
  139647. /**
  139648. * Gets or sets the light associated with this block
  139649. */
  139650. light: Nullable<Light>;
  139651. /**
  139652. * Creates a new LightInformationBlock
  139653. * @param name defines the block name
  139654. */
  139655. constructor(name: string);
  139656. /**
  139657. * Gets the current class name
  139658. * @returns the class name
  139659. */
  139660. getClassName(): string;
  139661. /**
  139662. * Gets the world position input component
  139663. */
  139664. get worldPosition(): NodeMaterialConnectionPoint;
  139665. /**
  139666. * Gets the direction output component
  139667. */
  139668. get direction(): NodeMaterialConnectionPoint;
  139669. /**
  139670. * Gets the direction output component
  139671. */
  139672. get color(): NodeMaterialConnectionPoint;
  139673. /**
  139674. * Gets the direction output component
  139675. */
  139676. get intensity(): NodeMaterialConnectionPoint;
  139677. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139678. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139679. protected _buildBlock(state: NodeMaterialBuildState): this;
  139680. serialize(): any;
  139681. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139682. }
  139683. }
  139684. declare module BABYLON {
  139685. /**
  139686. * Block used to add image processing support to fragment shader
  139687. */
  139688. export class ImageProcessingBlock extends NodeMaterialBlock {
  139689. /**
  139690. * Create a new ImageProcessingBlock
  139691. * @param name defines the block name
  139692. */
  139693. constructor(name: string);
  139694. /**
  139695. * Gets the current class name
  139696. * @returns the class name
  139697. */
  139698. getClassName(): string;
  139699. /**
  139700. * Gets the color input component
  139701. */
  139702. get color(): NodeMaterialConnectionPoint;
  139703. /**
  139704. * Gets the output component
  139705. */
  139706. get output(): NodeMaterialConnectionPoint;
  139707. /**
  139708. * Initialize the block and prepare the context for build
  139709. * @param state defines the state that will be used for the build
  139710. */
  139711. initialize(state: NodeMaterialBuildState): void;
  139712. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  139713. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139714. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139715. protected _buildBlock(state: NodeMaterialBuildState): this;
  139716. }
  139717. }
  139718. declare module BABYLON {
  139719. /**
  139720. * Block used to pertub normals based on a normal map
  139721. */
  139722. export class PerturbNormalBlock extends NodeMaterialBlock {
  139723. private _tangentSpaceParameterName;
  139724. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139725. invertX: boolean;
  139726. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  139727. invertY: boolean;
  139728. /**
  139729. * Create a new PerturbNormalBlock
  139730. * @param name defines the block name
  139731. */
  139732. constructor(name: string);
  139733. /**
  139734. * Gets the current class name
  139735. * @returns the class name
  139736. */
  139737. getClassName(): string;
  139738. /**
  139739. * Gets the world position input component
  139740. */
  139741. get worldPosition(): NodeMaterialConnectionPoint;
  139742. /**
  139743. * Gets the world normal input component
  139744. */
  139745. get worldNormal(): NodeMaterialConnectionPoint;
  139746. /**
  139747. * Gets the world tangent input component
  139748. */
  139749. get worldTangent(): NodeMaterialConnectionPoint;
  139750. /**
  139751. * Gets the uv input component
  139752. */
  139753. get uv(): NodeMaterialConnectionPoint;
  139754. /**
  139755. * Gets the normal map color input component
  139756. */
  139757. get normalMapColor(): NodeMaterialConnectionPoint;
  139758. /**
  139759. * Gets the strength input component
  139760. */
  139761. get strength(): NodeMaterialConnectionPoint;
  139762. /**
  139763. * Gets the output component
  139764. */
  139765. get output(): NodeMaterialConnectionPoint;
  139766. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139767. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139768. autoConfigure(material: NodeMaterial): void;
  139769. protected _buildBlock(state: NodeMaterialBuildState): this;
  139770. protected _dumpPropertiesCode(): string;
  139771. serialize(): any;
  139772. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139773. }
  139774. }
  139775. declare module BABYLON {
  139776. /**
  139777. * Block used to discard a pixel if a value is smaller than a cutoff
  139778. */
  139779. export class DiscardBlock extends NodeMaterialBlock {
  139780. /**
  139781. * Create a new DiscardBlock
  139782. * @param name defines the block name
  139783. */
  139784. constructor(name: string);
  139785. /**
  139786. * Gets the current class name
  139787. * @returns the class name
  139788. */
  139789. getClassName(): string;
  139790. /**
  139791. * Gets the color input component
  139792. */
  139793. get value(): NodeMaterialConnectionPoint;
  139794. /**
  139795. * Gets the cutoff input component
  139796. */
  139797. get cutoff(): NodeMaterialConnectionPoint;
  139798. protected _buildBlock(state: NodeMaterialBuildState): this;
  139799. }
  139800. }
  139801. declare module BABYLON {
  139802. /**
  139803. * Block used to test if the fragment shader is front facing
  139804. */
  139805. export class FrontFacingBlock extends NodeMaterialBlock {
  139806. /**
  139807. * Creates a new FrontFacingBlock
  139808. * @param name defines the block name
  139809. */
  139810. constructor(name: string);
  139811. /**
  139812. * Gets the current class name
  139813. * @returns the class name
  139814. */
  139815. getClassName(): string;
  139816. /**
  139817. * Gets the output component
  139818. */
  139819. get output(): NodeMaterialConnectionPoint;
  139820. protected _buildBlock(state: NodeMaterialBuildState): this;
  139821. }
  139822. }
  139823. declare module BABYLON {
  139824. /**
  139825. * Block used to get the derivative value on x and y of a given input
  139826. */
  139827. export class DerivativeBlock extends NodeMaterialBlock {
  139828. /**
  139829. * Create a new DerivativeBlock
  139830. * @param name defines the block name
  139831. */
  139832. constructor(name: string);
  139833. /**
  139834. * Gets the current class name
  139835. * @returns the class name
  139836. */
  139837. getClassName(): string;
  139838. /**
  139839. * Gets the input component
  139840. */
  139841. get input(): NodeMaterialConnectionPoint;
  139842. /**
  139843. * Gets the derivative output on x
  139844. */
  139845. get dx(): NodeMaterialConnectionPoint;
  139846. /**
  139847. * Gets the derivative output on y
  139848. */
  139849. get dy(): NodeMaterialConnectionPoint;
  139850. protected _buildBlock(state: NodeMaterialBuildState): this;
  139851. }
  139852. }
  139853. declare module BABYLON {
  139854. /**
  139855. * Block used to make gl_FragCoord available
  139856. */
  139857. export class FragCoordBlock extends NodeMaterialBlock {
  139858. /**
  139859. * Creates a new FragCoordBlock
  139860. * @param name defines the block name
  139861. */
  139862. constructor(name: string);
  139863. /**
  139864. * Gets the current class name
  139865. * @returns the class name
  139866. */
  139867. getClassName(): string;
  139868. /**
  139869. * Gets the xy component
  139870. */
  139871. get xy(): NodeMaterialConnectionPoint;
  139872. /**
  139873. * Gets the xyz component
  139874. */
  139875. get xyz(): NodeMaterialConnectionPoint;
  139876. /**
  139877. * Gets the xyzw component
  139878. */
  139879. get xyzw(): NodeMaterialConnectionPoint;
  139880. /**
  139881. * Gets the x component
  139882. */
  139883. get x(): NodeMaterialConnectionPoint;
  139884. /**
  139885. * Gets the y component
  139886. */
  139887. get y(): NodeMaterialConnectionPoint;
  139888. /**
  139889. * Gets the z component
  139890. */
  139891. get z(): NodeMaterialConnectionPoint;
  139892. /**
  139893. * Gets the w component
  139894. */
  139895. get output(): NodeMaterialConnectionPoint;
  139896. protected writeOutputs(state: NodeMaterialBuildState): string;
  139897. protected _buildBlock(state: NodeMaterialBuildState): this;
  139898. }
  139899. }
  139900. declare module BABYLON {
  139901. /**
  139902. * Block used to get the screen sizes
  139903. */
  139904. export class ScreenSizeBlock extends NodeMaterialBlock {
  139905. private _varName;
  139906. private _scene;
  139907. /**
  139908. * Creates a new ScreenSizeBlock
  139909. * @param name defines the block name
  139910. */
  139911. constructor(name: string);
  139912. /**
  139913. * Gets the current class name
  139914. * @returns the class name
  139915. */
  139916. getClassName(): string;
  139917. /**
  139918. * Gets the xy component
  139919. */
  139920. get xy(): NodeMaterialConnectionPoint;
  139921. /**
  139922. * Gets the x component
  139923. */
  139924. get x(): NodeMaterialConnectionPoint;
  139925. /**
  139926. * Gets the y component
  139927. */
  139928. get y(): NodeMaterialConnectionPoint;
  139929. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139930. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  139931. protected _buildBlock(state: NodeMaterialBuildState): this;
  139932. }
  139933. }
  139934. declare module BABYLON {
  139935. /**
  139936. * Block used to add support for scene fog
  139937. */
  139938. export class FogBlock extends NodeMaterialBlock {
  139939. private _fogDistanceName;
  139940. private _fogParameters;
  139941. /**
  139942. * Create a new FogBlock
  139943. * @param name defines the block name
  139944. */
  139945. constructor(name: string);
  139946. /**
  139947. * Gets the current class name
  139948. * @returns the class name
  139949. */
  139950. getClassName(): string;
  139951. /**
  139952. * Gets the world position input component
  139953. */
  139954. get worldPosition(): NodeMaterialConnectionPoint;
  139955. /**
  139956. * Gets the view input component
  139957. */
  139958. get view(): NodeMaterialConnectionPoint;
  139959. /**
  139960. * Gets the color input component
  139961. */
  139962. get input(): NodeMaterialConnectionPoint;
  139963. /**
  139964. * Gets the fog color input component
  139965. */
  139966. get fogColor(): NodeMaterialConnectionPoint;
  139967. /**
  139968. * Gets the output component
  139969. */
  139970. get output(): NodeMaterialConnectionPoint;
  139971. autoConfigure(material: NodeMaterial): void;
  139972. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139973. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139974. protected _buildBlock(state: NodeMaterialBuildState): this;
  139975. }
  139976. }
  139977. declare module BABYLON {
  139978. /**
  139979. * Block used to add light in the fragment shader
  139980. */
  139981. export class LightBlock extends NodeMaterialBlock {
  139982. private _lightId;
  139983. /**
  139984. * Gets or sets the light associated with this block
  139985. */
  139986. light: Nullable<Light>;
  139987. /**
  139988. * Create a new LightBlock
  139989. * @param name defines the block name
  139990. */
  139991. constructor(name: string);
  139992. /**
  139993. * Gets the current class name
  139994. * @returns the class name
  139995. */
  139996. getClassName(): string;
  139997. /**
  139998. * Gets the world position input component
  139999. */
  140000. get worldPosition(): NodeMaterialConnectionPoint;
  140001. /**
  140002. * Gets the world normal input component
  140003. */
  140004. get worldNormal(): NodeMaterialConnectionPoint;
  140005. /**
  140006. * Gets the camera (or eye) position component
  140007. */
  140008. get cameraPosition(): NodeMaterialConnectionPoint;
  140009. /**
  140010. * Gets the glossiness component
  140011. */
  140012. get glossiness(): NodeMaterialConnectionPoint;
  140013. /**
  140014. * Gets the glossinness power component
  140015. */
  140016. get glossPower(): NodeMaterialConnectionPoint;
  140017. /**
  140018. * Gets the diffuse color component
  140019. */
  140020. get diffuseColor(): NodeMaterialConnectionPoint;
  140021. /**
  140022. * Gets the specular color component
  140023. */
  140024. get specularColor(): NodeMaterialConnectionPoint;
  140025. /**
  140026. * Gets the diffuse output component
  140027. */
  140028. get diffuseOutput(): NodeMaterialConnectionPoint;
  140029. /**
  140030. * Gets the specular output component
  140031. */
  140032. get specularOutput(): NodeMaterialConnectionPoint;
  140033. /**
  140034. * Gets the shadow output component
  140035. */
  140036. get shadow(): NodeMaterialConnectionPoint;
  140037. autoConfigure(material: NodeMaterial): void;
  140038. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140039. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  140040. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140041. private _injectVertexCode;
  140042. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140043. serialize(): any;
  140044. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140045. }
  140046. }
  140047. declare module BABYLON {
  140048. /**
  140049. * Block used to read a reflection texture from a sampler
  140050. */
  140051. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  140052. /**
  140053. * Create a new ReflectionTextureBlock
  140054. * @param name defines the block name
  140055. */
  140056. constructor(name: string);
  140057. /**
  140058. * Gets the current class name
  140059. * @returns the class name
  140060. */
  140061. getClassName(): string;
  140062. /**
  140063. * Gets the world position input component
  140064. */
  140065. get position(): NodeMaterialConnectionPoint;
  140066. /**
  140067. * Gets the world position input component
  140068. */
  140069. get worldPosition(): NodeMaterialConnectionPoint;
  140070. /**
  140071. * Gets the world normal input component
  140072. */
  140073. get worldNormal(): NodeMaterialConnectionPoint;
  140074. /**
  140075. * Gets the world input component
  140076. */
  140077. get world(): NodeMaterialConnectionPoint;
  140078. /**
  140079. * Gets the camera (or eye) position component
  140080. */
  140081. get cameraPosition(): NodeMaterialConnectionPoint;
  140082. /**
  140083. * Gets the view input component
  140084. */
  140085. get view(): NodeMaterialConnectionPoint;
  140086. /**
  140087. * Gets the rgb output component
  140088. */
  140089. get rgb(): NodeMaterialConnectionPoint;
  140090. /**
  140091. * Gets the rgba output component
  140092. */
  140093. get rgba(): NodeMaterialConnectionPoint;
  140094. /**
  140095. * Gets the r output component
  140096. */
  140097. get r(): NodeMaterialConnectionPoint;
  140098. /**
  140099. * Gets the g output component
  140100. */
  140101. get g(): NodeMaterialConnectionPoint;
  140102. /**
  140103. * Gets the b output component
  140104. */
  140105. get b(): NodeMaterialConnectionPoint;
  140106. /**
  140107. * Gets the a output component
  140108. */
  140109. get a(): NodeMaterialConnectionPoint;
  140110. autoConfigure(material: NodeMaterial): void;
  140111. protected _buildBlock(state: NodeMaterialBuildState): this;
  140112. }
  140113. }
  140114. declare module BABYLON {
  140115. /**
  140116. * Block used to add 2 vectors
  140117. */
  140118. export class AddBlock extends NodeMaterialBlock {
  140119. /**
  140120. * Creates a new AddBlock
  140121. * @param name defines the block name
  140122. */
  140123. constructor(name: string);
  140124. /**
  140125. * Gets the current class name
  140126. * @returns the class name
  140127. */
  140128. getClassName(): string;
  140129. /**
  140130. * Gets the left operand input component
  140131. */
  140132. get left(): NodeMaterialConnectionPoint;
  140133. /**
  140134. * Gets the right operand input component
  140135. */
  140136. get right(): NodeMaterialConnectionPoint;
  140137. /**
  140138. * Gets the output component
  140139. */
  140140. get output(): NodeMaterialConnectionPoint;
  140141. protected _buildBlock(state: NodeMaterialBuildState): this;
  140142. }
  140143. }
  140144. declare module BABYLON {
  140145. /**
  140146. * Block used to scale a vector by a float
  140147. */
  140148. export class ScaleBlock extends NodeMaterialBlock {
  140149. /**
  140150. * Creates a new ScaleBlock
  140151. * @param name defines the block name
  140152. */
  140153. constructor(name: string);
  140154. /**
  140155. * Gets the current class name
  140156. * @returns the class name
  140157. */
  140158. getClassName(): string;
  140159. /**
  140160. * Gets the input component
  140161. */
  140162. get input(): NodeMaterialConnectionPoint;
  140163. /**
  140164. * Gets the factor input component
  140165. */
  140166. get factor(): NodeMaterialConnectionPoint;
  140167. /**
  140168. * Gets the output component
  140169. */
  140170. get output(): NodeMaterialConnectionPoint;
  140171. protected _buildBlock(state: NodeMaterialBuildState): this;
  140172. }
  140173. }
  140174. declare module BABYLON {
  140175. /**
  140176. * Block used to clamp a float
  140177. */
  140178. export class ClampBlock extends NodeMaterialBlock {
  140179. /** Gets or sets the minimum range */
  140180. minimum: number;
  140181. /** Gets or sets the maximum range */
  140182. maximum: number;
  140183. /**
  140184. * Creates a new ClampBlock
  140185. * @param name defines the block name
  140186. */
  140187. constructor(name: string);
  140188. /**
  140189. * Gets the current class name
  140190. * @returns the class name
  140191. */
  140192. getClassName(): string;
  140193. /**
  140194. * Gets the value input component
  140195. */
  140196. get value(): NodeMaterialConnectionPoint;
  140197. /**
  140198. * Gets the output component
  140199. */
  140200. get output(): NodeMaterialConnectionPoint;
  140201. protected _buildBlock(state: NodeMaterialBuildState): this;
  140202. protected _dumpPropertiesCode(): string;
  140203. serialize(): any;
  140204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140205. }
  140206. }
  140207. declare module BABYLON {
  140208. /**
  140209. * Block used to apply a cross product between 2 vectors
  140210. */
  140211. export class CrossBlock extends NodeMaterialBlock {
  140212. /**
  140213. * Creates a new CrossBlock
  140214. * @param name defines the block name
  140215. */
  140216. constructor(name: string);
  140217. /**
  140218. * Gets the current class name
  140219. * @returns the class name
  140220. */
  140221. getClassName(): string;
  140222. /**
  140223. * Gets the left operand input component
  140224. */
  140225. get left(): NodeMaterialConnectionPoint;
  140226. /**
  140227. * Gets the right operand input component
  140228. */
  140229. get right(): NodeMaterialConnectionPoint;
  140230. /**
  140231. * Gets the output component
  140232. */
  140233. get output(): NodeMaterialConnectionPoint;
  140234. protected _buildBlock(state: NodeMaterialBuildState): this;
  140235. }
  140236. }
  140237. declare module BABYLON {
  140238. /**
  140239. * Block used to apply a dot product between 2 vectors
  140240. */
  140241. export class DotBlock extends NodeMaterialBlock {
  140242. /**
  140243. * Creates a new DotBlock
  140244. * @param name defines the block name
  140245. */
  140246. constructor(name: string);
  140247. /**
  140248. * Gets the current class name
  140249. * @returns the class name
  140250. */
  140251. getClassName(): string;
  140252. /**
  140253. * Gets the left operand input component
  140254. */
  140255. get left(): NodeMaterialConnectionPoint;
  140256. /**
  140257. * Gets the right operand input component
  140258. */
  140259. get right(): NodeMaterialConnectionPoint;
  140260. /**
  140261. * Gets the output component
  140262. */
  140263. get output(): NodeMaterialConnectionPoint;
  140264. protected _buildBlock(state: NodeMaterialBuildState): this;
  140265. }
  140266. }
  140267. declare module BABYLON {
  140268. /**
  140269. * Block used to normalize a vector
  140270. */
  140271. export class NormalizeBlock extends NodeMaterialBlock {
  140272. /**
  140273. * Creates a new NormalizeBlock
  140274. * @param name defines the block name
  140275. */
  140276. constructor(name: string);
  140277. /**
  140278. * Gets the current class name
  140279. * @returns the class name
  140280. */
  140281. getClassName(): string;
  140282. /**
  140283. * Gets the input component
  140284. */
  140285. get input(): NodeMaterialConnectionPoint;
  140286. /**
  140287. * Gets the output component
  140288. */
  140289. get output(): NodeMaterialConnectionPoint;
  140290. protected _buildBlock(state: NodeMaterialBuildState): this;
  140291. }
  140292. }
  140293. declare module BABYLON {
  140294. /**
  140295. * Operations supported by the Trigonometry block
  140296. */
  140297. export enum TrigonometryBlockOperations {
  140298. /** Cos */
  140299. Cos = 0,
  140300. /** Sin */
  140301. Sin = 1,
  140302. /** Abs */
  140303. Abs = 2,
  140304. /** Exp */
  140305. Exp = 3,
  140306. /** Exp2 */
  140307. Exp2 = 4,
  140308. /** Round */
  140309. Round = 5,
  140310. /** Floor */
  140311. Floor = 6,
  140312. /** Ceiling */
  140313. Ceiling = 7,
  140314. /** Square root */
  140315. Sqrt = 8,
  140316. /** Log */
  140317. Log = 9,
  140318. /** Tangent */
  140319. Tan = 10,
  140320. /** Arc tangent */
  140321. ArcTan = 11,
  140322. /** Arc cosinus */
  140323. ArcCos = 12,
  140324. /** Arc sinus */
  140325. ArcSin = 13,
  140326. /** Fraction */
  140327. Fract = 14,
  140328. /** Sign */
  140329. Sign = 15,
  140330. /** To radians (from degrees) */
  140331. Radians = 16,
  140332. /** To degrees (from radians) */
  140333. Degrees = 17
  140334. }
  140335. /**
  140336. * Block used to apply trigonometry operation to floats
  140337. */
  140338. export class TrigonometryBlock extends NodeMaterialBlock {
  140339. /**
  140340. * Gets or sets the operation applied by the block
  140341. */
  140342. operation: TrigonometryBlockOperations;
  140343. /**
  140344. * Creates a new TrigonometryBlock
  140345. * @param name defines the block name
  140346. */
  140347. constructor(name: string);
  140348. /**
  140349. * Gets the current class name
  140350. * @returns the class name
  140351. */
  140352. getClassName(): string;
  140353. /**
  140354. * Gets the input component
  140355. */
  140356. get input(): NodeMaterialConnectionPoint;
  140357. /**
  140358. * Gets the output component
  140359. */
  140360. get output(): NodeMaterialConnectionPoint;
  140361. protected _buildBlock(state: NodeMaterialBuildState): this;
  140362. serialize(): any;
  140363. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140364. protected _dumpPropertiesCode(): string;
  140365. }
  140366. }
  140367. declare module BABYLON {
  140368. /**
  140369. * Block used to create a Color3/4 out of individual inputs (one for each component)
  140370. */
  140371. export class ColorMergerBlock extends NodeMaterialBlock {
  140372. /**
  140373. * Create a new ColorMergerBlock
  140374. * @param name defines the block name
  140375. */
  140376. constructor(name: string);
  140377. /**
  140378. * Gets the current class name
  140379. * @returns the class name
  140380. */
  140381. getClassName(): string;
  140382. /**
  140383. * Gets the rgb component (input)
  140384. */
  140385. get rgbIn(): NodeMaterialConnectionPoint;
  140386. /**
  140387. * Gets the r component (input)
  140388. */
  140389. get r(): NodeMaterialConnectionPoint;
  140390. /**
  140391. * Gets the g component (input)
  140392. */
  140393. get g(): NodeMaterialConnectionPoint;
  140394. /**
  140395. * Gets the b component (input)
  140396. */
  140397. get b(): NodeMaterialConnectionPoint;
  140398. /**
  140399. * Gets the a component (input)
  140400. */
  140401. get a(): NodeMaterialConnectionPoint;
  140402. /**
  140403. * Gets the rgba component (output)
  140404. */
  140405. get rgba(): NodeMaterialConnectionPoint;
  140406. /**
  140407. * Gets the rgb component (output)
  140408. */
  140409. get rgbOut(): NodeMaterialConnectionPoint;
  140410. /**
  140411. * Gets the rgb component (output)
  140412. * @deprecated Please use rgbOut instead.
  140413. */
  140414. get rgb(): NodeMaterialConnectionPoint;
  140415. protected _buildBlock(state: NodeMaterialBuildState): this;
  140416. }
  140417. }
  140418. declare module BABYLON {
  140419. /**
  140420. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  140421. */
  140422. export class VectorSplitterBlock extends NodeMaterialBlock {
  140423. /**
  140424. * Create a new VectorSplitterBlock
  140425. * @param name defines the block name
  140426. */
  140427. constructor(name: string);
  140428. /**
  140429. * Gets the current class name
  140430. * @returns the class name
  140431. */
  140432. getClassName(): string;
  140433. /**
  140434. * Gets the xyzw component (input)
  140435. */
  140436. get xyzw(): NodeMaterialConnectionPoint;
  140437. /**
  140438. * Gets the xyz component (input)
  140439. */
  140440. get xyzIn(): NodeMaterialConnectionPoint;
  140441. /**
  140442. * Gets the xy component (input)
  140443. */
  140444. get xyIn(): NodeMaterialConnectionPoint;
  140445. /**
  140446. * Gets the xyz component (output)
  140447. */
  140448. get xyzOut(): NodeMaterialConnectionPoint;
  140449. /**
  140450. * Gets the xy component (output)
  140451. */
  140452. get xyOut(): NodeMaterialConnectionPoint;
  140453. /**
  140454. * Gets the x component (output)
  140455. */
  140456. get x(): NodeMaterialConnectionPoint;
  140457. /**
  140458. * Gets the y component (output)
  140459. */
  140460. get y(): NodeMaterialConnectionPoint;
  140461. /**
  140462. * Gets the z component (output)
  140463. */
  140464. get z(): NodeMaterialConnectionPoint;
  140465. /**
  140466. * Gets the w component (output)
  140467. */
  140468. get w(): NodeMaterialConnectionPoint;
  140469. protected _inputRename(name: string): string;
  140470. protected _outputRename(name: string): string;
  140471. protected _buildBlock(state: NodeMaterialBuildState): this;
  140472. }
  140473. }
  140474. declare module BABYLON {
  140475. /**
  140476. * Block used to lerp between 2 values
  140477. */
  140478. export class LerpBlock extends NodeMaterialBlock {
  140479. /**
  140480. * Creates a new LerpBlock
  140481. * @param name defines the block name
  140482. */
  140483. constructor(name: string);
  140484. /**
  140485. * Gets the current class name
  140486. * @returns the class name
  140487. */
  140488. getClassName(): string;
  140489. /**
  140490. * Gets the left operand input component
  140491. */
  140492. get left(): NodeMaterialConnectionPoint;
  140493. /**
  140494. * Gets the right operand input component
  140495. */
  140496. get right(): NodeMaterialConnectionPoint;
  140497. /**
  140498. * Gets the gradient operand input component
  140499. */
  140500. get gradient(): NodeMaterialConnectionPoint;
  140501. /**
  140502. * Gets the output component
  140503. */
  140504. get output(): NodeMaterialConnectionPoint;
  140505. protected _buildBlock(state: NodeMaterialBuildState): this;
  140506. }
  140507. }
  140508. declare module BABYLON {
  140509. /**
  140510. * Block used to divide 2 vectors
  140511. */
  140512. export class DivideBlock extends NodeMaterialBlock {
  140513. /**
  140514. * Creates a new DivideBlock
  140515. * @param name defines the block name
  140516. */
  140517. constructor(name: string);
  140518. /**
  140519. * Gets the current class name
  140520. * @returns the class name
  140521. */
  140522. getClassName(): string;
  140523. /**
  140524. * Gets the left operand input component
  140525. */
  140526. get left(): NodeMaterialConnectionPoint;
  140527. /**
  140528. * Gets the right operand input component
  140529. */
  140530. get right(): NodeMaterialConnectionPoint;
  140531. /**
  140532. * Gets the output component
  140533. */
  140534. get output(): NodeMaterialConnectionPoint;
  140535. protected _buildBlock(state: NodeMaterialBuildState): this;
  140536. }
  140537. }
  140538. declare module BABYLON {
  140539. /**
  140540. * Block used to subtract 2 vectors
  140541. */
  140542. export class SubtractBlock extends NodeMaterialBlock {
  140543. /**
  140544. * Creates a new SubtractBlock
  140545. * @param name defines the block name
  140546. */
  140547. constructor(name: string);
  140548. /**
  140549. * Gets the current class name
  140550. * @returns the class name
  140551. */
  140552. getClassName(): string;
  140553. /**
  140554. * Gets the left operand input component
  140555. */
  140556. get left(): NodeMaterialConnectionPoint;
  140557. /**
  140558. * Gets the right operand input component
  140559. */
  140560. get right(): NodeMaterialConnectionPoint;
  140561. /**
  140562. * Gets the output component
  140563. */
  140564. get output(): NodeMaterialConnectionPoint;
  140565. protected _buildBlock(state: NodeMaterialBuildState): this;
  140566. }
  140567. }
  140568. declare module BABYLON {
  140569. /**
  140570. * Block used to step a value
  140571. */
  140572. export class StepBlock extends NodeMaterialBlock {
  140573. /**
  140574. * Creates a new StepBlock
  140575. * @param name defines the block name
  140576. */
  140577. constructor(name: string);
  140578. /**
  140579. * Gets the current class name
  140580. * @returns the class name
  140581. */
  140582. getClassName(): string;
  140583. /**
  140584. * Gets the value operand input component
  140585. */
  140586. get value(): NodeMaterialConnectionPoint;
  140587. /**
  140588. * Gets the edge operand input component
  140589. */
  140590. get edge(): NodeMaterialConnectionPoint;
  140591. /**
  140592. * Gets the output component
  140593. */
  140594. get output(): NodeMaterialConnectionPoint;
  140595. protected _buildBlock(state: NodeMaterialBuildState): this;
  140596. }
  140597. }
  140598. declare module BABYLON {
  140599. /**
  140600. * Block used to get the opposite (1 - x) of a value
  140601. */
  140602. export class OneMinusBlock extends NodeMaterialBlock {
  140603. /**
  140604. * Creates a new OneMinusBlock
  140605. * @param name defines the block name
  140606. */
  140607. constructor(name: string);
  140608. /**
  140609. * Gets the current class name
  140610. * @returns the class name
  140611. */
  140612. getClassName(): string;
  140613. /**
  140614. * Gets the input component
  140615. */
  140616. get input(): NodeMaterialConnectionPoint;
  140617. /**
  140618. * Gets the output component
  140619. */
  140620. get output(): NodeMaterialConnectionPoint;
  140621. protected _buildBlock(state: NodeMaterialBuildState): this;
  140622. }
  140623. }
  140624. declare module BABYLON {
  140625. /**
  140626. * Block used to get the view direction
  140627. */
  140628. export class ViewDirectionBlock extends NodeMaterialBlock {
  140629. /**
  140630. * Creates a new ViewDirectionBlock
  140631. * @param name defines the block name
  140632. */
  140633. constructor(name: string);
  140634. /**
  140635. * Gets the current class name
  140636. * @returns the class name
  140637. */
  140638. getClassName(): string;
  140639. /**
  140640. * Gets the world position component
  140641. */
  140642. get worldPosition(): NodeMaterialConnectionPoint;
  140643. /**
  140644. * Gets the camera position component
  140645. */
  140646. get cameraPosition(): NodeMaterialConnectionPoint;
  140647. /**
  140648. * Gets the output component
  140649. */
  140650. get output(): NodeMaterialConnectionPoint;
  140651. autoConfigure(material: NodeMaterial): void;
  140652. protected _buildBlock(state: NodeMaterialBuildState): this;
  140653. }
  140654. }
  140655. declare module BABYLON {
  140656. /**
  140657. * Block used to compute fresnel value
  140658. */
  140659. export class FresnelBlock extends NodeMaterialBlock {
  140660. /**
  140661. * Create a new FresnelBlock
  140662. * @param name defines the block name
  140663. */
  140664. constructor(name: string);
  140665. /**
  140666. * Gets the current class name
  140667. * @returns the class name
  140668. */
  140669. getClassName(): string;
  140670. /**
  140671. * Gets the world normal input component
  140672. */
  140673. get worldNormal(): NodeMaterialConnectionPoint;
  140674. /**
  140675. * Gets the view direction input component
  140676. */
  140677. get viewDirection(): NodeMaterialConnectionPoint;
  140678. /**
  140679. * Gets the bias input component
  140680. */
  140681. get bias(): NodeMaterialConnectionPoint;
  140682. /**
  140683. * Gets the camera (or eye) position component
  140684. */
  140685. get power(): NodeMaterialConnectionPoint;
  140686. /**
  140687. * Gets the fresnel output component
  140688. */
  140689. get fresnel(): NodeMaterialConnectionPoint;
  140690. autoConfigure(material: NodeMaterial): void;
  140691. protected _buildBlock(state: NodeMaterialBuildState): this;
  140692. }
  140693. }
  140694. declare module BABYLON {
  140695. /**
  140696. * Block used to get the max of 2 values
  140697. */
  140698. export class MaxBlock extends NodeMaterialBlock {
  140699. /**
  140700. * Creates a new MaxBlock
  140701. * @param name defines the block name
  140702. */
  140703. constructor(name: string);
  140704. /**
  140705. * Gets the current class name
  140706. * @returns the class name
  140707. */
  140708. getClassName(): string;
  140709. /**
  140710. * Gets the left operand input component
  140711. */
  140712. get left(): NodeMaterialConnectionPoint;
  140713. /**
  140714. * Gets the right operand input component
  140715. */
  140716. get right(): NodeMaterialConnectionPoint;
  140717. /**
  140718. * Gets the output component
  140719. */
  140720. get output(): NodeMaterialConnectionPoint;
  140721. protected _buildBlock(state: NodeMaterialBuildState): this;
  140722. }
  140723. }
  140724. declare module BABYLON {
  140725. /**
  140726. * Block used to get the min of 2 values
  140727. */
  140728. export class MinBlock extends NodeMaterialBlock {
  140729. /**
  140730. * Creates a new MinBlock
  140731. * @param name defines the block name
  140732. */
  140733. constructor(name: string);
  140734. /**
  140735. * Gets the current class name
  140736. * @returns the class name
  140737. */
  140738. getClassName(): string;
  140739. /**
  140740. * Gets the left operand input component
  140741. */
  140742. get left(): NodeMaterialConnectionPoint;
  140743. /**
  140744. * Gets the right operand input component
  140745. */
  140746. get right(): NodeMaterialConnectionPoint;
  140747. /**
  140748. * Gets the output component
  140749. */
  140750. get output(): NodeMaterialConnectionPoint;
  140751. protected _buildBlock(state: NodeMaterialBuildState): this;
  140752. }
  140753. }
  140754. declare module BABYLON {
  140755. /**
  140756. * Block used to get the distance between 2 values
  140757. */
  140758. export class DistanceBlock extends NodeMaterialBlock {
  140759. /**
  140760. * Creates a new DistanceBlock
  140761. * @param name defines the block name
  140762. */
  140763. constructor(name: string);
  140764. /**
  140765. * Gets the current class name
  140766. * @returns the class name
  140767. */
  140768. getClassName(): string;
  140769. /**
  140770. * Gets the left operand input component
  140771. */
  140772. get left(): NodeMaterialConnectionPoint;
  140773. /**
  140774. * Gets the right operand input component
  140775. */
  140776. get right(): NodeMaterialConnectionPoint;
  140777. /**
  140778. * Gets the output component
  140779. */
  140780. get output(): NodeMaterialConnectionPoint;
  140781. protected _buildBlock(state: NodeMaterialBuildState): this;
  140782. }
  140783. }
  140784. declare module BABYLON {
  140785. /**
  140786. * Block used to get the length of a vector
  140787. */
  140788. export class LengthBlock extends NodeMaterialBlock {
  140789. /**
  140790. * Creates a new LengthBlock
  140791. * @param name defines the block name
  140792. */
  140793. constructor(name: string);
  140794. /**
  140795. * Gets the current class name
  140796. * @returns the class name
  140797. */
  140798. getClassName(): string;
  140799. /**
  140800. * Gets the value input component
  140801. */
  140802. get value(): NodeMaterialConnectionPoint;
  140803. /**
  140804. * Gets the output component
  140805. */
  140806. get output(): NodeMaterialConnectionPoint;
  140807. protected _buildBlock(state: NodeMaterialBuildState): this;
  140808. }
  140809. }
  140810. declare module BABYLON {
  140811. /**
  140812. * Block used to get negative version of a value (i.e. x * -1)
  140813. */
  140814. export class NegateBlock extends NodeMaterialBlock {
  140815. /**
  140816. * Creates a new NegateBlock
  140817. * @param name defines the block name
  140818. */
  140819. constructor(name: string);
  140820. /**
  140821. * Gets the current class name
  140822. * @returns the class name
  140823. */
  140824. getClassName(): string;
  140825. /**
  140826. * Gets the value input component
  140827. */
  140828. get value(): NodeMaterialConnectionPoint;
  140829. /**
  140830. * Gets the output component
  140831. */
  140832. get output(): NodeMaterialConnectionPoint;
  140833. protected _buildBlock(state: NodeMaterialBuildState): this;
  140834. }
  140835. }
  140836. declare module BABYLON {
  140837. /**
  140838. * Block used to get the value of the first parameter raised to the power of the second
  140839. */
  140840. export class PowBlock extends NodeMaterialBlock {
  140841. /**
  140842. * Creates a new PowBlock
  140843. * @param name defines the block name
  140844. */
  140845. constructor(name: string);
  140846. /**
  140847. * Gets the current class name
  140848. * @returns the class name
  140849. */
  140850. getClassName(): string;
  140851. /**
  140852. * Gets the value operand input component
  140853. */
  140854. get value(): NodeMaterialConnectionPoint;
  140855. /**
  140856. * Gets the power operand input component
  140857. */
  140858. get power(): NodeMaterialConnectionPoint;
  140859. /**
  140860. * Gets the output component
  140861. */
  140862. get output(): NodeMaterialConnectionPoint;
  140863. protected _buildBlock(state: NodeMaterialBuildState): this;
  140864. }
  140865. }
  140866. declare module BABYLON {
  140867. /**
  140868. * Block used to get a random number
  140869. */
  140870. export class RandomNumberBlock extends NodeMaterialBlock {
  140871. /**
  140872. * Creates a new RandomNumberBlock
  140873. * @param name defines the block name
  140874. */
  140875. constructor(name: string);
  140876. /**
  140877. * Gets the current class name
  140878. * @returns the class name
  140879. */
  140880. getClassName(): string;
  140881. /**
  140882. * Gets the seed input component
  140883. */
  140884. get seed(): NodeMaterialConnectionPoint;
  140885. /**
  140886. * Gets the output component
  140887. */
  140888. get output(): NodeMaterialConnectionPoint;
  140889. protected _buildBlock(state: NodeMaterialBuildState): this;
  140890. }
  140891. }
  140892. declare module BABYLON {
  140893. /**
  140894. * Block used to compute arc tangent of 2 values
  140895. */
  140896. export class ArcTan2Block extends NodeMaterialBlock {
  140897. /**
  140898. * Creates a new ArcTan2Block
  140899. * @param name defines the block name
  140900. */
  140901. constructor(name: string);
  140902. /**
  140903. * Gets the current class name
  140904. * @returns the class name
  140905. */
  140906. getClassName(): string;
  140907. /**
  140908. * Gets the x operand input component
  140909. */
  140910. get x(): NodeMaterialConnectionPoint;
  140911. /**
  140912. * Gets the y operand input component
  140913. */
  140914. get y(): NodeMaterialConnectionPoint;
  140915. /**
  140916. * Gets the output component
  140917. */
  140918. get output(): NodeMaterialConnectionPoint;
  140919. protected _buildBlock(state: NodeMaterialBuildState): this;
  140920. }
  140921. }
  140922. declare module BABYLON {
  140923. /**
  140924. * Block used to smooth step a value
  140925. */
  140926. export class SmoothStepBlock extends NodeMaterialBlock {
  140927. /**
  140928. * Creates a new SmoothStepBlock
  140929. * @param name defines the block name
  140930. */
  140931. constructor(name: string);
  140932. /**
  140933. * Gets the current class name
  140934. * @returns the class name
  140935. */
  140936. getClassName(): string;
  140937. /**
  140938. * Gets the value operand input component
  140939. */
  140940. get value(): NodeMaterialConnectionPoint;
  140941. /**
  140942. * Gets the first edge operand input component
  140943. */
  140944. get edge0(): NodeMaterialConnectionPoint;
  140945. /**
  140946. * Gets the second edge operand input component
  140947. */
  140948. get edge1(): NodeMaterialConnectionPoint;
  140949. /**
  140950. * Gets the output component
  140951. */
  140952. get output(): NodeMaterialConnectionPoint;
  140953. protected _buildBlock(state: NodeMaterialBuildState): this;
  140954. }
  140955. }
  140956. declare module BABYLON {
  140957. /**
  140958. * Block used to get the reciprocal (1 / x) of a value
  140959. */
  140960. export class ReciprocalBlock extends NodeMaterialBlock {
  140961. /**
  140962. * Creates a new ReciprocalBlock
  140963. * @param name defines the block name
  140964. */
  140965. constructor(name: string);
  140966. /**
  140967. * Gets the current class name
  140968. * @returns the class name
  140969. */
  140970. getClassName(): string;
  140971. /**
  140972. * Gets the input component
  140973. */
  140974. get input(): NodeMaterialConnectionPoint;
  140975. /**
  140976. * Gets the output component
  140977. */
  140978. get output(): NodeMaterialConnectionPoint;
  140979. protected _buildBlock(state: NodeMaterialBuildState): this;
  140980. }
  140981. }
  140982. declare module BABYLON {
  140983. /**
  140984. * Block used to replace a color by another one
  140985. */
  140986. export class ReplaceColorBlock extends NodeMaterialBlock {
  140987. /**
  140988. * Creates a new ReplaceColorBlock
  140989. * @param name defines the block name
  140990. */
  140991. constructor(name: string);
  140992. /**
  140993. * Gets the current class name
  140994. * @returns the class name
  140995. */
  140996. getClassName(): string;
  140997. /**
  140998. * Gets the value input component
  140999. */
  141000. get value(): NodeMaterialConnectionPoint;
  141001. /**
  141002. * Gets the reference input component
  141003. */
  141004. get reference(): NodeMaterialConnectionPoint;
  141005. /**
  141006. * Gets the distance input component
  141007. */
  141008. get distance(): NodeMaterialConnectionPoint;
  141009. /**
  141010. * Gets the replacement input component
  141011. */
  141012. get replacement(): NodeMaterialConnectionPoint;
  141013. /**
  141014. * Gets the output component
  141015. */
  141016. get output(): NodeMaterialConnectionPoint;
  141017. protected _buildBlock(state: NodeMaterialBuildState): this;
  141018. }
  141019. }
  141020. declare module BABYLON {
  141021. /**
  141022. * Block used to posterize a value
  141023. * @see https://en.wikipedia.org/wiki/Posterization
  141024. */
  141025. export class PosterizeBlock extends NodeMaterialBlock {
  141026. /**
  141027. * Creates a new PosterizeBlock
  141028. * @param name defines the block name
  141029. */
  141030. constructor(name: string);
  141031. /**
  141032. * Gets the current class name
  141033. * @returns the class name
  141034. */
  141035. getClassName(): string;
  141036. /**
  141037. * Gets the value input component
  141038. */
  141039. get value(): NodeMaterialConnectionPoint;
  141040. /**
  141041. * Gets the steps input component
  141042. */
  141043. get steps(): NodeMaterialConnectionPoint;
  141044. /**
  141045. * Gets the output component
  141046. */
  141047. get output(): NodeMaterialConnectionPoint;
  141048. protected _buildBlock(state: NodeMaterialBuildState): this;
  141049. }
  141050. }
  141051. declare module BABYLON {
  141052. /**
  141053. * Operations supported by the Wave block
  141054. */
  141055. export enum WaveBlockKind {
  141056. /** SawTooth */
  141057. SawTooth = 0,
  141058. /** Square */
  141059. Square = 1,
  141060. /** Triangle */
  141061. Triangle = 2
  141062. }
  141063. /**
  141064. * Block used to apply wave operation to floats
  141065. */
  141066. export class WaveBlock extends NodeMaterialBlock {
  141067. /**
  141068. * Gets or sets the kibnd of wave to be applied by the block
  141069. */
  141070. kind: WaveBlockKind;
  141071. /**
  141072. * Creates a new WaveBlock
  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 input component
  141083. */
  141084. get input(): NodeMaterialConnectionPoint;
  141085. /**
  141086. * Gets the output component
  141087. */
  141088. get output(): NodeMaterialConnectionPoint;
  141089. protected _buildBlock(state: NodeMaterialBuildState): this;
  141090. serialize(): any;
  141091. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141092. }
  141093. }
  141094. declare module BABYLON {
  141095. /**
  141096. * Class used to store a color step for the GradientBlock
  141097. */
  141098. export class GradientBlockColorStep {
  141099. /**
  141100. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141101. */
  141102. step: number;
  141103. /**
  141104. * Gets or sets the color associated with this step
  141105. */
  141106. color: Color3;
  141107. /**
  141108. * Creates a new GradientBlockColorStep
  141109. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  141110. * @param color defines the color associated with this step
  141111. */
  141112. constructor(
  141113. /**
  141114. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141115. */
  141116. step: number,
  141117. /**
  141118. * Gets or sets the color associated with this step
  141119. */
  141120. color: Color3);
  141121. }
  141122. /**
  141123. * Block used to return a color from a gradient based on an input value between 0 and 1
  141124. */
  141125. export class GradientBlock extends NodeMaterialBlock {
  141126. /**
  141127. * Gets or sets the list of color steps
  141128. */
  141129. colorSteps: GradientBlockColorStep[];
  141130. /**
  141131. * Creates a new GradientBlock
  141132. * @param name defines the block name
  141133. */
  141134. constructor(name: string);
  141135. /**
  141136. * Gets the current class name
  141137. * @returns the class name
  141138. */
  141139. getClassName(): string;
  141140. /**
  141141. * Gets the gradient input component
  141142. */
  141143. get gradient(): NodeMaterialConnectionPoint;
  141144. /**
  141145. * Gets the output component
  141146. */
  141147. get output(): NodeMaterialConnectionPoint;
  141148. private _writeColorConstant;
  141149. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141150. serialize(): any;
  141151. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141152. protected _dumpPropertiesCode(): string;
  141153. }
  141154. }
  141155. declare module BABYLON {
  141156. /**
  141157. * Block used to normalize lerp between 2 values
  141158. */
  141159. export class NLerpBlock extends NodeMaterialBlock {
  141160. /**
  141161. * Creates a new NLerpBlock
  141162. * @param name defines the block name
  141163. */
  141164. constructor(name: string);
  141165. /**
  141166. * Gets the current class name
  141167. * @returns the class name
  141168. */
  141169. getClassName(): string;
  141170. /**
  141171. * Gets the left operand input component
  141172. */
  141173. get left(): NodeMaterialConnectionPoint;
  141174. /**
  141175. * Gets the right operand input component
  141176. */
  141177. get right(): NodeMaterialConnectionPoint;
  141178. /**
  141179. * Gets the gradient operand input component
  141180. */
  141181. get gradient(): NodeMaterialConnectionPoint;
  141182. /**
  141183. * Gets the output component
  141184. */
  141185. get output(): NodeMaterialConnectionPoint;
  141186. protected _buildBlock(state: NodeMaterialBuildState): this;
  141187. }
  141188. }
  141189. declare module BABYLON {
  141190. /**
  141191. * block used to Generate a Worley Noise 3D Noise Pattern
  141192. */
  141193. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  141194. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  141195. manhattanDistance: boolean;
  141196. /**
  141197. * Creates a new WorleyNoise3DBlock
  141198. * @param name defines the block name
  141199. */
  141200. constructor(name: string);
  141201. /**
  141202. * Gets the current class name
  141203. * @returns the class name
  141204. */
  141205. getClassName(): string;
  141206. /**
  141207. * Gets the seed input component
  141208. */
  141209. get seed(): NodeMaterialConnectionPoint;
  141210. /**
  141211. * Gets the jitter input component
  141212. */
  141213. get jitter(): NodeMaterialConnectionPoint;
  141214. /**
  141215. * Gets the output component
  141216. */
  141217. get output(): NodeMaterialConnectionPoint;
  141218. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141219. /**
  141220. * Exposes the properties to the UI?
  141221. */
  141222. protected _dumpPropertiesCode(): string;
  141223. /**
  141224. * Exposes the properties to the Seralize?
  141225. */
  141226. serialize(): any;
  141227. /**
  141228. * Exposes the properties to the deseralize?
  141229. */
  141230. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141231. }
  141232. }
  141233. declare module BABYLON {
  141234. /**
  141235. * block used to Generate a Simplex Perlin 3d Noise Pattern
  141236. */
  141237. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  141238. /**
  141239. * Creates a new SimplexPerlin3DBlock
  141240. * @param name defines the block name
  141241. */
  141242. constructor(name: string);
  141243. /**
  141244. * Gets the current class name
  141245. * @returns the class name
  141246. */
  141247. getClassName(): string;
  141248. /**
  141249. * Gets the seed operand input component
  141250. */
  141251. get seed(): NodeMaterialConnectionPoint;
  141252. /**
  141253. * Gets the output component
  141254. */
  141255. get output(): NodeMaterialConnectionPoint;
  141256. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141257. }
  141258. }
  141259. declare module BABYLON {
  141260. /**
  141261. * Block used to blend normals
  141262. */
  141263. export class NormalBlendBlock extends NodeMaterialBlock {
  141264. /**
  141265. * Creates a new NormalBlendBlock
  141266. * @param name defines the block name
  141267. */
  141268. constructor(name: string);
  141269. /**
  141270. * Gets the current class name
  141271. * @returns the class name
  141272. */
  141273. getClassName(): string;
  141274. /**
  141275. * Gets the first input component
  141276. */
  141277. get normalMap0(): NodeMaterialConnectionPoint;
  141278. /**
  141279. * Gets the second input component
  141280. */
  141281. get normalMap1(): NodeMaterialConnectionPoint;
  141282. /**
  141283. * Gets the output component
  141284. */
  141285. get output(): NodeMaterialConnectionPoint;
  141286. protected _buildBlock(state: NodeMaterialBuildState): this;
  141287. }
  141288. }
  141289. declare module BABYLON {
  141290. /**
  141291. * Block used to rotate a 2d vector by a given angle
  141292. */
  141293. export class Rotate2dBlock extends NodeMaterialBlock {
  141294. /**
  141295. * Creates a new Rotate2dBlock
  141296. * @param name defines the block name
  141297. */
  141298. constructor(name: string);
  141299. /**
  141300. * Gets the current class name
  141301. * @returns the class name
  141302. */
  141303. getClassName(): string;
  141304. /**
  141305. * Gets the input vector
  141306. */
  141307. get input(): NodeMaterialConnectionPoint;
  141308. /**
  141309. * Gets the input angle
  141310. */
  141311. get angle(): NodeMaterialConnectionPoint;
  141312. /**
  141313. * Gets the output component
  141314. */
  141315. get output(): NodeMaterialConnectionPoint;
  141316. autoConfigure(material: NodeMaterial): void;
  141317. protected _buildBlock(state: NodeMaterialBuildState): this;
  141318. }
  141319. }
  141320. declare module BABYLON {
  141321. /**
  141322. * Block used to get the reflected vector from a direction and a normal
  141323. */
  141324. export class ReflectBlock extends NodeMaterialBlock {
  141325. /**
  141326. * Creates a new ReflectBlock
  141327. * @param name defines the block name
  141328. */
  141329. constructor(name: string);
  141330. /**
  141331. * Gets the current class name
  141332. * @returns the class name
  141333. */
  141334. getClassName(): string;
  141335. /**
  141336. * Gets the incident component
  141337. */
  141338. get incident(): NodeMaterialConnectionPoint;
  141339. /**
  141340. * Gets the normal component
  141341. */
  141342. get normal(): NodeMaterialConnectionPoint;
  141343. /**
  141344. * Gets the output component
  141345. */
  141346. get output(): NodeMaterialConnectionPoint;
  141347. protected _buildBlock(state: NodeMaterialBuildState): this;
  141348. }
  141349. }
  141350. declare module BABYLON {
  141351. /**
  141352. * Block used to get the refracted vector from a direction and a normal
  141353. */
  141354. export class RefractBlock extends NodeMaterialBlock {
  141355. /**
  141356. * Creates a new RefractBlock
  141357. * @param name defines the block name
  141358. */
  141359. constructor(name: string);
  141360. /**
  141361. * Gets the current class name
  141362. * @returns the class name
  141363. */
  141364. getClassName(): string;
  141365. /**
  141366. * Gets the incident component
  141367. */
  141368. get incident(): NodeMaterialConnectionPoint;
  141369. /**
  141370. * Gets the normal component
  141371. */
  141372. get normal(): NodeMaterialConnectionPoint;
  141373. /**
  141374. * Gets the index of refraction component
  141375. */
  141376. get ior(): NodeMaterialConnectionPoint;
  141377. /**
  141378. * Gets the output component
  141379. */
  141380. get output(): NodeMaterialConnectionPoint;
  141381. protected _buildBlock(state: NodeMaterialBuildState): this;
  141382. }
  141383. }
  141384. declare module BABYLON {
  141385. /**
  141386. * Block used to desaturate a color
  141387. */
  141388. export class DesaturateBlock extends NodeMaterialBlock {
  141389. /**
  141390. * Creates a new DesaturateBlock
  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 color operand input component
  141401. */
  141402. get color(): NodeMaterialConnectionPoint;
  141403. /**
  141404. * Gets the level operand input component
  141405. */
  141406. get level(): NodeMaterialConnectionPoint;
  141407. /**
  141408. * Gets the output component
  141409. */
  141410. get output(): NodeMaterialConnectionPoint;
  141411. protected _buildBlock(state: NodeMaterialBuildState): this;
  141412. }
  141413. }
  141414. declare module BABYLON {
  141415. /**
  141416. * Block used to implement the ambient occlusion module of the PBR material
  141417. */
  141418. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  141419. /**
  141420. * Create a new AmbientOcclusionBlock
  141421. * @param name defines the block name
  141422. */
  141423. constructor(name: string);
  141424. /**
  141425. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  141426. */
  141427. useAmbientInGrayScale: boolean;
  141428. /**
  141429. * Initialize the block and prepare the context for build
  141430. * @param state defines the state that will be used for the build
  141431. */
  141432. initialize(state: NodeMaterialBuildState): void;
  141433. /**
  141434. * Gets the current class name
  141435. * @returns the class name
  141436. */
  141437. getClassName(): string;
  141438. /**
  141439. * Gets the texture input component
  141440. */
  141441. get texture(): NodeMaterialConnectionPoint;
  141442. /**
  141443. * Gets the texture intensity component
  141444. */
  141445. get intensity(): NodeMaterialConnectionPoint;
  141446. /**
  141447. * Gets the direct light intensity input component
  141448. */
  141449. get directLightIntensity(): NodeMaterialConnectionPoint;
  141450. /**
  141451. * Gets the ambient occlusion object output component
  141452. */
  141453. get ambientOcclusion(): NodeMaterialConnectionPoint;
  141454. /**
  141455. * Gets the main code of the block (fragment side)
  141456. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  141457. * @returns the shader code
  141458. */
  141459. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  141460. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141461. protected _buildBlock(state: NodeMaterialBuildState): this;
  141462. protected _dumpPropertiesCode(): string;
  141463. serialize(): any;
  141464. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141465. }
  141466. }
  141467. declare module BABYLON {
  141468. /**
  141469. * Block used to implement the reflection module of the PBR material
  141470. */
  141471. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  141472. /** @hidden */
  141473. _defineLODReflectionAlpha: string;
  141474. /** @hidden */
  141475. _defineLinearSpecularReflection: string;
  141476. private _vEnvironmentIrradianceName;
  141477. /** @hidden */
  141478. _vReflectionMicrosurfaceInfosName: string;
  141479. /** @hidden */
  141480. _vReflectionInfosName: string;
  141481. /** @hidden */
  141482. _vReflectionFilteringInfoName: string;
  141483. private _scene;
  141484. /**
  141485. * The three properties below are set by the main PBR block prior to calling methods of this class.
  141486. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141487. * It's less burden on the user side in the editor part.
  141488. */
  141489. /** @hidden */
  141490. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141491. /** @hidden */
  141492. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141493. /** @hidden */
  141494. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  141495. /**
  141496. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  141497. * diffuse part of the IBL.
  141498. */
  141499. useSphericalHarmonics: boolean;
  141500. /**
  141501. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  141502. */
  141503. forceIrradianceInFragment: boolean;
  141504. /**
  141505. * Create a new ReflectionBlock
  141506. * @param name defines the block name
  141507. */
  141508. constructor(name: string);
  141509. /**
  141510. * Gets the current class name
  141511. * @returns the class name
  141512. */
  141513. getClassName(): string;
  141514. /**
  141515. * Gets the position input component
  141516. */
  141517. get position(): NodeMaterialConnectionPoint;
  141518. /**
  141519. * Gets the world position input component
  141520. */
  141521. get worldPosition(): NodeMaterialConnectionPoint;
  141522. /**
  141523. * Gets the world normal input component
  141524. */
  141525. get worldNormal(): NodeMaterialConnectionPoint;
  141526. /**
  141527. * Gets the world input component
  141528. */
  141529. get world(): NodeMaterialConnectionPoint;
  141530. /**
  141531. * Gets the camera (or eye) position component
  141532. */
  141533. get cameraPosition(): NodeMaterialConnectionPoint;
  141534. /**
  141535. * Gets the view input component
  141536. */
  141537. get view(): NodeMaterialConnectionPoint;
  141538. /**
  141539. * Gets the color input component
  141540. */
  141541. get color(): NodeMaterialConnectionPoint;
  141542. /**
  141543. * Gets the reflection object output component
  141544. */
  141545. get reflection(): NodeMaterialConnectionPoint;
  141546. /**
  141547. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  141548. */
  141549. get hasTexture(): boolean;
  141550. /**
  141551. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  141552. */
  141553. get reflectionColor(): string;
  141554. protected _getTexture(): Nullable<BaseTexture>;
  141555. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141556. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141557. /**
  141558. * Gets the code to inject in the vertex shader
  141559. * @param state current state of the node material building
  141560. * @returns the shader code
  141561. */
  141562. handleVertexSide(state: NodeMaterialBuildState): string;
  141563. /**
  141564. * Gets the main code of the block (fragment side)
  141565. * @param state current state of the node material building
  141566. * @param normalVarName name of the existing variable corresponding to the normal
  141567. * @returns the shader code
  141568. */
  141569. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  141570. protected _buildBlock(state: NodeMaterialBuildState): this;
  141571. protected _dumpPropertiesCode(): string;
  141572. serialize(): any;
  141573. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141574. }
  141575. }
  141576. declare module BABYLON {
  141577. /**
  141578. * Block used to implement the sheen module of the PBR material
  141579. */
  141580. export class SheenBlock extends NodeMaterialBlock {
  141581. /**
  141582. * Create a new SheenBlock
  141583. * @param name defines the block name
  141584. */
  141585. constructor(name: string);
  141586. /**
  141587. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  141588. * It allows the strength of the sheen effect to not depend on the base color of the material,
  141589. * making it easier to setup and tweak the effect
  141590. */
  141591. albedoScaling: boolean;
  141592. /**
  141593. * Defines if the sheen is linked to the sheen color.
  141594. */
  141595. linkSheenWithAlbedo: boolean;
  141596. /**
  141597. * Initialize the block and prepare the context for build
  141598. * @param state defines the state that will be used for the build
  141599. */
  141600. initialize(state: NodeMaterialBuildState): void;
  141601. /**
  141602. * Gets the current class name
  141603. * @returns the class name
  141604. */
  141605. getClassName(): string;
  141606. /**
  141607. * Gets the intensity input component
  141608. */
  141609. get intensity(): NodeMaterialConnectionPoint;
  141610. /**
  141611. * Gets the color input component
  141612. */
  141613. get color(): NodeMaterialConnectionPoint;
  141614. /**
  141615. * Gets the roughness input component
  141616. */
  141617. get roughness(): NodeMaterialConnectionPoint;
  141618. /**
  141619. * Gets the sheen object output component
  141620. */
  141621. get sheen(): NodeMaterialConnectionPoint;
  141622. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141623. /**
  141624. * Gets the main code of the block (fragment side)
  141625. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141626. * @returns the shader code
  141627. */
  141628. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  141629. protected _buildBlock(state: NodeMaterialBuildState): this;
  141630. protected _dumpPropertiesCode(): string;
  141631. serialize(): any;
  141632. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141633. }
  141634. }
  141635. declare module BABYLON {
  141636. /**
  141637. * Block used to implement the reflectivity module of the PBR material
  141638. */
  141639. export class ReflectivityBlock extends NodeMaterialBlock {
  141640. private _metallicReflectanceColor;
  141641. private _metallicF0Factor;
  141642. /** @hidden */
  141643. _vMetallicReflectanceFactorsName: string;
  141644. /**
  141645. * The property below is set by the main PBR block prior to calling methods of this class.
  141646. */
  141647. /** @hidden */
  141648. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  141649. /**
  141650. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  141651. */
  141652. useAmbientOcclusionFromMetallicTextureRed: boolean;
  141653. /**
  141654. * Specifies if the metallic texture contains the metallness information in its blue channel.
  141655. */
  141656. useMetallnessFromMetallicTextureBlue: boolean;
  141657. /**
  141658. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  141659. */
  141660. useRoughnessFromMetallicTextureAlpha: boolean;
  141661. /**
  141662. * Specifies if the metallic texture contains the roughness information in its green channel.
  141663. */
  141664. useRoughnessFromMetallicTextureGreen: boolean;
  141665. /**
  141666. * Create a new ReflectivityBlock
  141667. * @param name defines the block name
  141668. */
  141669. constructor(name: string);
  141670. /**
  141671. * Initialize the block and prepare the context for build
  141672. * @param state defines the state that will be used for the build
  141673. */
  141674. initialize(state: NodeMaterialBuildState): void;
  141675. /**
  141676. * Gets the current class name
  141677. * @returns the class name
  141678. */
  141679. getClassName(): string;
  141680. /**
  141681. * Gets the metallic input component
  141682. */
  141683. get metallic(): NodeMaterialConnectionPoint;
  141684. /**
  141685. * Gets the roughness input component
  141686. */
  141687. get roughness(): NodeMaterialConnectionPoint;
  141688. /**
  141689. * Gets the texture input component
  141690. */
  141691. get texture(): NodeMaterialConnectionPoint;
  141692. /**
  141693. * Gets the reflectivity object output component
  141694. */
  141695. get reflectivity(): NodeMaterialConnectionPoint;
  141696. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141697. /**
  141698. * Gets the main code of the block (fragment side)
  141699. * @param state current state of the node material building
  141700. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  141701. * @returns the shader code
  141702. */
  141703. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  141704. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141705. protected _buildBlock(state: NodeMaterialBuildState): this;
  141706. protected _dumpPropertiesCode(): string;
  141707. serialize(): any;
  141708. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141709. }
  141710. }
  141711. declare module BABYLON {
  141712. /**
  141713. * Block used to implement the anisotropy module of the PBR material
  141714. */
  141715. export class AnisotropyBlock extends NodeMaterialBlock {
  141716. /**
  141717. * The two properties below are set by the main PBR block prior to calling methods of this class.
  141718. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141719. * It's less burden on the user side in the editor part.
  141720. */
  141721. /** @hidden */
  141722. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141723. /** @hidden */
  141724. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141725. /**
  141726. * Create a new AnisotropyBlock
  141727. * @param name defines the block name
  141728. */
  141729. constructor(name: string);
  141730. /**
  141731. * Initialize the block and prepare the context for build
  141732. * @param state defines the state that will be used for the build
  141733. */
  141734. initialize(state: NodeMaterialBuildState): void;
  141735. /**
  141736. * Gets the current class name
  141737. * @returns the class name
  141738. */
  141739. getClassName(): string;
  141740. /**
  141741. * Gets the intensity input component
  141742. */
  141743. get intensity(): NodeMaterialConnectionPoint;
  141744. /**
  141745. * Gets the direction input component
  141746. */
  141747. get direction(): NodeMaterialConnectionPoint;
  141748. /**
  141749. * Gets the texture input component
  141750. */
  141751. get texture(): NodeMaterialConnectionPoint;
  141752. /**
  141753. * Gets the uv input component
  141754. */
  141755. get uv(): NodeMaterialConnectionPoint;
  141756. /**
  141757. * Gets the worldTangent input component
  141758. */
  141759. get worldTangent(): NodeMaterialConnectionPoint;
  141760. /**
  141761. * Gets the anisotropy object output component
  141762. */
  141763. get anisotropy(): NodeMaterialConnectionPoint;
  141764. private _generateTBNSpace;
  141765. /**
  141766. * Gets the main code of the block (fragment side)
  141767. * @param state current state of the node material building
  141768. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141769. * @returns the shader code
  141770. */
  141771. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  141772. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141773. protected _buildBlock(state: NodeMaterialBuildState): this;
  141774. }
  141775. }
  141776. declare module BABYLON {
  141777. /**
  141778. * Block used to implement the clear coat module of the PBR material
  141779. */
  141780. export class ClearCoatBlock extends NodeMaterialBlock {
  141781. private _scene;
  141782. /**
  141783. * Create a new ClearCoatBlock
  141784. * @param name defines the block name
  141785. */
  141786. constructor(name: string);
  141787. /**
  141788. * Initialize the block and prepare the context for build
  141789. * @param state defines the state that will be used for the build
  141790. */
  141791. initialize(state: NodeMaterialBuildState): void;
  141792. /**
  141793. * Gets the current class name
  141794. * @returns the class name
  141795. */
  141796. getClassName(): string;
  141797. /**
  141798. * Gets the intensity input component
  141799. */
  141800. get intensity(): NodeMaterialConnectionPoint;
  141801. /**
  141802. * Gets the roughness input component
  141803. */
  141804. get roughness(): NodeMaterialConnectionPoint;
  141805. /**
  141806. * Gets the ior input component
  141807. */
  141808. get ior(): NodeMaterialConnectionPoint;
  141809. /**
  141810. * Gets the texture input component
  141811. */
  141812. get texture(): NodeMaterialConnectionPoint;
  141813. /**
  141814. * Gets the bump texture input component
  141815. */
  141816. get bumpTexture(): NodeMaterialConnectionPoint;
  141817. /**
  141818. * Gets the uv input component
  141819. */
  141820. get uv(): NodeMaterialConnectionPoint;
  141821. /**
  141822. * Gets the tint color input component
  141823. */
  141824. get tintColor(): NodeMaterialConnectionPoint;
  141825. /**
  141826. * Gets the tint "at distance" input component
  141827. */
  141828. get tintAtDistance(): NodeMaterialConnectionPoint;
  141829. /**
  141830. * Gets the tint thickness input component
  141831. */
  141832. get tintThickness(): NodeMaterialConnectionPoint;
  141833. /**
  141834. * Gets the world tangent input component
  141835. */
  141836. get worldTangent(): NodeMaterialConnectionPoint;
  141837. /**
  141838. * Gets the clear coat object output component
  141839. */
  141840. get clearcoat(): NodeMaterialConnectionPoint;
  141841. autoConfigure(material: NodeMaterial): void;
  141842. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141843. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141844. private _generateTBNSpace;
  141845. /**
  141846. * Gets the main code of the block (fragment side)
  141847. * @param state current state of the node material building
  141848. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  141849. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141850. * @param worldPosVarName name of the variable holding the world position
  141851. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141852. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  141853. * @param worldNormalVarName name of the variable holding the world normal
  141854. * @returns the shader code
  141855. */
  141856. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  141857. protected _buildBlock(state: NodeMaterialBuildState): this;
  141858. }
  141859. }
  141860. declare module BABYLON {
  141861. /**
  141862. * Block used to implement the sub surface module of the PBR material
  141863. */
  141864. export class SubSurfaceBlock extends NodeMaterialBlock {
  141865. /**
  141866. * Create a new SubSurfaceBlock
  141867. * @param name defines the block name
  141868. */
  141869. constructor(name: string);
  141870. /**
  141871. * Stores the intensity of the different subsurface effects in the thickness texture.
  141872. * * the green channel is the translucency intensity.
  141873. * * the blue channel is the scattering intensity.
  141874. * * the alpha channel is the refraction intensity.
  141875. */
  141876. useMaskFromThicknessTexture: boolean;
  141877. /**
  141878. * Initialize the block and prepare the context for build
  141879. * @param state defines the state that will be used for the build
  141880. */
  141881. initialize(state: NodeMaterialBuildState): void;
  141882. /**
  141883. * Gets the current class name
  141884. * @returns the class name
  141885. */
  141886. getClassName(): string;
  141887. /**
  141888. * Gets the min thickness input component
  141889. */
  141890. get minThickness(): NodeMaterialConnectionPoint;
  141891. /**
  141892. * Gets the max thickness input component
  141893. */
  141894. get maxThickness(): NodeMaterialConnectionPoint;
  141895. /**
  141896. * Gets the thickness texture component
  141897. */
  141898. get thicknessTexture(): NodeMaterialConnectionPoint;
  141899. /**
  141900. * Gets the tint color input component
  141901. */
  141902. get tintColor(): NodeMaterialConnectionPoint;
  141903. /**
  141904. * Gets the translucency intensity input component
  141905. */
  141906. get translucencyIntensity(): NodeMaterialConnectionPoint;
  141907. /**
  141908. * Gets the translucency diffusion distance input component
  141909. */
  141910. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  141911. /**
  141912. * Gets the refraction object parameters
  141913. */
  141914. get refraction(): NodeMaterialConnectionPoint;
  141915. /**
  141916. * Gets the sub surface object output component
  141917. */
  141918. get subsurface(): NodeMaterialConnectionPoint;
  141919. autoConfigure(material: NodeMaterial): void;
  141920. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141921. /**
  141922. * Gets the main code of the block (fragment side)
  141923. * @param state current state of the node material building
  141924. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  141925. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141926. * @param worldPosVarName name of the variable holding the world position
  141927. * @returns the shader code
  141928. */
  141929. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  141930. protected _buildBlock(state: NodeMaterialBuildState): this;
  141931. }
  141932. }
  141933. declare module BABYLON {
  141934. /**
  141935. * Block used to implement the PBR metallic/roughness model
  141936. */
  141937. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  141938. /**
  141939. * Gets or sets the light associated with this block
  141940. */
  141941. light: Nullable<Light>;
  141942. private _lightId;
  141943. private _scene;
  141944. private _environmentBRDFTexture;
  141945. private _environmentBrdfSamplerName;
  141946. private _vNormalWName;
  141947. private _invertNormalName;
  141948. /**
  141949. * Create a new ReflectionBlock
  141950. * @param name defines the block name
  141951. */
  141952. constructor(name: string);
  141953. /**
  141954. * Intensity of the direct lights e.g. the four lights available in your scene.
  141955. * This impacts both the direct diffuse and specular highlights.
  141956. */
  141957. directIntensity: number;
  141958. /**
  141959. * Intensity of the environment e.g. how much the environment will light the object
  141960. * either through harmonics for rough material or through the refelction for shiny ones.
  141961. */
  141962. environmentIntensity: number;
  141963. /**
  141964. * This is a special control allowing the reduction of the specular highlights coming from the
  141965. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  141966. */
  141967. specularIntensity: number;
  141968. /**
  141969. * Defines the falloff type used in this material.
  141970. * It by default is Physical.
  141971. */
  141972. lightFalloff: number;
  141973. /**
  141974. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  141975. */
  141976. useAlphaFromAlbedoTexture: boolean;
  141977. /**
  141978. * Specifies that alpha test should be used
  141979. */
  141980. useAlphaTest: boolean;
  141981. /**
  141982. * Defines the alpha limits in alpha test mode.
  141983. */
  141984. alphaTestCutoff: number;
  141985. /**
  141986. * Specifies that alpha blending should be used
  141987. */
  141988. useAlphaBlending: boolean;
  141989. /**
  141990. * Defines if the alpha value should be determined via the rgb values.
  141991. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  141992. */
  141993. opacityRGB: boolean;
  141994. /**
  141995. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  141996. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  141997. */
  141998. useRadianceOverAlpha: boolean;
  141999. /**
  142000. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  142001. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  142002. */
  142003. useSpecularOverAlpha: boolean;
  142004. /**
  142005. * Enables specular anti aliasing in the PBR shader.
  142006. * It will both interacts on the Geometry for analytical and IBL lighting.
  142007. * It also prefilter the roughness map based on the bump values.
  142008. */
  142009. enableSpecularAntiAliasing: boolean;
  142010. /**
  142011. * Enables realtime filtering on the texture.
  142012. */
  142013. realTimeFiltering: boolean;
  142014. /**
  142015. * Quality switch for realtime filtering
  142016. */
  142017. realTimeFilteringQuality: number;
  142018. /**
  142019. * Defines if the material uses energy conservation.
  142020. */
  142021. useEnergyConservation: boolean;
  142022. /**
  142023. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  142024. * too much the area relying on ambient texture to define their ambient occlusion.
  142025. */
  142026. useRadianceOcclusion: boolean;
  142027. /**
  142028. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  142029. * makes the reflect vector face the model (under horizon).
  142030. */
  142031. useHorizonOcclusion: boolean;
  142032. /**
  142033. * If set to true, no lighting calculations will be applied.
  142034. */
  142035. unlit: boolean;
  142036. /**
  142037. * Force normal to face away from face.
  142038. */
  142039. forceNormalForward: boolean;
  142040. /**
  142041. * Defines the material debug mode.
  142042. * It helps seeing only some components of the material while troubleshooting.
  142043. */
  142044. debugMode: number;
  142045. /**
  142046. * Specify from where on screen the debug mode should start.
  142047. * The value goes from -1 (full screen) to 1 (not visible)
  142048. * It helps with side by side comparison against the final render
  142049. * This defaults to 0
  142050. */
  142051. debugLimit: number;
  142052. /**
  142053. * As the default viewing range might not be enough (if the ambient is really small for instance)
  142054. * You can use the factor to better multiply the final value.
  142055. */
  142056. debugFactor: number;
  142057. /**
  142058. * Initialize the block and prepare the context for build
  142059. * @param state defines the state that will be used for the build
  142060. */
  142061. initialize(state: NodeMaterialBuildState): void;
  142062. /**
  142063. * Gets the current class name
  142064. * @returns the class name
  142065. */
  142066. getClassName(): string;
  142067. /**
  142068. * Gets the world position input component
  142069. */
  142070. get worldPosition(): NodeMaterialConnectionPoint;
  142071. /**
  142072. * Gets the world normal input component
  142073. */
  142074. get worldNormal(): NodeMaterialConnectionPoint;
  142075. /**
  142076. * Gets the perturbed normal input component
  142077. */
  142078. get perturbedNormal(): NodeMaterialConnectionPoint;
  142079. /**
  142080. * Gets the camera position input component
  142081. */
  142082. get cameraPosition(): NodeMaterialConnectionPoint;
  142083. /**
  142084. * Gets the base color input component
  142085. */
  142086. get baseColor(): NodeMaterialConnectionPoint;
  142087. /**
  142088. * Gets the opacity texture input component
  142089. */
  142090. get opacityTexture(): NodeMaterialConnectionPoint;
  142091. /**
  142092. * Gets the ambient color input component
  142093. */
  142094. get ambientColor(): NodeMaterialConnectionPoint;
  142095. /**
  142096. * Gets the reflectivity object parameters
  142097. */
  142098. get reflectivity(): NodeMaterialConnectionPoint;
  142099. /**
  142100. * Gets the ambient occlusion object parameters
  142101. */
  142102. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142103. /**
  142104. * Gets the reflection object parameters
  142105. */
  142106. get reflection(): NodeMaterialConnectionPoint;
  142107. /**
  142108. * Gets the sheen object parameters
  142109. */
  142110. get sheen(): NodeMaterialConnectionPoint;
  142111. /**
  142112. * Gets the clear coat object parameters
  142113. */
  142114. get clearcoat(): NodeMaterialConnectionPoint;
  142115. /**
  142116. * Gets the sub surface object parameters
  142117. */
  142118. get subsurface(): NodeMaterialConnectionPoint;
  142119. /**
  142120. * Gets the anisotropy object parameters
  142121. */
  142122. get anisotropy(): NodeMaterialConnectionPoint;
  142123. /**
  142124. * Gets the ambient output component
  142125. */
  142126. get ambient(): NodeMaterialConnectionPoint;
  142127. /**
  142128. * Gets the diffuse output component
  142129. */
  142130. get diffuse(): NodeMaterialConnectionPoint;
  142131. /**
  142132. * Gets the specular output component
  142133. */
  142134. get specular(): NodeMaterialConnectionPoint;
  142135. /**
  142136. * Gets the sheen output component
  142137. */
  142138. get sheenDir(): NodeMaterialConnectionPoint;
  142139. /**
  142140. * Gets the clear coat output component
  142141. */
  142142. get clearcoatDir(): NodeMaterialConnectionPoint;
  142143. /**
  142144. * Gets the indirect diffuse output component
  142145. */
  142146. get diffuseIndirect(): NodeMaterialConnectionPoint;
  142147. /**
  142148. * Gets the indirect specular output component
  142149. */
  142150. get specularIndirect(): NodeMaterialConnectionPoint;
  142151. /**
  142152. * Gets the indirect sheen output component
  142153. */
  142154. get sheenIndirect(): NodeMaterialConnectionPoint;
  142155. /**
  142156. * Gets the indirect clear coat output component
  142157. */
  142158. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  142159. /**
  142160. * Gets the refraction output component
  142161. */
  142162. get refraction(): NodeMaterialConnectionPoint;
  142163. /**
  142164. * Gets the global lighting output component
  142165. */
  142166. get lighting(): NodeMaterialConnectionPoint;
  142167. /**
  142168. * Gets the shadow output component
  142169. */
  142170. get shadow(): NodeMaterialConnectionPoint;
  142171. /**
  142172. * Gets the alpha output component
  142173. */
  142174. get alpha(): NodeMaterialConnectionPoint;
  142175. autoConfigure(material: NodeMaterial): void;
  142176. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142177. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142178. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142179. private _injectVertexCode;
  142180. /**
  142181. * Gets the code corresponding to the albedo/opacity module
  142182. * @returns the shader code
  142183. */
  142184. getAlbedoOpacityCode(): string;
  142185. protected _buildBlock(state: NodeMaterialBuildState): this;
  142186. protected _dumpPropertiesCode(): string;
  142187. serialize(): any;
  142188. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142189. }
  142190. }
  142191. declare module BABYLON {
  142192. /**
  142193. * Block used to compute value of one parameter modulo another
  142194. */
  142195. export class ModBlock extends NodeMaterialBlock {
  142196. /**
  142197. * Creates a new ModBlock
  142198. * @param name defines the block name
  142199. */
  142200. constructor(name: string);
  142201. /**
  142202. * Gets the current class name
  142203. * @returns the class name
  142204. */
  142205. getClassName(): string;
  142206. /**
  142207. * Gets the left operand input component
  142208. */
  142209. get left(): NodeMaterialConnectionPoint;
  142210. /**
  142211. * Gets the right operand input component
  142212. */
  142213. get right(): NodeMaterialConnectionPoint;
  142214. /**
  142215. * Gets the output component
  142216. */
  142217. get output(): NodeMaterialConnectionPoint;
  142218. protected _buildBlock(state: NodeMaterialBuildState): this;
  142219. }
  142220. }
  142221. declare module BABYLON {
  142222. /**
  142223. * Helper class to push actions to a pool of workers.
  142224. */
  142225. export class WorkerPool implements IDisposable {
  142226. private _workerInfos;
  142227. private _pendingActions;
  142228. /**
  142229. * Constructor
  142230. * @param workers Array of workers to use for actions
  142231. */
  142232. constructor(workers: Array<Worker>);
  142233. /**
  142234. * Terminates all workers and clears any pending actions.
  142235. */
  142236. dispose(): void;
  142237. /**
  142238. * Pushes an action to the worker pool. If all the workers are active, the action will be
  142239. * pended until a worker has completed its action.
  142240. * @param action The action to perform. Call onComplete when the action is complete.
  142241. */
  142242. push(action: (worker: Worker, onComplete: () => void) => void): void;
  142243. private _execute;
  142244. }
  142245. }
  142246. declare module BABYLON {
  142247. /**
  142248. * Configuration for Draco compression
  142249. */
  142250. export interface IDracoCompressionConfiguration {
  142251. /**
  142252. * Configuration for the decoder.
  142253. */
  142254. decoder: {
  142255. /**
  142256. * The url to the WebAssembly module.
  142257. */
  142258. wasmUrl?: string;
  142259. /**
  142260. * The url to the WebAssembly binary.
  142261. */
  142262. wasmBinaryUrl?: string;
  142263. /**
  142264. * The url to the fallback JavaScript module.
  142265. */
  142266. fallbackUrl?: string;
  142267. };
  142268. }
  142269. /**
  142270. * Draco compression (https://google.github.io/draco/)
  142271. *
  142272. * This class wraps the Draco module.
  142273. *
  142274. * **Encoder**
  142275. *
  142276. * The encoder is not currently implemented.
  142277. *
  142278. * **Decoder**
  142279. *
  142280. * 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.
  142281. *
  142282. * To update the configuration, use the following code:
  142283. * ```javascript
  142284. * DracoCompression.Configuration = {
  142285. * decoder: {
  142286. * wasmUrl: "<url to the WebAssembly library>",
  142287. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  142288. * fallbackUrl: "<url to the fallback JavaScript library>",
  142289. * }
  142290. * };
  142291. * ```
  142292. *
  142293. * 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.
  142294. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  142295. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  142296. *
  142297. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  142298. * ```javascript
  142299. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  142300. * ```
  142301. *
  142302. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  142303. */
  142304. export class DracoCompression implements IDisposable {
  142305. private _workerPoolPromise?;
  142306. private _decoderModulePromise?;
  142307. /**
  142308. * The configuration. Defaults to the following urls:
  142309. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  142310. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  142311. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  142312. */
  142313. static Configuration: IDracoCompressionConfiguration;
  142314. /**
  142315. * Returns true if the decoder configuration is available.
  142316. */
  142317. static get DecoderAvailable(): boolean;
  142318. /**
  142319. * Default number of workers to create when creating the draco compression object.
  142320. */
  142321. static DefaultNumWorkers: number;
  142322. private static GetDefaultNumWorkers;
  142323. private static _Default;
  142324. /**
  142325. * Default instance for the draco compression object.
  142326. */
  142327. static get Default(): DracoCompression;
  142328. /**
  142329. * Constructor
  142330. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  142331. */
  142332. constructor(numWorkers?: number);
  142333. /**
  142334. * Stop all async operations and release resources.
  142335. */
  142336. dispose(): void;
  142337. /**
  142338. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  142339. * @returns a promise that resolves when ready
  142340. */
  142341. whenReadyAsync(): Promise<void>;
  142342. /**
  142343. * Decode Draco compressed mesh data to vertex data.
  142344. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  142345. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  142346. * @returns A promise that resolves with the decoded vertex data
  142347. */
  142348. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  142349. [kind: string]: number;
  142350. }): Promise<VertexData>;
  142351. }
  142352. }
  142353. declare module BABYLON {
  142354. /**
  142355. * Class for building Constructive Solid Geometry
  142356. */
  142357. export class CSG {
  142358. private polygons;
  142359. /**
  142360. * The world matrix
  142361. */
  142362. matrix: Matrix;
  142363. /**
  142364. * Stores the position
  142365. */
  142366. position: Vector3;
  142367. /**
  142368. * Stores the rotation
  142369. */
  142370. rotation: Vector3;
  142371. /**
  142372. * Stores the rotation quaternion
  142373. */
  142374. rotationQuaternion: Nullable<Quaternion>;
  142375. /**
  142376. * Stores the scaling vector
  142377. */
  142378. scaling: Vector3;
  142379. /**
  142380. * Convert the Mesh to CSG
  142381. * @param mesh The Mesh to convert to CSG
  142382. * @returns A new CSG from the Mesh
  142383. */
  142384. static FromMesh(mesh: Mesh): CSG;
  142385. /**
  142386. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  142387. * @param polygons Polygons used to construct a CSG solid
  142388. */
  142389. private static FromPolygons;
  142390. /**
  142391. * Clones, or makes a deep copy, of the CSG
  142392. * @returns A new CSG
  142393. */
  142394. clone(): CSG;
  142395. /**
  142396. * Unions this CSG with another CSG
  142397. * @param csg The CSG to union against this CSG
  142398. * @returns The unioned CSG
  142399. */
  142400. union(csg: CSG): CSG;
  142401. /**
  142402. * Unions this CSG with another CSG in place
  142403. * @param csg The CSG to union against this CSG
  142404. */
  142405. unionInPlace(csg: CSG): void;
  142406. /**
  142407. * Subtracts this CSG with another CSG
  142408. * @param csg The CSG to subtract against this CSG
  142409. * @returns A new CSG
  142410. */
  142411. subtract(csg: CSG): CSG;
  142412. /**
  142413. * Subtracts this CSG with another CSG in place
  142414. * @param csg The CSG to subtact against this CSG
  142415. */
  142416. subtractInPlace(csg: CSG): void;
  142417. /**
  142418. * Intersect this CSG with another CSG
  142419. * @param csg The CSG to intersect against this CSG
  142420. * @returns A new CSG
  142421. */
  142422. intersect(csg: CSG): CSG;
  142423. /**
  142424. * Intersects this CSG with another CSG in place
  142425. * @param csg The CSG to intersect against this CSG
  142426. */
  142427. intersectInPlace(csg: CSG): void;
  142428. /**
  142429. * Return a new CSG solid with solid and empty space switched. This solid is
  142430. * not modified.
  142431. * @returns A new CSG solid with solid and empty space switched
  142432. */
  142433. inverse(): CSG;
  142434. /**
  142435. * Inverses the CSG in place
  142436. */
  142437. inverseInPlace(): void;
  142438. /**
  142439. * This is used to keep meshes transformations so they can be restored
  142440. * when we build back a Babylon Mesh
  142441. * NB : All CSG operations are performed in world coordinates
  142442. * @param csg The CSG to copy the transform attributes from
  142443. * @returns This CSG
  142444. */
  142445. copyTransformAttributes(csg: CSG): CSG;
  142446. /**
  142447. * Build Raw mesh from CSG
  142448. * Coordinates here are in world space
  142449. * @param name The name of the mesh geometry
  142450. * @param scene The Scene
  142451. * @param keepSubMeshes Specifies if the submeshes should be kept
  142452. * @returns A new Mesh
  142453. */
  142454. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142455. /**
  142456. * Build Mesh from CSG taking material and transforms into account
  142457. * @param name The name of the Mesh
  142458. * @param material The material of the Mesh
  142459. * @param scene The Scene
  142460. * @param keepSubMeshes Specifies if submeshes should be kept
  142461. * @returns The new Mesh
  142462. */
  142463. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142464. }
  142465. }
  142466. declare module BABYLON {
  142467. /**
  142468. * Class used to create a trail following a mesh
  142469. */
  142470. export class TrailMesh extends Mesh {
  142471. private _generator;
  142472. private _autoStart;
  142473. private _running;
  142474. private _diameter;
  142475. private _length;
  142476. private _sectionPolygonPointsCount;
  142477. private _sectionVectors;
  142478. private _sectionNormalVectors;
  142479. private _beforeRenderObserver;
  142480. /**
  142481. * @constructor
  142482. * @param name The value used by scene.getMeshByName() to do a lookup.
  142483. * @param generator The mesh or transform node to generate a trail.
  142484. * @param scene The scene to add this mesh to.
  142485. * @param diameter Diameter of trailing mesh. Default is 1.
  142486. * @param length Length of trailing mesh. Default is 60.
  142487. * @param autoStart Automatically start trailing mesh. Default true.
  142488. */
  142489. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  142490. /**
  142491. * "TrailMesh"
  142492. * @returns "TrailMesh"
  142493. */
  142494. getClassName(): string;
  142495. private _createMesh;
  142496. /**
  142497. * Start trailing mesh.
  142498. */
  142499. start(): void;
  142500. /**
  142501. * Stop trailing mesh.
  142502. */
  142503. stop(): void;
  142504. /**
  142505. * Update trailing mesh geometry.
  142506. */
  142507. update(): void;
  142508. /**
  142509. * Returns a new TrailMesh object.
  142510. * @param name is a string, the name given to the new mesh
  142511. * @param newGenerator use new generator object for cloned trail mesh
  142512. * @returns a new mesh
  142513. */
  142514. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  142515. /**
  142516. * Serializes this trail mesh
  142517. * @param serializationObject object to write serialization to
  142518. */
  142519. serialize(serializationObject: any): void;
  142520. /**
  142521. * Parses a serialized trail mesh
  142522. * @param parsedMesh the serialized mesh
  142523. * @param scene the scene to create the trail mesh in
  142524. * @returns the created trail mesh
  142525. */
  142526. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  142527. }
  142528. }
  142529. declare module BABYLON {
  142530. /**
  142531. * Class containing static functions to help procedurally build meshes
  142532. */
  142533. export class TiledBoxBuilder {
  142534. /**
  142535. * Creates a box mesh
  142536. * 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)
  142537. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142541. * @param name defines the name of the mesh
  142542. * @param options defines the options used to create the mesh
  142543. * @param scene defines the hosting scene
  142544. * @returns the box mesh
  142545. */
  142546. static CreateTiledBox(name: string, options: {
  142547. pattern?: number;
  142548. width?: number;
  142549. height?: number;
  142550. depth?: number;
  142551. tileSize?: number;
  142552. tileWidth?: number;
  142553. tileHeight?: number;
  142554. alignHorizontal?: number;
  142555. alignVertical?: number;
  142556. faceUV?: Vector4[];
  142557. faceColors?: Color4[];
  142558. sideOrientation?: number;
  142559. updatable?: boolean;
  142560. }, scene?: Nullable<Scene>): Mesh;
  142561. }
  142562. }
  142563. declare module BABYLON {
  142564. /**
  142565. * Class containing static functions to help procedurally build meshes
  142566. */
  142567. export class TorusKnotBuilder {
  142568. /**
  142569. * Creates a torus knot mesh
  142570. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  142571. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  142572. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  142573. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  142574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142577. * @param name defines the name of the mesh
  142578. * @param options defines the options used to create the mesh
  142579. * @param scene defines the hosting scene
  142580. * @returns the torus knot mesh
  142581. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  142582. */
  142583. static CreateTorusKnot(name: string, options: {
  142584. radius?: number;
  142585. tube?: number;
  142586. radialSegments?: number;
  142587. tubularSegments?: number;
  142588. p?: number;
  142589. q?: number;
  142590. updatable?: boolean;
  142591. sideOrientation?: number;
  142592. frontUVs?: Vector4;
  142593. backUVs?: Vector4;
  142594. }, scene: any): Mesh;
  142595. }
  142596. }
  142597. declare module BABYLON {
  142598. /**
  142599. * Polygon
  142600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  142601. */
  142602. export class Polygon {
  142603. /**
  142604. * Creates a rectangle
  142605. * @param xmin bottom X coord
  142606. * @param ymin bottom Y coord
  142607. * @param xmax top X coord
  142608. * @param ymax top Y coord
  142609. * @returns points that make the resulting rectation
  142610. */
  142611. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  142612. /**
  142613. * Creates a circle
  142614. * @param radius radius of circle
  142615. * @param cx scale in x
  142616. * @param cy scale in y
  142617. * @param numberOfSides number of sides that make up the circle
  142618. * @returns points that make the resulting circle
  142619. */
  142620. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  142621. /**
  142622. * Creates a polygon from input string
  142623. * @param input Input polygon data
  142624. * @returns the parsed points
  142625. */
  142626. static Parse(input: string): Vector2[];
  142627. /**
  142628. * Starts building a polygon from x and y coordinates
  142629. * @param x x coordinate
  142630. * @param y y coordinate
  142631. * @returns the started path2
  142632. */
  142633. static StartingAt(x: number, y: number): Path2;
  142634. }
  142635. /**
  142636. * Builds a polygon
  142637. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  142638. */
  142639. export class PolygonMeshBuilder {
  142640. private _points;
  142641. private _outlinepoints;
  142642. private _holes;
  142643. private _name;
  142644. private _scene;
  142645. private _epoints;
  142646. private _eholes;
  142647. private _addToepoint;
  142648. /**
  142649. * Babylon reference to the earcut plugin.
  142650. */
  142651. bjsEarcut: any;
  142652. /**
  142653. * Creates a PolygonMeshBuilder
  142654. * @param name name of the builder
  142655. * @param contours Path of the polygon
  142656. * @param scene scene to add to when creating the mesh
  142657. * @param earcutInjection can be used to inject your own earcut reference
  142658. */
  142659. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  142660. /**
  142661. * Adds a whole within the polygon
  142662. * @param hole Array of points defining the hole
  142663. * @returns this
  142664. */
  142665. addHole(hole: Vector2[]): PolygonMeshBuilder;
  142666. /**
  142667. * Creates the polygon
  142668. * @param updatable If the mesh should be updatable
  142669. * @param depth The depth of the mesh created
  142670. * @returns the created mesh
  142671. */
  142672. build(updatable?: boolean, depth?: number): Mesh;
  142673. /**
  142674. * Creates the polygon
  142675. * @param depth The depth of the mesh created
  142676. * @returns the created VertexData
  142677. */
  142678. buildVertexData(depth?: number): VertexData;
  142679. /**
  142680. * Adds a side to the polygon
  142681. * @param positions points that make the polygon
  142682. * @param normals normals of the polygon
  142683. * @param uvs uvs of the polygon
  142684. * @param indices indices of the polygon
  142685. * @param bounds bounds of the polygon
  142686. * @param points points of the polygon
  142687. * @param depth depth of the polygon
  142688. * @param flip flip of the polygon
  142689. */
  142690. private addSide;
  142691. }
  142692. }
  142693. declare module BABYLON {
  142694. /**
  142695. * Class containing static functions to help procedurally build meshes
  142696. */
  142697. export class PolygonBuilder {
  142698. /**
  142699. * Creates a polygon mesh
  142700. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  142701. * * 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
  142702. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  142705. * * Remember you can only change the shape positions, not their number when updating a polygon
  142706. * @param name defines the name of the mesh
  142707. * @param options defines the options used to create the mesh
  142708. * @param scene defines the hosting scene
  142709. * @param earcutInjection can be used to inject your own earcut reference
  142710. * @returns the polygon mesh
  142711. */
  142712. static CreatePolygon(name: string, options: {
  142713. shape: Vector3[];
  142714. holes?: Vector3[][];
  142715. depth?: number;
  142716. faceUV?: Vector4[];
  142717. faceColors?: Color4[];
  142718. updatable?: boolean;
  142719. sideOrientation?: number;
  142720. frontUVs?: Vector4;
  142721. backUVs?: Vector4;
  142722. wrap?: boolean;
  142723. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142724. /**
  142725. * Creates an extruded polygon mesh, with depth in the Y direction.
  142726. * * 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)
  142727. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142728. * @param name defines the name of the mesh
  142729. * @param options defines the options used to create the mesh
  142730. * @param scene defines the hosting scene
  142731. * @param earcutInjection can be used to inject your own earcut reference
  142732. * @returns the polygon mesh
  142733. */
  142734. static ExtrudePolygon(name: string, options: {
  142735. shape: Vector3[];
  142736. holes?: Vector3[][];
  142737. depth?: number;
  142738. faceUV?: Vector4[];
  142739. faceColors?: Color4[];
  142740. updatable?: boolean;
  142741. sideOrientation?: number;
  142742. frontUVs?: Vector4;
  142743. backUVs?: Vector4;
  142744. wrap?: boolean;
  142745. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142746. }
  142747. }
  142748. declare module BABYLON {
  142749. /**
  142750. * Class containing static functions to help procedurally build meshes
  142751. */
  142752. export class LatheBuilder {
  142753. /**
  142754. * Creates lathe mesh.
  142755. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142756. * * 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
  142757. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142758. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142759. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142760. * * 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
  142761. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142762. * * 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
  142763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142764. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142765. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142767. * @param name defines the name of the mesh
  142768. * @param options defines the options used to create the mesh
  142769. * @param scene defines the hosting scene
  142770. * @returns the lathe mesh
  142771. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142772. */
  142773. static CreateLathe(name: string, options: {
  142774. shape: Vector3[];
  142775. radius?: number;
  142776. tessellation?: number;
  142777. clip?: number;
  142778. arc?: number;
  142779. closed?: boolean;
  142780. updatable?: boolean;
  142781. sideOrientation?: number;
  142782. frontUVs?: Vector4;
  142783. backUVs?: Vector4;
  142784. cap?: number;
  142785. invertUV?: boolean;
  142786. }, scene?: Nullable<Scene>): Mesh;
  142787. }
  142788. }
  142789. declare module BABYLON {
  142790. /**
  142791. * Class containing static functions to help procedurally build meshes
  142792. */
  142793. export class TiledPlaneBuilder {
  142794. /**
  142795. * Creates a tiled plane mesh
  142796. * * The parameter `pattern` will, depending on value, do nothing or
  142797. * * * flip (reflect about central vertical) alternate tiles across and up
  142798. * * * flip every tile on alternate rows
  142799. * * * rotate (180 degs) alternate tiles across and up
  142800. * * * rotate every tile on alternate rows
  142801. * * * flip and rotate alternate tiles across and up
  142802. * * * flip and rotate every tile on alternate rows
  142803. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  142804. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  142805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142806. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142807. * * 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)
  142808. * * 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)
  142809. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142810. * @param name defines the name of the mesh
  142811. * @param options defines the options used to create the mesh
  142812. * @param scene defines the hosting scene
  142813. * @returns the box mesh
  142814. */
  142815. static CreateTiledPlane(name: string, options: {
  142816. pattern?: number;
  142817. tileSize?: number;
  142818. tileWidth?: number;
  142819. tileHeight?: number;
  142820. size?: number;
  142821. width?: number;
  142822. height?: number;
  142823. alignHorizontal?: number;
  142824. alignVertical?: number;
  142825. sideOrientation?: number;
  142826. frontUVs?: Vector4;
  142827. backUVs?: Vector4;
  142828. updatable?: boolean;
  142829. }, scene?: Nullable<Scene>): Mesh;
  142830. }
  142831. }
  142832. declare module BABYLON {
  142833. /**
  142834. * Class containing static functions to help procedurally build meshes
  142835. */
  142836. export class TubeBuilder {
  142837. /**
  142838. * Creates a tube mesh.
  142839. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142840. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142841. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142842. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142843. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142844. * * 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)
  142845. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142846. * * 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
  142847. * * 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
  142848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142849. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142850. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142852. * @param name defines the name of the mesh
  142853. * @param options defines the options used to create the mesh
  142854. * @param scene defines the hosting scene
  142855. * @returns the tube mesh
  142856. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142857. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142858. */
  142859. static CreateTube(name: string, options: {
  142860. path: Vector3[];
  142861. radius?: number;
  142862. tessellation?: number;
  142863. radiusFunction?: {
  142864. (i: number, distance: number): number;
  142865. };
  142866. cap?: number;
  142867. arc?: number;
  142868. updatable?: boolean;
  142869. sideOrientation?: number;
  142870. frontUVs?: Vector4;
  142871. backUVs?: Vector4;
  142872. instance?: Mesh;
  142873. invertUV?: boolean;
  142874. }, scene?: Nullable<Scene>): Mesh;
  142875. }
  142876. }
  142877. declare module BABYLON {
  142878. /**
  142879. * Class containing static functions to help procedurally build meshes
  142880. */
  142881. export class IcoSphereBuilder {
  142882. /**
  142883. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142884. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142885. * * 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`)
  142886. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142887. * * 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
  142888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142891. * @param name defines the name of the mesh
  142892. * @param options defines the options used to create the mesh
  142893. * @param scene defines the hosting scene
  142894. * @returns the icosahedron mesh
  142895. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142896. */
  142897. static CreateIcoSphere(name: string, options: {
  142898. radius?: number;
  142899. radiusX?: number;
  142900. radiusY?: number;
  142901. radiusZ?: number;
  142902. flat?: boolean;
  142903. subdivisions?: number;
  142904. sideOrientation?: number;
  142905. frontUVs?: Vector4;
  142906. backUVs?: Vector4;
  142907. updatable?: boolean;
  142908. }, scene?: Nullable<Scene>): Mesh;
  142909. }
  142910. }
  142911. declare module BABYLON {
  142912. /**
  142913. * Class containing static functions to help procedurally build meshes
  142914. */
  142915. export class DecalBuilder {
  142916. /**
  142917. * Creates a decal mesh.
  142918. * 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
  142919. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142920. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142921. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142922. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142923. * @param name defines the name of the mesh
  142924. * @param sourceMesh defines the mesh where the decal must be applied
  142925. * @param options defines the options used to create the mesh
  142926. * @param scene defines the hosting scene
  142927. * @returns the decal mesh
  142928. * @see https://doc.babylonjs.com/how_to/decals
  142929. */
  142930. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142931. position?: Vector3;
  142932. normal?: Vector3;
  142933. size?: Vector3;
  142934. angle?: number;
  142935. }): Mesh;
  142936. }
  142937. }
  142938. declare module BABYLON {
  142939. /**
  142940. * Class containing static functions to help procedurally build meshes
  142941. */
  142942. export class MeshBuilder {
  142943. /**
  142944. * Creates a box mesh
  142945. * * The parameter `size` sets the size (float) of each box side (default 1)
  142946. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  142947. * * 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)
  142948. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142950. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142952. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142953. * @param name defines the name of the mesh
  142954. * @param options defines the options used to create the mesh
  142955. * @param scene defines the hosting scene
  142956. * @returns the box mesh
  142957. */
  142958. static CreateBox(name: string, options: {
  142959. size?: number;
  142960. width?: number;
  142961. height?: number;
  142962. depth?: number;
  142963. faceUV?: Vector4[];
  142964. faceColors?: Color4[];
  142965. sideOrientation?: number;
  142966. frontUVs?: Vector4;
  142967. backUVs?: Vector4;
  142968. wrap?: boolean;
  142969. topBaseAt?: number;
  142970. bottomBaseAt?: number;
  142971. updatable?: boolean;
  142972. }, scene?: Nullable<Scene>): Mesh;
  142973. /**
  142974. * Creates a tiled box mesh
  142975. * * faceTiles sets the pattern, tile size and number of tiles for a face
  142976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142977. * @param name defines the name of the mesh
  142978. * @param options defines the options used to create the mesh
  142979. * @param scene defines the hosting scene
  142980. * @returns the tiled box mesh
  142981. */
  142982. static CreateTiledBox(name: string, options: {
  142983. pattern?: number;
  142984. size?: number;
  142985. width?: number;
  142986. height?: number;
  142987. depth: number;
  142988. tileSize?: number;
  142989. tileWidth?: number;
  142990. tileHeight?: number;
  142991. faceUV?: Vector4[];
  142992. faceColors?: Color4[];
  142993. alignHorizontal?: number;
  142994. alignVertical?: number;
  142995. sideOrientation?: number;
  142996. updatable?: boolean;
  142997. }, scene?: Nullable<Scene>): Mesh;
  142998. /**
  142999. * Creates a sphere mesh
  143000. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  143001. * * 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`)
  143002. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  143003. * * 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
  143004. * * 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)
  143005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143008. * @param name defines the name of the mesh
  143009. * @param options defines the options used to create the mesh
  143010. * @param scene defines the hosting scene
  143011. * @returns the sphere mesh
  143012. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  143013. */
  143014. static CreateSphere(name: string, options: {
  143015. segments?: number;
  143016. diameter?: number;
  143017. diameterX?: number;
  143018. diameterY?: number;
  143019. diameterZ?: number;
  143020. arc?: number;
  143021. slice?: number;
  143022. sideOrientation?: number;
  143023. frontUVs?: Vector4;
  143024. backUVs?: Vector4;
  143025. updatable?: boolean;
  143026. }, scene?: Nullable<Scene>): Mesh;
  143027. /**
  143028. * Creates a plane polygonal mesh. By default, this is a disc
  143029. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  143030. * * 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
  143031. * * 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
  143032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143033. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143035. * @param name defines the name of the mesh
  143036. * @param options defines the options used to create the mesh
  143037. * @param scene defines the hosting scene
  143038. * @returns the plane polygonal mesh
  143039. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  143040. */
  143041. static CreateDisc(name: string, options: {
  143042. radius?: number;
  143043. tessellation?: number;
  143044. arc?: number;
  143045. updatable?: boolean;
  143046. sideOrientation?: number;
  143047. frontUVs?: Vector4;
  143048. backUVs?: Vector4;
  143049. }, scene?: Nullable<Scene>): Mesh;
  143050. /**
  143051. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  143052. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  143053. * * 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`)
  143054. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  143055. * * 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
  143056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143059. * @param name defines the name of the mesh
  143060. * @param options defines the options used to create the mesh
  143061. * @param scene defines the hosting scene
  143062. * @returns the icosahedron mesh
  143063. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  143064. */
  143065. static CreateIcoSphere(name: string, options: {
  143066. radius?: number;
  143067. radiusX?: number;
  143068. radiusY?: number;
  143069. radiusZ?: number;
  143070. flat?: boolean;
  143071. subdivisions?: number;
  143072. sideOrientation?: number;
  143073. frontUVs?: Vector4;
  143074. backUVs?: Vector4;
  143075. updatable?: boolean;
  143076. }, scene?: Nullable<Scene>): Mesh;
  143077. /**
  143078. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143079. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  143080. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  143081. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  143082. * * 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
  143083. * * 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
  143084. * * 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
  143085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143086. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143087. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143088. * * 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
  143089. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  143090. * * 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
  143091. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  143092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143093. * @param name defines the name of the mesh
  143094. * @param options defines the options used to create the mesh
  143095. * @param scene defines the hosting scene
  143096. * @returns the ribbon mesh
  143097. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  143098. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143099. */
  143100. static CreateRibbon(name: string, options: {
  143101. pathArray: Vector3[][];
  143102. closeArray?: boolean;
  143103. closePath?: boolean;
  143104. offset?: number;
  143105. updatable?: boolean;
  143106. sideOrientation?: number;
  143107. frontUVs?: Vector4;
  143108. backUVs?: Vector4;
  143109. instance?: Mesh;
  143110. invertUV?: boolean;
  143111. uvs?: Vector2[];
  143112. colors?: Color4[];
  143113. }, scene?: Nullable<Scene>): Mesh;
  143114. /**
  143115. * Creates a cylinder or a cone mesh
  143116. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  143117. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  143118. * * 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.
  143119. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  143120. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  143121. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  143122. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  143123. * * 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).
  143124. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  143125. * * 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).
  143126. * * 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
  143127. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  143128. * * 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
  143129. * * 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.
  143130. * * If `enclose` is false, a ring surface is one element.
  143131. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  143132. * * 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
  143133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143136. * @param name defines the name of the mesh
  143137. * @param options defines the options used to create the mesh
  143138. * @param scene defines the hosting scene
  143139. * @returns the cylinder mesh
  143140. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  143141. */
  143142. static CreateCylinder(name: string, options: {
  143143. height?: number;
  143144. diameterTop?: number;
  143145. diameterBottom?: number;
  143146. diameter?: number;
  143147. tessellation?: number;
  143148. subdivisions?: number;
  143149. arc?: number;
  143150. faceColors?: Color4[];
  143151. faceUV?: Vector4[];
  143152. updatable?: boolean;
  143153. hasRings?: boolean;
  143154. enclose?: boolean;
  143155. cap?: number;
  143156. sideOrientation?: number;
  143157. frontUVs?: Vector4;
  143158. backUVs?: Vector4;
  143159. }, scene?: Nullable<Scene>): Mesh;
  143160. /**
  143161. * Creates a torus mesh
  143162. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  143163. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  143164. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  143165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143168. * @param name defines the name of the mesh
  143169. * @param options defines the options used to create the mesh
  143170. * @param scene defines the hosting scene
  143171. * @returns the torus mesh
  143172. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  143173. */
  143174. static CreateTorus(name: string, options: {
  143175. diameter?: number;
  143176. thickness?: number;
  143177. tessellation?: number;
  143178. updatable?: boolean;
  143179. sideOrientation?: number;
  143180. frontUVs?: Vector4;
  143181. backUVs?: Vector4;
  143182. }, scene?: Nullable<Scene>): Mesh;
  143183. /**
  143184. * Creates a torus knot mesh
  143185. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  143186. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  143187. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  143188. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  143189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143192. * @param name defines the name of the mesh
  143193. * @param options defines the options used to create the mesh
  143194. * @param scene defines the hosting scene
  143195. * @returns the torus knot mesh
  143196. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  143197. */
  143198. static CreateTorusKnot(name: string, options: {
  143199. radius?: number;
  143200. tube?: number;
  143201. radialSegments?: number;
  143202. tubularSegments?: number;
  143203. p?: number;
  143204. q?: number;
  143205. updatable?: boolean;
  143206. sideOrientation?: number;
  143207. frontUVs?: Vector4;
  143208. backUVs?: Vector4;
  143209. }, scene?: Nullable<Scene>): Mesh;
  143210. /**
  143211. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  143212. * * 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
  143213. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  143214. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  143215. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  143216. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  143217. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  143218. * * 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
  143219. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  143220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143221. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  143222. * @param name defines the name of the new line system
  143223. * @param options defines the options used to create the line system
  143224. * @param scene defines the hosting scene
  143225. * @returns a new line system mesh
  143226. */
  143227. static CreateLineSystem(name: string, options: {
  143228. lines: Vector3[][];
  143229. updatable?: boolean;
  143230. instance?: Nullable<LinesMesh>;
  143231. colors?: Nullable<Color4[][]>;
  143232. useVertexAlpha?: boolean;
  143233. }, scene: Nullable<Scene>): LinesMesh;
  143234. /**
  143235. * Creates a line mesh
  143236. * 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
  143237. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  143238. * * The parameter `points` is an array successive Vector3
  143239. * * 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
  143240. * * The optional parameter `colors` is an array of successive Color4, one per line point
  143241. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  143242. * * When updating an instance, remember that only point positions can change, not the number of points
  143243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  143245. * @param name defines the name of the new line system
  143246. * @param options defines the options used to create the line system
  143247. * @param scene defines the hosting scene
  143248. * @returns a new line mesh
  143249. */
  143250. static CreateLines(name: string, options: {
  143251. points: Vector3[];
  143252. updatable?: boolean;
  143253. instance?: Nullable<LinesMesh>;
  143254. colors?: Color4[];
  143255. useVertexAlpha?: boolean;
  143256. }, scene?: Nullable<Scene>): LinesMesh;
  143257. /**
  143258. * Creates a dashed line mesh
  143259. * * 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
  143260. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  143261. * * The parameter `points` is an array successive Vector3
  143262. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  143263. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  143264. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  143265. * * 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
  143266. * * When updating an instance, remember that only point positions can change, not the number of points
  143267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143268. * @param name defines the name of the mesh
  143269. * @param options defines the options used to create the mesh
  143270. * @param scene defines the hosting scene
  143271. * @returns the dashed line mesh
  143272. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  143273. */
  143274. static CreateDashedLines(name: string, options: {
  143275. points: Vector3[];
  143276. dashSize?: number;
  143277. gapSize?: number;
  143278. dashNb?: number;
  143279. updatable?: boolean;
  143280. instance?: LinesMesh;
  143281. }, scene?: Nullable<Scene>): LinesMesh;
  143282. /**
  143283. * 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.
  143284. * * 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.
  143285. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143286. * * 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.
  143287. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  143288. * * 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
  143289. * * 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
  143290. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  143291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143293. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  143294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143295. * @param name defines the name of the mesh
  143296. * @param options defines the options used to create the mesh
  143297. * @param scene defines the hosting scene
  143298. * @returns the extruded shape mesh
  143299. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143300. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143301. */
  143302. static ExtrudeShape(name: string, options: {
  143303. shape: Vector3[];
  143304. path: Vector3[];
  143305. scale?: number;
  143306. rotation?: number;
  143307. cap?: number;
  143308. updatable?: boolean;
  143309. sideOrientation?: number;
  143310. frontUVs?: Vector4;
  143311. backUVs?: Vector4;
  143312. instance?: Mesh;
  143313. invertUV?: boolean;
  143314. }, scene?: Nullable<Scene>): Mesh;
  143315. /**
  143316. * Creates an custom extruded shape mesh.
  143317. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  143318. * * 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.
  143319. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143320. * * 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
  143321. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  143322. * * 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
  143323. * * It must returns a float value that will be the scale value applied to the shape on each path point
  143324. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  143325. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  143326. * * 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
  143327. * * 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
  143328. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  143329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143331. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143333. * @param name defines the name of the mesh
  143334. * @param options defines the options used to create the mesh
  143335. * @param scene defines the hosting scene
  143336. * @returns the custom extruded shape mesh
  143337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  143338. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143339. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143340. */
  143341. static ExtrudeShapeCustom(name: string, options: {
  143342. shape: Vector3[];
  143343. path: Vector3[];
  143344. scaleFunction?: any;
  143345. rotationFunction?: any;
  143346. ribbonCloseArray?: boolean;
  143347. ribbonClosePath?: boolean;
  143348. cap?: number;
  143349. updatable?: boolean;
  143350. sideOrientation?: number;
  143351. frontUVs?: Vector4;
  143352. backUVs?: Vector4;
  143353. instance?: Mesh;
  143354. invertUV?: boolean;
  143355. }, scene?: Nullable<Scene>): Mesh;
  143356. /**
  143357. * Creates lathe mesh.
  143358. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  143359. * * 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
  143360. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  143361. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  143362. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  143363. * * 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
  143364. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  143365. * * 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
  143366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143368. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143370. * @param name defines the name of the mesh
  143371. * @param options defines the options used to create the mesh
  143372. * @param scene defines the hosting scene
  143373. * @returns the lathe mesh
  143374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  143375. */
  143376. static CreateLathe(name: string, options: {
  143377. shape: Vector3[];
  143378. radius?: number;
  143379. tessellation?: number;
  143380. clip?: number;
  143381. arc?: number;
  143382. closed?: boolean;
  143383. updatable?: boolean;
  143384. sideOrientation?: number;
  143385. frontUVs?: Vector4;
  143386. backUVs?: Vector4;
  143387. cap?: number;
  143388. invertUV?: boolean;
  143389. }, scene?: Nullable<Scene>): Mesh;
  143390. /**
  143391. * Creates a tiled plane mesh
  143392. * * You can set a limited pattern arrangement with the tiles
  143393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143394. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143396. * @param name defines the name of the mesh
  143397. * @param options defines the options used to create the mesh
  143398. * @param scene defines the hosting scene
  143399. * @returns the plane mesh
  143400. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  143401. */
  143402. static CreateTiledPlane(name: string, options: {
  143403. pattern?: number;
  143404. tileSize?: number;
  143405. tileWidth?: number;
  143406. tileHeight?: number;
  143407. size?: number;
  143408. width?: number;
  143409. height?: number;
  143410. alignHorizontal?: number;
  143411. alignVertical?: number;
  143412. sideOrientation?: number;
  143413. frontUVs?: Vector4;
  143414. backUVs?: Vector4;
  143415. updatable?: boolean;
  143416. }, scene?: Nullable<Scene>): Mesh;
  143417. /**
  143418. * Creates a plane mesh
  143419. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  143420. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  143421. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  143422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143425. * @param name defines the name of the mesh
  143426. * @param options defines the options used to create the mesh
  143427. * @param scene defines the hosting scene
  143428. * @returns the plane mesh
  143429. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  143430. */
  143431. static CreatePlane(name: string, options: {
  143432. size?: number;
  143433. width?: number;
  143434. height?: number;
  143435. sideOrientation?: number;
  143436. frontUVs?: Vector4;
  143437. backUVs?: Vector4;
  143438. updatable?: boolean;
  143439. sourcePlane?: Plane;
  143440. }, scene?: Nullable<Scene>): Mesh;
  143441. /**
  143442. * Creates a ground mesh
  143443. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  143444. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  143445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143446. * @param name defines the name of the mesh
  143447. * @param options defines the options used to create the mesh
  143448. * @param scene defines the hosting scene
  143449. * @returns the ground mesh
  143450. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  143451. */
  143452. static CreateGround(name: string, options: {
  143453. width?: number;
  143454. height?: number;
  143455. subdivisions?: number;
  143456. subdivisionsX?: number;
  143457. subdivisionsY?: number;
  143458. updatable?: boolean;
  143459. }, scene?: Nullable<Scene>): Mesh;
  143460. /**
  143461. * Creates a tiled ground mesh
  143462. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  143463. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  143464. * * 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
  143465. * * 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
  143466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143467. * @param name defines the name of the mesh
  143468. * @param options defines the options used to create the mesh
  143469. * @param scene defines the hosting scene
  143470. * @returns the tiled ground mesh
  143471. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  143472. */
  143473. static CreateTiledGround(name: string, options: {
  143474. xmin: number;
  143475. zmin: number;
  143476. xmax: number;
  143477. zmax: number;
  143478. subdivisions?: {
  143479. w: number;
  143480. h: number;
  143481. };
  143482. precision?: {
  143483. w: number;
  143484. h: number;
  143485. };
  143486. updatable?: boolean;
  143487. }, scene?: Nullable<Scene>): Mesh;
  143488. /**
  143489. * Creates a ground mesh from a height map
  143490. * * The parameter `url` sets the URL of the height map image resource.
  143491. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  143492. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  143493. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  143494. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  143495. * * 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.
  143496. * * 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).
  143497. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  143498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143499. * @param name defines the name of the mesh
  143500. * @param url defines the url to the height map
  143501. * @param options defines the options used to create the mesh
  143502. * @param scene defines the hosting scene
  143503. * @returns the ground mesh
  143504. * @see https://doc.babylonjs.com/babylon101/height_map
  143505. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  143506. */
  143507. static CreateGroundFromHeightMap(name: string, url: string, options: {
  143508. width?: number;
  143509. height?: number;
  143510. subdivisions?: number;
  143511. minHeight?: number;
  143512. maxHeight?: number;
  143513. colorFilter?: Color3;
  143514. alphaFilter?: number;
  143515. updatable?: boolean;
  143516. onReady?: (mesh: GroundMesh) => void;
  143517. }, scene?: Nullable<Scene>): GroundMesh;
  143518. /**
  143519. * Creates a polygon mesh
  143520. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  143521. * * 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
  143522. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  143525. * * Remember you can only change the shape positions, not their number when updating a polygon
  143526. * @param name defines the name of the mesh
  143527. * @param options defines the options used to create the mesh
  143528. * @param scene defines the hosting scene
  143529. * @param earcutInjection can be used to inject your own earcut reference
  143530. * @returns the polygon mesh
  143531. */
  143532. static CreatePolygon(name: string, options: {
  143533. shape: Vector3[];
  143534. holes?: Vector3[][];
  143535. depth?: number;
  143536. faceUV?: Vector4[];
  143537. faceColors?: Color4[];
  143538. updatable?: boolean;
  143539. sideOrientation?: number;
  143540. frontUVs?: Vector4;
  143541. backUVs?: Vector4;
  143542. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143543. /**
  143544. * Creates an extruded polygon mesh, with depth in the Y direction.
  143545. * * 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)
  143546. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143547. * @param name defines the name of the mesh
  143548. * @param options defines the options used to create the mesh
  143549. * @param scene defines the hosting scene
  143550. * @param earcutInjection can be used to inject your own earcut reference
  143551. * @returns the polygon mesh
  143552. */
  143553. static ExtrudePolygon(name: string, options: {
  143554. shape: Vector3[];
  143555. holes?: Vector3[][];
  143556. depth?: number;
  143557. faceUV?: Vector4[];
  143558. faceColors?: Color4[];
  143559. updatable?: boolean;
  143560. sideOrientation?: number;
  143561. frontUVs?: Vector4;
  143562. backUVs?: Vector4;
  143563. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143564. /**
  143565. * Creates a tube mesh.
  143566. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143567. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  143568. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  143569. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  143570. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  143571. * * 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)
  143572. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  143573. * * 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
  143574. * * 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
  143575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143577. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143579. * @param name defines the name of the mesh
  143580. * @param options defines the options used to create the mesh
  143581. * @param scene defines the hosting scene
  143582. * @returns the tube mesh
  143583. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143584. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  143585. */
  143586. static CreateTube(name: string, options: {
  143587. path: Vector3[];
  143588. radius?: number;
  143589. tessellation?: number;
  143590. radiusFunction?: {
  143591. (i: number, distance: number): number;
  143592. };
  143593. cap?: number;
  143594. arc?: number;
  143595. updatable?: boolean;
  143596. sideOrientation?: number;
  143597. frontUVs?: Vector4;
  143598. backUVs?: Vector4;
  143599. instance?: Mesh;
  143600. invertUV?: boolean;
  143601. }, scene?: Nullable<Scene>): Mesh;
  143602. /**
  143603. * Creates a polyhedron mesh
  143604. * * 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
  143605. * * The parameter `size` (positive float, default 1) sets the polygon size
  143606. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  143607. * * 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`
  143608. * * 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
  143609. * * 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)`)
  143610. * * 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
  143611. * * 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
  143612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143615. * @param name defines the name of the mesh
  143616. * @param options defines the options used to create the mesh
  143617. * @param scene defines the hosting scene
  143618. * @returns the polyhedron mesh
  143619. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  143620. */
  143621. static CreatePolyhedron(name: string, options: {
  143622. type?: number;
  143623. size?: number;
  143624. sizeX?: number;
  143625. sizeY?: number;
  143626. sizeZ?: number;
  143627. custom?: any;
  143628. faceUV?: Vector4[];
  143629. faceColors?: Color4[];
  143630. flat?: boolean;
  143631. updatable?: boolean;
  143632. sideOrientation?: number;
  143633. frontUVs?: Vector4;
  143634. backUVs?: Vector4;
  143635. }, scene?: Nullable<Scene>): Mesh;
  143636. /**
  143637. * Creates a decal mesh.
  143638. * 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
  143639. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  143640. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  143641. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  143642. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  143643. * @param name defines the name of the mesh
  143644. * @param sourceMesh defines the mesh where the decal must be applied
  143645. * @param options defines the options used to create the mesh
  143646. * @param scene defines the hosting scene
  143647. * @returns the decal mesh
  143648. * @see https://doc.babylonjs.com/how_to/decals
  143649. */
  143650. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  143651. position?: Vector3;
  143652. normal?: Vector3;
  143653. size?: Vector3;
  143654. angle?: number;
  143655. }): Mesh;
  143656. }
  143657. }
  143658. declare module BABYLON {
  143659. /**
  143660. * A simplifier interface for future simplification implementations
  143661. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143662. */
  143663. export interface ISimplifier {
  143664. /**
  143665. * Simplification of a given mesh according to the given settings.
  143666. * Since this requires computation, it is assumed that the function runs async.
  143667. * @param settings The settings of the simplification, including quality and distance
  143668. * @param successCallback A callback that will be called after the mesh was simplified.
  143669. * @param errorCallback in case of an error, this callback will be called. optional.
  143670. */
  143671. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  143672. }
  143673. /**
  143674. * Expected simplification settings.
  143675. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  143676. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143677. */
  143678. export interface ISimplificationSettings {
  143679. /**
  143680. * Gets or sets the expected quality
  143681. */
  143682. quality: number;
  143683. /**
  143684. * Gets or sets the distance when this optimized version should be used
  143685. */
  143686. distance: number;
  143687. /**
  143688. * Gets an already optimized mesh
  143689. */
  143690. optimizeMesh?: boolean;
  143691. }
  143692. /**
  143693. * Class used to specify simplification options
  143694. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143695. */
  143696. export class SimplificationSettings implements ISimplificationSettings {
  143697. /** expected quality */
  143698. quality: number;
  143699. /** distance when this optimized version should be used */
  143700. distance: number;
  143701. /** already optimized mesh */
  143702. optimizeMesh?: boolean | undefined;
  143703. /**
  143704. * Creates a SimplificationSettings
  143705. * @param quality expected quality
  143706. * @param distance distance when this optimized version should be used
  143707. * @param optimizeMesh already optimized mesh
  143708. */
  143709. constructor(
  143710. /** expected quality */
  143711. quality: number,
  143712. /** distance when this optimized version should be used */
  143713. distance: number,
  143714. /** already optimized mesh */
  143715. optimizeMesh?: boolean | undefined);
  143716. }
  143717. /**
  143718. * Interface used to define a simplification task
  143719. */
  143720. export interface ISimplificationTask {
  143721. /**
  143722. * Array of settings
  143723. */
  143724. settings: Array<ISimplificationSettings>;
  143725. /**
  143726. * Simplification type
  143727. */
  143728. simplificationType: SimplificationType;
  143729. /**
  143730. * Mesh to simplify
  143731. */
  143732. mesh: Mesh;
  143733. /**
  143734. * Callback called on success
  143735. */
  143736. successCallback?: () => void;
  143737. /**
  143738. * Defines if parallel processing can be used
  143739. */
  143740. parallelProcessing: boolean;
  143741. }
  143742. /**
  143743. * Queue used to order the simplification tasks
  143744. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143745. */
  143746. export class SimplificationQueue {
  143747. private _simplificationArray;
  143748. /**
  143749. * Gets a boolean indicating that the process is still running
  143750. */
  143751. running: boolean;
  143752. /**
  143753. * Creates a new queue
  143754. */
  143755. constructor();
  143756. /**
  143757. * Adds a new simplification task
  143758. * @param task defines a task to add
  143759. */
  143760. addTask(task: ISimplificationTask): void;
  143761. /**
  143762. * Execute next task
  143763. */
  143764. executeNext(): void;
  143765. /**
  143766. * Execute a simplification task
  143767. * @param task defines the task to run
  143768. */
  143769. runSimplification(task: ISimplificationTask): void;
  143770. private getSimplifier;
  143771. }
  143772. /**
  143773. * The implemented types of simplification
  143774. * At the moment only Quadratic Error Decimation is implemented
  143775. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143776. */
  143777. export enum SimplificationType {
  143778. /** Quadratic error decimation */
  143779. QUADRATIC = 0
  143780. }
  143781. /**
  143782. * An implementation of the Quadratic Error simplification algorithm.
  143783. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  143784. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  143785. * @author RaananW
  143786. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143787. */
  143788. export class QuadraticErrorSimplification implements ISimplifier {
  143789. private _mesh;
  143790. private triangles;
  143791. private vertices;
  143792. private references;
  143793. private _reconstructedMesh;
  143794. /** Gets or sets the number pf sync interations */
  143795. syncIterations: number;
  143796. /** Gets or sets the aggressiveness of the simplifier */
  143797. aggressiveness: number;
  143798. /** Gets or sets the number of allowed iterations for decimation */
  143799. decimationIterations: number;
  143800. /** Gets or sets the espilon to use for bounding box computation */
  143801. boundingBoxEpsilon: number;
  143802. /**
  143803. * Creates a new QuadraticErrorSimplification
  143804. * @param _mesh defines the target mesh
  143805. */
  143806. constructor(_mesh: Mesh);
  143807. /**
  143808. * Simplification of a given mesh according to the given settings.
  143809. * Since this requires computation, it is assumed that the function runs async.
  143810. * @param settings The settings of the simplification, including quality and distance
  143811. * @param successCallback A callback that will be called after the mesh was simplified.
  143812. */
  143813. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  143814. private runDecimation;
  143815. private initWithMesh;
  143816. private init;
  143817. private reconstructMesh;
  143818. private initDecimatedMesh;
  143819. private isFlipped;
  143820. private updateTriangles;
  143821. private identifyBorder;
  143822. private updateMesh;
  143823. private vertexError;
  143824. private calculateError;
  143825. }
  143826. }
  143827. declare module BABYLON {
  143828. interface Scene {
  143829. /** @hidden (Backing field) */
  143830. _simplificationQueue: SimplificationQueue;
  143831. /**
  143832. * Gets or sets the simplification queue attached to the scene
  143833. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143834. */
  143835. simplificationQueue: SimplificationQueue;
  143836. }
  143837. interface Mesh {
  143838. /**
  143839. * Simplify the mesh according to the given array of settings.
  143840. * Function will return immediately and will simplify async
  143841. * @param settings a collection of simplification settings
  143842. * @param parallelProcessing should all levels calculate parallel or one after the other
  143843. * @param simplificationType the type of simplification to run
  143844. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  143845. * @returns the current mesh
  143846. */
  143847. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  143848. }
  143849. /**
  143850. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  143851. * created in a scene
  143852. */
  143853. export class SimplicationQueueSceneComponent implements ISceneComponent {
  143854. /**
  143855. * The component name helpfull to identify the component in the list of scene components.
  143856. */
  143857. readonly name: string;
  143858. /**
  143859. * The scene the component belongs to.
  143860. */
  143861. scene: Scene;
  143862. /**
  143863. * Creates a new instance of the component for the given scene
  143864. * @param scene Defines the scene to register the component in
  143865. */
  143866. constructor(scene: Scene);
  143867. /**
  143868. * Registers the component in a given scene
  143869. */
  143870. register(): void;
  143871. /**
  143872. * Rebuilds the elements related to this component in case of
  143873. * context lost for instance.
  143874. */
  143875. rebuild(): void;
  143876. /**
  143877. * Disposes the component and the associated ressources
  143878. */
  143879. dispose(): void;
  143880. private _beforeCameraUpdate;
  143881. }
  143882. }
  143883. declare module BABYLON {
  143884. interface Mesh {
  143885. /**
  143886. * Creates a new thin instance
  143887. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  143888. * @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
  143889. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  143890. */
  143891. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  143892. /**
  143893. * Adds the transformation (matrix) of the current mesh as a thin instance
  143894. * @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
  143895. * @returns the thin instance index number
  143896. */
  143897. thinInstanceAddSelf(refresh: boolean): number;
  143898. /**
  143899. * Registers a custom attribute to be used with thin instances
  143900. * @param kind name of the attribute
  143901. * @param stride size in floats of the attribute
  143902. */
  143903. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  143904. /**
  143905. * Sets the matrix of a thin instance
  143906. * @param index index of the thin instance
  143907. * @param matrix matrix to set
  143908. * @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
  143909. */
  143910. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  143911. /**
  143912. * Sets the value of a custom attribute for a thin instance
  143913. * @param kind name of the attribute
  143914. * @param index index of the thin instance
  143915. * @param value value to set
  143916. * @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
  143917. */
  143918. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  143919. /**
  143920. * 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.
  143921. */
  143922. thinInstanceCount: number;
  143923. /**
  143924. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  143925. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  143926. * @param buffer buffer to set
  143927. * @param stride size in floats of each value of the buffer
  143928. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  143929. */
  143930. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  143931. /**
  143932. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  143933. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  143934. */
  143935. thinInstanceBufferUpdated(kind: string): void;
  143936. /**
  143937. * Refreshes the bounding info, taking into account all the thin instances defined
  143938. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  143939. */
  143940. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  143941. /** @hidden */
  143942. _thinInstanceInitializeUserStorage(): void;
  143943. /** @hidden */
  143944. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  143945. /** @hidden */
  143946. _userThinInstanceBuffersStorage: {
  143947. data: {
  143948. [key: string]: Float32Array;
  143949. };
  143950. sizes: {
  143951. [key: string]: number;
  143952. };
  143953. vertexBuffers: {
  143954. [key: string]: Nullable<VertexBuffer>;
  143955. };
  143956. strides: {
  143957. [key: string]: number;
  143958. };
  143959. };
  143960. }
  143961. }
  143962. declare module BABYLON {
  143963. /**
  143964. * Navigation plugin interface to add navigation constrained by a navigation mesh
  143965. */
  143966. export interface INavigationEnginePlugin {
  143967. /**
  143968. * plugin name
  143969. */
  143970. name: string;
  143971. /**
  143972. * Creates a navigation mesh
  143973. * @param meshes array of all the geometry used to compute the navigatio mesh
  143974. * @param parameters bunch of parameters used to filter geometry
  143975. */
  143976. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143977. /**
  143978. * Create a navigation mesh debug mesh
  143979. * @param scene is where the mesh will be added
  143980. * @returns debug display mesh
  143981. */
  143982. createDebugNavMesh(scene: Scene): Mesh;
  143983. /**
  143984. * Get a navigation mesh constrained position, closest to the parameter position
  143985. * @param position world position
  143986. * @returns the closest point to position constrained by the navigation mesh
  143987. */
  143988. getClosestPoint(position: Vector3): Vector3;
  143989. /**
  143990. * Get a navigation mesh constrained position, closest to the parameter position
  143991. * @param position world position
  143992. * @param result output the closest point to position constrained by the navigation mesh
  143993. */
  143994. getClosestPointToRef(position: Vector3, result: Vector3): void;
  143995. /**
  143996. * Get a navigation mesh constrained position, within a particular radius
  143997. * @param position world position
  143998. * @param maxRadius the maximum distance to the constrained world position
  143999. * @returns the closest point to position constrained by the navigation mesh
  144000. */
  144001. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144002. /**
  144003. * Get a navigation mesh constrained position, within a particular radius
  144004. * @param position world position
  144005. * @param maxRadius the maximum distance to the constrained world position
  144006. * @param result output the closest point to position constrained by the navigation mesh
  144007. */
  144008. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144009. /**
  144010. * Compute the final position from a segment made of destination-position
  144011. * @param position world position
  144012. * @param destination world position
  144013. * @returns the resulting point along the navmesh
  144014. */
  144015. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144016. /**
  144017. * Compute the final position from a segment made of destination-position
  144018. * @param position world position
  144019. * @param destination world position
  144020. * @param result output the resulting point along the navmesh
  144021. */
  144022. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144023. /**
  144024. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144025. * @param start world position
  144026. * @param end world position
  144027. * @returns array containing world position composing the path
  144028. */
  144029. computePath(start: Vector3, end: Vector3): Vector3[];
  144030. /**
  144031. * If this plugin is supported
  144032. * @returns true if plugin is supported
  144033. */
  144034. isSupported(): boolean;
  144035. /**
  144036. * Create a new Crowd so you can add agents
  144037. * @param maxAgents the maximum agent count in the crowd
  144038. * @param maxAgentRadius the maximum radius an agent can have
  144039. * @param scene to attach the crowd to
  144040. * @returns the crowd you can add agents to
  144041. */
  144042. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144043. /**
  144044. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144045. * The queries will try to find a solution within those bounds
  144046. * default is (1,1,1)
  144047. * @param extent x,y,z value that define the extent around the queries point of reference
  144048. */
  144049. setDefaultQueryExtent(extent: Vector3): void;
  144050. /**
  144051. * Get the Bounding box extent specified by setDefaultQueryExtent
  144052. * @returns the box extent values
  144053. */
  144054. getDefaultQueryExtent(): Vector3;
  144055. /**
  144056. * build the navmesh from a previously saved state using getNavmeshData
  144057. * @param data the Uint8Array returned by getNavmeshData
  144058. */
  144059. buildFromNavmeshData(data: Uint8Array): void;
  144060. /**
  144061. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144062. * @returns data the Uint8Array that can be saved and reused
  144063. */
  144064. getNavmeshData(): Uint8Array;
  144065. /**
  144066. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144067. * @param result output the box extent values
  144068. */
  144069. getDefaultQueryExtentToRef(result: Vector3): void;
  144070. /**
  144071. * Release all resources
  144072. */
  144073. dispose(): void;
  144074. }
  144075. /**
  144076. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  144077. */
  144078. export interface ICrowd {
  144079. /**
  144080. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144081. * You can attach anything to that node. The node position is updated in the scene update tick.
  144082. * @param pos world position that will be constrained by the navigation mesh
  144083. * @param parameters agent parameters
  144084. * @param transform hooked to the agent that will be update by the scene
  144085. * @returns agent index
  144086. */
  144087. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144088. /**
  144089. * Returns the agent position in world space
  144090. * @param index agent index returned by addAgent
  144091. * @returns world space position
  144092. */
  144093. getAgentPosition(index: number): Vector3;
  144094. /**
  144095. * Gets the agent position result in world space
  144096. * @param index agent index returned by addAgent
  144097. * @param result output world space position
  144098. */
  144099. getAgentPositionToRef(index: number, result: Vector3): void;
  144100. /**
  144101. * Gets the agent velocity in world space
  144102. * @param index agent index returned by addAgent
  144103. * @returns world space velocity
  144104. */
  144105. getAgentVelocity(index: number): Vector3;
  144106. /**
  144107. * Gets the agent velocity result in world space
  144108. * @param index agent index returned by addAgent
  144109. * @param result output world space velocity
  144110. */
  144111. getAgentVelocityToRef(index: number, result: Vector3): void;
  144112. /**
  144113. * remove a particular agent previously created
  144114. * @param index agent index returned by addAgent
  144115. */
  144116. removeAgent(index: number): void;
  144117. /**
  144118. * get the list of all agents attached to this crowd
  144119. * @returns list of agent indices
  144120. */
  144121. getAgents(): number[];
  144122. /**
  144123. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144124. * @param deltaTime in seconds
  144125. */
  144126. update(deltaTime: number): void;
  144127. /**
  144128. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144129. * @param index agent index returned by addAgent
  144130. * @param destination targeted world position
  144131. */
  144132. agentGoto(index: number, destination: Vector3): void;
  144133. /**
  144134. * Teleport the agent to a new position
  144135. * @param index agent index returned by addAgent
  144136. * @param destination targeted world position
  144137. */
  144138. agentTeleport(index: number, destination: Vector3): void;
  144139. /**
  144140. * Update agent parameters
  144141. * @param index agent index returned by addAgent
  144142. * @param parameters agent parameters
  144143. */
  144144. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144145. /**
  144146. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144147. * The queries will try to find a solution within those bounds
  144148. * default is (1,1,1)
  144149. * @param extent x,y,z value that define the extent around the queries point of reference
  144150. */
  144151. setDefaultQueryExtent(extent: Vector3): void;
  144152. /**
  144153. * Get the Bounding box extent specified by setDefaultQueryExtent
  144154. * @returns the box extent values
  144155. */
  144156. getDefaultQueryExtent(): Vector3;
  144157. /**
  144158. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144159. * @param result output the box extent values
  144160. */
  144161. getDefaultQueryExtentToRef(result: Vector3): void;
  144162. /**
  144163. * Release all resources
  144164. */
  144165. dispose(): void;
  144166. }
  144167. /**
  144168. * Configures an agent
  144169. */
  144170. export interface IAgentParameters {
  144171. /**
  144172. * Agent radius. [Limit: >= 0]
  144173. */
  144174. radius: number;
  144175. /**
  144176. * Agent height. [Limit: > 0]
  144177. */
  144178. height: number;
  144179. /**
  144180. * Maximum allowed acceleration. [Limit: >= 0]
  144181. */
  144182. maxAcceleration: number;
  144183. /**
  144184. * Maximum allowed speed. [Limit: >= 0]
  144185. */
  144186. maxSpeed: number;
  144187. /**
  144188. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  144189. */
  144190. collisionQueryRange: number;
  144191. /**
  144192. * The path visibility optimization range. [Limit: > 0]
  144193. */
  144194. pathOptimizationRange: number;
  144195. /**
  144196. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  144197. */
  144198. separationWeight: number;
  144199. }
  144200. /**
  144201. * Configures the navigation mesh creation
  144202. */
  144203. export interface INavMeshParameters {
  144204. /**
  144205. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  144206. */
  144207. cs: number;
  144208. /**
  144209. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  144210. */
  144211. ch: number;
  144212. /**
  144213. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  144214. */
  144215. walkableSlopeAngle: number;
  144216. /**
  144217. * Minimum floor to 'ceiling' height that will still allow the floor area to
  144218. * be considered walkable. [Limit: >= 3] [Units: vx]
  144219. */
  144220. walkableHeight: number;
  144221. /**
  144222. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  144223. */
  144224. walkableClimb: number;
  144225. /**
  144226. * The distance to erode/shrink the walkable area of the heightfield away from
  144227. * obstructions. [Limit: >=0] [Units: vx]
  144228. */
  144229. walkableRadius: number;
  144230. /**
  144231. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  144232. */
  144233. maxEdgeLen: number;
  144234. /**
  144235. * The maximum distance a simplfied contour's border edges should deviate
  144236. * the original raw contour. [Limit: >=0] [Units: vx]
  144237. */
  144238. maxSimplificationError: number;
  144239. /**
  144240. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  144241. */
  144242. minRegionArea: number;
  144243. /**
  144244. * Any regions with a span count smaller than this value will, if possible,
  144245. * be merged with larger regions. [Limit: >=0] [Units: vx]
  144246. */
  144247. mergeRegionArea: number;
  144248. /**
  144249. * The maximum number of vertices allowed for polygons generated during the
  144250. * contour to polygon conversion process. [Limit: >= 3]
  144251. */
  144252. maxVertsPerPoly: number;
  144253. /**
  144254. * Sets the sampling distance to use when generating the detail mesh.
  144255. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  144256. */
  144257. detailSampleDist: number;
  144258. /**
  144259. * The maximum distance the detail mesh surface should deviate from heightfield
  144260. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  144261. */
  144262. detailSampleMaxError: number;
  144263. }
  144264. }
  144265. declare module BABYLON {
  144266. /**
  144267. * RecastJS navigation plugin
  144268. */
  144269. export class RecastJSPlugin implements INavigationEnginePlugin {
  144270. /**
  144271. * Reference to the Recast library
  144272. */
  144273. bjsRECAST: any;
  144274. /**
  144275. * plugin name
  144276. */
  144277. name: string;
  144278. /**
  144279. * the first navmesh created. We might extend this to support multiple navmeshes
  144280. */
  144281. navMesh: any;
  144282. /**
  144283. * Initializes the recastJS plugin
  144284. * @param recastInjection can be used to inject your own recast reference
  144285. */
  144286. constructor(recastInjection?: any);
  144287. /**
  144288. * Creates a navigation mesh
  144289. * @param meshes array of all the geometry used to compute the navigatio mesh
  144290. * @param parameters bunch of parameters used to filter geometry
  144291. */
  144292. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  144293. /**
  144294. * Create a navigation mesh debug mesh
  144295. * @param scene is where the mesh will be added
  144296. * @returns debug display mesh
  144297. */
  144298. createDebugNavMesh(scene: Scene): Mesh;
  144299. /**
  144300. * Get a navigation mesh constrained position, closest to the parameter position
  144301. * @param position world position
  144302. * @returns the closest point to position constrained by the navigation mesh
  144303. */
  144304. getClosestPoint(position: Vector3): Vector3;
  144305. /**
  144306. * Get a navigation mesh constrained position, closest to the parameter position
  144307. * @param position world position
  144308. * @param result output the closest point to position constrained by the navigation mesh
  144309. */
  144310. getClosestPointToRef(position: Vector3, result: Vector3): void;
  144311. /**
  144312. * Get a navigation mesh constrained position, within a particular radius
  144313. * @param position world position
  144314. * @param maxRadius the maximum distance to the constrained world position
  144315. * @returns the closest point to position constrained by the navigation mesh
  144316. */
  144317. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144318. /**
  144319. * Get a navigation mesh constrained position, within a particular radius
  144320. * @param position world position
  144321. * @param maxRadius the maximum distance to the constrained world position
  144322. * @param result output the closest point to position constrained by the navigation mesh
  144323. */
  144324. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144325. /**
  144326. * Compute the final position from a segment made of destination-position
  144327. * @param position world position
  144328. * @param destination world position
  144329. * @returns the resulting point along the navmesh
  144330. */
  144331. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144332. /**
  144333. * Compute the final position from a segment made of destination-position
  144334. * @param position world position
  144335. * @param destination world position
  144336. * @param result output the resulting point along the navmesh
  144337. */
  144338. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144339. /**
  144340. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144341. * @param start world position
  144342. * @param end world position
  144343. * @returns array containing world position composing the path
  144344. */
  144345. computePath(start: Vector3, end: Vector3): Vector3[];
  144346. /**
  144347. * Create a new Crowd so you can add agents
  144348. * @param maxAgents the maximum agent count in the crowd
  144349. * @param maxAgentRadius the maximum radius an agent can have
  144350. * @param scene to attach the crowd to
  144351. * @returns the crowd you can add agents to
  144352. */
  144353. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144354. /**
  144355. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144356. * The queries will try to find a solution within those bounds
  144357. * default is (1,1,1)
  144358. * @param extent x,y,z value that define the extent around the queries point of reference
  144359. */
  144360. setDefaultQueryExtent(extent: Vector3): void;
  144361. /**
  144362. * Get the Bounding box extent specified by setDefaultQueryExtent
  144363. * @returns the box extent values
  144364. */
  144365. getDefaultQueryExtent(): Vector3;
  144366. /**
  144367. * build the navmesh from a previously saved state using getNavmeshData
  144368. * @param data the Uint8Array returned by getNavmeshData
  144369. */
  144370. buildFromNavmeshData(data: Uint8Array): void;
  144371. /**
  144372. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144373. * @returns data the Uint8Array that can be saved and reused
  144374. */
  144375. getNavmeshData(): Uint8Array;
  144376. /**
  144377. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144378. * @param result output the box extent values
  144379. */
  144380. getDefaultQueryExtentToRef(result: Vector3): void;
  144381. /**
  144382. * Disposes
  144383. */
  144384. dispose(): void;
  144385. /**
  144386. * If this plugin is supported
  144387. * @returns true if plugin is supported
  144388. */
  144389. isSupported(): boolean;
  144390. }
  144391. /**
  144392. * Recast detour crowd implementation
  144393. */
  144394. export class RecastJSCrowd implements ICrowd {
  144395. /**
  144396. * Recast/detour plugin
  144397. */
  144398. bjsRECASTPlugin: RecastJSPlugin;
  144399. /**
  144400. * Link to the detour crowd
  144401. */
  144402. recastCrowd: any;
  144403. /**
  144404. * One transform per agent
  144405. */
  144406. transforms: TransformNode[];
  144407. /**
  144408. * All agents created
  144409. */
  144410. agents: number[];
  144411. /**
  144412. * Link to the scene is kept to unregister the crowd from the scene
  144413. */
  144414. private _scene;
  144415. /**
  144416. * Observer for crowd updates
  144417. */
  144418. private _onBeforeAnimationsObserver;
  144419. /**
  144420. * Constructor
  144421. * @param plugin recastJS plugin
  144422. * @param maxAgents the maximum agent count in the crowd
  144423. * @param maxAgentRadius the maximum radius an agent can have
  144424. * @param scene to attach the crowd to
  144425. * @returns the crowd you can add agents to
  144426. */
  144427. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  144428. /**
  144429. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144430. * You can attach anything to that node. The node position is updated in the scene update tick.
  144431. * @param pos world position that will be constrained by the navigation mesh
  144432. * @param parameters agent parameters
  144433. * @param transform hooked to the agent that will be update by the scene
  144434. * @returns agent index
  144435. */
  144436. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144437. /**
  144438. * Returns the agent position in world space
  144439. * @param index agent index returned by addAgent
  144440. * @returns world space position
  144441. */
  144442. getAgentPosition(index: number): Vector3;
  144443. /**
  144444. * Returns the agent position result in world space
  144445. * @param index agent index returned by addAgent
  144446. * @param result output world space position
  144447. */
  144448. getAgentPositionToRef(index: number, result: Vector3): void;
  144449. /**
  144450. * Returns the agent velocity in world space
  144451. * @param index agent index returned by addAgent
  144452. * @returns world space velocity
  144453. */
  144454. getAgentVelocity(index: number): Vector3;
  144455. /**
  144456. * Returns the agent velocity result in world space
  144457. * @param index agent index returned by addAgent
  144458. * @param result output world space velocity
  144459. */
  144460. getAgentVelocityToRef(index: number, result: Vector3): void;
  144461. /**
  144462. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144463. * @param index agent index returned by addAgent
  144464. * @param destination targeted world position
  144465. */
  144466. agentGoto(index: number, destination: Vector3): void;
  144467. /**
  144468. * Teleport the agent to a new position
  144469. * @param index agent index returned by addAgent
  144470. * @param destination targeted world position
  144471. */
  144472. agentTeleport(index: number, destination: Vector3): void;
  144473. /**
  144474. * Update agent parameters
  144475. * @param index agent index returned by addAgent
  144476. * @param parameters agent parameters
  144477. */
  144478. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144479. /**
  144480. * remove a particular agent previously created
  144481. * @param index agent index returned by addAgent
  144482. */
  144483. removeAgent(index: number): void;
  144484. /**
  144485. * get the list of all agents attached to this crowd
  144486. * @returns list of agent indices
  144487. */
  144488. getAgents(): number[];
  144489. /**
  144490. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144491. * @param deltaTime in seconds
  144492. */
  144493. update(deltaTime: number): void;
  144494. /**
  144495. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144496. * The queries will try to find a solution within those bounds
  144497. * default is (1,1,1)
  144498. * @param extent x,y,z value that define the extent around the queries point of reference
  144499. */
  144500. setDefaultQueryExtent(extent: Vector3): void;
  144501. /**
  144502. * Get the Bounding box extent specified by setDefaultQueryExtent
  144503. * @returns the box extent values
  144504. */
  144505. getDefaultQueryExtent(): Vector3;
  144506. /**
  144507. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144508. * @param result output the box extent values
  144509. */
  144510. getDefaultQueryExtentToRef(result: Vector3): void;
  144511. /**
  144512. * Release all resources
  144513. */
  144514. dispose(): void;
  144515. }
  144516. }
  144517. declare module BABYLON {
  144518. /**
  144519. * Class used to enable access to IndexedDB
  144520. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  144521. */
  144522. export class Database implements IOfflineProvider {
  144523. private _callbackManifestChecked;
  144524. private _currentSceneUrl;
  144525. private _db;
  144526. private _enableSceneOffline;
  144527. private _enableTexturesOffline;
  144528. private _manifestVersionFound;
  144529. private _mustUpdateRessources;
  144530. private _hasReachedQuota;
  144531. private _isSupported;
  144532. private _idbFactory;
  144533. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  144534. private static IsUASupportingBlobStorage;
  144535. /**
  144536. * Gets a boolean indicating if Database storate is enabled (off by default)
  144537. */
  144538. static IDBStorageEnabled: boolean;
  144539. /**
  144540. * Gets a boolean indicating if scene must be saved in the database
  144541. */
  144542. get enableSceneOffline(): boolean;
  144543. /**
  144544. * Gets a boolean indicating if textures must be saved in the database
  144545. */
  144546. get enableTexturesOffline(): boolean;
  144547. /**
  144548. * Creates a new Database
  144549. * @param urlToScene defines the url to load the scene
  144550. * @param callbackManifestChecked defines the callback to use when manifest is checked
  144551. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  144552. */
  144553. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  144554. private static _ParseURL;
  144555. private static _ReturnFullUrlLocation;
  144556. private _checkManifestFile;
  144557. /**
  144558. * Open the database and make it available
  144559. * @param successCallback defines the callback to call on success
  144560. * @param errorCallback defines the callback to call on error
  144561. */
  144562. open(successCallback: () => void, errorCallback: () => void): void;
  144563. /**
  144564. * Loads an image from the database
  144565. * @param url defines the url to load from
  144566. * @param image defines the target DOM image
  144567. */
  144568. loadImage(url: string, image: HTMLImageElement): void;
  144569. private _loadImageFromDBAsync;
  144570. private _saveImageIntoDBAsync;
  144571. private _checkVersionFromDB;
  144572. private _loadVersionFromDBAsync;
  144573. private _saveVersionIntoDBAsync;
  144574. /**
  144575. * Loads a file from database
  144576. * @param url defines the URL to load from
  144577. * @param sceneLoaded defines a callback to call on success
  144578. * @param progressCallBack defines a callback to call when progress changed
  144579. * @param errorCallback defines a callback to call on error
  144580. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  144581. */
  144582. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  144583. private _loadFileAsync;
  144584. private _saveFileAsync;
  144585. /**
  144586. * Validates if xhr data is correct
  144587. * @param xhr defines the request to validate
  144588. * @param dataType defines the expected data type
  144589. * @returns true if data is correct
  144590. */
  144591. private static _ValidateXHRData;
  144592. }
  144593. }
  144594. declare module BABYLON {
  144595. /** @hidden */
  144596. export var gpuUpdateParticlesPixelShader: {
  144597. name: string;
  144598. shader: string;
  144599. };
  144600. }
  144601. declare module BABYLON {
  144602. /** @hidden */
  144603. export var gpuUpdateParticlesVertexShader: {
  144604. name: string;
  144605. shader: string;
  144606. };
  144607. }
  144608. declare module BABYLON {
  144609. /** @hidden */
  144610. export var clipPlaneFragmentDeclaration2: {
  144611. name: string;
  144612. shader: string;
  144613. };
  144614. }
  144615. declare module BABYLON {
  144616. /** @hidden */
  144617. export var gpuRenderParticlesPixelShader: {
  144618. name: string;
  144619. shader: string;
  144620. };
  144621. }
  144622. declare module BABYLON {
  144623. /** @hidden */
  144624. export var clipPlaneVertexDeclaration2: {
  144625. name: string;
  144626. shader: string;
  144627. };
  144628. }
  144629. declare module BABYLON {
  144630. /** @hidden */
  144631. export var gpuRenderParticlesVertexShader: {
  144632. name: string;
  144633. shader: string;
  144634. };
  144635. }
  144636. declare module BABYLON {
  144637. /**
  144638. * This represents a GPU particle system in Babylon
  144639. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  144640. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  144641. */
  144642. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  144643. /**
  144644. * The layer mask we are rendering the particles through.
  144645. */
  144646. layerMask: number;
  144647. private _capacity;
  144648. private _activeCount;
  144649. private _currentActiveCount;
  144650. private _accumulatedCount;
  144651. private _renderEffect;
  144652. private _updateEffect;
  144653. private _buffer0;
  144654. private _buffer1;
  144655. private _spriteBuffer;
  144656. private _updateVAO;
  144657. private _renderVAO;
  144658. private _targetIndex;
  144659. private _sourceBuffer;
  144660. private _targetBuffer;
  144661. private _engine;
  144662. private _currentRenderId;
  144663. private _started;
  144664. private _stopped;
  144665. private _timeDelta;
  144666. private _randomTexture;
  144667. private _randomTexture2;
  144668. private _attributesStrideSize;
  144669. private _updateEffectOptions;
  144670. private _randomTextureSize;
  144671. private _actualFrame;
  144672. private _customEffect;
  144673. private readonly _rawTextureWidth;
  144674. /**
  144675. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  144676. */
  144677. static get IsSupported(): boolean;
  144678. /**
  144679. * An event triggered when the system is disposed.
  144680. */
  144681. onDisposeObservable: Observable<IParticleSystem>;
  144682. /**
  144683. * Gets the maximum number of particles active at the same time.
  144684. * @returns The max number of active particles.
  144685. */
  144686. getCapacity(): number;
  144687. /**
  144688. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  144689. * to override the particles.
  144690. */
  144691. forceDepthWrite: boolean;
  144692. /**
  144693. * Gets or set the number of active particles
  144694. */
  144695. get activeParticleCount(): number;
  144696. set activeParticleCount(value: number);
  144697. private _preWarmDone;
  144698. /**
  144699. * Specifies if the particles are updated in emitter local space or world space.
  144700. */
  144701. isLocal: boolean;
  144702. /**
  144703. * Is this system ready to be used/rendered
  144704. * @return true if the system is ready
  144705. */
  144706. isReady(): boolean;
  144707. /**
  144708. * Gets if the system has been started. (Note: this will still be true after stop is called)
  144709. * @returns True if it has been started, otherwise false.
  144710. */
  144711. isStarted(): boolean;
  144712. /**
  144713. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  144714. * @returns True if it has been stopped, otherwise false.
  144715. */
  144716. isStopped(): boolean;
  144717. /**
  144718. * Gets a boolean indicating that the system is stopping
  144719. * @returns true if the system is currently stopping
  144720. */
  144721. isStopping(): boolean;
  144722. /**
  144723. * Gets the number of particles active at the same time.
  144724. * @returns The number of active particles.
  144725. */
  144726. getActiveCount(): number;
  144727. /**
  144728. * Starts the particle system and begins to emit
  144729. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  144730. */
  144731. start(delay?: number): void;
  144732. /**
  144733. * Stops the particle system.
  144734. */
  144735. stop(): void;
  144736. /**
  144737. * Remove all active particles
  144738. */
  144739. reset(): void;
  144740. /**
  144741. * Returns the string "GPUParticleSystem"
  144742. * @returns a string containing the class name
  144743. */
  144744. getClassName(): string;
  144745. /**
  144746. * Gets the custom effect used to render the particles
  144747. * @param blendMode Blend mode for which the effect should be retrieved
  144748. * @returns The effect
  144749. */
  144750. getCustomEffect(blendMode?: number): Nullable<Effect>;
  144751. /**
  144752. * Sets the custom effect used to render the particles
  144753. * @param effect The effect to set
  144754. * @param blendMode Blend mode for which the effect should be set
  144755. */
  144756. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  144757. /** @hidden */
  144758. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  144759. /**
  144760. * Observable that will be called just before the particles are drawn
  144761. */
  144762. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  144763. /**
  144764. * Gets the name of the particle vertex shader
  144765. */
  144766. get vertexShaderName(): string;
  144767. private _colorGradientsTexture;
  144768. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  144769. /**
  144770. * Adds a new color gradient
  144771. * @param gradient defines the gradient to use (between 0 and 1)
  144772. * @param color1 defines the color to affect to the specified gradient
  144773. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  144774. * @returns the current particle system
  144775. */
  144776. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  144777. private _refreshColorGradient;
  144778. /** Force the system to rebuild all gradients that need to be resync */
  144779. forceRefreshGradients(): void;
  144780. /**
  144781. * Remove a specific color gradient
  144782. * @param gradient defines the gradient to remove
  144783. * @returns the current particle system
  144784. */
  144785. removeColorGradient(gradient: number): GPUParticleSystem;
  144786. private _angularSpeedGradientsTexture;
  144787. private _sizeGradientsTexture;
  144788. private _velocityGradientsTexture;
  144789. private _limitVelocityGradientsTexture;
  144790. private _dragGradientsTexture;
  144791. private _addFactorGradient;
  144792. /**
  144793. * Adds a new size gradient
  144794. * @param gradient defines the gradient to use (between 0 and 1)
  144795. * @param factor defines the size factor to affect to the specified gradient
  144796. * @returns the current particle system
  144797. */
  144798. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  144799. /**
  144800. * Remove a specific size gradient
  144801. * @param gradient defines the gradient to remove
  144802. * @returns the current particle system
  144803. */
  144804. removeSizeGradient(gradient: number): GPUParticleSystem;
  144805. private _refreshFactorGradient;
  144806. /**
  144807. * Adds a new angular speed gradient
  144808. * @param gradient defines the gradient to use (between 0 and 1)
  144809. * @param factor defines the angular speed to affect to the specified gradient
  144810. * @returns the current particle system
  144811. */
  144812. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  144813. /**
  144814. * Remove a specific angular speed gradient
  144815. * @param gradient defines the gradient to remove
  144816. * @returns the current particle system
  144817. */
  144818. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  144819. /**
  144820. * Adds a new velocity gradient
  144821. * @param gradient defines the gradient to use (between 0 and 1)
  144822. * @param factor defines the velocity to affect to the specified gradient
  144823. * @returns the current particle system
  144824. */
  144825. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144826. /**
  144827. * Remove a specific velocity gradient
  144828. * @param gradient defines the gradient to remove
  144829. * @returns the current particle system
  144830. */
  144831. removeVelocityGradient(gradient: number): GPUParticleSystem;
  144832. /**
  144833. * Adds a new limit velocity gradient
  144834. * @param gradient defines the gradient to use (between 0 and 1)
  144835. * @param factor defines the limit velocity value to affect to the specified gradient
  144836. * @returns the current particle system
  144837. */
  144838. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144839. /**
  144840. * Remove a specific limit velocity gradient
  144841. * @param gradient defines the gradient to remove
  144842. * @returns the current particle system
  144843. */
  144844. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  144845. /**
  144846. * Adds a new drag gradient
  144847. * @param gradient defines the gradient to use (between 0 and 1)
  144848. * @param factor defines the drag value to affect to the specified gradient
  144849. * @returns the current particle system
  144850. */
  144851. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  144852. /**
  144853. * Remove a specific drag gradient
  144854. * @param gradient defines the gradient to remove
  144855. * @returns the current particle system
  144856. */
  144857. removeDragGradient(gradient: number): GPUParticleSystem;
  144858. /**
  144859. * Not supported by GPUParticleSystem
  144860. * @param gradient defines the gradient to use (between 0 and 1)
  144861. * @param factor defines the emit rate value to affect to the specified gradient
  144862. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144863. * @returns the current particle system
  144864. */
  144865. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144866. /**
  144867. * Not supported by GPUParticleSystem
  144868. * @param gradient defines the gradient to remove
  144869. * @returns the current particle system
  144870. */
  144871. removeEmitRateGradient(gradient: number): IParticleSystem;
  144872. /**
  144873. * Not supported by GPUParticleSystem
  144874. * @param gradient defines the gradient to use (between 0 and 1)
  144875. * @param factor defines the start size value to affect to the specified gradient
  144876. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144877. * @returns the current particle system
  144878. */
  144879. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144880. /**
  144881. * Not supported by GPUParticleSystem
  144882. * @param gradient defines the gradient to remove
  144883. * @returns the current particle system
  144884. */
  144885. removeStartSizeGradient(gradient: number): IParticleSystem;
  144886. /**
  144887. * Not supported by GPUParticleSystem
  144888. * @param gradient defines the gradient to use (between 0 and 1)
  144889. * @param min defines the color remap minimal range
  144890. * @param max defines the color remap maximal range
  144891. * @returns the current particle system
  144892. */
  144893. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144894. /**
  144895. * Not supported by GPUParticleSystem
  144896. * @param gradient defines the gradient to remove
  144897. * @returns the current particle system
  144898. */
  144899. removeColorRemapGradient(): IParticleSystem;
  144900. /**
  144901. * Not supported by GPUParticleSystem
  144902. * @param gradient defines the gradient to use (between 0 and 1)
  144903. * @param min defines the alpha remap minimal range
  144904. * @param max defines the alpha remap maximal range
  144905. * @returns the current particle system
  144906. */
  144907. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144908. /**
  144909. * Not supported by GPUParticleSystem
  144910. * @param gradient defines the gradient to remove
  144911. * @returns the current particle system
  144912. */
  144913. removeAlphaRemapGradient(): IParticleSystem;
  144914. /**
  144915. * Not supported by GPUParticleSystem
  144916. * @param gradient defines the gradient to use (between 0 and 1)
  144917. * @param color defines the color to affect to the specified gradient
  144918. * @returns the current particle system
  144919. */
  144920. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  144921. /**
  144922. * Not supported by GPUParticleSystem
  144923. * @param gradient defines the gradient to remove
  144924. * @returns the current particle system
  144925. */
  144926. removeRampGradient(): IParticleSystem;
  144927. /**
  144928. * Not supported by GPUParticleSystem
  144929. * @returns the list of ramp gradients
  144930. */
  144931. getRampGradients(): Nullable<Array<Color3Gradient>>;
  144932. /**
  144933. * Not supported by GPUParticleSystem
  144934. * Gets or sets a boolean indicating that ramp gradients must be used
  144935. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  144936. */
  144937. get useRampGradients(): boolean;
  144938. set useRampGradients(value: boolean);
  144939. /**
  144940. * Not supported by GPUParticleSystem
  144941. * @param gradient defines the gradient to use (between 0 and 1)
  144942. * @param factor defines the life time factor to affect to the specified gradient
  144943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144944. * @returns the current particle system
  144945. */
  144946. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144947. /**
  144948. * Not supported by GPUParticleSystem
  144949. * @param gradient defines the gradient to remove
  144950. * @returns the current particle system
  144951. */
  144952. removeLifeTimeGradient(gradient: number): IParticleSystem;
  144953. /**
  144954. * Instantiates a GPU particle system.
  144955. * 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.
  144956. * @param name The name of the particle system
  144957. * @param options The options used to create the system
  144958. * @param scene The scene the particle system belongs to
  144959. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  144960. * @param customEffect a custom effect used to change the way particles are rendered by default
  144961. */
  144962. constructor(name: string, options: Partial<{
  144963. capacity: number;
  144964. randomTextureSize: number;
  144965. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  144966. protected _reset(): void;
  144967. private _createUpdateVAO;
  144968. private _createRenderVAO;
  144969. private _initialize;
  144970. /** @hidden */
  144971. _recreateUpdateEffect(): void;
  144972. private _getEffect;
  144973. /**
  144974. * Fill the defines array according to the current settings of the particle system
  144975. * @param defines Array to be updated
  144976. * @param blendMode blend mode to take into account when updating the array
  144977. */
  144978. fillDefines(defines: Array<string>, blendMode?: number): void;
  144979. /**
  144980. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  144981. * @param uniforms Uniforms array to fill
  144982. * @param attributes Attributes array to fill
  144983. * @param samplers Samplers array to fill
  144984. */
  144985. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  144986. /** @hidden */
  144987. _recreateRenderEffect(): Effect;
  144988. /**
  144989. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  144990. * @param preWarm defines if we are in the pre-warmimg phase
  144991. */
  144992. animate(preWarm?: boolean): void;
  144993. private _createFactorGradientTexture;
  144994. private _createSizeGradientTexture;
  144995. private _createAngularSpeedGradientTexture;
  144996. private _createVelocityGradientTexture;
  144997. private _createLimitVelocityGradientTexture;
  144998. private _createDragGradientTexture;
  144999. private _createColorGradientTexture;
  145000. /**
  145001. * Renders the particle system in its current state
  145002. * @param preWarm defines if the system should only update the particles but not render them
  145003. * @returns the current number of particles
  145004. */
  145005. render(preWarm?: boolean): number;
  145006. /**
  145007. * Rebuilds the particle system
  145008. */
  145009. rebuild(): void;
  145010. private _releaseBuffers;
  145011. private _releaseVAOs;
  145012. /**
  145013. * Disposes the particle system and free the associated resources
  145014. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  145015. */
  145016. dispose(disposeTexture?: boolean): void;
  145017. /**
  145018. * Clones the particle system.
  145019. * @param name The name of the cloned object
  145020. * @param newEmitter The new emitter to use
  145021. * @returns the cloned particle system
  145022. */
  145023. clone(name: string, newEmitter: any): GPUParticleSystem;
  145024. /**
  145025. * Serializes the particle system to a JSON object
  145026. * @param serializeTexture defines if the texture must be serialized as well
  145027. * @returns the JSON object
  145028. */
  145029. serialize(serializeTexture?: boolean): any;
  145030. /**
  145031. * Parses a JSON object to create a GPU particle system.
  145032. * @param parsedParticleSystem The JSON object to parse
  145033. * @param scene The scene to create the particle system in
  145034. * @param rootUrl The root url to use to load external dependencies like texture
  145035. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  145036. * @returns the parsed GPU particle system
  145037. */
  145038. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  145039. }
  145040. }
  145041. declare module BABYLON {
  145042. /**
  145043. * Represents a set of particle systems working together to create a specific effect
  145044. */
  145045. export class ParticleSystemSet implements IDisposable {
  145046. /**
  145047. * Gets or sets base Assets URL
  145048. */
  145049. static BaseAssetsUrl: string;
  145050. private _emitterCreationOptions;
  145051. private _emitterNode;
  145052. /**
  145053. * Gets the particle system list
  145054. */
  145055. systems: IParticleSystem[];
  145056. /**
  145057. * Gets the emitter node used with this set
  145058. */
  145059. get emitterNode(): Nullable<TransformNode>;
  145060. /**
  145061. * Creates a new emitter mesh as a sphere
  145062. * @param options defines the options used to create the sphere
  145063. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  145064. * @param scene defines the hosting scene
  145065. */
  145066. setEmitterAsSphere(options: {
  145067. diameter: number;
  145068. segments: number;
  145069. color: Color3;
  145070. }, renderingGroupId: number, scene: Scene): void;
  145071. /**
  145072. * Starts all particle systems of the set
  145073. * @param emitter defines an optional mesh to use as emitter for the particle systems
  145074. */
  145075. start(emitter?: AbstractMesh): void;
  145076. /**
  145077. * Release all associated resources
  145078. */
  145079. dispose(): void;
  145080. /**
  145081. * Serialize the set into a JSON compatible object
  145082. * @param serializeTexture defines if the texture must be serialized as well
  145083. * @returns a JSON compatible representation of the set
  145084. */
  145085. serialize(serializeTexture?: boolean): any;
  145086. /**
  145087. * Parse a new ParticleSystemSet from a serialized source
  145088. * @param data defines a JSON compatible representation of the set
  145089. * @param scene defines the hosting scene
  145090. * @param gpu defines if we want GPU particles or CPU particles
  145091. * @returns a new ParticleSystemSet
  145092. */
  145093. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  145094. }
  145095. }
  145096. declare module BABYLON {
  145097. /**
  145098. * This class is made for on one-liner static method to help creating particle system set.
  145099. */
  145100. export class ParticleHelper {
  145101. /**
  145102. * Gets or sets base Assets URL
  145103. */
  145104. static BaseAssetsUrl: string;
  145105. /** Define the Url to load snippets */
  145106. static SnippetUrl: string;
  145107. /**
  145108. * Create a default particle system that you can tweak
  145109. * @param emitter defines the emitter to use
  145110. * @param capacity defines the system capacity (default is 500 particles)
  145111. * @param scene defines the hosting scene
  145112. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  145113. * @returns the new Particle system
  145114. */
  145115. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  145116. /**
  145117. * This is the main static method (one-liner) of this helper to create different particle systems
  145118. * @param type This string represents the type to the particle system to create
  145119. * @param scene The scene where the particle system should live
  145120. * @param gpu If the system will use gpu
  145121. * @returns the ParticleSystemSet created
  145122. */
  145123. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  145124. /**
  145125. * Static function used to export a particle system to a ParticleSystemSet variable.
  145126. * Please note that the emitter shape is not exported
  145127. * @param systems defines the particle systems to export
  145128. * @returns the created particle system set
  145129. */
  145130. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  145131. /**
  145132. * Creates a particle system from a snippet saved in a remote file
  145133. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  145134. * @param url defines the url to load from
  145135. * @param scene defines the hosting scene
  145136. * @param gpu If the system will use gpu
  145137. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145138. * @returns a promise that will resolve to the new particle system
  145139. */
  145140. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145141. /**
  145142. * Creates a particle system from a snippet saved by the particle system editor
  145143. * @param snippetId defines the snippet to load
  145144. * @param scene defines the hosting scene
  145145. * @param gpu If the system will use gpu
  145146. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145147. * @returns a promise that will resolve to the new particle system
  145148. */
  145149. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145150. }
  145151. }
  145152. declare module BABYLON {
  145153. interface Engine {
  145154. /**
  145155. * Create an effect to use with particle systems.
  145156. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  145157. * the particle system for which you want to create a custom effect in the last parameter
  145158. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  145159. * @param uniformsNames defines a list of attribute names
  145160. * @param samplers defines an array of string used to represent textures
  145161. * @param defines defines the string containing the defines to use to compile the shaders
  145162. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  145163. * @param onCompiled defines a function to call when the effect creation is successful
  145164. * @param onError defines a function to call when the effect creation has failed
  145165. * @param particleSystem the particle system you want to create the effect for
  145166. * @returns the new Effect
  145167. */
  145168. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  145169. }
  145170. interface Mesh {
  145171. /**
  145172. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  145173. * @returns an array of IParticleSystem
  145174. */
  145175. getEmittedParticleSystems(): IParticleSystem[];
  145176. /**
  145177. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  145178. * @returns an array of IParticleSystem
  145179. */
  145180. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  145181. }
  145182. }
  145183. declare module BABYLON {
  145184. /** Defines the 4 color options */
  145185. export enum PointColor {
  145186. /** color value */
  145187. Color = 2,
  145188. /** uv value */
  145189. UV = 1,
  145190. /** random value */
  145191. Random = 0,
  145192. /** stated value */
  145193. Stated = 3
  145194. }
  145195. /**
  145196. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  145197. * 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.
  145198. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  145199. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  145200. *
  145201. * Full documentation here : TO BE ENTERED
  145202. */
  145203. export class PointsCloudSystem implements IDisposable {
  145204. /**
  145205. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  145206. * Example : var p = SPS.particles[i];
  145207. */
  145208. particles: CloudPoint[];
  145209. /**
  145210. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  145211. */
  145212. nbParticles: number;
  145213. /**
  145214. * This a counter for your own usage. It's not set by any SPS functions.
  145215. */
  145216. counter: number;
  145217. /**
  145218. * The PCS name. This name is also given to the underlying mesh.
  145219. */
  145220. name: string;
  145221. /**
  145222. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  145223. */
  145224. mesh: Mesh;
  145225. /**
  145226. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  145227. * Please read :
  145228. */
  145229. vars: any;
  145230. /**
  145231. * @hidden
  145232. */
  145233. _size: number;
  145234. private _scene;
  145235. private _promises;
  145236. private _positions;
  145237. private _indices;
  145238. private _normals;
  145239. private _colors;
  145240. private _uvs;
  145241. private _indices32;
  145242. private _positions32;
  145243. private _colors32;
  145244. private _uvs32;
  145245. private _updatable;
  145246. private _isVisibilityBoxLocked;
  145247. private _alwaysVisible;
  145248. private _groups;
  145249. private _groupCounter;
  145250. private _computeParticleColor;
  145251. private _computeParticleTexture;
  145252. private _computeParticleRotation;
  145253. private _computeBoundingBox;
  145254. private _isReady;
  145255. /**
  145256. * Creates a PCS (Points Cloud System) object
  145257. * @param name (String) is the PCS name, this will be the underlying mesh name
  145258. * @param pointSize (number) is the size for each point
  145259. * @param scene (Scene) is the scene in which the PCS is added
  145260. * @param options defines the options of the PCS e.g.
  145261. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  145262. */
  145263. constructor(name: string, pointSize: number, scene: Scene, options?: {
  145264. updatable?: boolean;
  145265. });
  145266. /**
  145267. * Builds the PCS underlying mesh. Returns a standard Mesh.
  145268. * If no points were added to the PCS, the returned mesh is just a single point.
  145269. * @returns a promise for the created mesh
  145270. */
  145271. buildMeshAsync(): Promise<Mesh>;
  145272. /**
  145273. * @hidden
  145274. */
  145275. private _buildMesh;
  145276. private _addParticle;
  145277. private _randomUnitVector;
  145278. private _getColorIndicesForCoord;
  145279. private _setPointsColorOrUV;
  145280. private _colorFromTexture;
  145281. private _calculateDensity;
  145282. /**
  145283. * Adds points to the PCS in random positions within a unit sphere
  145284. * @param nb (positive integer) the number of particles to be created from this model
  145285. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  145286. * @returns the number of groups in the system
  145287. */
  145288. addPoints(nb: number, pointFunction?: any): number;
  145289. /**
  145290. * Adds points to the PCS from the surface of the model shape
  145291. * @param mesh is any Mesh object that will be used as a surface model for the points
  145292. * @param nb (positive integer) the number of particles to be created from this model
  145293. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  145294. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  145295. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  145296. * @returns the number of groups in the system
  145297. */
  145298. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  145299. /**
  145300. * Adds points to the PCS inside the model shape
  145301. * @param mesh is any Mesh object that will be used as a surface model for the points
  145302. * @param nb (positive integer) the number of particles to be created from this model
  145303. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  145304. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  145305. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  145306. * @returns the number of groups in the system
  145307. */
  145308. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  145309. /**
  145310. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  145311. * This method calls `updateParticle()` for each particle of the SPS.
  145312. * For an animated SPS, it is usually called within the render loop.
  145313. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  145314. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  145315. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  145316. * @returns the PCS.
  145317. */
  145318. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  145319. /**
  145320. * Disposes the PCS.
  145321. */
  145322. dispose(): void;
  145323. /**
  145324. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  145325. * doc :
  145326. * @returns the PCS.
  145327. */
  145328. refreshVisibleSize(): PointsCloudSystem;
  145329. /**
  145330. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  145331. * @param size the size (float) of the visibility box
  145332. * note : this doesn't lock the PCS mesh bounding box.
  145333. * doc :
  145334. */
  145335. setVisibilityBox(size: number): void;
  145336. /**
  145337. * Gets whether the PCS is always visible or not
  145338. * doc :
  145339. */
  145340. get isAlwaysVisible(): boolean;
  145341. /**
  145342. * Sets the PCS as always visible or not
  145343. * doc :
  145344. */
  145345. set isAlwaysVisible(val: boolean);
  145346. /**
  145347. * Tells to `setParticles()` to compute the particle rotations or not
  145348. * Default value : false. The PCS is faster when it's set to false
  145349. * Note : particle rotations are only applied to parent particles
  145350. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  145351. */
  145352. set computeParticleRotation(val: boolean);
  145353. /**
  145354. * Tells to `setParticles()` to compute the particle colors or not.
  145355. * Default value : true. The PCS is faster when it's set to false.
  145356. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  145357. */
  145358. set computeParticleColor(val: boolean);
  145359. set computeParticleTexture(val: boolean);
  145360. /**
  145361. * Gets if `setParticles()` computes the particle colors or not.
  145362. * Default value : false. The PCS is faster when it's set to false.
  145363. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  145364. */
  145365. get computeParticleColor(): boolean;
  145366. /**
  145367. * Gets if `setParticles()` computes the particle textures or not.
  145368. * Default value : false. The PCS is faster when it's set to false.
  145369. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  145370. */
  145371. get computeParticleTexture(): boolean;
  145372. /**
  145373. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  145374. */
  145375. set computeBoundingBox(val: boolean);
  145376. /**
  145377. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  145378. */
  145379. get computeBoundingBox(): boolean;
  145380. /**
  145381. * This function does nothing. It may be overwritten to set all the particle first values.
  145382. * The PCS doesn't call this function, you may have to call it by your own.
  145383. * doc :
  145384. */
  145385. initParticles(): void;
  145386. /**
  145387. * This function does nothing. It may be overwritten to recycle a particle
  145388. * The PCS doesn't call this function, you can to call it
  145389. * doc :
  145390. * @param particle The particle to recycle
  145391. * @returns the recycled particle
  145392. */
  145393. recycleParticle(particle: CloudPoint): CloudPoint;
  145394. /**
  145395. * Updates a particle : this function should be overwritten by the user.
  145396. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  145397. * doc :
  145398. * @example : just set a particle position or velocity and recycle conditions
  145399. * @param particle The particle to update
  145400. * @returns the updated particle
  145401. */
  145402. updateParticle(particle: CloudPoint): CloudPoint;
  145403. /**
  145404. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  145405. * This does nothing and may be overwritten by the user.
  145406. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  145407. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  145408. * @param update the boolean update value actually passed to setParticles()
  145409. */
  145410. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  145411. /**
  145412. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  145413. * This will be passed three parameters.
  145414. * This does nothing and may be overwritten by the user.
  145415. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  145416. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  145417. * @param update the boolean update value actually passed to setParticles()
  145418. */
  145419. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  145420. }
  145421. }
  145422. declare module BABYLON {
  145423. /**
  145424. * Represents one particle of a points cloud system.
  145425. */
  145426. export class CloudPoint {
  145427. /**
  145428. * particle global index
  145429. */
  145430. idx: number;
  145431. /**
  145432. * The color of the particle
  145433. */
  145434. color: Nullable<Color4>;
  145435. /**
  145436. * The world space position of the particle.
  145437. */
  145438. position: Vector3;
  145439. /**
  145440. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  145441. */
  145442. rotation: Vector3;
  145443. /**
  145444. * The world space rotation quaternion of the particle.
  145445. */
  145446. rotationQuaternion: Nullable<Quaternion>;
  145447. /**
  145448. * The uv of the particle.
  145449. */
  145450. uv: Nullable<Vector2>;
  145451. /**
  145452. * The current speed of the particle.
  145453. */
  145454. velocity: Vector3;
  145455. /**
  145456. * The pivot point in the particle local space.
  145457. */
  145458. pivot: Vector3;
  145459. /**
  145460. * Must the particle be translated from its pivot point in its local space ?
  145461. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  145462. * Default : false
  145463. */
  145464. translateFromPivot: boolean;
  145465. /**
  145466. * Index of this particle in the global "positions" array (Internal use)
  145467. * @hidden
  145468. */
  145469. _pos: number;
  145470. /**
  145471. * @hidden Index of this particle in the global "indices" array (Internal use)
  145472. */
  145473. _ind: number;
  145474. /**
  145475. * Group this particle belongs to
  145476. */
  145477. _group: PointsGroup;
  145478. /**
  145479. * Group id of this particle
  145480. */
  145481. groupId: number;
  145482. /**
  145483. * Index of the particle in its group id (Internal use)
  145484. */
  145485. idxInGroup: number;
  145486. /**
  145487. * @hidden Particle BoundingInfo object (Internal use)
  145488. */
  145489. _boundingInfo: BoundingInfo;
  145490. /**
  145491. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  145492. */
  145493. _pcs: PointsCloudSystem;
  145494. /**
  145495. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  145496. */
  145497. _stillInvisible: boolean;
  145498. /**
  145499. * @hidden Last computed particle rotation matrix
  145500. */
  145501. _rotationMatrix: number[];
  145502. /**
  145503. * Parent particle Id, if any.
  145504. * Default null.
  145505. */
  145506. parentId: Nullable<number>;
  145507. /**
  145508. * @hidden Internal global position in the PCS.
  145509. */
  145510. _globalPosition: Vector3;
  145511. /**
  145512. * Creates a Point Cloud object.
  145513. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  145514. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  145515. * @param group (PointsGroup) is the group the particle belongs to
  145516. * @param groupId (integer) is the group identifier in the PCS.
  145517. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  145518. * @param pcs defines the PCS it is associated to
  145519. */
  145520. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  145521. /**
  145522. * get point size
  145523. */
  145524. get size(): Vector3;
  145525. /**
  145526. * Set point size
  145527. */
  145528. set size(scale: Vector3);
  145529. /**
  145530. * Legacy support, changed quaternion to rotationQuaternion
  145531. */
  145532. get quaternion(): Nullable<Quaternion>;
  145533. /**
  145534. * Legacy support, changed quaternion to rotationQuaternion
  145535. */
  145536. set quaternion(q: Nullable<Quaternion>);
  145537. /**
  145538. * Returns a boolean. True if the particle intersects a mesh, else false
  145539. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  145540. * @param target is the object (point or mesh) what the intersection is computed against
  145541. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  145542. * @returns true if it intersects
  145543. */
  145544. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  145545. /**
  145546. * get the rotation matrix of the particle
  145547. * @hidden
  145548. */
  145549. getRotationMatrix(m: Matrix): void;
  145550. }
  145551. /**
  145552. * Represents a group of points in a points cloud system
  145553. * * PCS internal tool, don't use it manually.
  145554. */
  145555. export class PointsGroup {
  145556. /**
  145557. * The group id
  145558. * @hidden
  145559. */
  145560. groupID: number;
  145561. /**
  145562. * image data for group (internal use)
  145563. * @hidden
  145564. */
  145565. _groupImageData: Nullable<ArrayBufferView>;
  145566. /**
  145567. * Image Width (internal use)
  145568. * @hidden
  145569. */
  145570. _groupImgWidth: number;
  145571. /**
  145572. * Image Height (internal use)
  145573. * @hidden
  145574. */
  145575. _groupImgHeight: number;
  145576. /**
  145577. * Custom position function (internal use)
  145578. * @hidden
  145579. */
  145580. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  145581. /**
  145582. * density per facet for surface points
  145583. * @hidden
  145584. */
  145585. _groupDensity: number[];
  145586. /**
  145587. * Only when points are colored by texture carries pointer to texture list array
  145588. * @hidden
  145589. */
  145590. _textureNb: number;
  145591. /**
  145592. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  145593. * PCS internal tool, don't use it manually.
  145594. * @hidden
  145595. */
  145596. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  145597. }
  145598. }
  145599. declare module BABYLON {
  145600. interface Scene {
  145601. /** @hidden (Backing field) */
  145602. _physicsEngine: Nullable<IPhysicsEngine>;
  145603. /** @hidden */
  145604. _physicsTimeAccumulator: number;
  145605. /**
  145606. * Gets the current physics engine
  145607. * @returns a IPhysicsEngine or null if none attached
  145608. */
  145609. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  145610. /**
  145611. * Enables physics to the current scene
  145612. * @param gravity defines the scene's gravity for the physics engine
  145613. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  145614. * @return a boolean indicating if the physics engine was initialized
  145615. */
  145616. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  145617. /**
  145618. * Disables and disposes the physics engine associated with the scene
  145619. */
  145620. disablePhysicsEngine(): void;
  145621. /**
  145622. * Gets a boolean indicating if there is an active physics engine
  145623. * @returns a boolean indicating if there is an active physics engine
  145624. */
  145625. isPhysicsEnabled(): boolean;
  145626. /**
  145627. * Deletes a physics compound impostor
  145628. * @param compound defines the compound to delete
  145629. */
  145630. deleteCompoundImpostor(compound: any): void;
  145631. /**
  145632. * An event triggered when physic simulation is about to be run
  145633. */
  145634. onBeforePhysicsObservable: Observable<Scene>;
  145635. /**
  145636. * An event triggered when physic simulation has been done
  145637. */
  145638. onAfterPhysicsObservable: Observable<Scene>;
  145639. }
  145640. interface AbstractMesh {
  145641. /** @hidden */
  145642. _physicsImpostor: Nullable<PhysicsImpostor>;
  145643. /**
  145644. * Gets or sets impostor used for physic simulation
  145645. * @see https://doc.babylonjs.com/features/physics_engine
  145646. */
  145647. physicsImpostor: Nullable<PhysicsImpostor>;
  145648. /**
  145649. * Gets the current physics impostor
  145650. * @see https://doc.babylonjs.com/features/physics_engine
  145651. * @returns a physics impostor or null
  145652. */
  145653. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  145654. /** Apply a physic impulse to the mesh
  145655. * @param force defines the force to apply
  145656. * @param contactPoint defines where to apply the force
  145657. * @returns the current mesh
  145658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  145659. */
  145660. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  145661. /**
  145662. * Creates a physic joint between two meshes
  145663. * @param otherMesh defines the other mesh to use
  145664. * @param pivot1 defines the pivot to use on this mesh
  145665. * @param pivot2 defines the pivot to use on the other mesh
  145666. * @param options defines additional options (can be plugin dependent)
  145667. * @returns the current mesh
  145668. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  145669. */
  145670. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  145671. /** @hidden */
  145672. _disposePhysicsObserver: Nullable<Observer<Node>>;
  145673. }
  145674. /**
  145675. * Defines the physics engine scene component responsible to manage a physics engine
  145676. */
  145677. export class PhysicsEngineSceneComponent implements ISceneComponent {
  145678. /**
  145679. * The component name helpful to identify the component in the list of scene components.
  145680. */
  145681. readonly name: string;
  145682. /**
  145683. * The scene the component belongs to.
  145684. */
  145685. scene: Scene;
  145686. /**
  145687. * Creates a new instance of the component for the given scene
  145688. * @param scene Defines the scene to register the component in
  145689. */
  145690. constructor(scene: Scene);
  145691. /**
  145692. * Registers the component in a given scene
  145693. */
  145694. register(): void;
  145695. /**
  145696. * Rebuilds the elements related to this component in case of
  145697. * context lost for instance.
  145698. */
  145699. rebuild(): void;
  145700. /**
  145701. * Disposes the component and the associated ressources
  145702. */
  145703. dispose(): void;
  145704. }
  145705. }
  145706. declare module BABYLON {
  145707. /**
  145708. * A helper for physics simulations
  145709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145710. */
  145711. export class PhysicsHelper {
  145712. private _scene;
  145713. private _physicsEngine;
  145714. /**
  145715. * Initializes the Physics helper
  145716. * @param scene Babylon.js scene
  145717. */
  145718. constructor(scene: Scene);
  145719. /**
  145720. * Applies a radial explosion impulse
  145721. * @param origin the origin of the explosion
  145722. * @param radiusOrEventOptions the radius or the options of radial explosion
  145723. * @param strength the explosion strength
  145724. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145725. * @returns A physics radial explosion event, or null
  145726. */
  145727. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145728. /**
  145729. * Applies a radial explosion force
  145730. * @param origin the origin of the explosion
  145731. * @param radiusOrEventOptions the radius or the options of radial explosion
  145732. * @param strength the explosion strength
  145733. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145734. * @returns A physics radial explosion event, or null
  145735. */
  145736. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145737. /**
  145738. * Creates a gravitational field
  145739. * @param origin the origin of the explosion
  145740. * @param radiusOrEventOptions the radius or the options of radial explosion
  145741. * @param strength the explosion strength
  145742. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145743. * @returns A physics gravitational field event, or null
  145744. */
  145745. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  145746. /**
  145747. * Creates a physics updraft event
  145748. * @param origin the origin of the updraft
  145749. * @param radiusOrEventOptions the radius or the options of the updraft
  145750. * @param strength the strength of the updraft
  145751. * @param height the height of the updraft
  145752. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  145753. * @returns A physics updraft event, or null
  145754. */
  145755. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  145756. /**
  145757. * Creates a physics vortex event
  145758. * @param origin the of the vortex
  145759. * @param radiusOrEventOptions the radius or the options of the vortex
  145760. * @param strength the strength of the vortex
  145761. * @param height the height of the vortex
  145762. * @returns a Physics vortex event, or null
  145763. * A physics vortex event or null
  145764. */
  145765. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  145766. }
  145767. /**
  145768. * Represents a physics radial explosion event
  145769. */
  145770. class PhysicsRadialExplosionEvent {
  145771. private _scene;
  145772. private _options;
  145773. private _sphere;
  145774. private _dataFetched;
  145775. /**
  145776. * Initializes a radial explosioin event
  145777. * @param _scene BabylonJS scene
  145778. * @param _options The options for the vortex event
  145779. */
  145780. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  145781. /**
  145782. * Returns the data related to the radial explosion event (sphere).
  145783. * @returns The radial explosion event data
  145784. */
  145785. getData(): PhysicsRadialExplosionEventData;
  145786. /**
  145787. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  145788. * @param impostor A physics imposter
  145789. * @param origin the origin of the explosion
  145790. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  145791. */
  145792. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  145793. /**
  145794. * Triggers affecterd impostors callbacks
  145795. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  145796. */
  145797. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  145798. /**
  145799. * Disposes the sphere.
  145800. * @param force Specifies if the sphere should be disposed by force
  145801. */
  145802. dispose(force?: boolean): void;
  145803. /*** Helpers ***/
  145804. private _prepareSphere;
  145805. private _intersectsWithSphere;
  145806. }
  145807. /**
  145808. * Represents a gravitational field event
  145809. */
  145810. class PhysicsGravitationalFieldEvent {
  145811. private _physicsHelper;
  145812. private _scene;
  145813. private _origin;
  145814. private _options;
  145815. private _tickCallback;
  145816. private _sphere;
  145817. private _dataFetched;
  145818. /**
  145819. * Initializes the physics gravitational field event
  145820. * @param _physicsHelper A physics helper
  145821. * @param _scene BabylonJS scene
  145822. * @param _origin The origin position of the gravitational field event
  145823. * @param _options The options for the vortex event
  145824. */
  145825. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  145826. /**
  145827. * Returns the data related to the gravitational field event (sphere).
  145828. * @returns A gravitational field event
  145829. */
  145830. getData(): PhysicsGravitationalFieldEventData;
  145831. /**
  145832. * Enables the gravitational field.
  145833. */
  145834. enable(): void;
  145835. /**
  145836. * Disables the gravitational field.
  145837. */
  145838. disable(): void;
  145839. /**
  145840. * Disposes the sphere.
  145841. * @param force The force to dispose from the gravitational field event
  145842. */
  145843. dispose(force?: boolean): void;
  145844. private _tick;
  145845. }
  145846. /**
  145847. * Represents a physics updraft event
  145848. */
  145849. class PhysicsUpdraftEvent {
  145850. private _scene;
  145851. private _origin;
  145852. private _options;
  145853. private _physicsEngine;
  145854. private _originTop;
  145855. private _originDirection;
  145856. private _tickCallback;
  145857. private _cylinder;
  145858. private _cylinderPosition;
  145859. private _dataFetched;
  145860. /**
  145861. * Initializes the physics updraft event
  145862. * @param _scene BabylonJS scene
  145863. * @param _origin The origin position of the updraft
  145864. * @param _options The options for the updraft event
  145865. */
  145866. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  145867. /**
  145868. * Returns the data related to the updraft event (cylinder).
  145869. * @returns A physics updraft event
  145870. */
  145871. getData(): PhysicsUpdraftEventData;
  145872. /**
  145873. * Enables the updraft.
  145874. */
  145875. enable(): void;
  145876. /**
  145877. * Disables the updraft.
  145878. */
  145879. disable(): void;
  145880. /**
  145881. * Disposes the cylinder.
  145882. * @param force Specifies if the updraft should be disposed by force
  145883. */
  145884. dispose(force?: boolean): void;
  145885. private getImpostorHitData;
  145886. private _tick;
  145887. /*** Helpers ***/
  145888. private _prepareCylinder;
  145889. private _intersectsWithCylinder;
  145890. }
  145891. /**
  145892. * Represents a physics vortex event
  145893. */
  145894. class PhysicsVortexEvent {
  145895. private _scene;
  145896. private _origin;
  145897. private _options;
  145898. private _physicsEngine;
  145899. private _originTop;
  145900. private _tickCallback;
  145901. private _cylinder;
  145902. private _cylinderPosition;
  145903. private _dataFetched;
  145904. /**
  145905. * Initializes the physics vortex event
  145906. * @param _scene The BabylonJS scene
  145907. * @param _origin The origin position of the vortex
  145908. * @param _options The options for the vortex event
  145909. */
  145910. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  145911. /**
  145912. * Returns the data related to the vortex event (cylinder).
  145913. * @returns The physics vortex event data
  145914. */
  145915. getData(): PhysicsVortexEventData;
  145916. /**
  145917. * Enables the vortex.
  145918. */
  145919. enable(): void;
  145920. /**
  145921. * Disables the cortex.
  145922. */
  145923. disable(): void;
  145924. /**
  145925. * Disposes the sphere.
  145926. * @param force
  145927. */
  145928. dispose(force?: boolean): void;
  145929. private getImpostorHitData;
  145930. private _tick;
  145931. /*** Helpers ***/
  145932. private _prepareCylinder;
  145933. private _intersectsWithCylinder;
  145934. }
  145935. /**
  145936. * Options fot the radial explosion event
  145937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145938. */
  145939. export class PhysicsRadialExplosionEventOptions {
  145940. /**
  145941. * The radius of the sphere for the radial explosion.
  145942. */
  145943. radius: number;
  145944. /**
  145945. * The strenth of the explosion.
  145946. */
  145947. strength: number;
  145948. /**
  145949. * The strenght of the force in correspondence to the distance of the affected object
  145950. */
  145951. falloff: PhysicsRadialImpulseFalloff;
  145952. /**
  145953. * Sphere options for the radial explosion.
  145954. */
  145955. sphere: {
  145956. segments: number;
  145957. diameter: number;
  145958. };
  145959. /**
  145960. * Sphere options for the radial explosion.
  145961. */
  145962. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  145963. }
  145964. /**
  145965. * Options fot the updraft event
  145966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145967. */
  145968. export class PhysicsUpdraftEventOptions {
  145969. /**
  145970. * The radius of the cylinder for the vortex
  145971. */
  145972. radius: number;
  145973. /**
  145974. * The strenth of the updraft.
  145975. */
  145976. strength: number;
  145977. /**
  145978. * The height of the cylinder for the updraft.
  145979. */
  145980. height: number;
  145981. /**
  145982. * The mode for the the updraft.
  145983. */
  145984. updraftMode: PhysicsUpdraftMode;
  145985. }
  145986. /**
  145987. * Options fot the vortex event
  145988. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145989. */
  145990. export class PhysicsVortexEventOptions {
  145991. /**
  145992. * The radius of the cylinder for the vortex
  145993. */
  145994. radius: number;
  145995. /**
  145996. * The strenth of the vortex.
  145997. */
  145998. strength: number;
  145999. /**
  146000. * The height of the cylinder for the vortex.
  146001. */
  146002. height: number;
  146003. /**
  146004. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  146005. */
  146006. centripetalForceThreshold: number;
  146007. /**
  146008. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  146009. */
  146010. centripetalForceMultiplier: number;
  146011. /**
  146012. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  146013. */
  146014. centrifugalForceMultiplier: number;
  146015. /**
  146016. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  146017. */
  146018. updraftForceMultiplier: number;
  146019. }
  146020. /**
  146021. * The strenght of the force in correspondence to the distance of the affected object
  146022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146023. */
  146024. export enum PhysicsRadialImpulseFalloff {
  146025. /** Defines that impulse is constant in strength across it's whole radius */
  146026. Constant = 0,
  146027. /** Defines that impulse gets weaker if it's further from the origin */
  146028. Linear = 1
  146029. }
  146030. /**
  146031. * The strength of the force in correspondence to the distance of the affected object
  146032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146033. */
  146034. export enum PhysicsUpdraftMode {
  146035. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  146036. Center = 0,
  146037. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  146038. Perpendicular = 1
  146039. }
  146040. /**
  146041. * Interface for a physics hit data
  146042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146043. */
  146044. export interface PhysicsHitData {
  146045. /**
  146046. * The force applied at the contact point
  146047. */
  146048. force: Vector3;
  146049. /**
  146050. * The contact point
  146051. */
  146052. contactPoint: Vector3;
  146053. /**
  146054. * The distance from the origin to the contact point
  146055. */
  146056. distanceFromOrigin: number;
  146057. }
  146058. /**
  146059. * Interface for radial explosion event data
  146060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146061. */
  146062. export interface PhysicsRadialExplosionEventData {
  146063. /**
  146064. * A sphere used for the radial explosion event
  146065. */
  146066. sphere: Mesh;
  146067. }
  146068. /**
  146069. * Interface for gravitational field event data
  146070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146071. */
  146072. export interface PhysicsGravitationalFieldEventData {
  146073. /**
  146074. * A sphere mesh used for the gravitational field event
  146075. */
  146076. sphere: Mesh;
  146077. }
  146078. /**
  146079. * Interface for updraft event data
  146080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146081. */
  146082. export interface PhysicsUpdraftEventData {
  146083. /**
  146084. * A cylinder used for the updraft event
  146085. */
  146086. cylinder: Mesh;
  146087. }
  146088. /**
  146089. * Interface for vortex event data
  146090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146091. */
  146092. export interface PhysicsVortexEventData {
  146093. /**
  146094. * A cylinder used for the vortex event
  146095. */
  146096. cylinder: Mesh;
  146097. }
  146098. /**
  146099. * Interface for an affected physics impostor
  146100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146101. */
  146102. export interface PhysicsAffectedImpostorWithData {
  146103. /**
  146104. * The impostor affected by the effect
  146105. */
  146106. impostor: PhysicsImpostor;
  146107. /**
  146108. * The data about the hit/horce from the explosion
  146109. */
  146110. hitData: PhysicsHitData;
  146111. }
  146112. }
  146113. declare module BABYLON {
  146114. /** @hidden */
  146115. export var blackAndWhitePixelShader: {
  146116. name: string;
  146117. shader: string;
  146118. };
  146119. }
  146120. declare module BABYLON {
  146121. /**
  146122. * Post process used to render in black and white
  146123. */
  146124. export class BlackAndWhitePostProcess extends PostProcess {
  146125. /**
  146126. * Linear about to convert he result to black and white (default: 1)
  146127. */
  146128. degree: number;
  146129. /**
  146130. * Creates a black and white post process
  146131. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  146132. * @param name The name of the effect.
  146133. * @param options The required width/height ratio to downsize to before computing the render pass.
  146134. * @param camera The camera to apply the render pass to.
  146135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146136. * @param engine The engine which the post process will be applied. (default: current engine)
  146137. * @param reusable If the post process can be reused on the same frame. (default: false)
  146138. */
  146139. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146140. }
  146141. }
  146142. declare module BABYLON {
  146143. /**
  146144. * This represents a set of one or more post processes in Babylon.
  146145. * A post process can be used to apply a shader to a texture after it is rendered.
  146146. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146147. */
  146148. export class PostProcessRenderEffect {
  146149. private _postProcesses;
  146150. private _getPostProcesses;
  146151. private _singleInstance;
  146152. private _cameras;
  146153. private _indicesForCamera;
  146154. /**
  146155. * Name of the effect
  146156. * @hidden
  146157. */
  146158. _name: string;
  146159. /**
  146160. * Instantiates a post process render effect.
  146161. * A post process can be used to apply a shader to a texture after it is rendered.
  146162. * @param engine The engine the effect is tied to
  146163. * @param name The name of the effect
  146164. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  146165. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  146166. */
  146167. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  146168. /**
  146169. * Checks if all the post processes in the effect are supported.
  146170. */
  146171. get isSupported(): boolean;
  146172. /**
  146173. * Updates the current state of the effect
  146174. * @hidden
  146175. */
  146176. _update(): void;
  146177. /**
  146178. * Attaches the effect on cameras
  146179. * @param cameras The camera to attach to.
  146180. * @hidden
  146181. */
  146182. _attachCameras(cameras: Camera): void;
  146183. /**
  146184. * Attaches the effect on cameras
  146185. * @param cameras The camera to attach to.
  146186. * @hidden
  146187. */
  146188. _attachCameras(cameras: Camera[]): void;
  146189. /**
  146190. * Detaches the effect on cameras
  146191. * @param cameras The camera to detatch from.
  146192. * @hidden
  146193. */
  146194. _detachCameras(cameras: Camera): void;
  146195. /**
  146196. * Detatches the effect on cameras
  146197. * @param cameras The camera to detatch from.
  146198. * @hidden
  146199. */
  146200. _detachCameras(cameras: Camera[]): void;
  146201. /**
  146202. * Enables the effect on given cameras
  146203. * @param cameras The camera to enable.
  146204. * @hidden
  146205. */
  146206. _enable(cameras: Camera): void;
  146207. /**
  146208. * Enables the effect on given cameras
  146209. * @param cameras The camera to enable.
  146210. * @hidden
  146211. */
  146212. _enable(cameras: Nullable<Camera[]>): void;
  146213. /**
  146214. * Disables the effect on the given cameras
  146215. * @param cameras The camera to disable.
  146216. * @hidden
  146217. */
  146218. _disable(cameras: Camera): void;
  146219. /**
  146220. * Disables the effect on the given cameras
  146221. * @param cameras The camera to disable.
  146222. * @hidden
  146223. */
  146224. _disable(cameras: Nullable<Camera[]>): void;
  146225. /**
  146226. * Gets a list of the post processes contained in the effect.
  146227. * @param camera The camera to get the post processes on.
  146228. * @returns The list of the post processes in the effect.
  146229. */
  146230. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  146231. }
  146232. }
  146233. declare module BABYLON {
  146234. /** @hidden */
  146235. export var extractHighlightsPixelShader: {
  146236. name: string;
  146237. shader: string;
  146238. };
  146239. }
  146240. declare module BABYLON {
  146241. /**
  146242. * 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.
  146243. */
  146244. export class ExtractHighlightsPostProcess extends PostProcess {
  146245. /**
  146246. * The luminance threshold, pixels below this value will be set to black.
  146247. */
  146248. threshold: number;
  146249. /** @hidden */
  146250. _exposure: number;
  146251. /**
  146252. * Post process which has the input texture to be used when performing highlight extraction
  146253. * @hidden
  146254. */
  146255. _inputPostProcess: Nullable<PostProcess>;
  146256. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146257. }
  146258. }
  146259. declare module BABYLON {
  146260. /** @hidden */
  146261. export var bloomMergePixelShader: {
  146262. name: string;
  146263. shader: string;
  146264. };
  146265. }
  146266. declare module BABYLON {
  146267. /**
  146268. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146269. */
  146270. export class BloomMergePostProcess extends PostProcess {
  146271. /** Weight of the bloom to be added to the original input. */
  146272. weight: number;
  146273. /**
  146274. * Creates a new instance of @see BloomMergePostProcess
  146275. * @param name The name of the effect.
  146276. * @param originalFromInput Post process which's input will be used for the merge.
  146277. * @param blurred Blurred highlights post process which's output will be used.
  146278. * @param weight Weight of the bloom to be added to the original input.
  146279. * @param options The required width/height ratio to downsize to before computing the render pass.
  146280. * @param camera The camera to apply the render pass to.
  146281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146282. * @param engine The engine which the post process will be applied. (default: current engine)
  146283. * @param reusable If the post process can be reused on the same frame. (default: false)
  146284. * @param textureType Type of textures used when performing the post process. (default: 0)
  146285. * @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)
  146286. */
  146287. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  146288. /** Weight of the bloom to be added to the original input. */
  146289. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146290. }
  146291. }
  146292. declare module BABYLON {
  146293. /**
  146294. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  146295. */
  146296. export class BloomEffect extends PostProcessRenderEffect {
  146297. private bloomScale;
  146298. /**
  146299. * @hidden Internal
  146300. */
  146301. _effects: Array<PostProcess>;
  146302. /**
  146303. * @hidden Internal
  146304. */
  146305. _downscale: ExtractHighlightsPostProcess;
  146306. private _blurX;
  146307. private _blurY;
  146308. private _merge;
  146309. /**
  146310. * The luminance threshold to find bright areas of the image to bloom.
  146311. */
  146312. get threshold(): number;
  146313. set threshold(value: number);
  146314. /**
  146315. * The strength of the bloom.
  146316. */
  146317. get weight(): number;
  146318. set weight(value: number);
  146319. /**
  146320. * Specifies the size of the bloom blur kernel, relative to the final output size
  146321. */
  146322. get kernel(): number;
  146323. set kernel(value: number);
  146324. /**
  146325. * Creates a new instance of @see BloomEffect
  146326. * @param scene The scene the effect belongs to.
  146327. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  146328. * @param bloomKernel The size of the kernel to be used when applying the blur.
  146329. * @param bloomWeight The the strength of bloom.
  146330. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  146331. * @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)
  146332. */
  146333. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  146334. /**
  146335. * Disposes each of the internal effects for a given camera.
  146336. * @param camera The camera to dispose the effect on.
  146337. */
  146338. disposeEffects(camera: Camera): void;
  146339. /**
  146340. * @hidden Internal
  146341. */
  146342. _updateEffects(): void;
  146343. /**
  146344. * Internal
  146345. * @returns if all the contained post processes are ready.
  146346. * @hidden
  146347. */
  146348. _isReady(): boolean;
  146349. }
  146350. }
  146351. declare module BABYLON {
  146352. /** @hidden */
  146353. export var chromaticAberrationPixelShader: {
  146354. name: string;
  146355. shader: string;
  146356. };
  146357. }
  146358. declare module BABYLON {
  146359. /**
  146360. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  146361. */
  146362. export class ChromaticAberrationPostProcess extends PostProcess {
  146363. /**
  146364. * The amount of seperation of rgb channels (default: 30)
  146365. */
  146366. aberrationAmount: number;
  146367. /**
  146368. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  146369. */
  146370. radialIntensity: number;
  146371. /**
  146372. * 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))
  146373. */
  146374. direction: Vector2;
  146375. /**
  146376. * 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))
  146377. */
  146378. centerPosition: Vector2;
  146379. /**
  146380. * Creates a new instance ChromaticAberrationPostProcess
  146381. * @param name The name of the effect.
  146382. * @param screenWidth The width of the screen to apply the effect on.
  146383. * @param screenHeight The height of the screen to apply the effect on.
  146384. * @param options The required width/height ratio to downsize to before computing the render pass.
  146385. * @param camera The camera to apply the render pass to.
  146386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146387. * @param engine The engine which the post process will be applied. (default: current engine)
  146388. * @param reusable If the post process can be reused on the same frame. (default: false)
  146389. * @param textureType Type of textures used when performing the post process. (default: 0)
  146390. * @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)
  146391. */
  146392. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146393. }
  146394. }
  146395. declare module BABYLON {
  146396. /** @hidden */
  146397. export var circleOfConfusionPixelShader: {
  146398. name: string;
  146399. shader: string;
  146400. };
  146401. }
  146402. declare module BABYLON {
  146403. /**
  146404. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  146405. */
  146406. export class CircleOfConfusionPostProcess extends PostProcess {
  146407. /**
  146408. * 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.
  146409. */
  146410. lensSize: number;
  146411. /**
  146412. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  146413. */
  146414. fStop: number;
  146415. /**
  146416. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  146417. */
  146418. focusDistance: number;
  146419. /**
  146420. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  146421. */
  146422. focalLength: number;
  146423. private _depthTexture;
  146424. /**
  146425. * Creates a new instance CircleOfConfusionPostProcess
  146426. * @param name The name of the effect.
  146427. * @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.
  146428. * @param options The required width/height ratio to downsize to before computing the render pass.
  146429. * @param camera The camera to apply the render pass to.
  146430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146431. * @param engine The engine which the post process will be applied. (default: current engine)
  146432. * @param reusable If the post process can be reused on the same frame. (default: false)
  146433. * @param textureType Type of textures used when performing the post process. (default: 0)
  146434. * @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)
  146435. */
  146436. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146437. /**
  146438. * 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.
  146439. */
  146440. set depthTexture(value: RenderTargetTexture);
  146441. }
  146442. }
  146443. declare module BABYLON {
  146444. /** @hidden */
  146445. export var colorCorrectionPixelShader: {
  146446. name: string;
  146447. shader: string;
  146448. };
  146449. }
  146450. declare module BABYLON {
  146451. /**
  146452. *
  146453. * This post-process allows the modification of rendered colors by using
  146454. * a 'look-up table' (LUT). This effect is also called Color Grading.
  146455. *
  146456. * The object needs to be provided an url to a texture containing the color
  146457. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  146458. * Use an image editing software to tweak the LUT to match your needs.
  146459. *
  146460. * For an example of a color LUT, see here:
  146461. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  146462. * For explanations on color grading, see here:
  146463. * @see http://udn.epicgames.com/Three/ColorGrading.html
  146464. *
  146465. */
  146466. export class ColorCorrectionPostProcess extends PostProcess {
  146467. private _colorTableTexture;
  146468. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146469. }
  146470. }
  146471. declare module BABYLON {
  146472. /** @hidden */
  146473. export var convolutionPixelShader: {
  146474. name: string;
  146475. shader: string;
  146476. };
  146477. }
  146478. declare module BABYLON {
  146479. /**
  146480. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  146481. * input texture to perform effects such as edge detection or sharpening
  146482. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  146483. */
  146484. export class ConvolutionPostProcess extends PostProcess {
  146485. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146486. kernel: number[];
  146487. /**
  146488. * Creates a new instance ConvolutionPostProcess
  146489. * @param name The name of the effect.
  146490. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  146491. * @param options The required width/height ratio to downsize to before computing the render pass.
  146492. * @param camera The camera to apply the render pass to.
  146493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146494. * @param engine The engine which the post process will be applied. (default: current engine)
  146495. * @param reusable If the post process can be reused on the same frame. (default: false)
  146496. * @param textureType Type of textures used when performing the post process. (default: 0)
  146497. */
  146498. constructor(name: string,
  146499. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146500. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146501. /**
  146502. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146503. */
  146504. static EdgeDetect0Kernel: number[];
  146505. /**
  146506. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146507. */
  146508. static EdgeDetect1Kernel: number[];
  146509. /**
  146510. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146511. */
  146512. static EdgeDetect2Kernel: number[];
  146513. /**
  146514. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146515. */
  146516. static SharpenKernel: number[];
  146517. /**
  146518. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146519. */
  146520. static EmbossKernel: number[];
  146521. /**
  146522. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146523. */
  146524. static GaussianKernel: number[];
  146525. }
  146526. }
  146527. declare module BABYLON {
  146528. /**
  146529. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  146530. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  146531. * based on samples that have a large difference in distance than the center pixel.
  146532. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  146533. */
  146534. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  146535. direction: Vector2;
  146536. /**
  146537. * Creates a new instance CircleOfConfusionPostProcess
  146538. * @param name The name of the effect.
  146539. * @param scene The scene the effect belongs to.
  146540. * @param direction The direction the blur should be applied.
  146541. * @param kernel The size of the kernel used to blur.
  146542. * @param options The required width/height ratio to downsize to before computing the render pass.
  146543. * @param camera The camera to apply the render pass to.
  146544. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  146545. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  146546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146547. * @param engine The engine which the post process will be applied. (default: current engine)
  146548. * @param reusable If the post process can be reused on the same frame. (default: false)
  146549. * @param textureType Type of textures used when performing the post process. (default: 0)
  146550. * @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)
  146551. */
  146552. 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);
  146553. }
  146554. }
  146555. declare module BABYLON {
  146556. /** @hidden */
  146557. export var depthOfFieldMergePixelShader: {
  146558. name: string;
  146559. shader: string;
  146560. };
  146561. }
  146562. declare module BABYLON {
  146563. /**
  146564. * Options to be set when merging outputs from the default pipeline.
  146565. */
  146566. export class DepthOfFieldMergePostProcessOptions {
  146567. /**
  146568. * The original image to merge on top of
  146569. */
  146570. originalFromInput: PostProcess;
  146571. /**
  146572. * Parameters to perform the merge of the depth of field effect
  146573. */
  146574. depthOfField?: {
  146575. circleOfConfusion: PostProcess;
  146576. blurSteps: Array<PostProcess>;
  146577. };
  146578. /**
  146579. * Parameters to perform the merge of bloom effect
  146580. */
  146581. bloom?: {
  146582. blurred: PostProcess;
  146583. weight: number;
  146584. };
  146585. }
  146586. /**
  146587. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146588. */
  146589. export class DepthOfFieldMergePostProcess extends PostProcess {
  146590. private blurSteps;
  146591. /**
  146592. * Creates a new instance of DepthOfFieldMergePostProcess
  146593. * @param name The name of the effect.
  146594. * @param originalFromInput Post process which's input will be used for the merge.
  146595. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  146596. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  146597. * @param options The required width/height ratio to downsize to before computing the render pass.
  146598. * @param camera The camera to apply the render pass to.
  146599. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146600. * @param engine The engine which the post process will be applied. (default: current engine)
  146601. * @param reusable If the post process can be reused on the same frame. (default: false)
  146602. * @param textureType Type of textures used when performing the post process. (default: 0)
  146603. * @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)
  146604. */
  146605. 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);
  146606. /**
  146607. * Updates the effect with the current post process compile time values and recompiles the shader.
  146608. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  146609. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  146610. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  146611. * @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
  146612. * @param onCompiled Called when the shader has been compiled.
  146613. * @param onError Called if there is an error when compiling a shader.
  146614. */
  146615. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  146616. }
  146617. }
  146618. declare module BABYLON {
  146619. /**
  146620. * Specifies the level of max blur that should be applied when using the depth of field effect
  146621. */
  146622. export enum DepthOfFieldEffectBlurLevel {
  146623. /**
  146624. * Subtle blur
  146625. */
  146626. Low = 0,
  146627. /**
  146628. * Medium blur
  146629. */
  146630. Medium = 1,
  146631. /**
  146632. * Large blur
  146633. */
  146634. High = 2
  146635. }
  146636. /**
  146637. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  146638. */
  146639. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  146640. private _circleOfConfusion;
  146641. /**
  146642. * @hidden Internal, blurs from high to low
  146643. */
  146644. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  146645. private _depthOfFieldBlurY;
  146646. private _dofMerge;
  146647. /**
  146648. * @hidden Internal post processes in depth of field effect
  146649. */
  146650. _effects: Array<PostProcess>;
  146651. /**
  146652. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  146653. */
  146654. set focalLength(value: number);
  146655. get focalLength(): number;
  146656. /**
  146657. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  146658. */
  146659. set fStop(value: number);
  146660. get fStop(): number;
  146661. /**
  146662. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  146663. */
  146664. set focusDistance(value: number);
  146665. get focusDistance(): number;
  146666. /**
  146667. * 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.
  146668. */
  146669. set lensSize(value: number);
  146670. get lensSize(): number;
  146671. /**
  146672. * Creates a new instance DepthOfFieldEffect
  146673. * @param scene The scene the effect belongs to.
  146674. * @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.
  146675. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  146676. * @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)
  146677. */
  146678. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  146679. /**
  146680. * Get the current class name of the current effet
  146681. * @returns "DepthOfFieldEffect"
  146682. */
  146683. getClassName(): string;
  146684. /**
  146685. * 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.
  146686. */
  146687. set depthTexture(value: RenderTargetTexture);
  146688. /**
  146689. * Disposes each of the internal effects for a given camera.
  146690. * @param camera The camera to dispose the effect on.
  146691. */
  146692. disposeEffects(camera: Camera): void;
  146693. /**
  146694. * @hidden Internal
  146695. */
  146696. _updateEffects(): void;
  146697. /**
  146698. * Internal
  146699. * @returns if all the contained post processes are ready.
  146700. * @hidden
  146701. */
  146702. _isReady(): boolean;
  146703. }
  146704. }
  146705. declare module BABYLON {
  146706. /** @hidden */
  146707. export var displayPassPixelShader: {
  146708. name: string;
  146709. shader: string;
  146710. };
  146711. }
  146712. declare module BABYLON {
  146713. /**
  146714. * DisplayPassPostProcess which produces an output the same as it's input
  146715. */
  146716. export class DisplayPassPostProcess extends PostProcess {
  146717. /**
  146718. * Creates the DisplayPassPostProcess
  146719. * @param name The name of the effect.
  146720. * @param options The required width/height ratio to downsize to before computing the render pass.
  146721. * @param camera The camera to apply the render pass to.
  146722. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146723. * @param engine The engine which the post process will be applied. (default: current engine)
  146724. * @param reusable If the post process can be reused on the same frame. (default: false)
  146725. */
  146726. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146727. }
  146728. }
  146729. declare module BABYLON {
  146730. /** @hidden */
  146731. export var filterPixelShader: {
  146732. name: string;
  146733. shader: string;
  146734. };
  146735. }
  146736. declare module BABYLON {
  146737. /**
  146738. * Applies a kernel filter to the image
  146739. */
  146740. export class FilterPostProcess extends PostProcess {
  146741. /** The matrix to be applied to the image */
  146742. kernelMatrix: Matrix;
  146743. /**
  146744. *
  146745. * @param name The name of the effect.
  146746. * @param kernelMatrix The matrix to be applied to the image
  146747. * @param options The required width/height ratio to downsize to before computing the render pass.
  146748. * @param camera The camera to apply the render pass to.
  146749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146750. * @param engine The engine which the post process will be applied. (default: current engine)
  146751. * @param reusable If the post process can be reused on the same frame. (default: false)
  146752. */
  146753. constructor(name: string,
  146754. /** The matrix to be applied to the image */
  146755. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146756. }
  146757. }
  146758. declare module BABYLON {
  146759. /** @hidden */
  146760. export var fxaaPixelShader: {
  146761. name: string;
  146762. shader: string;
  146763. };
  146764. }
  146765. declare module BABYLON {
  146766. /** @hidden */
  146767. export var fxaaVertexShader: {
  146768. name: string;
  146769. shader: string;
  146770. };
  146771. }
  146772. declare module BABYLON {
  146773. /**
  146774. * Fxaa post process
  146775. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  146776. */
  146777. export class FxaaPostProcess extends PostProcess {
  146778. /** @hidden */
  146779. texelWidth: number;
  146780. /** @hidden */
  146781. texelHeight: number;
  146782. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146783. private _getDefines;
  146784. }
  146785. }
  146786. declare module BABYLON {
  146787. /** @hidden */
  146788. export var grainPixelShader: {
  146789. name: string;
  146790. shader: string;
  146791. };
  146792. }
  146793. declare module BABYLON {
  146794. /**
  146795. * The GrainPostProcess adds noise to the image at mid luminance levels
  146796. */
  146797. export class GrainPostProcess extends PostProcess {
  146798. /**
  146799. * The intensity of the grain added (default: 30)
  146800. */
  146801. intensity: number;
  146802. /**
  146803. * If the grain should be randomized on every frame
  146804. */
  146805. animated: boolean;
  146806. /**
  146807. * Creates a new instance of @see GrainPostProcess
  146808. * @param name The name of the effect.
  146809. * @param options The required width/height ratio to downsize to before computing the render pass.
  146810. * @param camera The camera to apply the render pass to.
  146811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146812. * @param engine The engine which the post process will be applied. (default: current engine)
  146813. * @param reusable If the post process can be reused on the same frame. (default: false)
  146814. * @param textureType Type of textures used when performing the post process. (default: 0)
  146815. * @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)
  146816. */
  146817. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146818. }
  146819. }
  146820. declare module BABYLON {
  146821. /** @hidden */
  146822. export var highlightsPixelShader: {
  146823. name: string;
  146824. shader: string;
  146825. };
  146826. }
  146827. declare module BABYLON {
  146828. /**
  146829. * Extracts highlights from the image
  146830. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146831. */
  146832. export class HighlightsPostProcess extends PostProcess {
  146833. /**
  146834. * Extracts highlights from the image
  146835. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146836. * @param name The name of the effect.
  146837. * @param options The required width/height ratio to downsize to before computing the render pass.
  146838. * @param camera The camera to apply the render pass to.
  146839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146840. * @param engine The engine which the post process will be applied. (default: current engine)
  146841. * @param reusable If the post process can be reused on the same frame. (default: false)
  146842. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  146843. */
  146844. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146845. }
  146846. }
  146847. declare module BABYLON {
  146848. /** @hidden */
  146849. export var mrtFragmentDeclaration: {
  146850. name: string;
  146851. shader: string;
  146852. };
  146853. }
  146854. declare module BABYLON {
  146855. /** @hidden */
  146856. export var geometryPixelShader: {
  146857. name: string;
  146858. shader: string;
  146859. };
  146860. }
  146861. declare module BABYLON {
  146862. /** @hidden */
  146863. export var geometryVertexShader: {
  146864. name: string;
  146865. shader: string;
  146866. };
  146867. }
  146868. declare module BABYLON {
  146869. /** @hidden */
  146870. interface ISavedTransformationMatrix {
  146871. world: Matrix;
  146872. viewProjection: Matrix;
  146873. }
  146874. /**
  146875. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  146876. */
  146877. export class GeometryBufferRenderer {
  146878. /**
  146879. * Constant used to retrieve the position texture index in the G-Buffer textures array
  146880. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  146881. */
  146882. static readonly POSITION_TEXTURE_TYPE: number;
  146883. /**
  146884. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  146885. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  146886. */
  146887. static readonly VELOCITY_TEXTURE_TYPE: number;
  146888. /**
  146889. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  146890. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  146891. */
  146892. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  146893. /**
  146894. * Dictionary used to store the previous transformation matrices of each rendered mesh
  146895. * in order to compute objects velocities when enableVelocity is set to "true"
  146896. * @hidden
  146897. */
  146898. _previousTransformationMatrices: {
  146899. [index: number]: ISavedTransformationMatrix;
  146900. };
  146901. /**
  146902. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  146903. * in order to compute objects velocities when enableVelocity is set to "true"
  146904. * @hidden
  146905. */
  146906. _previousBonesTransformationMatrices: {
  146907. [index: number]: Float32Array;
  146908. };
  146909. /**
  146910. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  146911. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  146912. */
  146913. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  146914. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  146915. renderTransparentMeshes: boolean;
  146916. private _scene;
  146917. private _multiRenderTarget;
  146918. private _ratio;
  146919. private _enablePosition;
  146920. private _enableVelocity;
  146921. private _enableReflectivity;
  146922. private _positionIndex;
  146923. private _velocityIndex;
  146924. private _reflectivityIndex;
  146925. protected _effect: Effect;
  146926. protected _cachedDefines: string;
  146927. /**
  146928. * Set the render list (meshes to be rendered) used in the G buffer.
  146929. */
  146930. set renderList(meshes: Mesh[]);
  146931. /**
  146932. * Gets wether or not G buffer are supported by the running hardware.
  146933. * This requires draw buffer supports
  146934. */
  146935. get isSupported(): boolean;
  146936. /**
  146937. * Returns the index of the given texture type in the G-Buffer textures array
  146938. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  146939. * @returns the index of the given texture type in the G-Buffer textures array
  146940. */
  146941. getTextureIndex(textureType: number): number;
  146942. /**
  146943. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  146944. */
  146945. get enablePosition(): boolean;
  146946. /**
  146947. * Sets whether or not objects positions are enabled for the G buffer.
  146948. */
  146949. set enablePosition(enable: boolean);
  146950. /**
  146951. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  146952. */
  146953. get enableVelocity(): boolean;
  146954. /**
  146955. * Sets wether or not objects velocities are enabled for the G buffer.
  146956. */
  146957. set enableVelocity(enable: boolean);
  146958. /**
  146959. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  146960. */
  146961. get enableReflectivity(): boolean;
  146962. /**
  146963. * Sets wether or not objects roughness are enabled for the G buffer.
  146964. */
  146965. set enableReflectivity(enable: boolean);
  146966. /**
  146967. * Gets the scene associated with the buffer.
  146968. */
  146969. get scene(): Scene;
  146970. /**
  146971. * Gets the ratio used by the buffer during its creation.
  146972. * How big is the buffer related to the main canvas.
  146973. */
  146974. get ratio(): number;
  146975. /** @hidden */
  146976. static _SceneComponentInitialization: (scene: Scene) => void;
  146977. /**
  146978. * Creates a new G Buffer for the scene
  146979. * @param scene The scene the buffer belongs to
  146980. * @param ratio How big is the buffer related to the main canvas.
  146981. */
  146982. constructor(scene: Scene, ratio?: number);
  146983. /**
  146984. * Checks wether everything is ready to render a submesh to the G buffer.
  146985. * @param subMesh the submesh to check readiness for
  146986. * @param useInstances is the mesh drawn using instance or not
  146987. * @returns true if ready otherwise false
  146988. */
  146989. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  146990. /**
  146991. * Gets the current underlying G Buffer.
  146992. * @returns the buffer
  146993. */
  146994. getGBuffer(): MultiRenderTarget;
  146995. /**
  146996. * Gets the number of samples used to render the buffer (anti aliasing).
  146997. */
  146998. get samples(): number;
  146999. /**
  147000. * Sets the number of samples used to render the buffer (anti aliasing).
  147001. */
  147002. set samples(value: number);
  147003. /**
  147004. * Disposes the renderer and frees up associated resources.
  147005. */
  147006. dispose(): void;
  147007. protected _createRenderTargets(): void;
  147008. private _copyBonesTransformationMatrices;
  147009. }
  147010. }
  147011. declare module BABYLON {
  147012. interface Scene {
  147013. /** @hidden (Backing field) */
  147014. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147015. /**
  147016. * Gets or Sets the current geometry buffer associated to the scene.
  147017. */
  147018. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147019. /**
  147020. * Enables a GeometryBufferRender and associates it with the scene
  147021. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  147022. * @returns the GeometryBufferRenderer
  147023. */
  147024. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  147025. /**
  147026. * Disables the GeometryBufferRender associated with the scene
  147027. */
  147028. disableGeometryBufferRenderer(): void;
  147029. }
  147030. /**
  147031. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  147032. * in several rendering techniques.
  147033. */
  147034. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  147035. /**
  147036. * The component name helpful to identify the component in the list of scene components.
  147037. */
  147038. readonly name: string;
  147039. /**
  147040. * The scene the component belongs to.
  147041. */
  147042. scene: Scene;
  147043. /**
  147044. * Creates a new instance of the component for the given scene
  147045. * @param scene Defines the scene to register the component in
  147046. */
  147047. constructor(scene: Scene);
  147048. /**
  147049. * Registers the component in a given scene
  147050. */
  147051. register(): void;
  147052. /**
  147053. * Rebuilds the elements related to this component in case of
  147054. * context lost for instance.
  147055. */
  147056. rebuild(): void;
  147057. /**
  147058. * Disposes the component and the associated ressources
  147059. */
  147060. dispose(): void;
  147061. private _gatherRenderTargets;
  147062. }
  147063. }
  147064. declare module BABYLON {
  147065. /** @hidden */
  147066. export var motionBlurPixelShader: {
  147067. name: string;
  147068. shader: string;
  147069. };
  147070. }
  147071. declare module BABYLON {
  147072. /**
  147073. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  147074. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  147075. * As an example, all you have to do is to create the post-process:
  147076. * var mb = new BABYLON.MotionBlurPostProcess(
  147077. * 'mb', // The name of the effect.
  147078. * scene, // The scene containing the objects to blur according to their velocity.
  147079. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  147080. * camera // The camera to apply the render pass to.
  147081. * );
  147082. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  147083. */
  147084. export class MotionBlurPostProcess extends PostProcess {
  147085. /**
  147086. * Defines how much the image is blurred by the movement. Default value is equal to 1
  147087. */
  147088. motionStrength: number;
  147089. /**
  147090. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  147091. */
  147092. get motionBlurSamples(): number;
  147093. /**
  147094. * Sets the number of iterations to be used for motion blur quality
  147095. */
  147096. set motionBlurSamples(samples: number);
  147097. private _motionBlurSamples;
  147098. private _geometryBufferRenderer;
  147099. /**
  147100. * Creates a new instance MotionBlurPostProcess
  147101. * @param name The name of the effect.
  147102. * @param scene The scene containing the objects to blur according to their velocity.
  147103. * @param options The required width/height ratio to downsize to before computing the render pass.
  147104. * @param camera The camera to apply the render pass to.
  147105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147106. * @param engine The engine which the post process will be applied. (default: current engine)
  147107. * @param reusable If the post process can be reused on the same frame. (default: false)
  147108. * @param textureType Type of textures used when performing the post process. (default: 0)
  147109. * @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)
  147110. */
  147111. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147112. /**
  147113. * Excludes the given skinned mesh from computing bones velocities.
  147114. * 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.
  147115. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  147116. */
  147117. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147118. /**
  147119. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  147120. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  147121. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  147122. */
  147123. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147124. /**
  147125. * Disposes the post process.
  147126. * @param camera The camera to dispose the post process on.
  147127. */
  147128. dispose(camera?: Camera): void;
  147129. }
  147130. }
  147131. declare module BABYLON {
  147132. /** @hidden */
  147133. export var refractionPixelShader: {
  147134. name: string;
  147135. shader: string;
  147136. };
  147137. }
  147138. declare module BABYLON {
  147139. /**
  147140. * Post process which applies a refractin texture
  147141. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147142. */
  147143. export class RefractionPostProcess extends PostProcess {
  147144. /** the base color of the refraction (used to taint the rendering) */
  147145. color: Color3;
  147146. /** simulated refraction depth */
  147147. depth: number;
  147148. /** the coefficient of the base color (0 to remove base color tainting) */
  147149. colorLevel: number;
  147150. private _refTexture;
  147151. private _ownRefractionTexture;
  147152. /**
  147153. * Gets or sets the refraction texture
  147154. * Please note that you are responsible for disposing the texture if you set it manually
  147155. */
  147156. get refractionTexture(): Texture;
  147157. set refractionTexture(value: Texture);
  147158. /**
  147159. * Initializes the RefractionPostProcess
  147160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147161. * @param name The name of the effect.
  147162. * @param refractionTextureUrl Url of the refraction texture to use
  147163. * @param color the base color of the refraction (used to taint the rendering)
  147164. * @param depth simulated refraction depth
  147165. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  147166. * @param camera The camera to apply the render pass to.
  147167. * @param options The required width/height ratio to downsize to before computing the render pass.
  147168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147169. * @param engine The engine which the post process will be applied. (default: current engine)
  147170. * @param reusable If the post process can be reused on the same frame. (default: false)
  147171. */
  147172. constructor(name: string, refractionTextureUrl: string,
  147173. /** the base color of the refraction (used to taint the rendering) */
  147174. color: Color3,
  147175. /** simulated refraction depth */
  147176. depth: number,
  147177. /** the coefficient of the base color (0 to remove base color tainting) */
  147178. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147179. /**
  147180. * Disposes of the post process
  147181. * @param camera Camera to dispose post process on
  147182. */
  147183. dispose(camera: Camera): void;
  147184. }
  147185. }
  147186. declare module BABYLON {
  147187. /** @hidden */
  147188. export var sharpenPixelShader: {
  147189. name: string;
  147190. shader: string;
  147191. };
  147192. }
  147193. declare module BABYLON {
  147194. /**
  147195. * The SharpenPostProcess applies a sharpen kernel to every pixel
  147196. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147197. */
  147198. export class SharpenPostProcess extends PostProcess {
  147199. /**
  147200. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  147201. */
  147202. colorAmount: number;
  147203. /**
  147204. * How much sharpness should be applied (default: 0.3)
  147205. */
  147206. edgeAmount: number;
  147207. /**
  147208. * Creates a new instance ConvolutionPostProcess
  147209. * @param name The name of the effect.
  147210. * @param options The required width/height ratio to downsize to before computing the render pass.
  147211. * @param camera The camera to apply the render pass to.
  147212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147213. * @param engine The engine which the post process will be applied. (default: current engine)
  147214. * @param reusable If the post process can be reused on the same frame. (default: false)
  147215. * @param textureType Type of textures used when performing the post process. (default: 0)
  147216. * @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)
  147217. */
  147218. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147219. }
  147220. }
  147221. declare module BABYLON {
  147222. /**
  147223. * PostProcessRenderPipeline
  147224. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147225. */
  147226. export class PostProcessRenderPipeline {
  147227. private engine;
  147228. private _renderEffects;
  147229. private _renderEffectsForIsolatedPass;
  147230. /**
  147231. * List of inspectable custom properties (used by the Inspector)
  147232. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  147233. */
  147234. inspectableCustomProperties: IInspectable[];
  147235. /**
  147236. * @hidden
  147237. */
  147238. protected _cameras: Camera[];
  147239. /** @hidden */
  147240. _name: string;
  147241. /**
  147242. * Gets pipeline name
  147243. */
  147244. get name(): string;
  147245. /** Gets the list of attached cameras */
  147246. get cameras(): Camera[];
  147247. /**
  147248. * Initializes a PostProcessRenderPipeline
  147249. * @param engine engine to add the pipeline to
  147250. * @param name name of the pipeline
  147251. */
  147252. constructor(engine: Engine, name: string);
  147253. /**
  147254. * Gets the class name
  147255. * @returns "PostProcessRenderPipeline"
  147256. */
  147257. getClassName(): string;
  147258. /**
  147259. * If all the render effects in the pipeline are supported
  147260. */
  147261. get isSupported(): boolean;
  147262. /**
  147263. * Adds an effect to the pipeline
  147264. * @param renderEffect the effect to add
  147265. */
  147266. addEffect(renderEffect: PostProcessRenderEffect): void;
  147267. /** @hidden */
  147268. _rebuild(): void;
  147269. /** @hidden */
  147270. _enableEffect(renderEffectName: string, cameras: Camera): void;
  147271. /** @hidden */
  147272. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  147273. /** @hidden */
  147274. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  147275. /** @hidden */
  147276. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  147277. /** @hidden */
  147278. _attachCameras(cameras: Camera, unique: boolean): void;
  147279. /** @hidden */
  147280. _attachCameras(cameras: Camera[], unique: boolean): void;
  147281. /** @hidden */
  147282. _detachCameras(cameras: Camera): void;
  147283. /** @hidden */
  147284. _detachCameras(cameras: Nullable<Camera[]>): void;
  147285. /** @hidden */
  147286. _update(): void;
  147287. /** @hidden */
  147288. _reset(): void;
  147289. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  147290. /**
  147291. * Disposes of the pipeline
  147292. */
  147293. dispose(): void;
  147294. }
  147295. }
  147296. declare module BABYLON {
  147297. /**
  147298. * PostProcessRenderPipelineManager class
  147299. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147300. */
  147301. export class PostProcessRenderPipelineManager {
  147302. private _renderPipelines;
  147303. /**
  147304. * Initializes a PostProcessRenderPipelineManager
  147305. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147306. */
  147307. constructor();
  147308. /**
  147309. * Gets the list of supported render pipelines
  147310. */
  147311. get supportedPipelines(): PostProcessRenderPipeline[];
  147312. /**
  147313. * Adds a pipeline to the manager
  147314. * @param renderPipeline The pipeline to add
  147315. */
  147316. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  147317. /**
  147318. * Attaches a camera to the pipeline
  147319. * @param renderPipelineName The name of the pipeline to attach to
  147320. * @param cameras the camera to attach
  147321. * @param unique if the camera can be attached multiple times to the pipeline
  147322. */
  147323. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  147324. /**
  147325. * Detaches a camera from the pipeline
  147326. * @param renderPipelineName The name of the pipeline to detach from
  147327. * @param cameras the camera to detach
  147328. */
  147329. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  147330. /**
  147331. * Enables an effect by name on a pipeline
  147332. * @param renderPipelineName the name of the pipeline to enable the effect in
  147333. * @param renderEffectName the name of the effect to enable
  147334. * @param cameras the cameras that the effect should be enabled on
  147335. */
  147336. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  147337. /**
  147338. * Disables an effect by name on a pipeline
  147339. * @param renderPipelineName the name of the pipeline to disable the effect in
  147340. * @param renderEffectName the name of the effect to disable
  147341. * @param cameras the cameras that the effect should be disabled on
  147342. */
  147343. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  147344. /**
  147345. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  147346. */
  147347. update(): void;
  147348. /** @hidden */
  147349. _rebuild(): void;
  147350. /**
  147351. * Disposes of the manager and pipelines
  147352. */
  147353. dispose(): void;
  147354. }
  147355. }
  147356. declare module BABYLON {
  147357. interface Scene {
  147358. /** @hidden (Backing field) */
  147359. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  147360. /**
  147361. * Gets the postprocess render pipeline manager
  147362. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147363. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  147364. */
  147365. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  147366. }
  147367. /**
  147368. * Defines the Render Pipeline scene component responsible to rendering pipelines
  147369. */
  147370. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  147371. /**
  147372. * The component name helpfull to identify the component in the list of scene components.
  147373. */
  147374. readonly name: string;
  147375. /**
  147376. * The scene the component belongs to.
  147377. */
  147378. scene: Scene;
  147379. /**
  147380. * Creates a new instance of the component for the given scene
  147381. * @param scene Defines the scene to register the component in
  147382. */
  147383. constructor(scene: Scene);
  147384. /**
  147385. * Registers the component in a given scene
  147386. */
  147387. register(): void;
  147388. /**
  147389. * Rebuilds the elements related to this component in case of
  147390. * context lost for instance.
  147391. */
  147392. rebuild(): void;
  147393. /**
  147394. * Disposes the component and the associated ressources
  147395. */
  147396. dispose(): void;
  147397. private _gatherRenderTargets;
  147398. }
  147399. }
  147400. declare module BABYLON {
  147401. /**
  147402. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  147403. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  147404. */
  147405. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  147406. private _scene;
  147407. private _camerasToBeAttached;
  147408. /**
  147409. * ID of the sharpen post process,
  147410. */
  147411. private readonly SharpenPostProcessId;
  147412. /**
  147413. * @ignore
  147414. * ID of the image processing post process;
  147415. */
  147416. readonly ImageProcessingPostProcessId: string;
  147417. /**
  147418. * @ignore
  147419. * ID of the Fast Approximate Anti-Aliasing post process;
  147420. */
  147421. readonly FxaaPostProcessId: string;
  147422. /**
  147423. * ID of the chromatic aberration post process,
  147424. */
  147425. private readonly ChromaticAberrationPostProcessId;
  147426. /**
  147427. * ID of the grain post process
  147428. */
  147429. private readonly GrainPostProcessId;
  147430. /**
  147431. * Sharpen post process which will apply a sharpen convolution to enhance edges
  147432. */
  147433. sharpen: SharpenPostProcess;
  147434. private _sharpenEffect;
  147435. private bloom;
  147436. /**
  147437. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  147438. */
  147439. depthOfField: DepthOfFieldEffect;
  147440. /**
  147441. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  147442. */
  147443. fxaa: FxaaPostProcess;
  147444. /**
  147445. * Image post processing pass used to perform operations such as tone mapping or color grading.
  147446. */
  147447. imageProcessing: ImageProcessingPostProcess;
  147448. /**
  147449. * Chromatic aberration post process which will shift rgb colors in the image
  147450. */
  147451. chromaticAberration: ChromaticAberrationPostProcess;
  147452. private _chromaticAberrationEffect;
  147453. /**
  147454. * Grain post process which add noise to the image
  147455. */
  147456. grain: GrainPostProcess;
  147457. private _grainEffect;
  147458. /**
  147459. * Glow post process which adds a glow to emissive areas of the image
  147460. */
  147461. private _glowLayer;
  147462. /**
  147463. * Animations which can be used to tweak settings over a period of time
  147464. */
  147465. animations: Animation[];
  147466. private _imageProcessingConfigurationObserver;
  147467. private _sharpenEnabled;
  147468. private _bloomEnabled;
  147469. private _depthOfFieldEnabled;
  147470. private _depthOfFieldBlurLevel;
  147471. private _fxaaEnabled;
  147472. private _imageProcessingEnabled;
  147473. private _defaultPipelineTextureType;
  147474. private _bloomScale;
  147475. private _chromaticAberrationEnabled;
  147476. private _grainEnabled;
  147477. private _buildAllowed;
  147478. /**
  147479. * Gets active scene
  147480. */
  147481. get scene(): Scene;
  147482. /**
  147483. * Enable or disable the sharpen process from the pipeline
  147484. */
  147485. set sharpenEnabled(enabled: boolean);
  147486. get sharpenEnabled(): boolean;
  147487. private _resizeObserver;
  147488. private _hardwareScaleLevel;
  147489. private _bloomKernel;
  147490. /**
  147491. * Specifies the size of the bloom blur kernel, relative to the final output size
  147492. */
  147493. get bloomKernel(): number;
  147494. set bloomKernel(value: number);
  147495. /**
  147496. * Specifies the weight of the bloom in the final rendering
  147497. */
  147498. private _bloomWeight;
  147499. /**
  147500. * Specifies the luma threshold for the area that will be blurred by the bloom
  147501. */
  147502. private _bloomThreshold;
  147503. private _hdr;
  147504. /**
  147505. * The strength of the bloom.
  147506. */
  147507. set bloomWeight(value: number);
  147508. get bloomWeight(): number;
  147509. /**
  147510. * The strength of the bloom.
  147511. */
  147512. set bloomThreshold(value: number);
  147513. get bloomThreshold(): number;
  147514. /**
  147515. * The scale of the bloom, lower value will provide better performance.
  147516. */
  147517. set bloomScale(value: number);
  147518. get bloomScale(): number;
  147519. /**
  147520. * Enable or disable the bloom from the pipeline
  147521. */
  147522. set bloomEnabled(enabled: boolean);
  147523. get bloomEnabled(): boolean;
  147524. private _rebuildBloom;
  147525. /**
  147526. * If the depth of field is enabled.
  147527. */
  147528. get depthOfFieldEnabled(): boolean;
  147529. set depthOfFieldEnabled(enabled: boolean);
  147530. /**
  147531. * Blur level of the depth of field effect. (Higher blur will effect performance)
  147532. */
  147533. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  147534. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  147535. /**
  147536. * If the anti aliasing is enabled.
  147537. */
  147538. set fxaaEnabled(enabled: boolean);
  147539. get fxaaEnabled(): boolean;
  147540. private _samples;
  147541. /**
  147542. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  147543. */
  147544. set samples(sampleCount: number);
  147545. get samples(): number;
  147546. /**
  147547. * If image processing is enabled.
  147548. */
  147549. set imageProcessingEnabled(enabled: boolean);
  147550. get imageProcessingEnabled(): boolean;
  147551. /**
  147552. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  147553. */
  147554. set glowLayerEnabled(enabled: boolean);
  147555. get glowLayerEnabled(): boolean;
  147556. /**
  147557. * Gets the glow layer (or null if not defined)
  147558. */
  147559. get glowLayer(): Nullable<GlowLayer>;
  147560. /**
  147561. * Enable or disable the chromaticAberration process from the pipeline
  147562. */
  147563. set chromaticAberrationEnabled(enabled: boolean);
  147564. get chromaticAberrationEnabled(): boolean;
  147565. /**
  147566. * Enable or disable the grain process from the pipeline
  147567. */
  147568. set grainEnabled(enabled: boolean);
  147569. get grainEnabled(): boolean;
  147570. /**
  147571. * @constructor
  147572. * @param name - The rendering pipeline name (default: "")
  147573. * @param hdr - If high dynamic range textures should be used (default: true)
  147574. * @param scene - The scene linked to this pipeline (default: the last created scene)
  147575. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  147576. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  147577. */
  147578. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  147579. /**
  147580. * Get the class name
  147581. * @returns "DefaultRenderingPipeline"
  147582. */
  147583. getClassName(): string;
  147584. /**
  147585. * Force the compilation of the entire pipeline.
  147586. */
  147587. prepare(): void;
  147588. private _hasCleared;
  147589. private _prevPostProcess;
  147590. private _prevPrevPostProcess;
  147591. private _setAutoClearAndTextureSharing;
  147592. private _depthOfFieldSceneObserver;
  147593. private _buildPipeline;
  147594. private _disposePostProcesses;
  147595. /**
  147596. * Adds a camera to the pipeline
  147597. * @param camera the camera to be added
  147598. */
  147599. addCamera(camera: Camera): void;
  147600. /**
  147601. * Removes a camera from the pipeline
  147602. * @param camera the camera to remove
  147603. */
  147604. removeCamera(camera: Camera): void;
  147605. /**
  147606. * Dispose of the pipeline and stop all post processes
  147607. */
  147608. dispose(): void;
  147609. /**
  147610. * Serialize the rendering pipeline (Used when exporting)
  147611. * @returns the serialized object
  147612. */
  147613. serialize(): any;
  147614. /**
  147615. * Parse the serialized pipeline
  147616. * @param source Source pipeline.
  147617. * @param scene The scene to load the pipeline to.
  147618. * @param rootUrl The URL of the serialized pipeline.
  147619. * @returns An instantiated pipeline from the serialized object.
  147620. */
  147621. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  147622. }
  147623. }
  147624. declare module BABYLON {
  147625. /** @hidden */
  147626. export var lensHighlightsPixelShader: {
  147627. name: string;
  147628. shader: string;
  147629. };
  147630. }
  147631. declare module BABYLON {
  147632. /** @hidden */
  147633. export var depthOfFieldPixelShader: {
  147634. name: string;
  147635. shader: string;
  147636. };
  147637. }
  147638. declare module BABYLON {
  147639. /**
  147640. * BABYLON.JS Chromatic Aberration GLSL Shader
  147641. * Author: Olivier Guyot
  147642. * Separates very slightly R, G and B colors on the edges of the screen
  147643. * Inspired by Francois Tarlier & Martins Upitis
  147644. */
  147645. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  147646. /**
  147647. * @ignore
  147648. * The chromatic aberration PostProcess id in the pipeline
  147649. */
  147650. LensChromaticAberrationEffect: string;
  147651. /**
  147652. * @ignore
  147653. * The highlights enhancing PostProcess id in the pipeline
  147654. */
  147655. HighlightsEnhancingEffect: string;
  147656. /**
  147657. * @ignore
  147658. * The depth-of-field PostProcess id in the pipeline
  147659. */
  147660. LensDepthOfFieldEffect: string;
  147661. private _scene;
  147662. private _depthTexture;
  147663. private _grainTexture;
  147664. private _chromaticAberrationPostProcess;
  147665. private _highlightsPostProcess;
  147666. private _depthOfFieldPostProcess;
  147667. private _edgeBlur;
  147668. private _grainAmount;
  147669. private _chromaticAberration;
  147670. private _distortion;
  147671. private _highlightsGain;
  147672. private _highlightsThreshold;
  147673. private _dofDistance;
  147674. private _dofAperture;
  147675. private _dofDarken;
  147676. private _dofPentagon;
  147677. private _blurNoise;
  147678. /**
  147679. * @constructor
  147680. *
  147681. * Effect parameters are as follow:
  147682. * {
  147683. * chromatic_aberration: number; // from 0 to x (1 for realism)
  147684. * edge_blur: number; // from 0 to x (1 for realism)
  147685. * distortion: number; // from 0 to x (1 for realism)
  147686. * grain_amount: number; // from 0 to 1
  147687. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  147688. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  147689. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  147690. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  147691. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  147692. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  147693. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  147694. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  147695. * }
  147696. * Note: if an effect parameter is unset, effect is disabled
  147697. *
  147698. * @param name The rendering pipeline name
  147699. * @param parameters - An object containing all parameters (see above)
  147700. * @param scene The scene linked to this pipeline
  147701. * @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)
  147702. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147703. */
  147704. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  147705. /**
  147706. * Get the class name
  147707. * @returns "LensRenderingPipeline"
  147708. */
  147709. getClassName(): string;
  147710. /**
  147711. * Gets associated scene
  147712. */
  147713. get scene(): Scene;
  147714. /**
  147715. * Gets or sets the edge blur
  147716. */
  147717. get edgeBlur(): number;
  147718. set edgeBlur(value: number);
  147719. /**
  147720. * Gets or sets the grain amount
  147721. */
  147722. get grainAmount(): number;
  147723. set grainAmount(value: number);
  147724. /**
  147725. * Gets or sets the chromatic aberration amount
  147726. */
  147727. get chromaticAberration(): number;
  147728. set chromaticAberration(value: number);
  147729. /**
  147730. * Gets or sets the depth of field aperture
  147731. */
  147732. get dofAperture(): number;
  147733. set dofAperture(value: number);
  147734. /**
  147735. * Gets or sets the edge distortion
  147736. */
  147737. get edgeDistortion(): number;
  147738. set edgeDistortion(value: number);
  147739. /**
  147740. * Gets or sets the depth of field distortion
  147741. */
  147742. get dofDistortion(): number;
  147743. set dofDistortion(value: number);
  147744. /**
  147745. * Gets or sets the darken out of focus amount
  147746. */
  147747. get darkenOutOfFocus(): number;
  147748. set darkenOutOfFocus(value: number);
  147749. /**
  147750. * Gets or sets a boolean indicating if blur noise is enabled
  147751. */
  147752. get blurNoise(): boolean;
  147753. set blurNoise(value: boolean);
  147754. /**
  147755. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  147756. */
  147757. get pentagonBokeh(): boolean;
  147758. set pentagonBokeh(value: boolean);
  147759. /**
  147760. * Gets or sets the highlight grain amount
  147761. */
  147762. get highlightsGain(): number;
  147763. set highlightsGain(value: number);
  147764. /**
  147765. * Gets or sets the highlight threshold
  147766. */
  147767. get highlightsThreshold(): number;
  147768. set highlightsThreshold(value: number);
  147769. /**
  147770. * Sets the amount of blur at the edges
  147771. * @param amount blur amount
  147772. */
  147773. setEdgeBlur(amount: number): void;
  147774. /**
  147775. * Sets edge blur to 0
  147776. */
  147777. disableEdgeBlur(): void;
  147778. /**
  147779. * Sets the amout of grain
  147780. * @param amount Amount of grain
  147781. */
  147782. setGrainAmount(amount: number): void;
  147783. /**
  147784. * Set grain amount to 0
  147785. */
  147786. disableGrain(): void;
  147787. /**
  147788. * Sets the chromatic aberration amount
  147789. * @param amount amount of chromatic aberration
  147790. */
  147791. setChromaticAberration(amount: number): void;
  147792. /**
  147793. * Sets chromatic aberration amount to 0
  147794. */
  147795. disableChromaticAberration(): void;
  147796. /**
  147797. * Sets the EdgeDistortion amount
  147798. * @param amount amount of EdgeDistortion
  147799. */
  147800. setEdgeDistortion(amount: number): void;
  147801. /**
  147802. * Sets edge distortion to 0
  147803. */
  147804. disableEdgeDistortion(): void;
  147805. /**
  147806. * Sets the FocusDistance amount
  147807. * @param amount amount of FocusDistance
  147808. */
  147809. setFocusDistance(amount: number): void;
  147810. /**
  147811. * Disables depth of field
  147812. */
  147813. disableDepthOfField(): void;
  147814. /**
  147815. * Sets the Aperture amount
  147816. * @param amount amount of Aperture
  147817. */
  147818. setAperture(amount: number): void;
  147819. /**
  147820. * Sets the DarkenOutOfFocus amount
  147821. * @param amount amount of DarkenOutOfFocus
  147822. */
  147823. setDarkenOutOfFocus(amount: number): void;
  147824. private _pentagonBokehIsEnabled;
  147825. /**
  147826. * Creates a pentagon bokeh effect
  147827. */
  147828. enablePentagonBokeh(): void;
  147829. /**
  147830. * Disables the pentagon bokeh effect
  147831. */
  147832. disablePentagonBokeh(): void;
  147833. /**
  147834. * Enables noise blur
  147835. */
  147836. enableNoiseBlur(): void;
  147837. /**
  147838. * Disables noise blur
  147839. */
  147840. disableNoiseBlur(): void;
  147841. /**
  147842. * Sets the HighlightsGain amount
  147843. * @param amount amount of HighlightsGain
  147844. */
  147845. setHighlightsGain(amount: number): void;
  147846. /**
  147847. * Sets the HighlightsThreshold amount
  147848. * @param amount amount of HighlightsThreshold
  147849. */
  147850. setHighlightsThreshold(amount: number): void;
  147851. /**
  147852. * Disables highlights
  147853. */
  147854. disableHighlights(): void;
  147855. /**
  147856. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  147857. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  147858. */
  147859. dispose(disableDepthRender?: boolean): void;
  147860. private _createChromaticAberrationPostProcess;
  147861. private _createHighlightsPostProcess;
  147862. private _createDepthOfFieldPostProcess;
  147863. private _createGrainTexture;
  147864. }
  147865. }
  147866. declare module BABYLON {
  147867. /** @hidden */
  147868. export var ssao2PixelShader: {
  147869. name: string;
  147870. shader: string;
  147871. };
  147872. }
  147873. declare module BABYLON {
  147874. /** @hidden */
  147875. export var ssaoCombinePixelShader: {
  147876. name: string;
  147877. shader: string;
  147878. };
  147879. }
  147880. declare module BABYLON {
  147881. /**
  147882. * Render pipeline to produce ssao effect
  147883. */
  147884. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  147885. /**
  147886. * @ignore
  147887. * The PassPostProcess id in the pipeline that contains the original scene color
  147888. */
  147889. SSAOOriginalSceneColorEffect: string;
  147890. /**
  147891. * @ignore
  147892. * The SSAO PostProcess id in the pipeline
  147893. */
  147894. SSAORenderEffect: string;
  147895. /**
  147896. * @ignore
  147897. * The horizontal blur PostProcess id in the pipeline
  147898. */
  147899. SSAOBlurHRenderEffect: string;
  147900. /**
  147901. * @ignore
  147902. * The vertical blur PostProcess id in the pipeline
  147903. */
  147904. SSAOBlurVRenderEffect: string;
  147905. /**
  147906. * @ignore
  147907. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147908. */
  147909. SSAOCombineRenderEffect: string;
  147910. /**
  147911. * The output strength of the SSAO post-process. Default value is 1.0.
  147912. */
  147913. totalStrength: number;
  147914. /**
  147915. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  147916. */
  147917. maxZ: number;
  147918. /**
  147919. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  147920. */
  147921. minZAspect: number;
  147922. private _samples;
  147923. /**
  147924. * Number of samples used for the SSAO calculations. Default value is 8
  147925. */
  147926. set samples(n: number);
  147927. get samples(): number;
  147928. private _textureSamples;
  147929. /**
  147930. * Number of samples to use for antialiasing
  147931. */
  147932. set textureSamples(n: number);
  147933. get textureSamples(): number;
  147934. /**
  147935. * Ratio object used for SSAO ratio and blur ratio
  147936. */
  147937. private _ratio;
  147938. /**
  147939. * Dynamically generated sphere sampler.
  147940. */
  147941. private _sampleSphere;
  147942. /**
  147943. * Blur filter offsets
  147944. */
  147945. private _samplerOffsets;
  147946. private _expensiveBlur;
  147947. /**
  147948. * If bilateral blur should be used
  147949. */
  147950. set expensiveBlur(b: boolean);
  147951. get expensiveBlur(): boolean;
  147952. /**
  147953. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  147954. */
  147955. radius: number;
  147956. /**
  147957. * The base color of the SSAO post-process
  147958. * The final result is "base + ssao" between [0, 1]
  147959. */
  147960. base: number;
  147961. /**
  147962. * Support test.
  147963. */
  147964. static get IsSupported(): boolean;
  147965. private _scene;
  147966. private _depthTexture;
  147967. private _normalTexture;
  147968. private _randomTexture;
  147969. private _originalColorPostProcess;
  147970. private _ssaoPostProcess;
  147971. private _blurHPostProcess;
  147972. private _blurVPostProcess;
  147973. private _ssaoCombinePostProcess;
  147974. /**
  147975. * Gets active scene
  147976. */
  147977. get scene(): Scene;
  147978. /**
  147979. * @constructor
  147980. * @param name The rendering pipeline name
  147981. * @param scene The scene linked to this pipeline
  147982. * @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 }
  147983. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147984. */
  147985. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147986. /**
  147987. * Get the class name
  147988. * @returns "SSAO2RenderingPipeline"
  147989. */
  147990. getClassName(): string;
  147991. /**
  147992. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  147993. */
  147994. dispose(disableGeometryBufferRenderer?: boolean): void;
  147995. private _createBlurPostProcess;
  147996. /** @hidden */
  147997. _rebuild(): void;
  147998. private _bits;
  147999. private _radicalInverse_VdC;
  148000. private _hammersley;
  148001. private _hemisphereSample_uniform;
  148002. private _generateHemisphere;
  148003. private _createSSAOPostProcess;
  148004. private _createSSAOCombinePostProcess;
  148005. private _createRandomTexture;
  148006. /**
  148007. * Serialize the rendering pipeline (Used when exporting)
  148008. * @returns the serialized object
  148009. */
  148010. serialize(): any;
  148011. /**
  148012. * Parse the serialized pipeline
  148013. * @param source Source pipeline.
  148014. * @param scene The scene to load the pipeline to.
  148015. * @param rootUrl The URL of the serialized pipeline.
  148016. * @returns An instantiated pipeline from the serialized object.
  148017. */
  148018. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  148019. }
  148020. }
  148021. declare module BABYLON {
  148022. /** @hidden */
  148023. export var ssaoPixelShader: {
  148024. name: string;
  148025. shader: string;
  148026. };
  148027. }
  148028. declare module BABYLON {
  148029. /**
  148030. * Render pipeline to produce ssao effect
  148031. */
  148032. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  148033. /**
  148034. * @ignore
  148035. * The PassPostProcess id in the pipeline that contains the original scene color
  148036. */
  148037. SSAOOriginalSceneColorEffect: string;
  148038. /**
  148039. * @ignore
  148040. * The SSAO PostProcess id in the pipeline
  148041. */
  148042. SSAORenderEffect: string;
  148043. /**
  148044. * @ignore
  148045. * The horizontal blur PostProcess id in the pipeline
  148046. */
  148047. SSAOBlurHRenderEffect: string;
  148048. /**
  148049. * @ignore
  148050. * The vertical blur PostProcess id in the pipeline
  148051. */
  148052. SSAOBlurVRenderEffect: string;
  148053. /**
  148054. * @ignore
  148055. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  148056. */
  148057. SSAOCombineRenderEffect: string;
  148058. /**
  148059. * The output strength of the SSAO post-process. Default value is 1.0.
  148060. */
  148061. totalStrength: number;
  148062. /**
  148063. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  148064. */
  148065. radius: number;
  148066. /**
  148067. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  148068. * Must not be equal to fallOff and superior to fallOff.
  148069. * Default value is 0.0075
  148070. */
  148071. area: number;
  148072. /**
  148073. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  148074. * Must not be equal to area and inferior to area.
  148075. * Default value is 0.000001
  148076. */
  148077. fallOff: number;
  148078. /**
  148079. * The base color of the SSAO post-process
  148080. * The final result is "base + ssao" between [0, 1]
  148081. */
  148082. base: number;
  148083. private _scene;
  148084. private _depthTexture;
  148085. private _randomTexture;
  148086. private _originalColorPostProcess;
  148087. private _ssaoPostProcess;
  148088. private _blurHPostProcess;
  148089. private _blurVPostProcess;
  148090. private _ssaoCombinePostProcess;
  148091. private _firstUpdate;
  148092. /**
  148093. * Gets active scene
  148094. */
  148095. get scene(): Scene;
  148096. /**
  148097. * @constructor
  148098. * @param name - The rendering pipeline name
  148099. * @param scene - The scene linked to this pipeline
  148100. * @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 }
  148101. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  148102. */
  148103. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  148104. /**
  148105. * Get the class name
  148106. * @returns "SSAORenderingPipeline"
  148107. */
  148108. getClassName(): string;
  148109. /**
  148110. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  148111. */
  148112. dispose(disableDepthRender?: boolean): void;
  148113. private _createBlurPostProcess;
  148114. /** @hidden */
  148115. _rebuild(): void;
  148116. private _createSSAOPostProcess;
  148117. private _createSSAOCombinePostProcess;
  148118. private _createRandomTexture;
  148119. }
  148120. }
  148121. declare module BABYLON {
  148122. /** @hidden */
  148123. export var screenSpaceReflectionPixelShader: {
  148124. name: string;
  148125. shader: string;
  148126. };
  148127. }
  148128. declare module BABYLON {
  148129. /**
  148130. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  148131. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  148132. */
  148133. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  148134. /**
  148135. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  148136. */
  148137. threshold: number;
  148138. /**
  148139. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  148140. */
  148141. strength: number;
  148142. /**
  148143. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  148144. */
  148145. reflectionSpecularFalloffExponent: number;
  148146. /**
  148147. * 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]
  148148. */
  148149. step: number;
  148150. /**
  148151. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  148152. */
  148153. roughnessFactor: number;
  148154. private _geometryBufferRenderer;
  148155. private _enableSmoothReflections;
  148156. private _reflectionSamples;
  148157. private _smoothSteps;
  148158. /**
  148159. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  148160. * @param name The name of the effect.
  148161. * @param scene The scene containing the objects to calculate reflections.
  148162. * @param options The required width/height ratio to downsize to before computing the render pass.
  148163. * @param camera The camera to apply the render pass to.
  148164. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148165. * @param engine The engine which the post process will be applied. (default: current engine)
  148166. * @param reusable If the post process can be reused on the same frame. (default: false)
  148167. * @param textureType Type of textures used when performing the post process. (default: 0)
  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(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148171. /**
  148172. * Gets wether or not smoothing reflections is enabled.
  148173. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148174. */
  148175. get enableSmoothReflections(): boolean;
  148176. /**
  148177. * Sets wether or not smoothing reflections is enabled.
  148178. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148179. */
  148180. set enableSmoothReflections(enabled: boolean);
  148181. /**
  148182. * Gets the number of samples taken while computing reflections. More samples count is high,
  148183. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148184. */
  148185. get reflectionSamples(): number;
  148186. /**
  148187. * Sets the number of samples taken while computing reflections. More samples count is high,
  148188. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148189. */
  148190. set reflectionSamples(samples: number);
  148191. /**
  148192. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  148193. * more the post-process will require GPU power and can generate a drop in FPS.
  148194. * Default value (5.0) work pretty well in all cases but can be adjusted.
  148195. */
  148196. get smoothSteps(): number;
  148197. set smoothSteps(steps: number);
  148198. private _updateEffectDefines;
  148199. }
  148200. }
  148201. declare module BABYLON {
  148202. /** @hidden */
  148203. export var standardPixelShader: {
  148204. name: string;
  148205. shader: string;
  148206. };
  148207. }
  148208. declare module BABYLON {
  148209. /**
  148210. * Standard rendering pipeline
  148211. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  148212. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  148213. */
  148214. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  148215. /**
  148216. * Public members
  148217. */
  148218. /**
  148219. * Post-process which contains the original scene color before the pipeline applies all the effects
  148220. */
  148221. originalPostProcess: Nullable<PostProcess>;
  148222. /**
  148223. * Post-process used to down scale an image x4
  148224. */
  148225. downSampleX4PostProcess: Nullable<PostProcess>;
  148226. /**
  148227. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  148228. */
  148229. brightPassPostProcess: Nullable<PostProcess>;
  148230. /**
  148231. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  148232. */
  148233. blurHPostProcesses: PostProcess[];
  148234. /**
  148235. * Post-process array storing all the vertical blur post-processes used by the pipeline
  148236. */
  148237. blurVPostProcesses: PostProcess[];
  148238. /**
  148239. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  148240. */
  148241. textureAdderPostProcess: Nullable<PostProcess>;
  148242. /**
  148243. * Post-process used to create volumetric lighting effect
  148244. */
  148245. volumetricLightPostProcess: Nullable<PostProcess>;
  148246. /**
  148247. * Post-process used to smooth the previous volumetric light post-process on the X axis
  148248. */
  148249. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  148250. /**
  148251. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  148252. */
  148253. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  148254. /**
  148255. * Post-process used to merge the volumetric light effect and the real scene color
  148256. */
  148257. volumetricLightMergePostProces: Nullable<PostProcess>;
  148258. /**
  148259. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  148260. */
  148261. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  148262. /**
  148263. * Base post-process used to calculate the average luminance of the final image for HDR
  148264. */
  148265. luminancePostProcess: Nullable<PostProcess>;
  148266. /**
  148267. * Post-processes used to create down sample post-processes in order to get
  148268. * the average luminance of the final image for HDR
  148269. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  148270. */
  148271. luminanceDownSamplePostProcesses: PostProcess[];
  148272. /**
  148273. * Post-process used to create a HDR effect (light adaptation)
  148274. */
  148275. hdrPostProcess: Nullable<PostProcess>;
  148276. /**
  148277. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  148278. */
  148279. textureAdderFinalPostProcess: Nullable<PostProcess>;
  148280. /**
  148281. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  148282. */
  148283. lensFlareFinalPostProcess: Nullable<PostProcess>;
  148284. /**
  148285. * Post-process used to merge the final HDR post-process and the real scene color
  148286. */
  148287. hdrFinalPostProcess: Nullable<PostProcess>;
  148288. /**
  148289. * Post-process used to create a lens flare effect
  148290. */
  148291. lensFlarePostProcess: Nullable<PostProcess>;
  148292. /**
  148293. * Post-process that merges the result of the lens flare post-process and the real scene color
  148294. */
  148295. lensFlareComposePostProcess: Nullable<PostProcess>;
  148296. /**
  148297. * Post-process used to create a motion blur effect
  148298. */
  148299. motionBlurPostProcess: Nullable<PostProcess>;
  148300. /**
  148301. * Post-process used to create a depth of field effect
  148302. */
  148303. depthOfFieldPostProcess: Nullable<PostProcess>;
  148304. /**
  148305. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  148306. */
  148307. fxaaPostProcess: Nullable<FxaaPostProcess>;
  148308. /**
  148309. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  148310. */
  148311. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  148312. /**
  148313. * Represents the brightness threshold in order to configure the illuminated surfaces
  148314. */
  148315. brightThreshold: number;
  148316. /**
  148317. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  148318. */
  148319. blurWidth: number;
  148320. /**
  148321. * Sets if the blur for highlighted surfaces must be only horizontal
  148322. */
  148323. horizontalBlur: boolean;
  148324. /**
  148325. * Gets the overall exposure used by the pipeline
  148326. */
  148327. get exposure(): number;
  148328. /**
  148329. * Sets the overall exposure used by the pipeline
  148330. */
  148331. set exposure(value: number);
  148332. /**
  148333. * Texture used typically to simulate "dirty" on camera lens
  148334. */
  148335. lensTexture: Nullable<Texture>;
  148336. /**
  148337. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  148338. */
  148339. volumetricLightCoefficient: number;
  148340. /**
  148341. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  148342. */
  148343. volumetricLightPower: number;
  148344. /**
  148345. * Used the set the blur intensity to smooth the volumetric lights
  148346. */
  148347. volumetricLightBlurScale: number;
  148348. /**
  148349. * Light (spot or directional) used to generate the volumetric lights rays
  148350. * The source light must have a shadow generate so the pipeline can get its
  148351. * depth map
  148352. */
  148353. sourceLight: Nullable<SpotLight | DirectionalLight>;
  148354. /**
  148355. * For eye adaptation, represents the minimum luminance the eye can see
  148356. */
  148357. hdrMinimumLuminance: number;
  148358. /**
  148359. * For eye adaptation, represents the decrease luminance speed
  148360. */
  148361. hdrDecreaseRate: number;
  148362. /**
  148363. * For eye adaptation, represents the increase luminance speed
  148364. */
  148365. hdrIncreaseRate: number;
  148366. /**
  148367. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  148368. */
  148369. get hdrAutoExposure(): boolean;
  148370. /**
  148371. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  148372. */
  148373. set hdrAutoExposure(value: boolean);
  148374. /**
  148375. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  148376. */
  148377. lensColorTexture: Nullable<Texture>;
  148378. /**
  148379. * The overall strengh for the lens flare effect
  148380. */
  148381. lensFlareStrength: number;
  148382. /**
  148383. * Dispersion coefficient for lens flare ghosts
  148384. */
  148385. lensFlareGhostDispersal: number;
  148386. /**
  148387. * Main lens flare halo width
  148388. */
  148389. lensFlareHaloWidth: number;
  148390. /**
  148391. * Based on the lens distortion effect, defines how much the lens flare result
  148392. * is distorted
  148393. */
  148394. lensFlareDistortionStrength: number;
  148395. /**
  148396. * Configures the blur intensity used for for lens flare (halo)
  148397. */
  148398. lensFlareBlurWidth: number;
  148399. /**
  148400. * Lens star texture must be used to simulate rays on the flares and is available
  148401. * in the documentation
  148402. */
  148403. lensStarTexture: Nullable<Texture>;
  148404. /**
  148405. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  148406. * flare effect by taking account of the dirt texture
  148407. */
  148408. lensFlareDirtTexture: Nullable<Texture>;
  148409. /**
  148410. * Represents the focal length for the depth of field effect
  148411. */
  148412. depthOfFieldDistance: number;
  148413. /**
  148414. * Represents the blur intensity for the blurred part of the depth of field effect
  148415. */
  148416. depthOfFieldBlurWidth: number;
  148417. /**
  148418. * Gets how much the image is blurred by the movement while using the motion blur post-process
  148419. */
  148420. get motionStrength(): number;
  148421. /**
  148422. * Sets how much the image is blurred by the movement while using the motion blur post-process
  148423. */
  148424. set motionStrength(strength: number);
  148425. /**
  148426. * Gets wether or not the motion blur post-process is object based or screen based.
  148427. */
  148428. get objectBasedMotionBlur(): boolean;
  148429. /**
  148430. * Sets wether or not the motion blur post-process should be object based or screen based
  148431. */
  148432. set objectBasedMotionBlur(value: boolean);
  148433. /**
  148434. * List of animations for the pipeline (IAnimatable implementation)
  148435. */
  148436. animations: Animation[];
  148437. /**
  148438. * Private members
  148439. */
  148440. private _scene;
  148441. private _currentDepthOfFieldSource;
  148442. private _basePostProcess;
  148443. private _fixedExposure;
  148444. private _currentExposure;
  148445. private _hdrAutoExposure;
  148446. private _hdrCurrentLuminance;
  148447. private _motionStrength;
  148448. private _isObjectBasedMotionBlur;
  148449. private _floatTextureType;
  148450. private _camerasToBeAttached;
  148451. private _ratio;
  148452. private _bloomEnabled;
  148453. private _depthOfFieldEnabled;
  148454. private _vlsEnabled;
  148455. private _lensFlareEnabled;
  148456. private _hdrEnabled;
  148457. private _motionBlurEnabled;
  148458. private _fxaaEnabled;
  148459. private _screenSpaceReflectionsEnabled;
  148460. private _motionBlurSamples;
  148461. private _volumetricLightStepsCount;
  148462. private _samples;
  148463. /**
  148464. * @ignore
  148465. * Specifies if the bloom pipeline is enabled
  148466. */
  148467. get BloomEnabled(): boolean;
  148468. set BloomEnabled(enabled: boolean);
  148469. /**
  148470. * @ignore
  148471. * Specifies if the depth of field pipeline is enabed
  148472. */
  148473. get DepthOfFieldEnabled(): boolean;
  148474. set DepthOfFieldEnabled(enabled: boolean);
  148475. /**
  148476. * @ignore
  148477. * Specifies if the lens flare pipeline is enabed
  148478. */
  148479. get LensFlareEnabled(): boolean;
  148480. set LensFlareEnabled(enabled: boolean);
  148481. /**
  148482. * @ignore
  148483. * Specifies if the HDR pipeline is enabled
  148484. */
  148485. get HDREnabled(): boolean;
  148486. set HDREnabled(enabled: boolean);
  148487. /**
  148488. * @ignore
  148489. * Specifies if the volumetric lights scattering effect is enabled
  148490. */
  148491. get VLSEnabled(): boolean;
  148492. set VLSEnabled(enabled: boolean);
  148493. /**
  148494. * @ignore
  148495. * Specifies if the motion blur effect is enabled
  148496. */
  148497. get MotionBlurEnabled(): boolean;
  148498. set MotionBlurEnabled(enabled: boolean);
  148499. /**
  148500. * Specifies if anti-aliasing is enabled
  148501. */
  148502. get fxaaEnabled(): boolean;
  148503. set fxaaEnabled(enabled: boolean);
  148504. /**
  148505. * Specifies if screen space reflections are enabled.
  148506. */
  148507. get screenSpaceReflectionsEnabled(): boolean;
  148508. set screenSpaceReflectionsEnabled(enabled: boolean);
  148509. /**
  148510. * Specifies the number of steps used to calculate the volumetric lights
  148511. * Typically in interval [50, 200]
  148512. */
  148513. get volumetricLightStepsCount(): number;
  148514. set volumetricLightStepsCount(count: number);
  148515. /**
  148516. * Specifies the number of samples used for the motion blur effect
  148517. * Typically in interval [16, 64]
  148518. */
  148519. get motionBlurSamples(): number;
  148520. set motionBlurSamples(samples: number);
  148521. /**
  148522. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  148523. */
  148524. get samples(): number;
  148525. set samples(sampleCount: number);
  148526. /**
  148527. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  148528. * @constructor
  148529. * @param name The rendering pipeline name
  148530. * @param scene The scene linked to this pipeline
  148531. * @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)
  148532. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  148533. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148534. */
  148535. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  148536. private _buildPipeline;
  148537. private _createDownSampleX4PostProcess;
  148538. private _createBrightPassPostProcess;
  148539. private _createBlurPostProcesses;
  148540. private _createTextureAdderPostProcess;
  148541. private _createVolumetricLightPostProcess;
  148542. private _createLuminancePostProcesses;
  148543. private _createHdrPostProcess;
  148544. private _createLensFlarePostProcess;
  148545. private _createDepthOfFieldPostProcess;
  148546. private _createMotionBlurPostProcess;
  148547. private _getDepthTexture;
  148548. private _disposePostProcesses;
  148549. /**
  148550. * Dispose of the pipeline and stop all post processes
  148551. */
  148552. dispose(): void;
  148553. /**
  148554. * Serialize the rendering pipeline (Used when exporting)
  148555. * @returns the serialized object
  148556. */
  148557. serialize(): any;
  148558. /**
  148559. * Parse the serialized pipeline
  148560. * @param source Source pipeline.
  148561. * @param scene The scene to load the pipeline to.
  148562. * @param rootUrl The URL of the serialized pipeline.
  148563. * @returns An instantiated pipeline from the serialized object.
  148564. */
  148565. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  148566. /**
  148567. * Luminance steps
  148568. */
  148569. static LuminanceSteps: number;
  148570. }
  148571. }
  148572. declare module BABYLON {
  148573. /** @hidden */
  148574. export var stereoscopicInterlacePixelShader: {
  148575. name: string;
  148576. shader: string;
  148577. };
  148578. }
  148579. declare module BABYLON {
  148580. /**
  148581. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  148582. */
  148583. export class StereoscopicInterlacePostProcessI extends PostProcess {
  148584. private _stepSize;
  148585. private _passedProcess;
  148586. /**
  148587. * Initializes a StereoscopicInterlacePostProcessI
  148588. * @param name The name of the effect.
  148589. * @param rigCameras The rig cameras to be appled to the post process
  148590. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  148591. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  148592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148593. * @param engine The engine which the post process will be applied. (default: current engine)
  148594. * @param reusable If the post process can be reused on the same frame. (default: false)
  148595. */
  148596. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148597. }
  148598. /**
  148599. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  148600. */
  148601. export class StereoscopicInterlacePostProcess extends PostProcess {
  148602. private _stepSize;
  148603. private _passedProcess;
  148604. /**
  148605. * Initializes a StereoscopicInterlacePostProcess
  148606. * @param name The name of the effect.
  148607. * @param rigCameras The rig cameras to be appled to the post process
  148608. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  148609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148610. * @param engine The engine which the post process will be applied. (default: current engine)
  148611. * @param reusable If the post process can be reused on the same frame. (default: false)
  148612. */
  148613. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148614. }
  148615. }
  148616. declare module BABYLON {
  148617. /** @hidden */
  148618. export var tonemapPixelShader: {
  148619. name: string;
  148620. shader: string;
  148621. };
  148622. }
  148623. declare module BABYLON {
  148624. /** Defines operator used for tonemapping */
  148625. export enum TonemappingOperator {
  148626. /** Hable */
  148627. Hable = 0,
  148628. /** Reinhard */
  148629. Reinhard = 1,
  148630. /** HejiDawson */
  148631. HejiDawson = 2,
  148632. /** Photographic */
  148633. Photographic = 3
  148634. }
  148635. /**
  148636. * Defines a post process to apply tone mapping
  148637. */
  148638. export class TonemapPostProcess extends PostProcess {
  148639. private _operator;
  148640. /** Defines the required exposure adjustement */
  148641. exposureAdjustment: number;
  148642. /**
  148643. * Creates a new TonemapPostProcess
  148644. * @param name defines the name of the postprocess
  148645. * @param _operator defines the operator to use
  148646. * @param exposureAdjustment defines the required exposure adjustement
  148647. * @param camera defines the camera to use (can be null)
  148648. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  148649. * @param engine defines the hosting engine (can be ignore if camera is set)
  148650. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  148651. */
  148652. constructor(name: string, _operator: TonemappingOperator,
  148653. /** Defines the required exposure adjustement */
  148654. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  148655. }
  148656. }
  148657. declare module BABYLON {
  148658. /** @hidden */
  148659. export var volumetricLightScatteringPixelShader: {
  148660. name: string;
  148661. shader: string;
  148662. };
  148663. }
  148664. declare module BABYLON {
  148665. /** @hidden */
  148666. export var volumetricLightScatteringPassVertexShader: {
  148667. name: string;
  148668. shader: string;
  148669. };
  148670. }
  148671. declare module BABYLON {
  148672. /** @hidden */
  148673. export var volumetricLightScatteringPassPixelShader: {
  148674. name: string;
  148675. shader: string;
  148676. };
  148677. }
  148678. declare module BABYLON {
  148679. /**
  148680. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  148681. */
  148682. export class VolumetricLightScatteringPostProcess extends PostProcess {
  148683. private _volumetricLightScatteringPass;
  148684. private _volumetricLightScatteringRTT;
  148685. private _viewPort;
  148686. private _screenCoordinates;
  148687. private _cachedDefines;
  148688. /**
  148689. * If not undefined, the mesh position is computed from the attached node position
  148690. */
  148691. attachedNode: {
  148692. position: Vector3;
  148693. };
  148694. /**
  148695. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  148696. */
  148697. customMeshPosition: Vector3;
  148698. /**
  148699. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  148700. */
  148701. useCustomMeshPosition: boolean;
  148702. /**
  148703. * If the post-process should inverse the light scattering direction
  148704. */
  148705. invert: boolean;
  148706. /**
  148707. * The internal mesh used by the post-process
  148708. */
  148709. mesh: Mesh;
  148710. /**
  148711. * @hidden
  148712. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  148713. */
  148714. get useDiffuseColor(): boolean;
  148715. set useDiffuseColor(useDiffuseColor: boolean);
  148716. /**
  148717. * Array containing the excluded meshes not rendered in the internal pass
  148718. */
  148719. excludedMeshes: AbstractMesh[];
  148720. /**
  148721. * Controls the overall intensity of the post-process
  148722. */
  148723. exposure: number;
  148724. /**
  148725. * Dissipates each sample's contribution in range [0, 1]
  148726. */
  148727. decay: number;
  148728. /**
  148729. * Controls the overall intensity of each sample
  148730. */
  148731. weight: number;
  148732. /**
  148733. * Controls the density of each sample
  148734. */
  148735. density: number;
  148736. /**
  148737. * @constructor
  148738. * @param name The post-process name
  148739. * @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)
  148740. * @param camera The camera that the post-process will be attached to
  148741. * @param mesh The mesh used to create the light scattering
  148742. * @param samples The post-process quality, default 100
  148743. * @param samplingModeThe post-process filtering mode
  148744. * @param engine The babylon engine
  148745. * @param reusable If the post-process is reusable
  148746. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  148747. */
  148748. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  148749. /**
  148750. * Returns the string "VolumetricLightScatteringPostProcess"
  148751. * @returns "VolumetricLightScatteringPostProcess"
  148752. */
  148753. getClassName(): string;
  148754. private _isReady;
  148755. /**
  148756. * Sets the new light position for light scattering effect
  148757. * @param position The new custom light position
  148758. */
  148759. setCustomMeshPosition(position: Vector3): void;
  148760. /**
  148761. * Returns the light position for light scattering effect
  148762. * @return Vector3 The custom light position
  148763. */
  148764. getCustomMeshPosition(): Vector3;
  148765. /**
  148766. * Disposes the internal assets and detaches the post-process from the camera
  148767. */
  148768. dispose(camera: Camera): void;
  148769. /**
  148770. * Returns the render target texture used by the post-process
  148771. * @return the render target texture used by the post-process
  148772. */
  148773. getPass(): RenderTargetTexture;
  148774. private _meshExcluded;
  148775. private _createPass;
  148776. private _updateMeshScreenCoordinates;
  148777. /**
  148778. * Creates a default mesh for the Volumeric Light Scattering post-process
  148779. * @param name The mesh name
  148780. * @param scene The scene where to create the mesh
  148781. * @return the default mesh
  148782. */
  148783. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  148784. }
  148785. }
  148786. declare module BABYLON {
  148787. interface Scene {
  148788. /** @hidden (Backing field) */
  148789. _boundingBoxRenderer: BoundingBoxRenderer;
  148790. /** @hidden (Backing field) */
  148791. _forceShowBoundingBoxes: boolean;
  148792. /**
  148793. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  148794. */
  148795. forceShowBoundingBoxes: boolean;
  148796. /**
  148797. * Gets the bounding box renderer associated with the scene
  148798. * @returns a BoundingBoxRenderer
  148799. */
  148800. getBoundingBoxRenderer(): BoundingBoxRenderer;
  148801. }
  148802. interface AbstractMesh {
  148803. /** @hidden (Backing field) */
  148804. _showBoundingBox: boolean;
  148805. /**
  148806. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  148807. */
  148808. showBoundingBox: boolean;
  148809. }
  148810. /**
  148811. * Component responsible of rendering the bounding box of the meshes in a scene.
  148812. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  148813. */
  148814. export class BoundingBoxRenderer implements ISceneComponent {
  148815. /**
  148816. * The component name helpfull to identify the component in the list of scene components.
  148817. */
  148818. readonly name: string;
  148819. /**
  148820. * The scene the component belongs to.
  148821. */
  148822. scene: Scene;
  148823. /**
  148824. * Color of the bounding box lines placed in front of an object
  148825. */
  148826. frontColor: Color3;
  148827. /**
  148828. * Color of the bounding box lines placed behind an object
  148829. */
  148830. backColor: Color3;
  148831. /**
  148832. * Defines if the renderer should show the back lines or not
  148833. */
  148834. showBackLines: boolean;
  148835. /**
  148836. * Observable raised before rendering a bounding box
  148837. */
  148838. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  148839. /**
  148840. * Observable raised after rendering a bounding box
  148841. */
  148842. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  148843. /**
  148844. * @hidden
  148845. */
  148846. renderList: SmartArray<BoundingBox>;
  148847. private _colorShader;
  148848. private _vertexBuffers;
  148849. private _indexBuffer;
  148850. private _fillIndexBuffer;
  148851. private _fillIndexData;
  148852. /**
  148853. * Instantiates a new bounding box renderer in a scene.
  148854. * @param scene the scene the renderer renders in
  148855. */
  148856. constructor(scene: Scene);
  148857. /**
  148858. * Registers the component in a given scene
  148859. */
  148860. register(): void;
  148861. private _evaluateSubMesh;
  148862. private _activeMesh;
  148863. private _prepareRessources;
  148864. private _createIndexBuffer;
  148865. /**
  148866. * Rebuilds the elements related to this component in case of
  148867. * context lost for instance.
  148868. */
  148869. rebuild(): void;
  148870. /**
  148871. * @hidden
  148872. */
  148873. reset(): void;
  148874. /**
  148875. * Render the bounding boxes of a specific rendering group
  148876. * @param renderingGroupId defines the rendering group to render
  148877. */
  148878. render(renderingGroupId: number): void;
  148879. /**
  148880. * In case of occlusion queries, we can render the occlusion bounding box through this method
  148881. * @param mesh Define the mesh to render the occlusion bounding box for
  148882. */
  148883. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  148884. /**
  148885. * Dispose and release the resources attached to this renderer.
  148886. */
  148887. dispose(): void;
  148888. }
  148889. }
  148890. declare module BABYLON {
  148891. interface Scene {
  148892. /** @hidden (Backing field) */
  148893. _depthRenderer: {
  148894. [id: string]: DepthRenderer;
  148895. };
  148896. /**
  148897. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  148898. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  148899. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  148900. * @returns the created depth renderer
  148901. */
  148902. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  148903. /**
  148904. * Disables a depth renderer for a given camera
  148905. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  148906. */
  148907. disableDepthRenderer(camera?: Nullable<Camera>): void;
  148908. }
  148909. /**
  148910. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  148911. * in several rendering techniques.
  148912. */
  148913. export class DepthRendererSceneComponent implements ISceneComponent {
  148914. /**
  148915. * The component name helpfull to identify the component in the list of scene components.
  148916. */
  148917. readonly name: string;
  148918. /**
  148919. * The scene the component belongs to.
  148920. */
  148921. scene: Scene;
  148922. /**
  148923. * Creates a new instance of the component for the given scene
  148924. * @param scene Defines the scene to register the component in
  148925. */
  148926. constructor(scene: Scene);
  148927. /**
  148928. * Registers the component in a given scene
  148929. */
  148930. register(): void;
  148931. /**
  148932. * Rebuilds the elements related to this component in case of
  148933. * context lost for instance.
  148934. */
  148935. rebuild(): void;
  148936. /**
  148937. * Disposes the component and the associated ressources
  148938. */
  148939. dispose(): void;
  148940. private _gatherRenderTargets;
  148941. private _gatherActiveCameraRenderTargets;
  148942. }
  148943. }
  148944. declare module BABYLON {
  148945. /** @hidden */
  148946. export var fibonacci: {
  148947. name: string;
  148948. shader: string;
  148949. };
  148950. }
  148951. declare module BABYLON {
  148952. /** @hidden */
  148953. export var diffusionProfile: {
  148954. name: string;
  148955. shader: string;
  148956. };
  148957. }
  148958. declare module BABYLON {
  148959. /** @hidden */
  148960. export var subSurfaceScatteringPixelShader: {
  148961. name: string;
  148962. shader: string;
  148963. };
  148964. }
  148965. declare module BABYLON {
  148966. /**
  148967. * Sub surface scattering post process
  148968. */
  148969. export class SubSurfaceScatteringPostProcess extends PostProcess {
  148970. /** @hidden */
  148971. texelWidth: number;
  148972. /** @hidden */
  148973. texelHeight: number;
  148974. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148975. }
  148976. }
  148977. declare module BABYLON {
  148978. /**
  148979. * Contains all parameters needed for the prepass to perform
  148980. * screen space subsurface scattering
  148981. */
  148982. export class SubSurfaceConfiguration {
  148983. private _ssDiffusionS;
  148984. private _ssFilterRadii;
  148985. private _ssDiffusionD;
  148986. /**
  148987. * Diffusion profile color for subsurface scattering
  148988. */
  148989. get ssDiffusionS(): number[];
  148990. /**
  148991. * Diffusion profile max color channel value for subsurface scattering
  148992. */
  148993. get ssDiffusionD(): number[];
  148994. /**
  148995. * Diffusion profile filter radius for subsurface scattering
  148996. */
  148997. get ssFilterRadii(): number[];
  148998. /**
  148999. * Diffusion profile colors for subsurface scattering
  149000. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  149001. * See ...
  149002. * Note that you can only store up to 5 of them
  149003. */
  149004. ssDiffusionProfileColors: Color3[];
  149005. /**
  149006. * Defines the ratio real world => scene units.
  149007. * Used for subsurface scattering
  149008. */
  149009. metersPerUnit: number;
  149010. /**
  149011. * Builds a subsurface configuration object
  149012. * @param scene The scene
  149013. */
  149014. constructor();
  149015. /**
  149016. * Adds a new diffusion profile.
  149017. * Useful for more realistic subsurface scattering on diverse materials.
  149018. * @param color The color of the diffusion profile. Should be the average color of the material.
  149019. * @return The index of the diffusion profile for the material subsurface configuration
  149020. */
  149021. addDiffusionProfile(color: Color3): number;
  149022. /**
  149023. * Deletes all diffusion profiles.
  149024. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  149025. */
  149026. clearAllDiffusionProfiles(): void;
  149027. /**
  149028. * Disposes this object
  149029. */
  149030. dispose(): void;
  149031. /**
  149032. * @hidden
  149033. * https://zero-radiance.github.io/post/sampling-diffusion/
  149034. *
  149035. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  149036. * ------------------------------------------------------------------------------------
  149037. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  149038. * PDF[r, phi, s] = r * R[r, phi, s]
  149039. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  149040. * ------------------------------------------------------------------------------------
  149041. * We importance sample the color channel with the widest scattering distance.
  149042. */
  149043. getDiffusionProfileParameters(color: Color3): number;
  149044. /**
  149045. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  149046. * 'u' is the random number (the value of the CDF): [0, 1).
  149047. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  149048. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  149049. */
  149050. private _sampleBurleyDiffusionProfile;
  149051. }
  149052. }
  149053. declare module BABYLON {
  149054. /**
  149055. * Renders a pre pass of the scene
  149056. * This means every mesh in the scene will be rendered to a render target texture
  149057. * And then this texture will be composited to the rendering canvas with post processes
  149058. * It is necessary for effects like subsurface scattering or deferred shading
  149059. */
  149060. export class PrePassRenderer {
  149061. /** @hidden */
  149062. static _SceneComponentInitialization: (scene: Scene) => void;
  149063. private _scene;
  149064. private _engine;
  149065. private _isDirty;
  149066. /**
  149067. * Number of textures in the multi render target texture where the scene is directly rendered
  149068. */
  149069. readonly mrtCount: number;
  149070. /**
  149071. * The render target where the scene is directly rendered
  149072. */
  149073. prePassRT: MultiRenderTarget;
  149074. private _mrtTypes;
  149075. private _multiRenderAttachments;
  149076. private _defaultAttachments;
  149077. private _clearAttachments;
  149078. private readonly _clearColor;
  149079. /**
  149080. * Image processing post process for composition
  149081. */
  149082. imageProcessingPostProcess: ImageProcessingPostProcess;
  149083. /**
  149084. * Post process for subsurface scattering
  149085. */
  149086. subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
  149087. /**
  149088. * Configuration for sub surface scattering post process
  149089. */
  149090. subSurfaceConfiguration: SubSurfaceConfiguration;
  149091. private _enabled;
  149092. /**
  149093. * Indicates if the prepass is enabled
  149094. */
  149095. get enabled(): boolean;
  149096. /**
  149097. * How many samples are used for MSAA of the scene render target
  149098. */
  149099. get samples(): number;
  149100. set samples(n: number);
  149101. /**
  149102. * Instanciates a prepass renderer
  149103. * @param scene The scene
  149104. */
  149105. constructor(scene: Scene);
  149106. private _initializeAttachments;
  149107. private _createEffects;
  149108. /**
  149109. * Indicates if rendering a prepass is supported
  149110. */
  149111. get isSupported(): boolean;
  149112. /**
  149113. * Sets the proper output textures to draw in the engine.
  149114. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  149115. */
  149116. bindAttachmentsForEffect(effect: Effect): void;
  149117. /**
  149118. * @hidden
  149119. */
  149120. _beforeCameraDraw(): void;
  149121. /**
  149122. * @hidden
  149123. */
  149124. _afterCameraDraw(): void;
  149125. private _checkRTSize;
  149126. private _bindFrameBuffer;
  149127. /**
  149128. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  149129. */
  149130. clear(): void;
  149131. private _setState;
  149132. private _enable;
  149133. private _disable;
  149134. /**
  149135. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  149136. */
  149137. markAsDirty(): void;
  149138. private _update;
  149139. /**
  149140. * Disposes the prepass renderer.
  149141. */
  149142. dispose(): void;
  149143. }
  149144. }
  149145. declare module BABYLON {
  149146. interface AbstractScene {
  149147. /** @hidden (Backing field) */
  149148. _prePassRenderer: Nullable<PrePassRenderer>;
  149149. /**
  149150. * Gets or Sets the current prepass renderer associated to the scene.
  149151. */
  149152. prePassRenderer: Nullable<PrePassRenderer>;
  149153. /**
  149154. * Enables the prepass and associates it with the scene
  149155. * @returns the PrePassRenderer
  149156. */
  149157. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  149158. /**
  149159. * Disables the prepass associated with the scene
  149160. */
  149161. disablePrePassRenderer(): void;
  149162. }
  149163. /**
  149164. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149165. * in several rendering techniques.
  149166. */
  149167. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  149168. /**
  149169. * The component name helpful to identify the component in the list of scene components.
  149170. */
  149171. readonly name: string;
  149172. /**
  149173. * The scene the component belongs to.
  149174. */
  149175. scene: Scene;
  149176. /**
  149177. * Creates a new instance of the component for the given scene
  149178. * @param scene Defines the scene to register the component in
  149179. */
  149180. constructor(scene: Scene);
  149181. /**
  149182. * Registers the component in a given scene
  149183. */
  149184. register(): void;
  149185. private _beforeCameraDraw;
  149186. private _afterCameraDraw;
  149187. private _beforeClearStage;
  149188. /**
  149189. * Serializes the component data to the specified json object
  149190. * @param serializationObject The object to serialize to
  149191. */
  149192. serialize(serializationObject: any): void;
  149193. /**
  149194. * Adds all the elements from the container to the scene
  149195. * @param container the container holding the elements
  149196. */
  149197. addFromContainer(container: AbstractScene): void;
  149198. /**
  149199. * Removes all the elements in the container from the scene
  149200. * @param container contains the elements to remove
  149201. * @param dispose if the removed element should be disposed (default: false)
  149202. */
  149203. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  149204. /**
  149205. * Rebuilds the elements related to this component in case of
  149206. * context lost for instance.
  149207. */
  149208. rebuild(): void;
  149209. /**
  149210. * Disposes the component and the associated ressources
  149211. */
  149212. dispose(): void;
  149213. }
  149214. }
  149215. declare module BABYLON {
  149216. /** @hidden */
  149217. export var outlinePixelShader: {
  149218. name: string;
  149219. shader: string;
  149220. };
  149221. }
  149222. declare module BABYLON {
  149223. /** @hidden */
  149224. export var outlineVertexShader: {
  149225. name: string;
  149226. shader: string;
  149227. };
  149228. }
  149229. declare module BABYLON {
  149230. interface Scene {
  149231. /** @hidden */
  149232. _outlineRenderer: OutlineRenderer;
  149233. /**
  149234. * Gets the outline renderer associated with the scene
  149235. * @returns a OutlineRenderer
  149236. */
  149237. getOutlineRenderer(): OutlineRenderer;
  149238. }
  149239. interface AbstractMesh {
  149240. /** @hidden (Backing field) */
  149241. _renderOutline: boolean;
  149242. /**
  149243. * Gets or sets a boolean indicating if the outline must be rendered as well
  149244. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  149245. */
  149246. renderOutline: boolean;
  149247. /** @hidden (Backing field) */
  149248. _renderOverlay: boolean;
  149249. /**
  149250. * Gets or sets a boolean indicating if the overlay must be rendered as well
  149251. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  149252. */
  149253. renderOverlay: boolean;
  149254. }
  149255. /**
  149256. * This class is responsible to draw bothe outline/overlay of meshes.
  149257. * It should not be used directly but through the available method on mesh.
  149258. */
  149259. export class OutlineRenderer implements ISceneComponent {
  149260. /**
  149261. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  149262. */
  149263. private static _StencilReference;
  149264. /**
  149265. * The name of the component. Each component must have a unique name.
  149266. */
  149267. name: string;
  149268. /**
  149269. * The scene the component belongs to.
  149270. */
  149271. scene: Scene;
  149272. /**
  149273. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  149274. */
  149275. zOffset: number;
  149276. private _engine;
  149277. private _effect;
  149278. private _cachedDefines;
  149279. private _savedDepthWrite;
  149280. /**
  149281. * Instantiates a new outline renderer. (There could be only one per scene).
  149282. * @param scene Defines the scene it belongs to
  149283. */
  149284. constructor(scene: Scene);
  149285. /**
  149286. * Register the component to one instance of a scene.
  149287. */
  149288. register(): void;
  149289. /**
  149290. * Rebuilds the elements related to this component in case of
  149291. * context lost for instance.
  149292. */
  149293. rebuild(): void;
  149294. /**
  149295. * Disposes the component and the associated ressources.
  149296. */
  149297. dispose(): void;
  149298. /**
  149299. * Renders the outline in the canvas.
  149300. * @param subMesh Defines the sumesh to render
  149301. * @param batch Defines the batch of meshes in case of instances
  149302. * @param useOverlay Defines if the rendering is for the overlay or the outline
  149303. */
  149304. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  149305. /**
  149306. * Returns whether or not the outline renderer is ready for a given submesh.
  149307. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  149308. * @param subMesh Defines the submesh to check readyness for
  149309. * @param useInstances Defines wheter wee are trying to render instances or not
  149310. * @returns true if ready otherwise false
  149311. */
  149312. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149313. private _beforeRenderingMesh;
  149314. private _afterRenderingMesh;
  149315. }
  149316. }
  149317. declare module BABYLON {
  149318. /**
  149319. * Defines the basic options interface of a Sprite Frame Source Size.
  149320. */
  149321. export interface ISpriteJSONSpriteSourceSize {
  149322. /**
  149323. * number of the original width of the Frame
  149324. */
  149325. w: number;
  149326. /**
  149327. * number of the original height of the Frame
  149328. */
  149329. h: number;
  149330. }
  149331. /**
  149332. * Defines the basic options interface of a Sprite Frame Data.
  149333. */
  149334. export interface ISpriteJSONSpriteFrameData {
  149335. /**
  149336. * number of the x offset of the Frame
  149337. */
  149338. x: number;
  149339. /**
  149340. * number of the y offset of the Frame
  149341. */
  149342. y: number;
  149343. /**
  149344. * number of the width of the Frame
  149345. */
  149346. w: number;
  149347. /**
  149348. * number of the height of the Frame
  149349. */
  149350. h: number;
  149351. }
  149352. /**
  149353. * Defines the basic options interface of a JSON Sprite.
  149354. */
  149355. export interface ISpriteJSONSprite {
  149356. /**
  149357. * string name of the Frame
  149358. */
  149359. filename: string;
  149360. /**
  149361. * ISpriteJSONSpriteFrame basic object of the frame data
  149362. */
  149363. frame: ISpriteJSONSpriteFrameData;
  149364. /**
  149365. * boolean to flag is the frame was rotated.
  149366. */
  149367. rotated: boolean;
  149368. /**
  149369. * boolean to flag is the frame was trimmed.
  149370. */
  149371. trimmed: boolean;
  149372. /**
  149373. * ISpriteJSONSpriteFrame basic object of the source data
  149374. */
  149375. spriteSourceSize: ISpriteJSONSpriteFrameData;
  149376. /**
  149377. * ISpriteJSONSpriteFrame basic object of the source data
  149378. */
  149379. sourceSize: ISpriteJSONSpriteSourceSize;
  149380. }
  149381. /**
  149382. * Defines the basic options interface of a JSON atlas.
  149383. */
  149384. export interface ISpriteJSONAtlas {
  149385. /**
  149386. * Array of objects that contain the frame data.
  149387. */
  149388. frames: Array<ISpriteJSONSprite>;
  149389. /**
  149390. * object basic object containing the sprite meta data.
  149391. */
  149392. meta?: object;
  149393. }
  149394. }
  149395. declare module BABYLON {
  149396. /** @hidden */
  149397. export var spriteMapPixelShader: {
  149398. name: string;
  149399. shader: string;
  149400. };
  149401. }
  149402. declare module BABYLON {
  149403. /** @hidden */
  149404. export var spriteMapVertexShader: {
  149405. name: string;
  149406. shader: string;
  149407. };
  149408. }
  149409. declare module BABYLON {
  149410. /**
  149411. * Defines the basic options interface of a SpriteMap
  149412. */
  149413. export interface ISpriteMapOptions {
  149414. /**
  149415. * Vector2 of the number of cells in the grid.
  149416. */
  149417. stageSize?: Vector2;
  149418. /**
  149419. * Vector2 of the size of the output plane in World Units.
  149420. */
  149421. outputSize?: Vector2;
  149422. /**
  149423. * Vector3 of the position of the output plane in World Units.
  149424. */
  149425. outputPosition?: Vector3;
  149426. /**
  149427. * Vector3 of the rotation of the output plane.
  149428. */
  149429. outputRotation?: Vector3;
  149430. /**
  149431. * number of layers that the system will reserve in resources.
  149432. */
  149433. layerCount?: number;
  149434. /**
  149435. * number of max animation frames a single cell will reserve in resources.
  149436. */
  149437. maxAnimationFrames?: number;
  149438. /**
  149439. * number cell index of the base tile when the system compiles.
  149440. */
  149441. baseTile?: number;
  149442. /**
  149443. * boolean flip the sprite after its been repositioned by the framing data.
  149444. */
  149445. flipU?: boolean;
  149446. /**
  149447. * Vector3 scalar of the global RGB values of the SpriteMap.
  149448. */
  149449. colorMultiply?: Vector3;
  149450. }
  149451. /**
  149452. * Defines the IDisposable interface in order to be cleanable from resources.
  149453. */
  149454. export interface ISpriteMap extends IDisposable {
  149455. /**
  149456. * String name of the SpriteMap.
  149457. */
  149458. name: string;
  149459. /**
  149460. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  149461. */
  149462. atlasJSON: ISpriteJSONAtlas;
  149463. /**
  149464. * Texture of the SpriteMap.
  149465. */
  149466. spriteSheet: Texture;
  149467. /**
  149468. * The parameters to initialize the SpriteMap with.
  149469. */
  149470. options: ISpriteMapOptions;
  149471. }
  149472. /**
  149473. * Class used to manage a grid restricted sprite deployment on an Output plane.
  149474. */
  149475. export class SpriteMap implements ISpriteMap {
  149476. /** The Name of the spriteMap */
  149477. name: string;
  149478. /** The JSON file with the frame and meta data */
  149479. atlasJSON: ISpriteJSONAtlas;
  149480. /** The systems Sprite Sheet Texture */
  149481. spriteSheet: Texture;
  149482. /** Arguments passed with the Constructor */
  149483. options: ISpriteMapOptions;
  149484. /** Public Sprite Storage array, parsed from atlasJSON */
  149485. sprites: Array<ISpriteJSONSprite>;
  149486. /** Returns the Number of Sprites in the System */
  149487. get spriteCount(): number;
  149488. /** Returns the Position of Output Plane*/
  149489. get position(): Vector3;
  149490. /** Returns the Position of Output Plane*/
  149491. set position(v: Vector3);
  149492. /** Returns the Rotation of Output Plane*/
  149493. get rotation(): Vector3;
  149494. /** Returns the Rotation of Output Plane*/
  149495. set rotation(v: Vector3);
  149496. /** Sets the AnimationMap*/
  149497. get animationMap(): RawTexture;
  149498. /** Sets the AnimationMap*/
  149499. set animationMap(v: RawTexture);
  149500. /** Scene that the SpriteMap was created in */
  149501. private _scene;
  149502. /** Texture Buffer of Float32 that holds tile frame data*/
  149503. private _frameMap;
  149504. /** Texture Buffers of Float32 that holds tileMap data*/
  149505. private _tileMaps;
  149506. /** Texture Buffer of Float32 that holds Animation Data*/
  149507. private _animationMap;
  149508. /** Custom ShaderMaterial Central to the System*/
  149509. private _material;
  149510. /** Custom ShaderMaterial Central to the System*/
  149511. private _output;
  149512. /** Systems Time Ticker*/
  149513. private _time;
  149514. /**
  149515. * Creates a new SpriteMap
  149516. * @param name defines the SpriteMaps Name
  149517. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  149518. * @param spriteSheet is the Texture that the Sprites are on.
  149519. * @param options a basic deployment configuration
  149520. * @param scene The Scene that the map is deployed on
  149521. */
  149522. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  149523. /**
  149524. * Returns tileID location
  149525. * @returns Vector2 the cell position ID
  149526. */
  149527. getTileID(): Vector2;
  149528. /**
  149529. * Gets the UV location of the mouse over the SpriteMap.
  149530. * @returns Vector2 the UV position of the mouse interaction
  149531. */
  149532. getMousePosition(): Vector2;
  149533. /**
  149534. * Creates the "frame" texture Buffer
  149535. * -------------------------------------
  149536. * Structure of frames
  149537. * "filename": "Falling-Water-2.png",
  149538. * "frame": {"x":69,"y":103,"w":24,"h":32},
  149539. * "rotated": true,
  149540. * "trimmed": true,
  149541. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  149542. * "sourceSize": {"w":32,"h":32}
  149543. * @returns RawTexture of the frameMap
  149544. */
  149545. private _createFrameBuffer;
  149546. /**
  149547. * Creates the tileMap texture Buffer
  149548. * @param buffer normally and array of numbers, or a false to generate from scratch
  149549. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  149550. * @returns RawTexture of the tileMap
  149551. */
  149552. private _createTileBuffer;
  149553. /**
  149554. * Modifies the data of the tileMaps
  149555. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  149556. * @param pos is the iVector2 Coordinates of the Tile
  149557. * @param tile The SpriteIndex of the new Tile
  149558. */
  149559. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  149560. /**
  149561. * Creates the animationMap texture Buffer
  149562. * @param buffer normally and array of numbers, or a false to generate from scratch
  149563. * @returns RawTexture of the animationMap
  149564. */
  149565. private _createTileAnimationBuffer;
  149566. /**
  149567. * Modifies the data of the animationMap
  149568. * @param cellID is the Index of the Sprite
  149569. * @param _frame is the target Animation frame
  149570. * @param toCell is the Target Index of the next frame of the animation
  149571. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  149572. * @param speed is a global scalar of the time variable on the map.
  149573. */
  149574. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  149575. /**
  149576. * Exports the .tilemaps file
  149577. */
  149578. saveTileMaps(): void;
  149579. /**
  149580. * Imports the .tilemaps file
  149581. * @param url of the .tilemaps file
  149582. */
  149583. loadTileMaps(url: string): void;
  149584. /**
  149585. * Release associated resources
  149586. */
  149587. dispose(): void;
  149588. }
  149589. }
  149590. declare module BABYLON {
  149591. /**
  149592. * Class used to manage multiple sprites of different sizes on the same spritesheet
  149593. * @see https://doc.babylonjs.com/babylon101/sprites
  149594. */
  149595. export class SpritePackedManager extends SpriteManager {
  149596. /** defines the packed manager's name */
  149597. name: string;
  149598. /**
  149599. * Creates a new sprite manager from a packed sprite sheet
  149600. * @param name defines the manager's name
  149601. * @param imgUrl defines the sprite sheet url
  149602. * @param capacity defines the maximum allowed number of sprites
  149603. * @param scene defines the hosting scene
  149604. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  149605. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  149606. * @param samplingMode defines the smapling mode to use with spritesheet
  149607. * @param fromPacked set to true; do not alter
  149608. */
  149609. constructor(
  149610. /** defines the packed manager's name */
  149611. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  149612. }
  149613. }
  149614. declare module BABYLON {
  149615. /**
  149616. * Defines the list of states available for a task inside a AssetsManager
  149617. */
  149618. export enum AssetTaskState {
  149619. /**
  149620. * Initialization
  149621. */
  149622. INIT = 0,
  149623. /**
  149624. * Running
  149625. */
  149626. RUNNING = 1,
  149627. /**
  149628. * Done
  149629. */
  149630. DONE = 2,
  149631. /**
  149632. * Error
  149633. */
  149634. ERROR = 3
  149635. }
  149636. /**
  149637. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  149638. */
  149639. export abstract class AbstractAssetTask {
  149640. /**
  149641. * Task name
  149642. */ name: string;
  149643. /**
  149644. * Callback called when the task is successful
  149645. */
  149646. onSuccess: (task: any) => void;
  149647. /**
  149648. * Callback called when the task is not successful
  149649. */
  149650. onError: (task: any, message?: string, exception?: any) => void;
  149651. /**
  149652. * Creates a new AssetsManager
  149653. * @param name defines the name of the task
  149654. */
  149655. constructor(
  149656. /**
  149657. * Task name
  149658. */ name: string);
  149659. private _isCompleted;
  149660. private _taskState;
  149661. private _errorObject;
  149662. /**
  149663. * Get if the task is completed
  149664. */
  149665. get isCompleted(): boolean;
  149666. /**
  149667. * Gets the current state of the task
  149668. */
  149669. get taskState(): AssetTaskState;
  149670. /**
  149671. * Gets the current error object (if task is in error)
  149672. */
  149673. get errorObject(): {
  149674. message?: string;
  149675. exception?: any;
  149676. };
  149677. /**
  149678. * Internal only
  149679. * @hidden
  149680. */
  149681. _setErrorObject(message?: string, exception?: any): void;
  149682. /**
  149683. * Execute the current task
  149684. * @param scene defines the scene where you want your assets to be loaded
  149685. * @param onSuccess is a callback called when the task is successfully executed
  149686. * @param onError is a callback called if an error occurs
  149687. */
  149688. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149689. /**
  149690. * Execute the current task
  149691. * @param scene defines the scene where you want your assets to be loaded
  149692. * @param onSuccess is a callback called when the task is successfully executed
  149693. * @param onError is a callback called if an error occurs
  149694. */
  149695. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149696. /**
  149697. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  149698. * This can be used with failed tasks that have the reason for failure fixed.
  149699. */
  149700. reset(): void;
  149701. private onErrorCallback;
  149702. private onDoneCallback;
  149703. }
  149704. /**
  149705. * Define the interface used by progress events raised during assets loading
  149706. */
  149707. export interface IAssetsProgressEvent {
  149708. /**
  149709. * Defines the number of remaining tasks to process
  149710. */
  149711. remainingCount: number;
  149712. /**
  149713. * Defines the total number of tasks
  149714. */
  149715. totalCount: number;
  149716. /**
  149717. * Defines the task that was just processed
  149718. */
  149719. task: AbstractAssetTask;
  149720. }
  149721. /**
  149722. * Class used to share progress information about assets loading
  149723. */
  149724. export class AssetsProgressEvent implements IAssetsProgressEvent {
  149725. /**
  149726. * Defines the number of remaining tasks to process
  149727. */
  149728. remainingCount: number;
  149729. /**
  149730. * Defines the total number of tasks
  149731. */
  149732. totalCount: number;
  149733. /**
  149734. * Defines the task that was just processed
  149735. */
  149736. task: AbstractAssetTask;
  149737. /**
  149738. * Creates a AssetsProgressEvent
  149739. * @param remainingCount defines the number of remaining tasks to process
  149740. * @param totalCount defines the total number of tasks
  149741. * @param task defines the task that was just processed
  149742. */
  149743. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  149744. }
  149745. /**
  149746. * Define a task used by AssetsManager to load meshes
  149747. */
  149748. export class MeshAssetTask extends AbstractAssetTask {
  149749. /**
  149750. * Defines the name of the task
  149751. */
  149752. name: string;
  149753. /**
  149754. * Defines the list of mesh's names you want to load
  149755. */
  149756. meshesNames: any;
  149757. /**
  149758. * Defines the root url to use as a base to load your meshes and associated resources
  149759. */
  149760. rootUrl: string;
  149761. /**
  149762. * Defines the filename or File of the scene to load from
  149763. */
  149764. sceneFilename: string | File;
  149765. /**
  149766. * Gets the list of loaded meshes
  149767. */
  149768. loadedMeshes: Array<AbstractMesh>;
  149769. /**
  149770. * Gets the list of loaded particle systems
  149771. */
  149772. loadedParticleSystems: Array<IParticleSystem>;
  149773. /**
  149774. * Gets the list of loaded skeletons
  149775. */
  149776. loadedSkeletons: Array<Skeleton>;
  149777. /**
  149778. * Gets the list of loaded animation groups
  149779. */
  149780. loadedAnimationGroups: Array<AnimationGroup>;
  149781. /**
  149782. * Callback called when the task is successful
  149783. */
  149784. onSuccess: (task: MeshAssetTask) => void;
  149785. /**
  149786. * Callback called when the task is successful
  149787. */
  149788. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  149789. /**
  149790. * Creates a new MeshAssetTask
  149791. * @param name defines the name of the task
  149792. * @param meshesNames defines the list of mesh's names you want to load
  149793. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  149794. * @param sceneFilename defines the filename or File of the scene to load from
  149795. */
  149796. constructor(
  149797. /**
  149798. * Defines the name of the task
  149799. */
  149800. name: string,
  149801. /**
  149802. * Defines the list of mesh's names you want to load
  149803. */
  149804. meshesNames: any,
  149805. /**
  149806. * Defines the root url to use as a base to load your meshes and associated resources
  149807. */
  149808. rootUrl: string,
  149809. /**
  149810. * Defines the filename or File of the scene to load from
  149811. */
  149812. sceneFilename: string | File);
  149813. /**
  149814. * Execute the current task
  149815. * @param scene defines the scene where you want your assets to be loaded
  149816. * @param onSuccess is a callback called when the task is successfully executed
  149817. * @param onError is a callback called if an error occurs
  149818. */
  149819. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149820. }
  149821. /**
  149822. * Define a task used by AssetsManager to load text content
  149823. */
  149824. export class TextFileAssetTask extends AbstractAssetTask {
  149825. /**
  149826. * Defines the name of the task
  149827. */
  149828. name: string;
  149829. /**
  149830. * Defines the location of the file to load
  149831. */
  149832. url: string;
  149833. /**
  149834. * Gets the loaded text string
  149835. */
  149836. text: string;
  149837. /**
  149838. * Callback called when the task is successful
  149839. */
  149840. onSuccess: (task: TextFileAssetTask) => void;
  149841. /**
  149842. * Callback called when the task is successful
  149843. */
  149844. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  149845. /**
  149846. * Creates a new TextFileAssetTask object
  149847. * @param name defines the name of the task
  149848. * @param url defines the location of the file to load
  149849. */
  149850. constructor(
  149851. /**
  149852. * Defines the name of the task
  149853. */
  149854. name: string,
  149855. /**
  149856. * Defines the location of the file to load
  149857. */
  149858. url: string);
  149859. /**
  149860. * Execute the current task
  149861. * @param scene defines the scene where you want your assets to be loaded
  149862. * @param onSuccess is a callback called when the task is successfully executed
  149863. * @param onError is a callback called if an error occurs
  149864. */
  149865. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149866. }
  149867. /**
  149868. * Define a task used by AssetsManager to load binary data
  149869. */
  149870. export class BinaryFileAssetTask extends AbstractAssetTask {
  149871. /**
  149872. * Defines the name of the task
  149873. */
  149874. name: string;
  149875. /**
  149876. * Defines the location of the file to load
  149877. */
  149878. url: string;
  149879. /**
  149880. * Gets the lodaded data (as an array buffer)
  149881. */
  149882. data: ArrayBuffer;
  149883. /**
  149884. * Callback called when the task is successful
  149885. */
  149886. onSuccess: (task: BinaryFileAssetTask) => void;
  149887. /**
  149888. * Callback called when the task is successful
  149889. */
  149890. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  149891. /**
  149892. * Creates a new BinaryFileAssetTask object
  149893. * @param name defines the name of the new task
  149894. * @param url defines the location of the file to load
  149895. */
  149896. constructor(
  149897. /**
  149898. * Defines the name of the task
  149899. */
  149900. name: string,
  149901. /**
  149902. * Defines the location of the file to load
  149903. */
  149904. url: string);
  149905. /**
  149906. * Execute the current task
  149907. * @param scene defines the scene where you want your assets to be loaded
  149908. * @param onSuccess is a callback called when the task is successfully executed
  149909. * @param onError is a callback called if an error occurs
  149910. */
  149911. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149912. }
  149913. /**
  149914. * Define a task used by AssetsManager to load images
  149915. */
  149916. export class ImageAssetTask extends AbstractAssetTask {
  149917. /**
  149918. * Defines the name of the task
  149919. */
  149920. name: string;
  149921. /**
  149922. * Defines the location of the image to load
  149923. */
  149924. url: string;
  149925. /**
  149926. * Gets the loaded images
  149927. */
  149928. image: HTMLImageElement;
  149929. /**
  149930. * Callback called when the task is successful
  149931. */
  149932. onSuccess: (task: ImageAssetTask) => void;
  149933. /**
  149934. * Callback called when the task is successful
  149935. */
  149936. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  149937. /**
  149938. * Creates a new ImageAssetTask
  149939. * @param name defines the name of the task
  149940. * @param url defines the location of the image to load
  149941. */
  149942. constructor(
  149943. /**
  149944. * Defines the name of the task
  149945. */
  149946. name: string,
  149947. /**
  149948. * Defines the location of the image to load
  149949. */
  149950. url: string);
  149951. /**
  149952. * Execute the current task
  149953. * @param scene defines the scene where you want your assets to be loaded
  149954. * @param onSuccess is a callback called when the task is successfully executed
  149955. * @param onError is a callback called if an error occurs
  149956. */
  149957. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149958. }
  149959. /**
  149960. * Defines the interface used by texture loading tasks
  149961. */
  149962. export interface ITextureAssetTask<TEX extends BaseTexture> {
  149963. /**
  149964. * Gets the loaded texture
  149965. */
  149966. texture: TEX;
  149967. }
  149968. /**
  149969. * Define a task used by AssetsManager to load 2D textures
  149970. */
  149971. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  149972. /**
  149973. * Defines the name of the task
  149974. */
  149975. name: string;
  149976. /**
  149977. * Defines the location of the file to load
  149978. */
  149979. url: string;
  149980. /**
  149981. * Defines if mipmap should not be generated (default is false)
  149982. */
  149983. noMipmap?: boolean | undefined;
  149984. /**
  149985. * Defines if texture must be inverted on Y axis (default is true)
  149986. */
  149987. invertY: boolean;
  149988. /**
  149989. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149990. */
  149991. samplingMode: number;
  149992. /**
  149993. * Gets the loaded texture
  149994. */
  149995. texture: Texture;
  149996. /**
  149997. * Callback called when the task is successful
  149998. */
  149999. onSuccess: (task: TextureAssetTask) => void;
  150000. /**
  150001. * Callback called when the task is successful
  150002. */
  150003. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  150004. /**
  150005. * Creates a new TextureAssetTask object
  150006. * @param name defines the name of the task
  150007. * @param url defines the location of the file to load
  150008. * @param noMipmap defines if mipmap should not be generated (default is false)
  150009. * @param invertY defines if texture must be inverted on Y axis (default is true)
  150010. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150011. */
  150012. constructor(
  150013. /**
  150014. * Defines the name of the task
  150015. */
  150016. name: string,
  150017. /**
  150018. * Defines the location of the file to load
  150019. */
  150020. url: string,
  150021. /**
  150022. * Defines if mipmap should not be generated (default is false)
  150023. */
  150024. noMipmap?: boolean | undefined,
  150025. /**
  150026. * Defines if texture must be inverted on Y axis (default is true)
  150027. */
  150028. invertY?: boolean,
  150029. /**
  150030. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150031. */
  150032. samplingMode?: number);
  150033. /**
  150034. * Execute the current task
  150035. * @param scene defines the scene where you want your assets to be loaded
  150036. * @param onSuccess is a callback called when the task is successfully executed
  150037. * @param onError is a callback called if an error occurs
  150038. */
  150039. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150040. }
  150041. /**
  150042. * Define a task used by AssetsManager to load cube textures
  150043. */
  150044. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  150045. /**
  150046. * Defines the name of the task
  150047. */
  150048. name: string;
  150049. /**
  150050. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150051. */
  150052. url: string;
  150053. /**
  150054. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150055. */
  150056. extensions?: string[] | undefined;
  150057. /**
  150058. * Defines if mipmaps should not be generated (default is false)
  150059. */
  150060. noMipmap?: boolean | undefined;
  150061. /**
  150062. * Defines the explicit list of files (undefined by default)
  150063. */
  150064. files?: string[] | undefined;
  150065. /**
  150066. * Gets the loaded texture
  150067. */
  150068. texture: CubeTexture;
  150069. /**
  150070. * Callback called when the task is successful
  150071. */
  150072. onSuccess: (task: CubeTextureAssetTask) => void;
  150073. /**
  150074. * Callback called when the task is successful
  150075. */
  150076. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  150077. /**
  150078. * Creates a new CubeTextureAssetTask
  150079. * @param name defines the name of the task
  150080. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150081. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150082. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150083. * @param files defines the explicit list of files (undefined by default)
  150084. */
  150085. constructor(
  150086. /**
  150087. * Defines the name of the task
  150088. */
  150089. name: string,
  150090. /**
  150091. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150092. */
  150093. url: string,
  150094. /**
  150095. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150096. */
  150097. extensions?: string[] | undefined,
  150098. /**
  150099. * Defines if mipmaps should not be generated (default is false)
  150100. */
  150101. noMipmap?: boolean | undefined,
  150102. /**
  150103. * Defines the explicit list of files (undefined by default)
  150104. */
  150105. files?: string[] | undefined);
  150106. /**
  150107. * Execute the current task
  150108. * @param scene defines the scene where you want your assets to be loaded
  150109. * @param onSuccess is a callback called when the task is successfully executed
  150110. * @param onError is a callback called if an error occurs
  150111. */
  150112. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150113. }
  150114. /**
  150115. * Define a task used by AssetsManager to load HDR cube textures
  150116. */
  150117. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  150118. /**
  150119. * Defines the name of the task
  150120. */
  150121. name: string;
  150122. /**
  150123. * Defines the location of the file to load
  150124. */
  150125. url: string;
  150126. /**
  150127. * Defines the desired size (the more it increases the longer the generation will be)
  150128. */
  150129. size: number;
  150130. /**
  150131. * Defines if mipmaps should not be generated (default is false)
  150132. */
  150133. noMipmap: boolean;
  150134. /**
  150135. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150136. */
  150137. generateHarmonics: boolean;
  150138. /**
  150139. * 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)
  150140. */
  150141. gammaSpace: boolean;
  150142. /**
  150143. * Internal Use Only
  150144. */
  150145. reserved: boolean;
  150146. /**
  150147. * Gets the loaded texture
  150148. */
  150149. texture: HDRCubeTexture;
  150150. /**
  150151. * Callback called when the task is successful
  150152. */
  150153. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  150154. /**
  150155. * Callback called when the task is successful
  150156. */
  150157. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  150158. /**
  150159. * Creates a new HDRCubeTextureAssetTask object
  150160. * @param name defines the name of the task
  150161. * @param url defines the location of the file to load
  150162. * @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.
  150163. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150164. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150165. * @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)
  150166. * @param reserved Internal use only
  150167. */
  150168. constructor(
  150169. /**
  150170. * Defines the name of the task
  150171. */
  150172. name: string,
  150173. /**
  150174. * Defines the location of the file to load
  150175. */
  150176. url: string,
  150177. /**
  150178. * Defines the desired size (the more it increases the longer the generation will be)
  150179. */
  150180. size: number,
  150181. /**
  150182. * Defines if mipmaps should not be generated (default is false)
  150183. */
  150184. noMipmap?: boolean,
  150185. /**
  150186. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150187. */
  150188. generateHarmonics?: boolean,
  150189. /**
  150190. * 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)
  150191. */
  150192. gammaSpace?: boolean,
  150193. /**
  150194. * Internal Use Only
  150195. */
  150196. reserved?: boolean);
  150197. /**
  150198. * Execute the current task
  150199. * @param scene defines the scene where you want your assets to be loaded
  150200. * @param onSuccess is a callback called when the task is successfully executed
  150201. * @param onError is a callback called if an error occurs
  150202. */
  150203. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150204. }
  150205. /**
  150206. * Define a task used by AssetsManager to load Equirectangular cube textures
  150207. */
  150208. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  150209. /**
  150210. * Defines the name of the task
  150211. */
  150212. name: string;
  150213. /**
  150214. * Defines the location of the file to load
  150215. */
  150216. url: string;
  150217. /**
  150218. * Defines the desired size (the more it increases the longer the generation will be)
  150219. */
  150220. size: number;
  150221. /**
  150222. * Defines if mipmaps should not be generated (default is false)
  150223. */
  150224. noMipmap: boolean;
  150225. /**
  150226. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150227. * but the standard material would require them in Gamma space) (default is true)
  150228. */
  150229. gammaSpace: boolean;
  150230. /**
  150231. * Gets the loaded texture
  150232. */
  150233. texture: EquiRectangularCubeTexture;
  150234. /**
  150235. * Callback called when the task is successful
  150236. */
  150237. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  150238. /**
  150239. * Callback called when the task is successful
  150240. */
  150241. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  150242. /**
  150243. * Creates a new EquiRectangularCubeTextureAssetTask object
  150244. * @param name defines the name of the task
  150245. * @param url defines the location of the file to load
  150246. * @param size defines the desired size (the more it increases the longer the generation will be)
  150247. * If the size is omitted this implies you are using a preprocessed cubemap.
  150248. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150249. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  150250. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  150251. * (default is true)
  150252. */
  150253. constructor(
  150254. /**
  150255. * Defines the name of the task
  150256. */
  150257. name: string,
  150258. /**
  150259. * Defines the location of the file to load
  150260. */
  150261. url: string,
  150262. /**
  150263. * Defines the desired size (the more it increases the longer the generation will be)
  150264. */
  150265. size: number,
  150266. /**
  150267. * Defines if mipmaps should not be generated (default is false)
  150268. */
  150269. noMipmap?: boolean,
  150270. /**
  150271. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150272. * but the standard material would require them in Gamma space) (default is true)
  150273. */
  150274. gammaSpace?: boolean);
  150275. /**
  150276. * Execute the current task
  150277. * @param scene defines the scene where you want your assets to be loaded
  150278. * @param onSuccess is a callback called when the task is successfully executed
  150279. * @param onError is a callback called if an error occurs
  150280. */
  150281. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150282. }
  150283. /**
  150284. * This class can be used to easily import assets into a scene
  150285. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  150286. */
  150287. export class AssetsManager {
  150288. private _scene;
  150289. private _isLoading;
  150290. protected _tasks: AbstractAssetTask[];
  150291. protected _waitingTasksCount: number;
  150292. protected _totalTasksCount: number;
  150293. /**
  150294. * Callback called when all tasks are processed
  150295. */
  150296. onFinish: (tasks: AbstractAssetTask[]) => void;
  150297. /**
  150298. * Callback called when a task is successful
  150299. */
  150300. onTaskSuccess: (task: AbstractAssetTask) => void;
  150301. /**
  150302. * Callback called when a task had an error
  150303. */
  150304. onTaskError: (task: AbstractAssetTask) => void;
  150305. /**
  150306. * Callback called when a task is done (whatever the result is)
  150307. */
  150308. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  150309. /**
  150310. * Observable called when all tasks are processed
  150311. */
  150312. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  150313. /**
  150314. * Observable called when a task had an error
  150315. */
  150316. onTaskErrorObservable: Observable<AbstractAssetTask>;
  150317. /**
  150318. * Observable called when all tasks were executed
  150319. */
  150320. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  150321. /**
  150322. * Observable called when a task is done (whatever the result is)
  150323. */
  150324. onProgressObservable: Observable<IAssetsProgressEvent>;
  150325. /**
  150326. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  150327. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  150328. */
  150329. useDefaultLoadingScreen: boolean;
  150330. /**
  150331. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  150332. * when all assets have been downloaded.
  150333. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  150334. */
  150335. autoHideLoadingUI: boolean;
  150336. /**
  150337. * Creates a new AssetsManager
  150338. * @param scene defines the scene to work on
  150339. */
  150340. constructor(scene: Scene);
  150341. /**
  150342. * Add a MeshAssetTask to the list of active tasks
  150343. * @param taskName defines the name of the new task
  150344. * @param meshesNames defines the name of meshes to load
  150345. * @param rootUrl defines the root url to use to locate files
  150346. * @param sceneFilename defines the filename of the scene file
  150347. * @returns a new MeshAssetTask object
  150348. */
  150349. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  150350. /**
  150351. * Add a TextFileAssetTask to the list of active tasks
  150352. * @param taskName defines the name of the new task
  150353. * @param url defines the url of the file to load
  150354. * @returns a new TextFileAssetTask object
  150355. */
  150356. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  150357. /**
  150358. * Add a BinaryFileAssetTask to the list of active tasks
  150359. * @param taskName defines the name of the new task
  150360. * @param url defines the url of the file to load
  150361. * @returns a new BinaryFileAssetTask object
  150362. */
  150363. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  150364. /**
  150365. * Add a ImageAssetTask to the list of active tasks
  150366. * @param taskName defines the name of the new task
  150367. * @param url defines the url of the file to load
  150368. * @returns a new ImageAssetTask object
  150369. */
  150370. addImageTask(taskName: string, url: string): ImageAssetTask;
  150371. /**
  150372. * Add a TextureAssetTask to the list of active tasks
  150373. * @param taskName defines the name of the new task
  150374. * @param url defines the url of the file to load
  150375. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150376. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  150377. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  150378. * @returns a new TextureAssetTask object
  150379. */
  150380. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  150381. /**
  150382. * Add a CubeTextureAssetTask to the list of active tasks
  150383. * @param taskName defines the name of the new task
  150384. * @param url defines the url of the file to load
  150385. * @param extensions defines the extension to use to load the cube map (can be null)
  150386. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150387. * @param files defines the list of files to load (can be null)
  150388. * @returns a new CubeTextureAssetTask object
  150389. */
  150390. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  150391. /**
  150392. *
  150393. * Add a HDRCubeTextureAssetTask to the list of active tasks
  150394. * @param taskName defines the name of the new task
  150395. * @param url defines the url of the file to load
  150396. * @param size defines the size you want for the cubemap (can be null)
  150397. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150398. * @param generateHarmonics defines if you want to automatically generate (true by default)
  150399. * @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)
  150400. * @param reserved Internal use only
  150401. * @returns a new HDRCubeTextureAssetTask object
  150402. */
  150403. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  150404. /**
  150405. *
  150406. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  150407. * @param taskName defines the name of the new task
  150408. * @param url defines the url of the file to load
  150409. * @param size defines the size you want for the cubemap (can be null)
  150410. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150411. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  150412. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  150413. * @returns a new EquiRectangularCubeTextureAssetTask object
  150414. */
  150415. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  150416. /**
  150417. * Remove a task from the assets manager.
  150418. * @param task the task to remove
  150419. */
  150420. removeTask(task: AbstractAssetTask): void;
  150421. private _decreaseWaitingTasksCount;
  150422. private _runTask;
  150423. /**
  150424. * Reset the AssetsManager and remove all tasks
  150425. * @return the current instance of the AssetsManager
  150426. */
  150427. reset(): AssetsManager;
  150428. /**
  150429. * Start the loading process
  150430. * @return the current instance of the AssetsManager
  150431. */
  150432. load(): AssetsManager;
  150433. /**
  150434. * Start the loading process as an async operation
  150435. * @return a promise returning the list of failed tasks
  150436. */
  150437. loadAsync(): Promise<void>;
  150438. }
  150439. }
  150440. declare module BABYLON {
  150441. /**
  150442. * Wrapper class for promise with external resolve and reject.
  150443. */
  150444. export class Deferred<T> {
  150445. /**
  150446. * The promise associated with this deferred object.
  150447. */
  150448. readonly promise: Promise<T>;
  150449. private _resolve;
  150450. private _reject;
  150451. /**
  150452. * The resolve method of the promise associated with this deferred object.
  150453. */
  150454. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  150455. /**
  150456. * The reject method of the promise associated with this deferred object.
  150457. */
  150458. get reject(): (reason?: any) => void;
  150459. /**
  150460. * Constructor for this deferred object.
  150461. */
  150462. constructor();
  150463. }
  150464. }
  150465. declare module BABYLON {
  150466. /**
  150467. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  150468. */
  150469. export class MeshExploder {
  150470. private _centerMesh;
  150471. private _meshes;
  150472. private _meshesOrigins;
  150473. private _toCenterVectors;
  150474. private _scaledDirection;
  150475. private _newPosition;
  150476. private _centerPosition;
  150477. /**
  150478. * Explodes meshes from a center mesh.
  150479. * @param meshes The meshes to explode.
  150480. * @param centerMesh The mesh to be center of explosion.
  150481. */
  150482. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  150483. private _setCenterMesh;
  150484. /**
  150485. * Get class name
  150486. * @returns "MeshExploder"
  150487. */
  150488. getClassName(): string;
  150489. /**
  150490. * "Exploded meshes"
  150491. * @returns Array of meshes with the centerMesh at index 0.
  150492. */
  150493. getMeshes(): Array<Mesh>;
  150494. /**
  150495. * Explodes meshes giving a specific direction
  150496. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  150497. */
  150498. explode(direction?: number): void;
  150499. }
  150500. }
  150501. declare module BABYLON {
  150502. /**
  150503. * Class used to help managing file picking and drag'n'drop
  150504. */
  150505. export class FilesInput {
  150506. /**
  150507. * List of files ready to be loaded
  150508. */
  150509. static get FilesToLoad(): {
  150510. [key: string]: File;
  150511. };
  150512. /**
  150513. * Callback called when a file is processed
  150514. */
  150515. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  150516. private _engine;
  150517. private _currentScene;
  150518. private _sceneLoadedCallback;
  150519. private _progressCallback;
  150520. private _additionalRenderLoopLogicCallback;
  150521. private _textureLoadingCallback;
  150522. private _startingProcessingFilesCallback;
  150523. private _onReloadCallback;
  150524. private _errorCallback;
  150525. private _elementToMonitor;
  150526. private _sceneFileToLoad;
  150527. private _filesToLoad;
  150528. /**
  150529. * Creates a new FilesInput
  150530. * @param engine defines the rendering engine
  150531. * @param scene defines the hosting scene
  150532. * @param sceneLoadedCallback callback called when scene is loaded
  150533. * @param progressCallback callback called to track progress
  150534. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  150535. * @param textureLoadingCallback callback called when a texture is loading
  150536. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  150537. * @param onReloadCallback callback called when a reload is requested
  150538. * @param errorCallback callback call if an error occurs
  150539. */
  150540. 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>);
  150541. private _dragEnterHandler;
  150542. private _dragOverHandler;
  150543. private _dropHandler;
  150544. /**
  150545. * Calls this function to listen to drag'n'drop events on a specific DOM element
  150546. * @param elementToMonitor defines the DOM element to track
  150547. */
  150548. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  150549. /** Gets the current list of files to load */
  150550. get filesToLoad(): File[];
  150551. /**
  150552. * Release all associated resources
  150553. */
  150554. dispose(): void;
  150555. private renderFunction;
  150556. private drag;
  150557. private drop;
  150558. private _traverseFolder;
  150559. private _processFiles;
  150560. /**
  150561. * Load files from a drop event
  150562. * @param event defines the drop event to use as source
  150563. */
  150564. loadFiles(event: any): void;
  150565. private _processReload;
  150566. /**
  150567. * Reload the current scene from the loaded files
  150568. */
  150569. reload(): void;
  150570. }
  150571. }
  150572. declare module BABYLON {
  150573. /**
  150574. * Defines the root class used to create scene optimization to use with SceneOptimizer
  150575. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150576. */
  150577. export class SceneOptimization {
  150578. /**
  150579. * Defines the priority of this optimization (0 by default which means first in the list)
  150580. */
  150581. priority: number;
  150582. /**
  150583. * Gets a string describing the action executed by the current optimization
  150584. * @returns description string
  150585. */
  150586. getDescription(): string;
  150587. /**
  150588. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150589. * @param scene defines the current scene where to apply this optimization
  150590. * @param optimizer defines the current optimizer
  150591. * @returns true if everything that can be done was applied
  150592. */
  150593. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150594. /**
  150595. * Creates the SceneOptimization object
  150596. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150597. * @param desc defines the description associated with the optimization
  150598. */
  150599. constructor(
  150600. /**
  150601. * Defines the priority of this optimization (0 by default which means first in the list)
  150602. */
  150603. priority?: number);
  150604. }
  150605. /**
  150606. * Defines an optimization used to reduce the size of render target textures
  150607. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150608. */
  150609. export class TextureOptimization extends SceneOptimization {
  150610. /**
  150611. * Defines the priority of this optimization (0 by default which means first in the list)
  150612. */
  150613. priority: number;
  150614. /**
  150615. * 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
  150616. */
  150617. maximumSize: number;
  150618. /**
  150619. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150620. */
  150621. step: number;
  150622. /**
  150623. * Gets a string describing the action executed by the current optimization
  150624. * @returns description string
  150625. */
  150626. getDescription(): string;
  150627. /**
  150628. * Creates the TextureOptimization object
  150629. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150630. * @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
  150631. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150632. */
  150633. constructor(
  150634. /**
  150635. * Defines the priority of this optimization (0 by default which means first in the list)
  150636. */
  150637. priority?: number,
  150638. /**
  150639. * 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
  150640. */
  150641. maximumSize?: number,
  150642. /**
  150643. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150644. */
  150645. step?: number);
  150646. /**
  150647. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150648. * @param scene defines the current scene where to apply this optimization
  150649. * @param optimizer defines the current optimizer
  150650. * @returns true if everything that can be done was applied
  150651. */
  150652. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150653. }
  150654. /**
  150655. * Defines an optimization used to increase or decrease the rendering resolution
  150656. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150657. */
  150658. export class HardwareScalingOptimization extends SceneOptimization {
  150659. /**
  150660. * Defines the priority of this optimization (0 by default which means first in the list)
  150661. */
  150662. priority: number;
  150663. /**
  150664. * Defines the maximum scale to use (2 by default)
  150665. */
  150666. maximumScale: number;
  150667. /**
  150668. * Defines the step to use between two passes (0.5 by default)
  150669. */
  150670. step: number;
  150671. private _currentScale;
  150672. private _directionOffset;
  150673. /**
  150674. * Gets a string describing the action executed by the current optimization
  150675. * @return description string
  150676. */
  150677. getDescription(): string;
  150678. /**
  150679. * Creates the HardwareScalingOptimization object
  150680. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150681. * @param maximumScale defines the maximum scale to use (2 by default)
  150682. * @param step defines the step to use between two passes (0.5 by default)
  150683. */
  150684. constructor(
  150685. /**
  150686. * Defines the priority of this optimization (0 by default which means first in the list)
  150687. */
  150688. priority?: number,
  150689. /**
  150690. * Defines the maximum scale to use (2 by default)
  150691. */
  150692. maximumScale?: number,
  150693. /**
  150694. * Defines the step to use between two passes (0.5 by default)
  150695. */
  150696. step?: number);
  150697. /**
  150698. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150699. * @param scene defines the current scene where to apply this optimization
  150700. * @param optimizer defines the current optimizer
  150701. * @returns true if everything that can be done was applied
  150702. */
  150703. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150704. }
  150705. /**
  150706. * Defines an optimization used to remove shadows
  150707. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150708. */
  150709. export class ShadowsOptimization extends SceneOptimization {
  150710. /**
  150711. * Gets a string describing the action executed by the current optimization
  150712. * @return description string
  150713. */
  150714. getDescription(): string;
  150715. /**
  150716. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150717. * @param scene defines the current scene where to apply this optimization
  150718. * @param optimizer defines the current optimizer
  150719. * @returns true if everything that can be done was applied
  150720. */
  150721. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150722. }
  150723. /**
  150724. * Defines an optimization used to turn post-processes off
  150725. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150726. */
  150727. export class PostProcessesOptimization extends SceneOptimization {
  150728. /**
  150729. * Gets a string describing the action executed by the current optimization
  150730. * @return description string
  150731. */
  150732. getDescription(): string;
  150733. /**
  150734. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150735. * @param scene defines the current scene where to apply this optimization
  150736. * @param optimizer defines the current optimizer
  150737. * @returns true if everything that can be done was applied
  150738. */
  150739. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150740. }
  150741. /**
  150742. * Defines an optimization used to turn lens flares off
  150743. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150744. */
  150745. export class LensFlaresOptimization extends SceneOptimization {
  150746. /**
  150747. * Gets a string describing the action executed by the current optimization
  150748. * @return description string
  150749. */
  150750. getDescription(): string;
  150751. /**
  150752. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150753. * @param scene defines the current scene where to apply this optimization
  150754. * @param optimizer defines the current optimizer
  150755. * @returns true if everything that can be done was applied
  150756. */
  150757. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150758. }
  150759. /**
  150760. * Defines an optimization based on user defined callback.
  150761. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150762. */
  150763. export class CustomOptimization extends SceneOptimization {
  150764. /**
  150765. * Callback called to apply the custom optimization.
  150766. */
  150767. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  150768. /**
  150769. * Callback called to get custom description
  150770. */
  150771. onGetDescription: () => string;
  150772. /**
  150773. * Gets a string describing the action executed by the current optimization
  150774. * @returns description string
  150775. */
  150776. getDescription(): string;
  150777. /**
  150778. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150779. * @param scene defines the current scene where to apply this optimization
  150780. * @param optimizer defines the current optimizer
  150781. * @returns true if everything that can be done was applied
  150782. */
  150783. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150784. }
  150785. /**
  150786. * Defines an optimization used to turn particles off
  150787. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150788. */
  150789. export class ParticlesOptimization extends SceneOptimization {
  150790. /**
  150791. * Gets a string describing the action executed by the current optimization
  150792. * @return description string
  150793. */
  150794. getDescription(): string;
  150795. /**
  150796. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150797. * @param scene defines the current scene where to apply this optimization
  150798. * @param optimizer defines the current optimizer
  150799. * @returns true if everything that can be done was applied
  150800. */
  150801. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150802. }
  150803. /**
  150804. * Defines an optimization used to turn render targets off
  150805. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150806. */
  150807. export class RenderTargetsOptimization extends SceneOptimization {
  150808. /**
  150809. * Gets a string describing the action executed by the current optimization
  150810. * @return description string
  150811. */
  150812. getDescription(): string;
  150813. /**
  150814. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150815. * @param scene defines the current scene where to apply this optimization
  150816. * @param optimizer defines the current optimizer
  150817. * @returns true if everything that can be done was applied
  150818. */
  150819. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150820. }
  150821. /**
  150822. * Defines an optimization used to merge meshes with compatible materials
  150823. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150824. */
  150825. export class MergeMeshesOptimization extends SceneOptimization {
  150826. private static _UpdateSelectionTree;
  150827. /**
  150828. * Gets or sets a boolean which defines if optimization octree has to be updated
  150829. */
  150830. static get UpdateSelectionTree(): boolean;
  150831. /**
  150832. * Gets or sets a boolean which defines if optimization octree has to be updated
  150833. */
  150834. static set UpdateSelectionTree(value: boolean);
  150835. /**
  150836. * Gets a string describing the action executed by the current optimization
  150837. * @return description string
  150838. */
  150839. getDescription(): string;
  150840. private _canBeMerged;
  150841. /**
  150842. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150843. * @param scene defines the current scene where to apply this optimization
  150844. * @param optimizer defines the current optimizer
  150845. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  150846. * @returns true if everything that can be done was applied
  150847. */
  150848. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  150849. }
  150850. /**
  150851. * Defines a list of options used by SceneOptimizer
  150852. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150853. */
  150854. export class SceneOptimizerOptions {
  150855. /**
  150856. * Defines the target frame rate to reach (60 by default)
  150857. */
  150858. targetFrameRate: number;
  150859. /**
  150860. * Defines the interval between two checkes (2000ms by default)
  150861. */
  150862. trackerDuration: number;
  150863. /**
  150864. * Gets the list of optimizations to apply
  150865. */
  150866. optimizations: SceneOptimization[];
  150867. /**
  150868. * Creates a new list of options used by SceneOptimizer
  150869. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  150870. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  150871. */
  150872. constructor(
  150873. /**
  150874. * Defines the target frame rate to reach (60 by default)
  150875. */
  150876. targetFrameRate?: number,
  150877. /**
  150878. * Defines the interval between two checkes (2000ms by default)
  150879. */
  150880. trackerDuration?: number);
  150881. /**
  150882. * Add a new optimization
  150883. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  150884. * @returns the current SceneOptimizerOptions
  150885. */
  150886. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  150887. /**
  150888. * Add a new custom optimization
  150889. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  150890. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  150891. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150892. * @returns the current SceneOptimizerOptions
  150893. */
  150894. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  150895. /**
  150896. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  150897. * @param targetFrameRate defines the target frame rate (60 by default)
  150898. * @returns a SceneOptimizerOptions object
  150899. */
  150900. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150901. /**
  150902. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  150903. * @param targetFrameRate defines the target frame rate (60 by default)
  150904. * @returns a SceneOptimizerOptions object
  150905. */
  150906. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150907. /**
  150908. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  150909. * @param targetFrameRate defines the target frame rate (60 by default)
  150910. * @returns a SceneOptimizerOptions object
  150911. */
  150912. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150913. }
  150914. /**
  150915. * Class used to run optimizations in order to reach a target frame rate
  150916. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150917. */
  150918. export class SceneOptimizer implements IDisposable {
  150919. private _isRunning;
  150920. private _options;
  150921. private _scene;
  150922. private _currentPriorityLevel;
  150923. private _targetFrameRate;
  150924. private _trackerDuration;
  150925. private _currentFrameRate;
  150926. private _sceneDisposeObserver;
  150927. private _improvementMode;
  150928. /**
  150929. * Defines an observable called when the optimizer reaches the target frame rate
  150930. */
  150931. onSuccessObservable: Observable<SceneOptimizer>;
  150932. /**
  150933. * Defines an observable called when the optimizer enables an optimization
  150934. */
  150935. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  150936. /**
  150937. * Defines an observable called when the optimizer is not able to reach the target frame rate
  150938. */
  150939. onFailureObservable: Observable<SceneOptimizer>;
  150940. /**
  150941. * Gets a boolean indicating if the optimizer is in improvement mode
  150942. */
  150943. get isInImprovementMode(): boolean;
  150944. /**
  150945. * Gets the current priority level (0 at start)
  150946. */
  150947. get currentPriorityLevel(): number;
  150948. /**
  150949. * Gets the current frame rate checked by the SceneOptimizer
  150950. */
  150951. get currentFrameRate(): number;
  150952. /**
  150953. * Gets or sets the current target frame rate (60 by default)
  150954. */
  150955. get targetFrameRate(): number;
  150956. /**
  150957. * Gets or sets the current target frame rate (60 by default)
  150958. */
  150959. set targetFrameRate(value: number);
  150960. /**
  150961. * Gets or sets the current interval between two checks (every 2000ms by default)
  150962. */
  150963. get trackerDuration(): number;
  150964. /**
  150965. * Gets or sets the current interval between two checks (every 2000ms by default)
  150966. */
  150967. set trackerDuration(value: number);
  150968. /**
  150969. * Gets the list of active optimizations
  150970. */
  150971. get optimizations(): SceneOptimization[];
  150972. /**
  150973. * Creates a new SceneOptimizer
  150974. * @param scene defines the scene to work on
  150975. * @param options defines the options to use with the SceneOptimizer
  150976. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  150977. * @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)
  150978. */
  150979. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  150980. /**
  150981. * Stops the current optimizer
  150982. */
  150983. stop(): void;
  150984. /**
  150985. * Reset the optimizer to initial step (current priority level = 0)
  150986. */
  150987. reset(): void;
  150988. /**
  150989. * Start the optimizer. By default it will try to reach a specific framerate
  150990. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  150991. */
  150992. start(): void;
  150993. private _checkCurrentState;
  150994. /**
  150995. * Release all resources
  150996. */
  150997. dispose(): void;
  150998. /**
  150999. * Helper function to create a SceneOptimizer with one single line of code
  151000. * @param scene defines the scene to work on
  151001. * @param options defines the options to use with the SceneOptimizer
  151002. * @param onSuccess defines a callback to call on success
  151003. * @param onFailure defines a callback to call on failure
  151004. * @returns the new SceneOptimizer object
  151005. */
  151006. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  151007. }
  151008. }
  151009. declare module BABYLON {
  151010. /**
  151011. * Class used to serialize a scene into a string
  151012. */
  151013. export class SceneSerializer {
  151014. /**
  151015. * Clear cache used by a previous serialization
  151016. */
  151017. static ClearCache(): void;
  151018. /**
  151019. * Serialize a scene into a JSON compatible object
  151020. * @param scene defines the scene to serialize
  151021. * @returns a JSON compatible object
  151022. */
  151023. static Serialize(scene: Scene): any;
  151024. /**
  151025. * Serialize a mesh into a JSON compatible object
  151026. * @param toSerialize defines the mesh to serialize
  151027. * @param withParents defines if parents must be serialized as well
  151028. * @param withChildren defines if children must be serialized as well
  151029. * @returns a JSON compatible object
  151030. */
  151031. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  151032. }
  151033. }
  151034. declare module BABYLON {
  151035. /**
  151036. * Class used to host texture specific utilities
  151037. */
  151038. export class TextureTools {
  151039. /**
  151040. * Uses the GPU to create a copy texture rescaled at a given size
  151041. * @param texture Texture to copy from
  151042. * @param width defines the desired width
  151043. * @param height defines the desired height
  151044. * @param useBilinearMode defines if bilinear mode has to be used
  151045. * @return the generated texture
  151046. */
  151047. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  151048. }
  151049. }
  151050. declare module BABYLON {
  151051. /**
  151052. * This represents the different options available for the video capture.
  151053. */
  151054. export interface VideoRecorderOptions {
  151055. /** Defines the mime type of the video. */
  151056. mimeType: string;
  151057. /** Defines the FPS the video should be recorded at. */
  151058. fps: number;
  151059. /** Defines the chunk size for the recording data. */
  151060. recordChunckSize: number;
  151061. /** The audio tracks to attach to the recording. */
  151062. audioTracks?: MediaStreamTrack[];
  151063. }
  151064. /**
  151065. * This can help with recording videos from BabylonJS.
  151066. * This is based on the available WebRTC functionalities of the browser.
  151067. *
  151068. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  151069. */
  151070. export class VideoRecorder {
  151071. private static readonly _defaultOptions;
  151072. /**
  151073. * Returns whether or not the VideoRecorder is available in your browser.
  151074. * @param engine Defines the Babylon Engine.
  151075. * @returns true if supported otherwise false.
  151076. */
  151077. static IsSupported(engine: Engine): boolean;
  151078. private readonly _options;
  151079. private _canvas;
  151080. private _mediaRecorder;
  151081. private _recordedChunks;
  151082. private _fileName;
  151083. private _resolve;
  151084. private _reject;
  151085. /**
  151086. * True when a recording is already in progress.
  151087. */
  151088. get isRecording(): boolean;
  151089. /**
  151090. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  151091. * @param engine Defines the BabylonJS Engine you wish to record.
  151092. * @param options Defines options that can be used to customize the capture.
  151093. */
  151094. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  151095. /**
  151096. * Stops the current recording before the default capture timeout passed in the startRecording function.
  151097. */
  151098. stopRecording(): void;
  151099. /**
  151100. * Starts recording the canvas for a max duration specified in parameters.
  151101. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  151102. * If null no automatic download will start and you can rely on the promise to get the data back.
  151103. * @param maxDuration Defines the maximum recording time in seconds.
  151104. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  151105. * @return A promise callback at the end of the recording with the video data in Blob.
  151106. */
  151107. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  151108. /**
  151109. * Releases internal resources used during the recording.
  151110. */
  151111. dispose(): void;
  151112. private _handleDataAvailable;
  151113. private _handleError;
  151114. private _handleStop;
  151115. }
  151116. }
  151117. declare module BABYLON {
  151118. /**
  151119. * Class containing a set of static utilities functions for screenshots
  151120. */
  151121. export class ScreenshotTools {
  151122. /**
  151123. * Captures a screenshot of the current rendering
  151124. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151125. * @param engine defines the rendering engine
  151126. * @param camera defines the source camera
  151127. * @param size This parameter can be set to a single number or to an object with the
  151128. * following (optional) properties: precision, width, height. If a single number is passed,
  151129. * it will be used for both width and height. If an object is passed, the screenshot size
  151130. * will be derived from the parameters. The precision property is a multiplier allowing
  151131. * rendering at a higher or lower resolution
  151132. * @param successCallback defines the callback receives a single parameter which contains the
  151133. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151134. * src parameter of an <img> to display it
  151135. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151136. * Check your browser for supported MIME types
  151137. */
  151138. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  151139. /**
  151140. * Captures a screenshot of the current rendering
  151141. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151142. * @param engine defines the rendering engine
  151143. * @param camera defines the source camera
  151144. * @param size This parameter can be set to a single number or to an object with the
  151145. * following (optional) properties: precision, width, height. If a single number is passed,
  151146. * it will be used for both width and height. If an object is passed, the screenshot size
  151147. * will be derived from the parameters. The precision property is a multiplier allowing
  151148. * rendering at a higher or lower resolution
  151149. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151150. * Check your browser for supported MIME types
  151151. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151152. * to the src parameter of an <img> to display it
  151153. */
  151154. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  151155. /**
  151156. * Generates an image screenshot from the specified camera.
  151157. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151158. * @param engine The engine to use for rendering
  151159. * @param camera The camera to use for rendering
  151160. * @param size This parameter can be set to a single number or to an object with the
  151161. * following (optional) properties: precision, width, height. If a single number is passed,
  151162. * it will be used for both width and height. If an object is passed, the screenshot size
  151163. * will be derived from the parameters. The precision property is a multiplier allowing
  151164. * rendering at a higher or lower resolution
  151165. * @param successCallback The callback receives a single parameter which contains the
  151166. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151167. * src parameter of an <img> to display it
  151168. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151169. * Check your browser for supported MIME types
  151170. * @param samples Texture samples (default: 1)
  151171. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151172. * @param fileName A name for for the downloaded file.
  151173. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151174. */
  151175. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  151176. /**
  151177. * Generates an image screenshot from the specified camera.
  151178. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151179. * @param engine The engine to use for rendering
  151180. * @param camera The camera to use for rendering
  151181. * @param size This parameter can be set to a single number or to an object with the
  151182. * following (optional) properties: precision, width, height. If a single number is passed,
  151183. * it will be used for both width and height. If an object is passed, the screenshot size
  151184. * will be derived from the parameters. The precision property is a multiplier allowing
  151185. * rendering at a higher or lower resolution
  151186. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151187. * Check your browser for supported MIME types
  151188. * @param samples Texture samples (default: 1)
  151189. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151190. * @param fileName A name for for the downloaded file.
  151191. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151192. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151193. * to the src parameter of an <img> to display it
  151194. */
  151195. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  151196. /**
  151197. * Gets height and width for screenshot size
  151198. * @private
  151199. */
  151200. private static _getScreenshotSize;
  151201. }
  151202. }
  151203. declare module BABYLON {
  151204. /**
  151205. * Interface for a data buffer
  151206. */
  151207. export interface IDataBuffer {
  151208. /**
  151209. * Reads bytes from the data buffer.
  151210. * @param byteOffset The byte offset to read
  151211. * @param byteLength The byte length to read
  151212. * @returns A promise that resolves when the bytes are read
  151213. */
  151214. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  151215. /**
  151216. * The byte length of the buffer.
  151217. */
  151218. readonly byteLength: number;
  151219. }
  151220. /**
  151221. * Utility class for reading from a data buffer
  151222. */
  151223. export class DataReader {
  151224. /**
  151225. * The data buffer associated with this data reader.
  151226. */
  151227. readonly buffer: IDataBuffer;
  151228. /**
  151229. * The current byte offset from the beginning of the data buffer.
  151230. */
  151231. byteOffset: number;
  151232. private _dataView;
  151233. private _dataByteOffset;
  151234. /**
  151235. * Constructor
  151236. * @param buffer The buffer to read
  151237. */
  151238. constructor(buffer: IDataBuffer);
  151239. /**
  151240. * Loads the given byte length.
  151241. * @param byteLength The byte length to load
  151242. * @returns A promise that resolves when the load is complete
  151243. */
  151244. loadAsync(byteLength: number): Promise<void>;
  151245. /**
  151246. * Read a unsigned 32-bit integer from the currently loaded data range.
  151247. * @returns The 32-bit integer read
  151248. */
  151249. readUint32(): number;
  151250. /**
  151251. * Read a byte array from the currently loaded data range.
  151252. * @param byteLength The byte length to read
  151253. * @returns The byte array read
  151254. */
  151255. readUint8Array(byteLength: number): Uint8Array;
  151256. /**
  151257. * Read a string from the currently loaded data range.
  151258. * @param byteLength The byte length to read
  151259. * @returns The string read
  151260. */
  151261. readString(byteLength: number): string;
  151262. /**
  151263. * Skips the given byte length the currently loaded data range.
  151264. * @param byteLength The byte length to skip
  151265. */
  151266. skipBytes(byteLength: number): void;
  151267. }
  151268. }
  151269. declare module BABYLON {
  151270. /**
  151271. * Class for storing data to local storage if available or in-memory storage otherwise
  151272. */
  151273. export class DataStorage {
  151274. private static _Storage;
  151275. private static _GetStorage;
  151276. /**
  151277. * Reads a string from the data storage
  151278. * @param key The key to read
  151279. * @param defaultValue The value if the key doesn't exist
  151280. * @returns The string value
  151281. */
  151282. static ReadString(key: string, defaultValue: string): string;
  151283. /**
  151284. * Writes a string to the data storage
  151285. * @param key The key to write
  151286. * @param value The value to write
  151287. */
  151288. static WriteString(key: string, value: string): void;
  151289. /**
  151290. * Reads a boolean from the data storage
  151291. * @param key The key to read
  151292. * @param defaultValue The value if the key doesn't exist
  151293. * @returns The boolean value
  151294. */
  151295. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  151296. /**
  151297. * Writes a boolean to the data storage
  151298. * @param key The key to write
  151299. * @param value The value to write
  151300. */
  151301. static WriteBoolean(key: string, value: boolean): void;
  151302. /**
  151303. * Reads a number from the data storage
  151304. * @param key The key to read
  151305. * @param defaultValue The value if the key doesn't exist
  151306. * @returns The number value
  151307. */
  151308. static ReadNumber(key: string, defaultValue: number): number;
  151309. /**
  151310. * Writes a number to the data storage
  151311. * @param key The key to write
  151312. * @param value The value to write
  151313. */
  151314. static WriteNumber(key: string, value: number): void;
  151315. }
  151316. }
  151317. declare module BABYLON {
  151318. /**
  151319. * An interface for all Hit test features
  151320. */
  151321. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  151322. /**
  151323. * Triggered when new babylon (transformed) hit test results are available
  151324. */
  151325. onHitTestResultObservable: Observable<T[]>;
  151326. }
  151327. /**
  151328. * Options used for hit testing
  151329. */
  151330. export interface IWebXRLegacyHitTestOptions {
  151331. /**
  151332. * Only test when user interacted with the scene. Default - hit test every frame
  151333. */
  151334. testOnPointerDownOnly?: boolean;
  151335. /**
  151336. * The node to use to transform the local results to world coordinates
  151337. */
  151338. worldParentNode?: TransformNode;
  151339. }
  151340. /**
  151341. * Interface defining the babylon result of raycasting/hit-test
  151342. */
  151343. export interface IWebXRLegacyHitResult {
  151344. /**
  151345. * Transformation matrix that can be applied to a node that will put it in the hit point location
  151346. */
  151347. transformationMatrix: Matrix;
  151348. /**
  151349. * The native hit test result
  151350. */
  151351. xrHitResult: XRHitResult | XRHitTestResult;
  151352. }
  151353. /**
  151354. * The currently-working hit-test module.
  151355. * Hit test (or Ray-casting) is used to interact with the real world.
  151356. * For further information read here - https://github.com/immersive-web/hit-test
  151357. */
  151358. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  151359. /**
  151360. * options to use when constructing this feature
  151361. */
  151362. readonly options: IWebXRLegacyHitTestOptions;
  151363. private _direction;
  151364. private _mat;
  151365. private _onSelectEnabled;
  151366. private _origin;
  151367. /**
  151368. * The module's name
  151369. */
  151370. static readonly Name: string;
  151371. /**
  151372. * The (Babylon) version of this module.
  151373. * This is an integer representing the implementation version.
  151374. * This number does not correspond to the WebXR specs version
  151375. */
  151376. static readonly Version: number;
  151377. /**
  151378. * Populated with the last native XR Hit Results
  151379. */
  151380. lastNativeXRHitResults: XRHitResult[];
  151381. /**
  151382. * Triggered when new babylon (transformed) hit test results are available
  151383. */
  151384. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  151385. /**
  151386. * Creates a new instance of the (legacy version) hit test feature
  151387. * @param _xrSessionManager an instance of WebXRSessionManager
  151388. * @param options options to use when constructing this feature
  151389. */
  151390. constructor(_xrSessionManager: WebXRSessionManager,
  151391. /**
  151392. * options to use when constructing this feature
  151393. */
  151394. options?: IWebXRLegacyHitTestOptions);
  151395. /**
  151396. * execute a hit test with an XR Ray
  151397. *
  151398. * @param xrSession a native xrSession that will execute this hit test
  151399. * @param xrRay the ray (position and direction) to use for ray-casting
  151400. * @param referenceSpace native XR reference space to use for the hit-test
  151401. * @param filter filter function that will filter the results
  151402. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  151403. */
  151404. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  151405. /**
  151406. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  151407. * @param event the (select) event to use to select with
  151408. * @param referenceSpace the reference space to use for this hit test
  151409. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  151410. */
  151411. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  151412. /**
  151413. * attach this feature
  151414. * Will usually be called by the features manager
  151415. *
  151416. * @returns true if successful.
  151417. */
  151418. attach(): boolean;
  151419. /**
  151420. * detach this feature.
  151421. * Will usually be called by the features manager
  151422. *
  151423. * @returns true if successful.
  151424. */
  151425. detach(): boolean;
  151426. /**
  151427. * Dispose this feature and all of the resources attached
  151428. */
  151429. dispose(): void;
  151430. protected _onXRFrame(frame: XRFrame): void;
  151431. private _onHitTestResults;
  151432. private _onSelect;
  151433. }
  151434. }
  151435. declare module BABYLON {
  151436. /**
  151437. * Options used for hit testing (version 2)
  151438. */
  151439. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  151440. /**
  151441. * Do not create a permanent hit test. Will usually be used when only
  151442. * transient inputs are needed.
  151443. */
  151444. disablePermanentHitTest?: boolean;
  151445. /**
  151446. * Enable transient (for example touch-based) hit test inspections
  151447. */
  151448. enableTransientHitTest?: boolean;
  151449. /**
  151450. * Offset ray for the permanent hit test
  151451. */
  151452. offsetRay?: Vector3;
  151453. /**
  151454. * Offset ray for the transient hit test
  151455. */
  151456. transientOffsetRay?: Vector3;
  151457. /**
  151458. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  151459. */
  151460. useReferenceSpace?: boolean;
  151461. }
  151462. /**
  151463. * Interface defining the babylon result of hit-test
  151464. */
  151465. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  151466. /**
  151467. * The input source that generated this hit test (if transient)
  151468. */
  151469. inputSource?: XRInputSource;
  151470. /**
  151471. * Is this a transient hit test
  151472. */
  151473. isTransient?: boolean;
  151474. /**
  151475. * Position of the hit test result
  151476. */
  151477. position: Vector3;
  151478. /**
  151479. * Rotation of the hit test result
  151480. */
  151481. rotationQuaternion: Quaternion;
  151482. /**
  151483. * The native hit test result
  151484. */
  151485. xrHitResult: XRHitTestResult;
  151486. }
  151487. /**
  151488. * The currently-working hit-test module.
  151489. * Hit test (or Ray-casting) is used to interact with the real world.
  151490. * For further information read here - https://github.com/immersive-web/hit-test
  151491. *
  151492. * Tested on chrome (mobile) 80.
  151493. */
  151494. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  151495. /**
  151496. * options to use when constructing this feature
  151497. */
  151498. readonly options: IWebXRHitTestOptions;
  151499. private _tmpMat;
  151500. private _tmpPos;
  151501. private _tmpQuat;
  151502. private _transientXrHitTestSource;
  151503. private _xrHitTestSource;
  151504. private initHitTestSource;
  151505. /**
  151506. * The module's name
  151507. */
  151508. static readonly Name: string;
  151509. /**
  151510. * The (Babylon) version of this module.
  151511. * This is an integer representing the implementation version.
  151512. * This number does not correspond to the WebXR specs version
  151513. */
  151514. static readonly Version: number;
  151515. /**
  151516. * When set to true, each hit test will have its own position/rotation objects
  151517. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  151518. * the developers will clone them or copy them as they see fit.
  151519. */
  151520. autoCloneTransformation: boolean;
  151521. /**
  151522. * Triggered when new babylon (transformed) hit test results are available
  151523. */
  151524. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  151525. /**
  151526. * Use this to temporarily pause hit test checks.
  151527. */
  151528. paused: boolean;
  151529. /**
  151530. * Creates a new instance of the hit test feature
  151531. * @param _xrSessionManager an instance of WebXRSessionManager
  151532. * @param options options to use when constructing this feature
  151533. */
  151534. constructor(_xrSessionManager: WebXRSessionManager,
  151535. /**
  151536. * options to use when constructing this feature
  151537. */
  151538. options?: IWebXRHitTestOptions);
  151539. /**
  151540. * attach this feature
  151541. * Will usually be called by the features manager
  151542. *
  151543. * @returns true if successful.
  151544. */
  151545. attach(): boolean;
  151546. /**
  151547. * detach this feature.
  151548. * Will usually be called by the features manager
  151549. *
  151550. * @returns true if successful.
  151551. */
  151552. detach(): boolean;
  151553. /**
  151554. * Dispose this feature and all of the resources attached
  151555. */
  151556. dispose(): void;
  151557. protected _onXRFrame(frame: XRFrame): void;
  151558. private _processWebXRHitTestResult;
  151559. }
  151560. }
  151561. declare module BABYLON {
  151562. /**
  151563. * Configuration options of the anchor system
  151564. */
  151565. export interface IWebXRAnchorSystemOptions {
  151566. /**
  151567. * a node that will be used to convert local to world coordinates
  151568. */
  151569. worldParentNode?: TransformNode;
  151570. /**
  151571. * If set to true a reference of the created anchors will be kept until the next session starts
  151572. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  151573. */
  151574. doNotRemoveAnchorsOnSessionEnded?: boolean;
  151575. }
  151576. /**
  151577. * A babylon container for an XR Anchor
  151578. */
  151579. export interface IWebXRAnchor {
  151580. /**
  151581. * A babylon-assigned ID for this anchor
  151582. */
  151583. id: number;
  151584. /**
  151585. * Transformation matrix to apply to an object attached to this anchor
  151586. */
  151587. transformationMatrix: Matrix;
  151588. /**
  151589. * The native anchor object
  151590. */
  151591. xrAnchor: XRAnchor;
  151592. /**
  151593. * if defined, this object will be constantly updated by the anchor's position and rotation
  151594. */
  151595. attachedNode?: TransformNode;
  151596. }
  151597. /**
  151598. * An implementation of the anchor system for WebXR.
  151599. * For further information see https://github.com/immersive-web/anchors/
  151600. */
  151601. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  151602. private _options;
  151603. private _lastFrameDetected;
  151604. private _trackedAnchors;
  151605. private _referenceSpaceForFrameAnchors;
  151606. private _futureAnchors;
  151607. /**
  151608. * The module's name
  151609. */
  151610. static readonly Name: string;
  151611. /**
  151612. * The (Babylon) version of this module.
  151613. * This is an integer representing the implementation version.
  151614. * This number does not correspond to the WebXR specs version
  151615. */
  151616. static readonly Version: number;
  151617. /**
  151618. * Observers registered here will be executed when a new anchor was added to the session
  151619. */
  151620. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  151621. /**
  151622. * Observers registered here will be executed when an anchor was removed from the session
  151623. */
  151624. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  151625. /**
  151626. * Observers registered here will be executed when an existing anchor updates
  151627. * This can execute N times every frame
  151628. */
  151629. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  151630. /**
  151631. * Set the reference space to use for anchor creation, when not using a hit test.
  151632. * Will default to the session's reference space if not defined
  151633. */
  151634. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  151635. /**
  151636. * constructs a new anchor system
  151637. * @param _xrSessionManager an instance of WebXRSessionManager
  151638. * @param _options configuration object for this feature
  151639. */
  151640. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  151641. private _tmpVector;
  151642. private _tmpQuaternion;
  151643. private _populateTmpTransformation;
  151644. /**
  151645. * Create a new anchor point using a hit test result at a specific point in the scene
  151646. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  151647. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  151648. *
  151649. * @param hitTestResult The hit test result to use for this anchor creation
  151650. * @param position an optional position offset for this anchor
  151651. * @param rotationQuaternion an optional rotation offset for this anchor
  151652. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  151653. */
  151654. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  151655. /**
  151656. * Add a new anchor at a specific position and rotation
  151657. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  151658. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  151659. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  151660. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  151661. *
  151662. * @param position the position in which to add an anchor
  151663. * @param rotationQuaternion an optional rotation for the anchor transformation
  151664. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  151665. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  151666. */
  151667. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  151668. /**
  151669. * detach this feature.
  151670. * Will usually be called by the features manager
  151671. *
  151672. * @returns true if successful.
  151673. */
  151674. detach(): boolean;
  151675. /**
  151676. * Dispose this feature and all of the resources attached
  151677. */
  151678. dispose(): void;
  151679. protected _onXRFrame(frame: XRFrame): void;
  151680. /**
  151681. * avoiding using Array.find for global support.
  151682. * @param xrAnchor the plane to find in the array
  151683. */
  151684. private _findIndexInAnchorArray;
  151685. private _updateAnchorWithXRFrame;
  151686. private _createAnchorAtTransformation;
  151687. }
  151688. }
  151689. declare module BABYLON {
  151690. /**
  151691. * Options used in the plane detector module
  151692. */
  151693. export interface IWebXRPlaneDetectorOptions {
  151694. /**
  151695. * The node to use to transform the local results to world coordinates
  151696. */
  151697. worldParentNode?: TransformNode;
  151698. /**
  151699. * If set to true a reference of the created planes will be kept until the next session starts
  151700. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  151701. */
  151702. doNotRemovePlanesOnSessionEnded?: boolean;
  151703. }
  151704. /**
  151705. * A babylon interface for a WebXR plane.
  151706. * A Plane is actually a polygon, built from N points in space
  151707. *
  151708. * Supported in chrome 79, not supported in canary 81 ATM
  151709. */
  151710. export interface IWebXRPlane {
  151711. /**
  151712. * a babylon-assigned ID for this polygon
  151713. */
  151714. id: number;
  151715. /**
  151716. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  151717. */
  151718. polygonDefinition: Array<Vector3>;
  151719. /**
  151720. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  151721. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  151722. */
  151723. transformationMatrix: Matrix;
  151724. /**
  151725. * the native xr-plane object
  151726. */
  151727. xrPlane: XRPlane;
  151728. }
  151729. /**
  151730. * The plane detector is used to detect planes in the real world when in AR
  151731. * For more information see https://github.com/immersive-web/real-world-geometry/
  151732. */
  151733. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  151734. private _options;
  151735. private _detectedPlanes;
  151736. private _enabled;
  151737. private _lastFrameDetected;
  151738. /**
  151739. * The module's name
  151740. */
  151741. static readonly Name: string;
  151742. /**
  151743. * The (Babylon) version of this module.
  151744. * This is an integer representing the implementation version.
  151745. * This number does not correspond to the WebXR specs version
  151746. */
  151747. static readonly Version: number;
  151748. /**
  151749. * Observers registered here will be executed when a new plane was added to the session
  151750. */
  151751. onPlaneAddedObservable: Observable<IWebXRPlane>;
  151752. /**
  151753. * Observers registered here will be executed when a plane is no longer detected in the session
  151754. */
  151755. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  151756. /**
  151757. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  151758. * This can execute N times every frame
  151759. */
  151760. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  151761. /**
  151762. * construct a new Plane Detector
  151763. * @param _xrSessionManager an instance of xr Session manager
  151764. * @param _options configuration to use when constructing this feature
  151765. */
  151766. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  151767. /**
  151768. * detach this feature.
  151769. * Will usually be called by the features manager
  151770. *
  151771. * @returns true if successful.
  151772. */
  151773. detach(): boolean;
  151774. /**
  151775. * Dispose this feature and all of the resources attached
  151776. */
  151777. dispose(): void;
  151778. protected _onXRFrame(frame: XRFrame): void;
  151779. private _init;
  151780. private _updatePlaneWithXRPlane;
  151781. /**
  151782. * avoiding using Array.find for global support.
  151783. * @param xrPlane the plane to find in the array
  151784. */
  151785. private findIndexInPlaneArray;
  151786. }
  151787. }
  151788. declare module BABYLON {
  151789. /**
  151790. * Options interface for the background remover plugin
  151791. */
  151792. export interface IWebXRBackgroundRemoverOptions {
  151793. /**
  151794. * Further background meshes to disable when entering AR
  151795. */
  151796. backgroundMeshes?: AbstractMesh[];
  151797. /**
  151798. * flags to configure the removal of the environment helper.
  151799. * If not set, the entire background will be removed. If set, flags should be set as well.
  151800. */
  151801. environmentHelperRemovalFlags?: {
  151802. /**
  151803. * Should the skybox be removed (default false)
  151804. */
  151805. skyBox?: boolean;
  151806. /**
  151807. * Should the ground be removed (default false)
  151808. */
  151809. ground?: boolean;
  151810. };
  151811. /**
  151812. * don't disable the environment helper
  151813. */
  151814. ignoreEnvironmentHelper?: boolean;
  151815. }
  151816. /**
  151817. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  151818. */
  151819. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  151820. /**
  151821. * read-only options to be used in this module
  151822. */
  151823. readonly options: IWebXRBackgroundRemoverOptions;
  151824. /**
  151825. * The module's name
  151826. */
  151827. static readonly Name: string;
  151828. /**
  151829. * The (Babylon) version of this module.
  151830. * This is an integer representing the implementation version.
  151831. * This number does not correspond to the WebXR specs version
  151832. */
  151833. static readonly Version: number;
  151834. /**
  151835. * registered observers will be triggered when the background state changes
  151836. */
  151837. onBackgroundStateChangedObservable: Observable<boolean>;
  151838. /**
  151839. * constructs a new background remover module
  151840. * @param _xrSessionManager the session manager for this module
  151841. * @param options read-only options to be used in this module
  151842. */
  151843. constructor(_xrSessionManager: WebXRSessionManager,
  151844. /**
  151845. * read-only options to be used in this module
  151846. */
  151847. options?: IWebXRBackgroundRemoverOptions);
  151848. /**
  151849. * attach this feature
  151850. * Will usually be called by the features manager
  151851. *
  151852. * @returns true if successful.
  151853. */
  151854. attach(): boolean;
  151855. /**
  151856. * detach this feature.
  151857. * Will usually be called by the features manager
  151858. *
  151859. * @returns true if successful.
  151860. */
  151861. detach(): boolean;
  151862. /**
  151863. * Dispose this feature and all of the resources attached
  151864. */
  151865. dispose(): void;
  151866. protected _onXRFrame(_xrFrame: XRFrame): void;
  151867. private _setBackgroundState;
  151868. }
  151869. }
  151870. declare module BABYLON {
  151871. /**
  151872. * Options for the controller physics feature
  151873. */
  151874. export class IWebXRControllerPhysicsOptions {
  151875. /**
  151876. * Should the headset get its own impostor
  151877. */
  151878. enableHeadsetImpostor?: boolean;
  151879. /**
  151880. * Optional parameters for the headset impostor
  151881. */
  151882. headsetImpostorParams?: {
  151883. /**
  151884. * The type of impostor to create. Default is sphere
  151885. */
  151886. impostorType: number;
  151887. /**
  151888. * the size of the impostor. Defaults to 10cm
  151889. */
  151890. impostorSize?: number | {
  151891. width: number;
  151892. height: number;
  151893. depth: number;
  151894. };
  151895. /**
  151896. * Friction definitions
  151897. */
  151898. friction?: number;
  151899. /**
  151900. * Restitution
  151901. */
  151902. restitution?: number;
  151903. };
  151904. /**
  151905. * The physics properties of the future impostors
  151906. */
  151907. physicsProperties?: {
  151908. /**
  151909. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  151910. * Note that this requires a physics engine that supports mesh impostors!
  151911. */
  151912. useControllerMesh?: boolean;
  151913. /**
  151914. * The type of impostor to create. Default is sphere
  151915. */
  151916. impostorType?: number;
  151917. /**
  151918. * the size of the impostor. Defaults to 10cm
  151919. */
  151920. impostorSize?: number | {
  151921. width: number;
  151922. height: number;
  151923. depth: number;
  151924. };
  151925. /**
  151926. * Friction definitions
  151927. */
  151928. friction?: number;
  151929. /**
  151930. * Restitution
  151931. */
  151932. restitution?: number;
  151933. };
  151934. /**
  151935. * the xr input to use with this pointer selection
  151936. */
  151937. xrInput: WebXRInput;
  151938. }
  151939. /**
  151940. * Add physics impostor to your webxr controllers,
  151941. * including naive calculation of their linear and angular velocity
  151942. */
  151943. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  151944. private readonly _options;
  151945. private _attachController;
  151946. private _controllers;
  151947. private _debugMode;
  151948. private _delta;
  151949. private _headsetImpostor?;
  151950. private _headsetMesh?;
  151951. private _lastTimestamp;
  151952. private _tmpQuaternion;
  151953. private _tmpVector;
  151954. /**
  151955. * The module's name
  151956. */
  151957. static readonly Name: string;
  151958. /**
  151959. * The (Babylon) version of this module.
  151960. * This is an integer representing the implementation version.
  151961. * This number does not correspond to the webxr specs version
  151962. */
  151963. static readonly Version: number;
  151964. /**
  151965. * Construct a new Controller Physics Feature
  151966. * @param _xrSessionManager the corresponding xr session manager
  151967. * @param _options options to create this feature with
  151968. */
  151969. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  151970. /**
  151971. * @hidden
  151972. * enable debugging - will show console outputs and the impostor mesh
  151973. */
  151974. _enablePhysicsDebug(): void;
  151975. /**
  151976. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  151977. * @param xrController the controller to add
  151978. */
  151979. addController(xrController: WebXRInputSource): void;
  151980. /**
  151981. * attach this feature
  151982. * Will usually be called by the features manager
  151983. *
  151984. * @returns true if successful.
  151985. */
  151986. attach(): boolean;
  151987. /**
  151988. * detach this feature.
  151989. * Will usually be called by the features manager
  151990. *
  151991. * @returns true if successful.
  151992. */
  151993. detach(): boolean;
  151994. /**
  151995. * Get the headset impostor, if enabled
  151996. * @returns the impostor
  151997. */
  151998. getHeadsetImpostor(): PhysicsImpostor | undefined;
  151999. /**
  152000. * Get the physics impostor of a specific controller.
  152001. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  152002. * @param controller the controller or the controller id of which to get the impostor
  152003. * @returns the impostor or null
  152004. */
  152005. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  152006. /**
  152007. * Update the physics properties provided in the constructor
  152008. * @param newProperties the new properties object
  152009. */
  152010. setPhysicsProperties(newProperties: {
  152011. impostorType?: number;
  152012. impostorSize?: number | {
  152013. width: number;
  152014. height: number;
  152015. depth: number;
  152016. };
  152017. friction?: number;
  152018. restitution?: number;
  152019. }): void;
  152020. protected _onXRFrame(_xrFrame: any): void;
  152021. private _detachController;
  152022. }
  152023. }
  152024. declare module BABYLON {
  152025. /**
  152026. * The motion controller class for all microsoft mixed reality controllers
  152027. */
  152028. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  152029. protected readonly _mapping: {
  152030. defaultButton: {
  152031. valueNodeName: string;
  152032. unpressedNodeName: string;
  152033. pressedNodeName: string;
  152034. };
  152035. defaultAxis: {
  152036. valueNodeName: string;
  152037. minNodeName: string;
  152038. maxNodeName: string;
  152039. };
  152040. buttons: {
  152041. "xr-standard-trigger": {
  152042. rootNodeName: string;
  152043. componentProperty: string;
  152044. states: string[];
  152045. };
  152046. "xr-standard-squeeze": {
  152047. rootNodeName: string;
  152048. componentProperty: string;
  152049. states: string[];
  152050. };
  152051. "xr-standard-touchpad": {
  152052. rootNodeName: string;
  152053. labelAnchorNodeName: string;
  152054. touchPointNodeName: string;
  152055. };
  152056. "xr-standard-thumbstick": {
  152057. rootNodeName: string;
  152058. componentProperty: string;
  152059. states: string[];
  152060. };
  152061. };
  152062. axes: {
  152063. "xr-standard-touchpad": {
  152064. "x-axis": {
  152065. rootNodeName: string;
  152066. };
  152067. "y-axis": {
  152068. rootNodeName: string;
  152069. };
  152070. };
  152071. "xr-standard-thumbstick": {
  152072. "x-axis": {
  152073. rootNodeName: string;
  152074. };
  152075. "y-axis": {
  152076. rootNodeName: string;
  152077. };
  152078. };
  152079. };
  152080. };
  152081. /**
  152082. * The base url used to load the left and right controller models
  152083. */
  152084. static MODEL_BASE_URL: string;
  152085. /**
  152086. * The name of the left controller model file
  152087. */
  152088. static MODEL_LEFT_FILENAME: string;
  152089. /**
  152090. * The name of the right controller model file
  152091. */
  152092. static MODEL_RIGHT_FILENAME: string;
  152093. profileId: string;
  152094. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152095. protected _getFilenameAndPath(): {
  152096. filename: string;
  152097. path: string;
  152098. };
  152099. protected _getModelLoadingConstraints(): boolean;
  152100. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152101. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152102. protected _updateModel(): void;
  152103. }
  152104. }
  152105. declare module BABYLON {
  152106. /**
  152107. * The motion controller class for oculus touch (quest, rift).
  152108. * This class supports legacy mapping as well the standard xr mapping
  152109. */
  152110. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  152111. private _forceLegacyControllers;
  152112. private _modelRootNode;
  152113. /**
  152114. * The base url used to load the left and right controller models
  152115. */
  152116. static MODEL_BASE_URL: string;
  152117. /**
  152118. * The name of the left controller model file
  152119. */
  152120. static MODEL_LEFT_FILENAME: string;
  152121. /**
  152122. * The name of the right controller model file
  152123. */
  152124. static MODEL_RIGHT_FILENAME: string;
  152125. /**
  152126. * Base Url for the Quest controller model.
  152127. */
  152128. static QUEST_MODEL_BASE_URL: string;
  152129. profileId: string;
  152130. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  152131. protected _getFilenameAndPath(): {
  152132. filename: string;
  152133. path: string;
  152134. };
  152135. protected _getModelLoadingConstraints(): boolean;
  152136. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152137. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152138. protected _updateModel(): void;
  152139. /**
  152140. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  152141. * between the touch and touch 2.
  152142. */
  152143. private _isQuest;
  152144. }
  152145. }
  152146. declare module BABYLON {
  152147. /**
  152148. * The motion controller class for the standard HTC-Vive controllers
  152149. */
  152150. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  152151. private _modelRootNode;
  152152. /**
  152153. * The base url used to load the left and right controller models
  152154. */
  152155. static MODEL_BASE_URL: string;
  152156. /**
  152157. * File name for the controller model.
  152158. */
  152159. static MODEL_FILENAME: string;
  152160. profileId: string;
  152161. /**
  152162. * Create a new Vive motion controller object
  152163. * @param scene the scene to use to create this controller
  152164. * @param gamepadObject the corresponding gamepad object
  152165. * @param handedness the handedness of the controller
  152166. */
  152167. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152168. protected _getFilenameAndPath(): {
  152169. filename: string;
  152170. path: string;
  152171. };
  152172. protected _getModelLoadingConstraints(): boolean;
  152173. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152174. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152175. protected _updateModel(): void;
  152176. }
  152177. }
  152178. declare module BABYLON {
  152179. /**
  152180. * A cursor which tracks a point on a path
  152181. */
  152182. export class PathCursor {
  152183. private path;
  152184. /**
  152185. * Stores path cursor callbacks for when an onchange event is triggered
  152186. */
  152187. private _onchange;
  152188. /**
  152189. * The value of the path cursor
  152190. */
  152191. value: number;
  152192. /**
  152193. * The animation array of the path cursor
  152194. */
  152195. animations: Animation[];
  152196. /**
  152197. * Initializes the path cursor
  152198. * @param path The path to track
  152199. */
  152200. constructor(path: Path2);
  152201. /**
  152202. * Gets the cursor point on the path
  152203. * @returns A point on the path cursor at the cursor location
  152204. */
  152205. getPoint(): Vector3;
  152206. /**
  152207. * Moves the cursor ahead by the step amount
  152208. * @param step The amount to move the cursor forward
  152209. * @returns This path cursor
  152210. */
  152211. moveAhead(step?: number): PathCursor;
  152212. /**
  152213. * Moves the cursor behind by the step amount
  152214. * @param step The amount to move the cursor back
  152215. * @returns This path cursor
  152216. */
  152217. moveBack(step?: number): PathCursor;
  152218. /**
  152219. * Moves the cursor by the step amount
  152220. * If the step amount is greater than one, an exception is thrown
  152221. * @param step The amount to move the cursor
  152222. * @returns This path cursor
  152223. */
  152224. move(step: number): PathCursor;
  152225. /**
  152226. * Ensures that the value is limited between zero and one
  152227. * @returns This path cursor
  152228. */
  152229. private ensureLimits;
  152230. /**
  152231. * Runs onchange callbacks on change (used by the animation engine)
  152232. * @returns This path cursor
  152233. */
  152234. private raiseOnChange;
  152235. /**
  152236. * Executes a function on change
  152237. * @param f A path cursor onchange callback
  152238. * @returns This path cursor
  152239. */
  152240. onchange(f: (cursor: PathCursor) => void): PathCursor;
  152241. }
  152242. }
  152243. declare module BABYLON {
  152244. /** @hidden */
  152245. export var blurPixelShader: {
  152246. name: string;
  152247. shader: string;
  152248. };
  152249. }
  152250. declare module BABYLON {
  152251. /** @hidden */
  152252. export var pointCloudVertexDeclaration: {
  152253. name: string;
  152254. shader: string;
  152255. };
  152256. }
  152257. // Mixins
  152258. interface Window {
  152259. mozIndexedDB: IDBFactory;
  152260. webkitIndexedDB: IDBFactory;
  152261. msIndexedDB: IDBFactory;
  152262. webkitURL: typeof URL;
  152263. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  152264. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  152265. WebGLRenderingContext: WebGLRenderingContext;
  152266. MSGesture: MSGesture;
  152267. CANNON: any;
  152268. AudioContext: AudioContext;
  152269. webkitAudioContext: AudioContext;
  152270. PointerEvent: any;
  152271. Math: Math;
  152272. Uint8Array: Uint8ArrayConstructor;
  152273. Float32Array: Float32ArrayConstructor;
  152274. mozURL: typeof URL;
  152275. msURL: typeof URL;
  152276. VRFrameData: any; // WebVR, from specs 1.1
  152277. DracoDecoderModule: any;
  152278. setImmediate(handler: (...args: any[]) => void): number;
  152279. }
  152280. interface HTMLCanvasElement {
  152281. requestPointerLock(): void;
  152282. msRequestPointerLock?(): void;
  152283. mozRequestPointerLock?(): void;
  152284. webkitRequestPointerLock?(): void;
  152285. /** Track wether a record is in progress */
  152286. isRecording: boolean;
  152287. /** Capture Stream method defined by some browsers */
  152288. captureStream(fps?: number): MediaStream;
  152289. }
  152290. interface CanvasRenderingContext2D {
  152291. msImageSmoothingEnabled: boolean;
  152292. }
  152293. interface MouseEvent {
  152294. mozMovementX: number;
  152295. mozMovementY: number;
  152296. webkitMovementX: number;
  152297. webkitMovementY: number;
  152298. msMovementX: number;
  152299. msMovementY: number;
  152300. }
  152301. interface Navigator {
  152302. mozGetVRDevices: (any: any) => any;
  152303. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152304. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152305. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152306. webkitGetGamepads(): Gamepad[];
  152307. msGetGamepads(): Gamepad[];
  152308. webkitGamepads(): Gamepad[];
  152309. }
  152310. interface HTMLVideoElement {
  152311. mozSrcObject: any;
  152312. }
  152313. interface Math {
  152314. fround(x: number): number;
  152315. imul(a: number, b: number): number;
  152316. }
  152317. interface WebGLRenderingContext {
  152318. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  152319. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  152320. vertexAttribDivisor(index: number, divisor: number): void;
  152321. createVertexArray(): any;
  152322. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  152323. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  152324. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  152325. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  152326. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  152327. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  152328. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  152329. // Queries
  152330. createQuery(): WebGLQuery;
  152331. deleteQuery(query: WebGLQuery): void;
  152332. beginQuery(target: number, query: WebGLQuery): void;
  152333. endQuery(target: number): void;
  152334. getQueryParameter(query: WebGLQuery, pname: number): any;
  152335. getQuery(target: number, pname: number): any;
  152336. MAX_SAMPLES: number;
  152337. RGBA8: number;
  152338. READ_FRAMEBUFFER: number;
  152339. DRAW_FRAMEBUFFER: number;
  152340. UNIFORM_BUFFER: number;
  152341. HALF_FLOAT_OES: number;
  152342. RGBA16F: number;
  152343. RGBA32F: number;
  152344. R32F: number;
  152345. RG32F: number;
  152346. RGB32F: number;
  152347. R16F: number;
  152348. RG16F: number;
  152349. RGB16F: number;
  152350. RED: number;
  152351. RG: number;
  152352. R8: number;
  152353. RG8: number;
  152354. UNSIGNED_INT_24_8: number;
  152355. DEPTH24_STENCIL8: number;
  152356. MIN: number;
  152357. MAX: number;
  152358. /* Multiple Render Targets */
  152359. drawBuffers(buffers: number[]): void;
  152360. readBuffer(src: number): void;
  152361. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  152362. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  152363. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  152364. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  152365. // Occlusion Query
  152366. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  152367. ANY_SAMPLES_PASSED: number;
  152368. QUERY_RESULT_AVAILABLE: number;
  152369. QUERY_RESULT: number;
  152370. }
  152371. interface WebGLProgram {
  152372. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  152373. }
  152374. interface EXT_disjoint_timer_query {
  152375. QUERY_COUNTER_BITS_EXT: number;
  152376. TIME_ELAPSED_EXT: number;
  152377. TIMESTAMP_EXT: number;
  152378. GPU_DISJOINT_EXT: number;
  152379. QUERY_RESULT_EXT: number;
  152380. QUERY_RESULT_AVAILABLE_EXT: number;
  152381. queryCounterEXT(query: WebGLQuery, target: number): void;
  152382. createQueryEXT(): WebGLQuery;
  152383. beginQueryEXT(target: number, query: WebGLQuery): void;
  152384. endQueryEXT(target: number): void;
  152385. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  152386. deleteQueryEXT(query: WebGLQuery): void;
  152387. }
  152388. interface WebGLUniformLocation {
  152389. _currentState: any;
  152390. }
  152391. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  152392. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  152393. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  152394. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  152395. interface WebGLRenderingContext {
  152396. readonly RASTERIZER_DISCARD: number;
  152397. readonly DEPTH_COMPONENT24: number;
  152398. readonly TEXTURE_3D: number;
  152399. readonly TEXTURE_2D_ARRAY: number;
  152400. readonly TEXTURE_COMPARE_FUNC: number;
  152401. readonly TEXTURE_COMPARE_MODE: number;
  152402. readonly COMPARE_REF_TO_TEXTURE: number;
  152403. readonly TEXTURE_WRAP_R: number;
  152404. readonly HALF_FLOAT: number;
  152405. readonly RGB8: number;
  152406. readonly RED_INTEGER: number;
  152407. readonly RG_INTEGER: number;
  152408. readonly RGB_INTEGER: number;
  152409. readonly RGBA_INTEGER: number;
  152410. readonly R8_SNORM: number;
  152411. readonly RG8_SNORM: number;
  152412. readonly RGB8_SNORM: number;
  152413. readonly RGBA8_SNORM: number;
  152414. readonly R8I: number;
  152415. readonly RG8I: number;
  152416. readonly RGB8I: number;
  152417. readonly RGBA8I: number;
  152418. readonly R8UI: number;
  152419. readonly RG8UI: number;
  152420. readonly RGB8UI: number;
  152421. readonly RGBA8UI: number;
  152422. readonly R16I: number;
  152423. readonly RG16I: number;
  152424. readonly RGB16I: number;
  152425. readonly RGBA16I: number;
  152426. readonly R16UI: number;
  152427. readonly RG16UI: number;
  152428. readonly RGB16UI: number;
  152429. readonly RGBA16UI: number;
  152430. readonly R32I: number;
  152431. readonly RG32I: number;
  152432. readonly RGB32I: number;
  152433. readonly RGBA32I: number;
  152434. readonly R32UI: number;
  152435. readonly RG32UI: number;
  152436. readonly RGB32UI: number;
  152437. readonly RGBA32UI: number;
  152438. readonly RGB10_A2UI: number;
  152439. readonly R11F_G11F_B10F: number;
  152440. readonly RGB9_E5: number;
  152441. readonly RGB10_A2: number;
  152442. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  152443. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  152444. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  152445. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  152446. readonly DEPTH_COMPONENT32F: number;
  152447. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  152448. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  152449. 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;
  152450. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  152451. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  152452. readonly TRANSFORM_FEEDBACK: number;
  152453. readonly INTERLEAVED_ATTRIBS: number;
  152454. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  152455. createTransformFeedback(): WebGLTransformFeedback;
  152456. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  152457. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  152458. beginTransformFeedback(primitiveMode: number): void;
  152459. endTransformFeedback(): void;
  152460. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  152461. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152462. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152463. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152464. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  152465. }
  152466. interface ImageBitmap {
  152467. readonly width: number;
  152468. readonly height: number;
  152469. close(): void;
  152470. }
  152471. interface WebGLQuery extends WebGLObject {
  152472. }
  152473. declare var WebGLQuery: {
  152474. prototype: WebGLQuery;
  152475. new(): WebGLQuery;
  152476. };
  152477. interface WebGLSampler extends WebGLObject {
  152478. }
  152479. declare var WebGLSampler: {
  152480. prototype: WebGLSampler;
  152481. new(): WebGLSampler;
  152482. };
  152483. interface WebGLSync extends WebGLObject {
  152484. }
  152485. declare var WebGLSync: {
  152486. prototype: WebGLSync;
  152487. new(): WebGLSync;
  152488. };
  152489. interface WebGLTransformFeedback extends WebGLObject {
  152490. }
  152491. declare var WebGLTransformFeedback: {
  152492. prototype: WebGLTransformFeedback;
  152493. new(): WebGLTransformFeedback;
  152494. };
  152495. interface WebGLVertexArrayObject extends WebGLObject {
  152496. }
  152497. declare var WebGLVertexArrayObject: {
  152498. prototype: WebGLVertexArrayObject;
  152499. new(): WebGLVertexArrayObject;
  152500. };
  152501. // Type definitions for WebVR API
  152502. // Project: https://w3c.github.io/webvr/
  152503. // Definitions by: six a <https://github.com/lostfictions>
  152504. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  152505. interface VRDisplay extends EventTarget {
  152506. /**
  152507. * Dictionary of capabilities describing the VRDisplay.
  152508. */
  152509. readonly capabilities: VRDisplayCapabilities;
  152510. /**
  152511. * z-depth defining the far plane of the eye view frustum
  152512. * enables mapping of values in the render target depth
  152513. * attachment to scene coordinates. Initially set to 10000.0.
  152514. */
  152515. depthFar: number;
  152516. /**
  152517. * z-depth defining the near plane of the eye view frustum
  152518. * enables mapping of values in the render target depth
  152519. * attachment to scene coordinates. Initially set to 0.01.
  152520. */
  152521. depthNear: number;
  152522. /**
  152523. * An identifier for this distinct VRDisplay. Used as an
  152524. * association point in the Gamepad API.
  152525. */
  152526. readonly displayId: number;
  152527. /**
  152528. * A display name, a user-readable name identifying it.
  152529. */
  152530. readonly displayName: string;
  152531. readonly isConnected: boolean;
  152532. readonly isPresenting: boolean;
  152533. /**
  152534. * If this VRDisplay supports room-scale experiences, the optional
  152535. * stage attribute contains details on the room-scale parameters.
  152536. */
  152537. readonly stageParameters: VRStageParameters | null;
  152538. /**
  152539. * Passing the value returned by `requestAnimationFrame` to
  152540. * `cancelAnimationFrame` will unregister the callback.
  152541. * @param handle Define the hanle of the request to cancel
  152542. */
  152543. cancelAnimationFrame(handle: number): void;
  152544. /**
  152545. * Stops presenting to the VRDisplay.
  152546. * @returns a promise to know when it stopped
  152547. */
  152548. exitPresent(): Promise<void>;
  152549. /**
  152550. * Return the current VREyeParameters for the given eye.
  152551. * @param whichEye Define the eye we want the parameter for
  152552. * @returns the eye parameters
  152553. */
  152554. getEyeParameters(whichEye: string): VREyeParameters;
  152555. /**
  152556. * Populates the passed VRFrameData with the information required to render
  152557. * the current frame.
  152558. * @param frameData Define the data structure to populate
  152559. * @returns true if ok otherwise false
  152560. */
  152561. getFrameData(frameData: VRFrameData): boolean;
  152562. /**
  152563. * Get the layers currently being presented.
  152564. * @returns the list of VR layers
  152565. */
  152566. getLayers(): VRLayer[];
  152567. /**
  152568. * Return a VRPose containing the future predicted pose of the VRDisplay
  152569. * when the current frame will be presented. The value returned will not
  152570. * change until JavaScript has returned control to the browser.
  152571. *
  152572. * The VRPose will contain the position, orientation, velocity,
  152573. * and acceleration of each of these properties.
  152574. * @returns the pose object
  152575. */
  152576. getPose(): VRPose;
  152577. /**
  152578. * Return the current instantaneous pose of the VRDisplay, with no
  152579. * prediction applied.
  152580. * @returns the current instantaneous pose
  152581. */
  152582. getImmediatePose(): VRPose;
  152583. /**
  152584. * The callback passed to `requestAnimationFrame` will be called
  152585. * any time a new frame should be rendered. When the VRDisplay is
  152586. * presenting the callback will be called at the native refresh
  152587. * rate of the HMD. When not presenting this function acts
  152588. * identically to how window.requestAnimationFrame acts. Content should
  152589. * make no assumptions of frame rate or vsync behavior as the HMD runs
  152590. * asynchronously from other displays and at differing refresh rates.
  152591. * @param callback Define the eaction to run next frame
  152592. * @returns the request handle it
  152593. */
  152594. requestAnimationFrame(callback: FrameRequestCallback): number;
  152595. /**
  152596. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  152597. * Repeat calls while already presenting will update the VRLayers being displayed.
  152598. * @param layers Define the list of layer to present
  152599. * @returns a promise to know when the request has been fulfilled
  152600. */
  152601. requestPresent(layers: VRLayer[]): Promise<void>;
  152602. /**
  152603. * Reset the pose for this display, treating its current position and
  152604. * orientation as the "origin/zero" values. VRPose.position,
  152605. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  152606. * updated when calling resetPose(). This should be called in only
  152607. * sitting-space experiences.
  152608. */
  152609. resetPose(): void;
  152610. /**
  152611. * The VRLayer provided to the VRDisplay will be captured and presented
  152612. * in the HMD. Calling this function has the same effect on the source
  152613. * canvas as any other operation that uses its source image, and canvases
  152614. * created without preserveDrawingBuffer set to true will be cleared.
  152615. * @param pose Define the pose to submit
  152616. */
  152617. submitFrame(pose?: VRPose): void;
  152618. }
  152619. declare var VRDisplay: {
  152620. prototype: VRDisplay;
  152621. new(): VRDisplay;
  152622. };
  152623. interface VRLayer {
  152624. leftBounds?: number[] | Float32Array | null;
  152625. rightBounds?: number[] | Float32Array | null;
  152626. source?: HTMLCanvasElement | null;
  152627. }
  152628. interface VRDisplayCapabilities {
  152629. readonly canPresent: boolean;
  152630. readonly hasExternalDisplay: boolean;
  152631. readonly hasOrientation: boolean;
  152632. readonly hasPosition: boolean;
  152633. readonly maxLayers: number;
  152634. }
  152635. interface VREyeParameters {
  152636. /** @deprecated */
  152637. readonly fieldOfView: VRFieldOfView;
  152638. readonly offset: Float32Array;
  152639. readonly renderHeight: number;
  152640. readonly renderWidth: number;
  152641. }
  152642. interface VRFieldOfView {
  152643. readonly downDegrees: number;
  152644. readonly leftDegrees: number;
  152645. readonly rightDegrees: number;
  152646. readonly upDegrees: number;
  152647. }
  152648. interface VRFrameData {
  152649. readonly leftProjectionMatrix: Float32Array;
  152650. readonly leftViewMatrix: Float32Array;
  152651. readonly pose: VRPose;
  152652. readonly rightProjectionMatrix: Float32Array;
  152653. readonly rightViewMatrix: Float32Array;
  152654. readonly timestamp: number;
  152655. }
  152656. interface VRPose {
  152657. readonly angularAcceleration: Float32Array | null;
  152658. readonly angularVelocity: Float32Array | null;
  152659. readonly linearAcceleration: Float32Array | null;
  152660. readonly linearVelocity: Float32Array | null;
  152661. readonly orientation: Float32Array | null;
  152662. readonly position: Float32Array | null;
  152663. readonly timestamp: number;
  152664. }
  152665. interface VRStageParameters {
  152666. sittingToStandingTransform?: Float32Array;
  152667. sizeX?: number;
  152668. sizeY?: number;
  152669. }
  152670. interface Navigator {
  152671. getVRDisplays(): Promise<VRDisplay[]>;
  152672. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  152673. }
  152674. interface Window {
  152675. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  152676. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  152677. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  152678. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  152679. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  152680. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  152681. }
  152682. interface Gamepad {
  152683. readonly displayId: number;
  152684. }
  152685. type XRSessionMode =
  152686. | "inline"
  152687. | "immersive-vr"
  152688. | "immersive-ar";
  152689. type XRReferenceSpaceType =
  152690. | "viewer"
  152691. | "local"
  152692. | "local-floor"
  152693. | "bounded-floor"
  152694. | "unbounded";
  152695. type XREnvironmentBlendMode =
  152696. | "opaque"
  152697. | "additive"
  152698. | "alpha-blend";
  152699. type XRVisibilityState =
  152700. | "visible"
  152701. | "visible-blurred"
  152702. | "hidden";
  152703. type XRHandedness =
  152704. | "none"
  152705. | "left"
  152706. | "right";
  152707. type XRTargetRayMode =
  152708. | "gaze"
  152709. | "tracked-pointer"
  152710. | "screen";
  152711. type XREye =
  152712. | "none"
  152713. | "left"
  152714. | "right";
  152715. type XREventType =
  152716. | "devicechange"
  152717. | "visibilitychange"
  152718. | "end"
  152719. | "inputsourceschange"
  152720. | "select"
  152721. | "selectstart"
  152722. | "selectend"
  152723. | "squeeze"
  152724. | "squeezestart"
  152725. | "squeezeend"
  152726. | "reset";
  152727. interface XRSpace extends EventTarget {
  152728. }
  152729. interface XRRenderState {
  152730. depthNear?: number;
  152731. depthFar?: number;
  152732. inlineVerticalFieldOfView?: number;
  152733. baseLayer?: XRWebGLLayer;
  152734. }
  152735. interface XRInputSource {
  152736. handedness: XRHandedness;
  152737. targetRayMode: XRTargetRayMode;
  152738. targetRaySpace: XRSpace;
  152739. gripSpace: XRSpace | undefined;
  152740. gamepad: Gamepad | undefined;
  152741. profiles: Array<string>;
  152742. }
  152743. interface XRSessionInit {
  152744. optionalFeatures?: string[];
  152745. requiredFeatures?: string[];
  152746. }
  152747. interface XRSession {
  152748. addEventListener: Function;
  152749. removeEventListener: Function;
  152750. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  152751. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  152752. requestAnimationFrame: Function;
  152753. end(): Promise<void>;
  152754. renderState: XRRenderState;
  152755. inputSources: Array<XRInputSource>;
  152756. // hit test
  152757. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  152758. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  152759. // legacy AR hit test
  152760. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  152761. // legacy plane detection
  152762. updateWorldTrackingState(options: {
  152763. planeDetectionState?: { enabled: boolean; }
  152764. }): void;
  152765. }
  152766. interface XRReferenceSpace extends XRSpace {
  152767. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  152768. onreset: any;
  152769. }
  152770. type XRPlaneSet = Set<XRPlane>;
  152771. type XRAnchorSet = Set<XRAnchor>;
  152772. interface XRFrame {
  152773. session: XRSession;
  152774. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  152775. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  152776. // AR
  152777. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  152778. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  152779. // Anchors
  152780. trackedAnchors?: XRAnchorSet;
  152781. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  152782. // Planes
  152783. worldInformation: {
  152784. detectedPlanes?: XRPlaneSet;
  152785. };
  152786. }
  152787. interface XRViewerPose extends XRPose {
  152788. views: Array<XRView>;
  152789. }
  152790. interface XRPose {
  152791. transform: XRRigidTransform;
  152792. emulatedPosition: boolean;
  152793. }
  152794. interface XRWebGLLayerOptions {
  152795. antialias?: boolean;
  152796. depth?: boolean;
  152797. stencil?: boolean;
  152798. alpha?: boolean;
  152799. multiview?: boolean;
  152800. framebufferScaleFactor?: number;
  152801. }
  152802. declare var XRWebGLLayer: {
  152803. prototype: XRWebGLLayer;
  152804. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  152805. };
  152806. interface XRWebGLLayer {
  152807. framebuffer: WebGLFramebuffer;
  152808. framebufferWidth: number;
  152809. framebufferHeight: number;
  152810. getViewport: Function;
  152811. }
  152812. declare class XRRigidTransform {
  152813. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  152814. position: DOMPointReadOnly;
  152815. orientation: DOMPointReadOnly;
  152816. matrix: Float32Array;
  152817. inverse: XRRigidTransform;
  152818. }
  152819. interface XRView {
  152820. eye: XREye;
  152821. projectionMatrix: Float32Array;
  152822. transform: XRRigidTransform;
  152823. }
  152824. interface XRInputSourceChangeEvent {
  152825. session: XRSession;
  152826. removed: Array<XRInputSource>;
  152827. added: Array<XRInputSource>;
  152828. }
  152829. interface XRInputSourceEvent extends Event {
  152830. readonly frame: XRFrame;
  152831. readonly inputSource: XRInputSource;
  152832. }
  152833. // Experimental(er) features
  152834. declare class XRRay {
  152835. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  152836. origin: DOMPointReadOnly;
  152837. direction: DOMPointReadOnly;
  152838. matrix: Float32Array;
  152839. }
  152840. declare enum XRHitTestTrackableType {
  152841. "point",
  152842. "plane"
  152843. }
  152844. interface XRHitResult {
  152845. hitMatrix: Float32Array;
  152846. }
  152847. interface XRTransientInputHitTestResult {
  152848. readonly inputSource: XRInputSource;
  152849. readonly results: Array<XRHitTestResult>;
  152850. }
  152851. interface XRHitTestResult {
  152852. getPose(baseSpace: XRSpace): XRPose | undefined;
  152853. // When anchor system is enabled
  152854. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  152855. }
  152856. interface XRHitTestSource {
  152857. cancel(): void;
  152858. }
  152859. interface XRTransientInputHitTestSource {
  152860. cancel(): void;
  152861. }
  152862. interface XRHitTestOptionsInit {
  152863. space: XRSpace;
  152864. entityTypes?: Array<XRHitTestTrackableType>;
  152865. offsetRay?: XRRay;
  152866. }
  152867. interface XRTransientInputHitTestOptionsInit {
  152868. profile: string;
  152869. entityTypes?: Array<XRHitTestTrackableType>;
  152870. offsetRay?: XRRay;
  152871. }
  152872. interface XRAnchor {
  152873. anchorSpace: XRSpace;
  152874. delete(): void;
  152875. }
  152876. interface XRPlane {
  152877. orientation: "Horizontal" | "Vertical";
  152878. planeSpace: XRSpace;
  152879. polygon: Array<DOMPointReadOnly>;
  152880. lastChangedTime: number;
  152881. }